📄 partsubtractform.aspx.cs
字号:
//文件名:PartSubtractForm.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_PartSubtractForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B3") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button1.OnClientClick = "return confirm('请检查配件领用信息是否正确,一旦新增就无法修改,是否继续?')";
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{//显示选择的配件信息
this.TextBox7.Text = this.GridView1.SelectedRow.Cells[1].Text.ToString();
this.TextBox8.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString();
this.TextBox9.Text = this.GridView1.SelectedRow.Cells[4].Text.ToString();
this.TextBox1.Text = this.GridView1.SelectedRow.Cells[6].Text.ToString();
this.TextBox12.Text = this.GridView1.SelectedRow.Cells[11].Text.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{//新增领用配件信息
if (Convert.ToDouble(this.TextBox11.Text) < 1)
return;
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
string MySQL = "INSERT INTO 配件领用(维修编号,配件编号,配件名称,规格型号,计量单位,领用数量,计费单价,领用部门,领用人员,领用日期)VALUES('";
MySQL += this.DropDownList1.SelectedItem.Text + "','";
MySQL += this.TextBox7.Text + "','";
MySQL += this.TextBox8.Text + "','";
MySQL += this.TextBox9.Text + "','";
MySQL += this.TextBox1.Text + "','";
MySQL += this.TextBox11.Text + "','";
MySQL += this.TextBox12.Text + "','";
MySQL += this.DropDownList3.SelectedItem.Text + "','";
MySQL += this.DropDownList4.SelectedItem.Text + "','";
MySQL += this.TextBox15.Text + "');";
MySQL += "Update 配件信息 SET 累计领用量=累计领用量+" + this.TextBox11.Text + " WHERE 配件编号='" + this.TextBox7.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.TextBox11.Text = "0";
this.SqlDataSource6.DataBind();
this.GridView2.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{//显示维修信息
String MyID = this.DropDownList1.SelectedValue;
DataTable MyTable = new DataTable();
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
string MySQL = "SELECT * FROM [维修登记] WHERE ([维修编号]=" + MyID + ")";
MyConnection.Open();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
this.TextBox3.Text = MyTable.Rows[0]["维修类别"].ToString();
this.TextBox4.Text = MyTable.Rows[0]["维修项目"].ToString();
this.TextBox5.Text = MyTable.Rows[0]["产品品牌"].ToString();
this.TextBox6.Text = MyTable.Rows[0]["产品型号"].ToString();
this.DropDownList4.SelectedValue = MyTable.Rows[0]["维修方式"].ToString();
this.DropDownList2.SelectedValue = MyTable.Rows[0]["客户名称"].ToString();
this.TextBox10.Text = MyTable.Rows[0]["客户电话"].ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{//打印配件领用信息
Server.Transfer("~/PartManage/PartSubtractPrint.aspx");
}
public String MyPrint维修编号
{//设置要传递到打印页的数据
get
{
return this.DropDownList1.SelectedItem.Text;
}
}
public String MyPrint客户名称
{//设置要传递到打印页的数据
get
{
return this.DropDownList2.SelectedItem.Text;
}
}
public String MyPrint客户电话
{//设置要传递到打印页的数据
get
{
return this.TextBox10.Text;
}
}
public String MyPrint产品品牌
{//设置要传递到打印页的数据
get
{
return this.TextBox5.Text; ;
}
}
public String MyPrint产品型号
{//设置要传递到打印页的数据
get
{
return this.TextBox6.Text; ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -