📄 assetoperate.cs
字号:
// label25
//
this.label25.Location = new System.Drawing.Point(8, 224);
this.label25.Name = "label25";
this.label25.TabIndex = 8;
this.label25.Text = "购入价格";
//
// label24
//
this.label24.Location = new System.Drawing.Point(8, 280);
this.label24.Name = "label24";
this.label24.TabIndex = 7;
this.label24.Text = "资产种类";
//
// comboBox2
//
this.comboBox2.Location = new System.Drawing.Point(136, 280);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(152, 24);
this.comboBox2.TabIndex = 6;
this.comboBox2.TextChanged += new System.EventHandler(this.comboBox2_TextChanged);
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// label23
//
this.label23.Location = new System.Drawing.Point(16, 168);
this.label23.Name = "label23";
this.label23.TabIndex = 4;
this.label23.Text = "购入日期";
//
// textBox18
//
this.textBox18.Location = new System.Drawing.Point(136, 64);
this.textBox18.Name = "textBox18";
this.textBox18.Size = new System.Drawing.Size(152, 26);
this.textBox18.TabIndex = 3;
this.textBox18.Text = "textBox18";
this.textBox18.TextChanged += new System.EventHandler(this.textBox18_TextChanged);
//
// label22
//
this.label22.Location = new System.Drawing.Point(16, 64);
this.label22.Name = "label22";
this.label22.TabIndex = 2;
this.label22.Text = "序列号";
//
// textBox17
//
this.textBox17.Location = new System.Drawing.Point(136, 16);
this.textBox17.Name = "textBox17";
this.textBox17.Size = new System.Drawing.Size(152, 26);
this.textBox17.TabIndex = 1;
this.textBox17.Text = "textBox17";
this.textBox17.TextChanged += new System.EventHandler(this.textBox17_TextChanged);
//
// label21
//
this.label21.Location = new System.Drawing.Point(16, 16);
this.label21.Name = "label21";
this.label21.TabIndex = 0;
this.label21.Text = "资产编号";
//
// tabPage5
//
this.tabPage5.BackColor = System.Drawing.Color.Gray;
this.tabPage5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.tabPage5.Controls.Add(this.button3);
this.tabPage5.Controls.Add(this.label18);
this.tabPage5.Controls.Add(this.label16);
this.tabPage5.Controls.Add(this.button10);
this.tabPage5.Controls.Add(this.button9);
this.tabPage5.Controls.Add(this.textBox29);
this.tabPage5.Controls.Add(this.label34);
this.tabPage5.Controls.Add(this.textBox28);
this.tabPage5.Controls.Add(this.label33);
this.tabPage5.Font = new System.Drawing.Font("隶书", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.tabPage5.Location = new System.Drawing.Point(4, 21);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Size = new System.Drawing.Size(506, 431);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "资产种类";
this.tabPage5.Click += new System.EventHandler(this.tabPage5_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(360, 320);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 24);
this.button3.TabIndex = 8;
this.button3.Text = "退出";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// label18
//
this.label18.ForeColor = System.Drawing.Color.Brown;
this.label18.Location = new System.Drawing.Point(392, 112);
this.label18.Name = "label18";
this.label18.TabIndex = 7;
this.label18.Text = "*";
//
// label16
//
this.label16.ForeColor = System.Drawing.Color.Brown;
this.label16.Location = new System.Drawing.Point(392, 48);
this.label16.Name = "label16";
this.label16.TabIndex = 6;
this.label16.Text = "*";
//
// button10
//
this.button10.Location = new System.Drawing.Point(256, 320);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(80, 24);
this.button10.TabIndex = 5;
this.button10.Text = "修改";
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button9
//
this.button9.Location = new System.Drawing.Point(136, 320);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(88, 24);
this.button9.TabIndex = 4;
this.button9.Text = "添加";
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// textBox29
//
this.textBox29.Location = new System.Drawing.Point(216, 112);
this.textBox29.Name = "textBox29";
this.textBox29.Size = new System.Drawing.Size(144, 26);
this.textBox29.TabIndex = 3;
this.textBox29.Text = "textBox29";
this.textBox29.TextChanged += new System.EventHandler(this.textBox29_TextChanged);
//
// label34
//
this.label34.Location = new System.Drawing.Point(40, 112);
this.label34.Name = "label34";
this.label34.Size = new System.Drawing.Size(120, 23);
this.label34.TabIndex = 2;
this.label34.Text = "资产种类备注";
//
// textBox28
//
this.textBox28.Location = new System.Drawing.Point(216, 48);
this.textBox28.Name = "textBox28";
this.textBox28.Size = new System.Drawing.Size(144, 26);
this.textBox28.TabIndex = 1;
this.textBox28.Text = "textBox28";
this.textBox28.TextChanged += new System.EventHandler(this.textBox28_TextChanged);
//
// label33
//
this.label33.Location = new System.Drawing.Point(40, 48);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(120, 24);
this.label33.TabIndex = 0;
this.label33.Text = "资产种类编号";
//
// assetOperate
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(514, 512);
this.Controls.Add(this.panel1);
this.Controls.Add(this.tabControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "assetOperate";
this.Text = "assetOperate";
this.Load += new System.EventHandler(this.assetOperate_Load);
this.panel1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabPage5.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void assetOperate_Load(object sender, System.EventArgs e)
{
switch (this.no)
{
case 1:
this.tabPage1.Focus();
//this.tabPage1.Click();
break;
case 2:
this.tabPage3.Focus();
//this.tabPage3.Click();
break;
case 3:
this.tabPage4.Focus();
break;
case 4:
this.tabPage5.Focus();
break;
default:
this.tabControl1.Focus();
break;
}
this.dateTimePicker1.Value = System.DateTime.Now;
//this.dateTimePicker2.s = "";
this.label1.Text = "操作员 " + this.EmployeeName;
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox4.Text = "";
this.textBox17.Text = "";
this.textBox18.Text = "";
this.textBox20.Text = "";
//this.textBox21.Text="";
//this.textBox22.Text="";
//this.textBox23.Text="";
this.textBox24.Text = "";
//this.textBox25.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
//this.textBox4.Text="";
this.textBox5.Text = "";
this.textBox27.Text = "";
this.textBox28.Text = "";
this.textBox29.Text = "";
this.textBox12.Text = "";
//this.textBox13.Text = "";
this.textBox14.Text = "";
this.textBox16.Text = "";
Connection s = new Connection();
SqlConnection conn = new SqlConnection(s.getConnectionString);
conn.Open();
string str = "select * from assetCategory";
SqlCommand cmd = new SqlCommand(str,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
this.comboBox1.Items.Add(Convert.ToString(dr["assetCategoryDescription"]));
this.comboBox2.Items.Add(Convert.ToString(dr["assetCategoryDescription"]));
}
dr.Close();
conn.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{
/*public bool addAsset(string assetNo,string assetCategoryNo,string employeeNo,
string statusNo,
string assetDescription,
int serialNo,float purchasePrice
,float currentValue,string dateSold,string nextMaintenanceDate)*/
bool check = false;
bool check1 = false;
string S = "";
string assetNo = textBox1.Text;
string serialNo = textBox2.Text;
string employeeNo = textBox5.Text.Trim().ToUpper();
string assetDescription = textBox27.Text;
asset ass = new asset();
string str = "select * from AssetCategory";
string str2 = "select * from Employee";
SqlConnection conn = new SqlConnection(ass.getConnectionString);
conn.Open();
if (this.textBox1.Text == "")
MessageBox.Show("资产号不能为空!");
else
{
SqlCommand cmd = new SqlCommand(str,conn);
SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
if (dr.GetString(1) == this.comboBox1.Text)
{
S = dr.GetString(0);
//MessageBox.Show(S);
check = true;
break;
}
}
dr.Close();
if (check)
{
string str3 = "select * from Asset";
SqlCommand r = new SqlCommand(str3,conn);
SqlDataReader dr3 = r.ExecuteReader();
while (dr3.Read())
{
if (dr3.GetString(0) == this.textBox1.Text)
{
check = false;
//MessageBox.Show("资产号已重复!");
}
}
dr3.Close();
if (!check)
{
MessageBox.Show("资产号已重复!");
this.textBox1.Text = "";
this.textBox1.Focus();
}
else
{
SqlCommand n = new SqlCommand(str2,conn);
SqlDataReader dr1 = n.ExecuteReader();
while (dr1.Read())
{
if (dr1.GetString(0) == this.textBox5.Text)
{
check1 = true;
break;
}
}
dr1.Close();
if (!check1)
{
MessageBox.Show("用户名不存在!");
this.textBox5.Focus();
}
else
{
check = false;
SqlCommand command = new SqlCommand("addAssetNo1",conn);
command.CommandType = CommandType.StoredProcedure;
SqlParameter AssetNo = new SqlParameter("@assetNo",SqlDbType.VarChar,10);
AssetNo.Value = this.textBox1.Text;
command.Parameters.Add(AssetNo);
SqlParameter AssetCategoryNo = new SqlParameter("@assetCategoryNo",SqlDbType.VarChar,10);
AssetCategoryNo.Value= S;
command.Parameters.Add(AssetCategoryNo);
SqlParameter EmployeeNo = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
EmployeeNo.Value = this.textBox5.Text;
command.Parameters.Add(EmployeeNo);
SqlParameter AssetDescription = new SqlParameter("@assetDescription",SqlDbType.VarChar,20);
AssetDescription.Value = this.textBox27.Text;
command.Parameters.Add(AssetDescription);
SqlParameter Serial = new SqlParameter("@serialNo",SqlDbType.Int);
try
{
Serial.Value = int.Parse(textBox2.Text);
}
catch
{
MessageBox.Show("序列号应为整数!");
}
command.Parameters.Add(Serial);
SqlParameter DateAcquired = new SqlParameter("@dateAcquired",SqlDbType.VarChar,20);
DateAcquired.Value = this.dateTimePicker2.Value.ToShortDateString();
command.Parameters.Add(DateAcquired);
SqlParameter PurchasePrice = new SqlParameter("@purchasePrice",SqlDbType.Float,8);
try
{
PurchasePrice.Value = float.Parse(this.textBox3.Text);
}
catch
{
MessageBox.Show("购入价格输入无效!");
}
command.Parameters.Add(PurchasePrice);
try
{
command.ExecuteNonQuery();
check = true;
}
catch
{
check = false;
}
if (check)
{
MessageBox.Show("添加成功!");
}
}
}
}
else
{
MessageBox.Show("请选择资产种类!");
}
}
conn.Close();
}
private void textBox29_TextChanged(object sender, System.EventArgs e)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -