⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assetoperate.cs

📁 本系统为资产管理系统
💻 CS
📖 第 1 页 / 共 5 页
字号:
		}

		private void button9_Click(object sender, System.EventArgs e)
		{
			assetCategory ass = new assetCategory();
			ass.Open();
			SqlConnection conn = new SqlConnection(ass.getConnectionString);
			conn.Open();

			if (this.textBox28.Text == "")
				MessageBox.Show("请输入资产种类号!");
			else
			{
				if (this.textBox29.Text == "")
					MessageBox.Show("请输入资产种类名!");
				else
				{
			       bool check = ass.AddAssetCategory(this.textBox28.Text,this.textBox29.Text);
					if (check)
					{
									MessageBox.Show("添加成功!");
									this.textBox28.Text = "";
									//this.textBox29.Text = "";
									this.comboBox1.Items.Add(this.textBox29.Text);
									this.comboBox2.Items.Add(this.textBox29.Text);
									//this.comboBox3.Items.Add(this.textBox29.Text);
									this.textBox29.Text = "";
								
					}
				}
			}
			conn.Close();
		}

		private void tabPage5_Click(object sender, System.EventArgs e)
		{

		}

		private void button10_Click(object sender, System.EventArgs e)
		{
			if (this.textBox28.Text == "")
			{
				MessageBox.Show("资产种类号不能为空!");
			}
			assetCategory ass = new assetCategory();
			ass.Open();
			string str1 = this.textBox29.Text.Trim();
			SqlConnection conn = new SqlConnection(ass.getConnectionString);
			conn.Open();

			//bool check = ass.modifyAssetCategory(textBox28.Text,textBox29.Text);
				bool check = ass.modifyAssetCategory(textBox28.Text,textBox29.Text);
				if (check)
				{
					MessageBox.Show("修改成功!");
					this.comboBox1.Items.Remove(str1);
					this.comboBox1.Items.Add(this.textBox29.Text.Trim());
					this.comboBox2.Items.Remove(str1);
					this.comboBox2.Items.Add(this.textBox29.Text.Trim());
				}

			conn.Close();
			
			
		}

		private void button11_Click(object sender, System.EventArgs e)
		{
			if (this.textBox28.Text == "")
			{
				MessageBox.Show("资产种类号不能为空!");
				this.textBox28.Focus();
				this.textBox28.Focus();
			}
			Connection conn = new Connection();
			SqlConnection coo = new SqlConnection(conn.getConnectionString);
			coo.Open();
			SqlCommand cmd = new SqlCommand("DeleteAssetCategory",coo);
			cmd.CommandType = CommandType.StoredProcedure;
			SqlParameter d = new SqlParameter("@assetCategoryNo",SqlDbType.VarChar,10);
			d.Value = this.textBox28.Text;
			cmd.Parameters.Add(d);
			try
			{
				cmd.ExecuteNonQuery();
				MessageBox.Show("删除成功!");
			}
			catch
			{
				MessageBox.Show("删除失败!");
			}
			coo.Close();
		}

		private void textBox28_TextChanged(object sender, System.EventArgs e)
		{
			assetCategory ass = new assetCategory();
			bool check = true;
			SqlConnection conn1 = new SqlConnection(ass.getConnectionString);
			conn1.Open();
			string stri = "select * from AssetCategory";
			SqlCommand cmd = new SqlCommand(stri,conn1);
			SqlDataReader dr1  = cmd.ExecuteReader();
			if (textBox28.Text.Trim().Length > 4)
			{
				MessageBox.Show("输入的资产种类号无效!");
			}
			else
			{
				while (dr1.Read())
				{
					if (dr1.GetString(0) == textBox28.Text)
					{
						textBox29.Text = dr1.GetString(1);
						check = false;
						this.button9.Enabled =false;
						//this.button11.Enabled = true;
						this.button10.Enabled = true;
						break;
					}
                
				}
				if (check)
				{
					this.button9.Enabled = true;
					//this.button11.Enabled = false;
					this.button10.Enabled = false;
					this.textBox29.Text = "";
				}
			}
			dr1.Close();
			conn1.Close();
	

			
		
		}

		private void dateTimePicker2_ValueChanged(object sender, System.EventArgs e)
		{
		
		}

		private void button7_Click(object sender, System.EventArgs e)
		{
			if (this.textBox17.Text.Trim() == "")
			{
				MessageBox.Show("资产号不能为空!");
				this.textBox17.Focus();
			}
			else
			{
				if (this.textBox4.Text.Trim() == "")
				{
					MessageBox.Show("员工号不能为空!");
					this.textBox4.Focus();
				}
				else
				{
					if (this.comboBox2.Text.Trim() == "")
					{
						MessageBox.Show("请选择资产种类!");
						this.comboBox2.Focus();
					}
					else
					{
						if (checking)
						{
							asset ass = new asset();
							string S = "";
							bool check = false;
							SqlConnection conn = new SqlConnection(ass.getConnectionString);
							conn.Open();
							string str = "select * from AssetCategory";
							SqlCommand cm = new SqlCommand(str,conn);
							SqlDataReader dr  = cm.ExecuteReader();
							while(dr.Read())
							{
								if (dr.GetString(1) == this.comboBox2.Text)
								{
									S = dr.GetString(0);
									//MessageBox.Show(S);
									//check = true;
									break;
								}
							}
							dr.Close();
							//string s = "001";
							//SqlConnection coo = new SqlConnection(ass.getConnectionString);
							SqlCommand cmd = new SqlCommand("modifyAsset1",conn);
							cmd.CommandType = CommandType.StoredProcedure;
							SqlParameter AssetNo = new SqlParameter("@assetNo",SqlDbType.VarChar,10);
							AssetNo.Value = this.textBox17.Text.Trim();
							cmd.Parameters.Add(AssetNo);
							SqlParameter AssetCategory = new SqlParameter("@assetCategoryNo",SqlDbType.VarChar,10);
							AssetCategory.Value = S;
							cmd.Parameters.Add(AssetCategory);
							SqlParameter EmployeeNo = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
							EmployeeNo.Value = this.textBox4.Text.Trim ().ToUpper();
							cmd.Parameters.Add(EmployeeNo);
							SqlParameter SerialNo = new SqlParameter("@serialNo",SqlDbType.Int);
							try
							{
								SerialNo.Value = int.Parse(this.textBox18.Text.Trim());
							}
							catch
							{
								MessageBox.Show("序列号应为整数!");
							}
							cmd.Parameters.Add(SerialNo);
							SqlParameter PurchasePrice = new SqlParameter("@purchasePrice",SqlDbType.Float,8);
							try
							{
								PurchasePrice.Value = float.Parse(this.textBox20.Text);
							}
							catch
							{
								MessageBox.Show("价格输入格式不对!");
							}
							cmd.Parameters.Add(PurchasePrice);
							SqlParameter DateAcquired = new SqlParameter("@dateAcquired",SqlDbType.VarChar,20);
							DateAcquired.Value = this.dateTimePicker3.Value.ToString();
							cmd.Parameters.Add(DateAcquired);
							//			SqlParameter DateSold = new SqlParameter("@dateSold",SqlDbType.VarChar,20);
							//			DateSold.Value = this.dateTimePicker4.Value.ToShortDateString();
							//			cmd.Parameters.Add(DateSold);
							//			SqlParameter NextMaintenanceDate = new SqlParameter("@nextMaintenanceDate",SqlDbType.VarChar,20);
							//			NextMaintenanceDate.Value = this.dateTimePicker5.Value.ToString();
							//			cmd.Parameters.Add(NextMaintenanceDate);
							SqlParameter AssetDescription = new SqlParameter("@assetDescription",SqlDbType.VarChar,20);
							AssetDescription.Value = this.textBox24.Text;
							cmd.Parameters.Add(AssetDescription);
							//SqlParameter StatusNo = new SqlParameter("@statusNo",SqlDbType.VarChar,10);
							//StatusNo.Value = this.textBox25.Text;
							//cmd.Parameters.Add(StatusNo);
							try
							{
								cmd.ExecuteNonQuery();
								check = true;
							}
							catch
							{
								MessageBox.Show("修改失败!");
							}
							if (check)
							{
								MessageBox.Show("修改成功!");
							}
							conn.Close();
						}
						else
						{
							MessageBox.Show("员工号不存在!");
							this.textBox4.Text = "";
							this.textBox4.Focus();
						}
					}
				}
			}

	}

		private void textBox21_TextChanged(object sender, System.EventArgs e)
		{
		   
		}

		private void textBox17_TextChanged(object sender, System.EventArgs e)
		{
			if (this.textBox17.Text.Trim().Length > 10)
			{
				MessageBox.Show("资产号长度不超过10位!");
				this.textBox17.Text = "";
				this.textBox17.Focus();
			}
			else
			{
				bool c = false;
				string employeeNo = "";
				string category = "";
				Connection s = new Connection();
				SqlConnection conn = new SqlConnection(s.getConnectionString);
				conn.Open();
				string str = "select * from asset";
                SqlCommand cmd  = new SqlCommand(str,conn);
				SqlDataReader dr = cmd.ExecuteReader();
				while (dr.Read())
				{
					if (this.textBox17.Text == Convert.ToString(dr["assetNo"]))
					{
						this.textBox18.Text = Convert.ToString(dr["serialNo"]);
						this.textBox4.Text = Convert.ToString(dr["employeeNo"]);
						this.textBox20.Text = Convert.ToString(dr["purchasePrice"]);
						this.textBox24.Text = Convert.ToString(dr["assetDescription"]);
						employeeNo = Convert.ToString(dr["employeeNo"]);
						category = Convert.ToString(dr["assetCategoryNo"]);
						c = true;
						this.button7.Enabled = true;
						break;
					}
				}
				dr.Close();
				if (c)
				{
					string str1 = "select * from employee";
					SqlCommand cmd1 = new SqlCommand(str1,conn);
					SqlDataReader dr1 = cmd1.ExecuteReader();
					while (dr1.Read())
					{
						if (employeeNo == Convert.ToString(dr1["employeeNo"]))
						{
							this.label12.Text = Convert.ToString(dr1["employeeName"]);
							break;
						}
					}
					dr1.Close();
					string str2 = "select * from assetCategory";
					SqlCommand cmd2 = new SqlCommand(str2,conn);
					SqlDataReader dr2 = cmd2.ExecuteReader();
					while (dr2.Read())
					{
						if (category == Convert.ToString(dr2["assetCategoryNo"]))
						{
							this.comboBox2.Text = Convert.ToString(dr2["assetCategoryDescription"]);
							break;
						}
					}
					dr2.Close();
				}
				else
				{
					//MessageBox.Show("资产号不存在!");
					//this.textBox17.Text = "";
					this.textBox17.Focus();
					this.button7.Enabled = false;
					this.textBox18.Text = "";
					this.textBox4.Text = "";
					this.textBox20.Text = "";
					this.textBox24.Text = "";
					this.label12.Text = "";
				}
				conn.Close();
			}
		}


		private void textBox18_TextChanged(object sender, System.EventArgs e)
		{
			string s = "";
			if (this.textBox18.Text.Trim().Length > 8)
			{
				MessageBox.Show("输入数据无效!");
				this.textBox18.Text = "";
				this.textBox18.Focus();
			}
			else
			{
				if (this.textBox18.Text.Trim() != "")
				{
					s = this.textBox18.Text.Trim();
					for (int i = 0;i < s.Length;i++)
					{
						if (s[i] >= '0'&&s[i] <= '9')
						{
							continue;
						}
						else
						{
							MessageBox.Show(" 序列号应为数字!");
							this.textBox18.Text = "";
							this.textBox18.Focus();
						}
					}
				}
			}
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			if (this.textBox12.Text.Trim() == "")
			{
				MessageBox.Show("资产号不能为空!");
				this.textBox12.Focus();
			}
			else
			{
				if (this.textBox14.Text.Trim() == "")
				{
					MessageBox.Show("估价号不能为空!");
					this.textBox14.Focus();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -