📄 partaddform.aspx.cs
字号:
//文件名:PartAddForm.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;
public partial class PartManage_PartAddForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B2") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button1.OnClientClick = "return confirm('请检查配件入库信息是否正确,一旦新增就无法修改,是否继续?')";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{//显示配件信息
DataTable MyTable = new DataTable();
string MySQL = "SELECT * FROM [配件信息] WHERE ([配件编号] LIKE '%" + this.DropDownList1.SelectedValue + "%') ";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
if (MyTable.Rows.Count == 1)
{
this.TextBox3.Text = MyTable.Rows[0]["配件编号"].ToString();
this.TextBox4.Text = MyTable.Rows[0]["规格型号"].ToString();
this.TextBox7.Text = MyTable.Rows[0]["计量单位"].ToString();
this.TextBox8.Text = MyTable.Rows[0]["建议采购价"].ToString();
}
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{//新增配件入库信息
if (Convert.ToDouble(this.TextBox6.Text)<1)
return;
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
string MySQL = "INSERT INTO 配件入库(入库编号,配件编号,配件名称,规格型号,入库日期,入库数量,计量单位,购买单价,生产厂家,供货商家,库管人员)VALUES('";
MySQL += this.TextBox1.Text + "','";
MySQL += this.TextBox3.Text + "','";
MySQL += this.DropDownList1.SelectedItem.Text+ "','";
MySQL += this.TextBox4.Text + "','";
MySQL += this.TextBox5.Text + "','";
MySQL += this.TextBox6.Text + "','";
MySQL += this.TextBox7.Text + "','";
MySQL += this.TextBox8.Text + "','";
MySQL += this.TextBox9.Text + "','";
MySQL += this.TextBox10.Text + "','";
MySQL += this.DropDownList2.SelectedValue.ToString() + "');";
MySQL+= "Update 配件信息 SET 累计入库量=累计入库量+" + this.TextBox6.Text + " WHERE 配件编号='" + this.TextBox3.Text + "';";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
this.TextBox6.Text = "0";
this.SqlDataSource3.DataBind();
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{//在GridView控件单元格中设置短日期显示格式
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime MyDate=DateTime.Parse(e.Row.Cells[5].Text);
e.Row.Cells[5].Text = MyDate.ToShortDateString();
}
}
protected void Button3_Click(object sender, EventArgs e)
{//打印配件入库信息
Server.Transfer("~/PartManage/PartAddPrint.aspx");
}
public DataTable MyQueryTable
{//设置要传递到打印页的数据
get
{
DataTable MyTable = new DataTable();
string MySQL = "SELECT * FROM [配件入库] WHERE ([入库编号] LIKE '%" + this.TextBox12.Text + "%') ";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
if (MyConnection.State == ConnectionState.Open)
MyConnection.Close();
return MyTable;
}
}
public String MyPrintDate
{//设置要传递到打印页的数据
get
{
string MyDate = "打印日期:" + DateTime.Now.ToShortDateString();
return MyDate;
}
}
public String MyPrintTitle
{//设置要传递到打印页的数据
get
{
return Session["MyServiceName"].ToString() + "配件入库信息表";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -