📄 stock_open.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using LoginCheckClass; //(类)验证用户是否登录
/// <summary>
/// 2008年7月23日 谈鸿如 编码
/// 2008年7月24日 测试
/// 用于显示在Stock_Search页面中选中信息的详细信息
/// </summary>
public partial class 进货管理_Stock_open : System.Web.UI.Page
{
//页面加载时运行
protected void Page_Load(object sender, EventArgs e)
{
//调用LoginCheck类的check方法来判断用户是否登录
LoginCheck a = new LoginCheck();
a.check();
try
{
using (SqlConnection connection = new SqlConnection(_connectString)) //建立连接
{
connection.Open(); //打开连接
using (SqlCommand command = new SqlCommand())
{
command.Connection = connection;
//读取在Stock_Search页面中建立的Session["Stock_Search_ID"]的值,用来确定页面读出tb_stock表中的哪条信息
command.Parameters.Add("@id", SqlDbType.Int).Value = (int)Session["Stock_Search_ID"];
//查询出所选信息的详细信息
command.CommandText = "SELECT dbo.tb_Commodity.CommodityName, dbo.tb_Company.CompanyName,dbo.tb_Stock.Type,dbo.tb_Stock.Number,dbo.tb_Stock.StockDate, dbo.tb_Stock.ManageMan,dbo.tb_Stock.SettlementType,dbo.tb_Stock.UserName,dbo.tb_Stock.AddTime,dbo.tb_Stock.Pirce,dbo.tb_Stock.id FROM dbo.tb_Company INNER JOIN dbo.tb_Commodity ON dbo.tb_Company.id = dbo.tb_Commodity.CompanyID INNER JOIN dbo.tb_Stock ON dbo.tb_Commodity.id = dbo.tb_Stock.CommodityID WHERE dbo.tb_Stock.id=@id";
command.ExecuteNonQuery();
SqlDataReader reader = command.ExecuteReader();
//将取出的信息以只读方式付给页面中各控件
while (reader.Read())
{
CommodityName.Text = reader.GetString(0); //商品名称
CompanyName.Text = reader.GetString(1); //供应商
InfoType.Text = reader.GetString(2); //信息类型,分别为进货、退货、销售信息、销售退货
Number.Text = Convert.ToString(reader.GetInt32(3)); //库存数量
Date.Text = Convert.ToString(reader.GetDateTime(4).ToShortDateString()); //进货、进货退货、销售、销售退货的日期
ManageMan.Text = reader.GetString(5); //经手人
SettlementType.Text = reader.GetString(6); //结款方式,分为现金、支票
username.Text = reader.GetString(7); //信息添加人,为当前登录人员
AddDate.Text = Convert.ToString(reader.GetDateTime(8)); //信息添加的当天日期
Price.Text = Convert.ToString(reader.GetInt32(9)); //单价
Label14.Text = Convert.ToString(reader.GetInt32(10)); //所选信息在tb_stock表中的ID值,不显示在页面中
}
}
}
//生成单据标号,供18位,前8位为时间信息,后10位为在tb_stock表中的ID
TotalPrice.Text = Convert.ToString(int.Parse(Number.Text) * int.Parse(Price.Text));
DateTime NO_Time = Convert.ToDateTime(Date.Text);
string time = NO_Time.ToString("yyyyMMdd");
string hou10 = Label14.Text;
hou10 = hou10.PadLeft(10, '0'); //后十位由tb_stock表中ID值前补零得到
time = time + hou10;
NO.Text = time;
}
//若查询失败,则抛出异常信息
catch (Exception ex)
{
Response.Write(@"<script>alert('系统错误');</script>");
}
}
//使用db_sellConnectionString连接字符串
private static readonly string _connectString = System.Configuration.ConfigurationManager.ConnectionStrings["db_sellConnectionString"].ConnectionString;
//点击关闭按钮后,关闭当前弹出窗口
protected void btnClose_Click(object sender, EventArgs e)
{
Response.Write("<script>window.close()</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -