📄 审核入库界面.aspx.cs
字号:
gonghuodidian = Convert.ToString(dr[0]);
wuzidanjia = Convert.ToString(dr[1]);
}
myReader1.Close();
string sql2 = "insert into 物资信息表(物资编号,物资名称,物资数量,生产地点,仓库名称,单价,备注) values('" +maxnum + "','" + this.TextBox2.Text + "','" + TextBox1.Text
+ "','" + gonghuodidian + "',' 成品仓库 '," + wuzidanjia + ",' 成品 ');";
myComm = new SqlCommand(sql2, myConn);
myComm.ExecuteNonQuery();
string sql4 = "select * from 物资信息表";
myComm = new SqlCommand(sql4, myConn);
SqlDataReader myReader = myComm.ExecuteReader();
DataTable dt = new DataTable();
dt = new DataTable();
dt.Columns.Add("物资编号", typeof(string));
dt.Columns.Add("物资名称", typeof(string));
dt.Columns.Add("物资数量", typeof(string));
dt.Columns.Add("生产地点", typeof(string));
dt.Columns.Add("仓库名称", typeof(string));
dt.Columns.Add("单 价", typeof(string));
dt.Columns.Add("备 注", typeof(string));
while (myReader.Read())
{
dr = dt.NewRow();
dr[0] = myReader.GetValue(0).ToString();
dr[1] = myReader.GetValue(1).ToString();
dr[2] = myReader.GetValue(2).ToString();
dr[3] = myReader.GetValue(3).ToString();
dr[4] = myReader.GetValue(4).ToString();
dr[5] = myReader.GetValue(5).ToString();
dr[6] = myReader.GetValue(6).ToString();
dt.Rows.Add(dr);
}
myReader.Close();
this.GridView2.DataSource = new DataView(dt);
this.GridView2.DataBind();
myConn.Close();
//提示用户操作成功
this.Response.Write("<script language=javascript>alert('通过审核!且物资信息表相应修改成功!')</script>");
}
}
if (this.DropDownListhegepanduan.Text == "不合格" && this.TextBoxrukudanbianhao.Text != "" && this.TextBox2.Text != "" && this.TextBox1.Text != "" && this.TextBoxrukuriqi.Text != "" && this.TextBoxjingshouren.Text != "")
{
this.Response.Write("<script language=javascript>alert('审核不合格,不予入库!')</script>");
}
this.TextBoxrukudanbianhao.Text = "";
this.TextBox2.Text = "";
this.TextBox1.Text = "";
this.TextBoxrukuriqi.Text = "";
this.TextBoxjingshouren.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
//设置数据库连接串
string myConnStr
= "data source= . ; database=物资管理系统;Trusted_Connection=SSPI ";
//设置要执行的SQL命令
SqlConnection myConn = new SqlConnection(myConnStr);
SqlDataReader myReader;
if (this.DropDownListyuanliaoshenhe.Text != "" && this.DropDownListchengpinshenhe.Text == "")
{
String sql
= "select 入库单编号,采购单编号,物资名称,物资数量,入库日期,经手人 from 原料入库信息表 where 入库单编号 like'%"
+ this.DropDownListyuanliaoshenhe.Text
+ "%'";
SqlCommand myComm = new SqlCommand(sql, myConn);
myConn.Open();
myReader = myComm.ExecuteReader();
//设置返回查询结果的表变量
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("入库单编号", typeof(String)));
dt.Columns.Add(new DataColumn("采购单编号", typeof(String)));
dt.Columns.Add(new DataColumn("物资名称", typeof(String)));
dt.Columns.Add(new DataColumn("物资数量", typeof(String)));
dt.Columns.Add(new DataColumn("入库日期", typeof(String)));
dt.Columns.Add(new DataColumn("经手人", typeof(String)));
//读查询的结果并放入表中
while (myReader.Read())
{
DataRow dr = dt.NewRow();
dr[0] = myReader.GetValue(0).ToString();
dr[1] = myReader.GetValue(1).ToString();
dr[2] = myReader.GetValue(2).ToString();
dr[3] = myReader.GetValue(3).ToString();
dr[4] = myReader.GetValue(4).ToString();
dr[5] = myReader.GetValue(5).ToString();
dt.Rows.Add(dr);
}
//关闭数据库连接
myConn.Close();
//将查询结果显示到表格控件
this.GridView1.DataSource = new DataView(dt);
this.GridView1.DataBind();
}
else if (this.DropDownListchengpinshenhe.Text == "" && this.DropDownListchengpinshenhe.Text == "")
//提示用户操作
this.Response.Write("<script language=javascript>alert('您没有选择查询依据!请选择!')</script>");
else if (this.DropDownListchengpinshenhe.Text != "" && this.DropDownListyuanliaoshenhe.Text != "")
//提示用户操作
this.Response.Write("<script language=javascript>alert('不允许同时选择两个查询依据!请重新选择!')</script>");
else if (this.DropDownListchengpinshenhe.Text != "" && this.DropDownListyuanliaoshenhe.Text == "")
{
String sql
= "select 成品编号,入库单编号,成品名称,成品数量,成品单价,入库日期,经手人 from 成品入库信息表 where 成品编号 like'%"
+ this.DropDownListchengpinshenhe.Text
+ "%'";
SqlCommand myComm = new SqlCommand(sql, myConn);
myConn.Open();
myReader = myComm.ExecuteReader();
//设置返回查询结果的表变量
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("成品编号", typeof(String)));
dt.Columns.Add(new DataColumn("入库单编号", typeof(String)));
dt.Columns.Add(new DataColumn("成品名称", typeof(String)));
dt.Columns.Add(new DataColumn("成品数量", typeof(String)));
dt.Columns.Add(new DataColumn("成品单价", typeof(String)));
dt.Columns.Add(new DataColumn("入库日期", typeof(String)));
dt.Columns.Add(new DataColumn("经手人", typeof(String)));
//读查询的结果并放入表中
while (myReader.Read())
{
DataRow dr = dt.NewRow();
dr[0] = myReader.GetValue(0).ToString();
dr[1] = myReader.GetValue(1).ToString();
dr[2] = myReader.GetValue(2).ToString();
dr[3] = myReader.GetValue(3).ToString();
dr[4] = myReader.GetValue(4).ToString();
dr[5] = myReader.GetValue(5).ToString();
dr[6] = myReader.GetValue(6).ToString();
dt.Rows.Add(dr);
}
//关闭数据库连接
myConn.Close();
//将查询结果显示到表格控件
this.GridView1.DataSource = new DataView(dt);
this.GridView1.DataBind();
}
}
protected void Buttonshanchu_Click(object sender, EventArgs e)
{
string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
SqlConnection myConn = new SqlConnection(myConnStr);
string sql="";
if (this.DropDownListyuanliaoshenhe.Text != "")
{
sql = "delete from 原料入库信息表 where 入库单编号='" + this.DropDownListyuanliaoshenhe.Text+"'";
Response.Write("<script>alert('该不合格物资信息已经从原料入库信息表中成功删除!')</script>");
}
else if (this.DropDownListchengpinshenhe.Text != "")
{
sql = "delete from 成品入库信息表 where 成品编号='" + this.DropDownListchengpinshenhe.Text+"'";
Response.Write("<script>alert('该不合格物资信息已经从成品入库信息表中成功删除!')</script>");
}
SqlCommand myComm = new SqlCommand(sql, myConn);
myConn.Open();
myComm.ExecuteNonQuery();
myConn.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -