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

📄 addmaintenance.cs

📁 本系统为资产管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.Name = "addMaintenance";
			this.Text = "addMaintenance";
			this.Load += new System.EventHandler(this.addMaintenance_Load);
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
		{
			if (this.radioButton2.Checked == true)
			{
				this.label4.Visible = true;
				this.label11.Visible = false;
				this.label12.Visible = false;
				this.panel2.Visible = true;
				this.radioButton1.Checked = false;
				this.textBox3.Focus();
			}
		}

		private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
		{
			if (this.radioButton1.Checked == true)
			{
				this.label4.Visible = false;
				this.panel2.Visible = false;
				this.radioButton2.Checked = false;
				this.textBox3.Focus();
			}
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
			if (this.textBox1.Text.Trim().Length > 8)
			{
				MessageBox.Show("输入的编号无效!");
				this.textBox1.Text = "";
				this.textBox1.Focus();
			}
		}

		private void textBox2_TextChanged(object sender, System.EventArgs e)
		{
			if (this.textBox2.Text.Trim().Length > 8)
			{
				MessageBox.Show("输入的编号无效!");
				this.textBox2.Text = "";
				this.textBox2.Focus();
			}
		}

		private void textBox3_TextChanged(object sender, System.EventArgs e)
		{
			if (this.textBox3.Text.Trim().Length > 8)
			{
				MessageBox.Show("输入的编号无效!");
				this.textBox3.Text = "";
				this.textBox3.Focus();
			}
			else
			{
				bool check1 = false;
				Connection s = new Connection();
				SqlConnection conn = new SqlConnection(s.getConnectionString);
				conn.Open();
				string str = "select * from agent";
				SqlCommand cmd = new SqlCommand(str,conn);
				SqlDataReader dr = cmd.ExecuteReader();
				while (dr.Read())
				{
					if (this.textBox3.Text.Trim() == Convert.ToString(dr["agentNo"]))
					{
						check1 = true;
						this.label11.Visible = true;
						this.label12.Visible = true;
						this.label12.Text = Convert.ToString(dr["agentName"]);
						break;
					}
					check1 = false;
				}
				if (!check1)
				{
					this.label11.Visible = false;
					this.label12.Visible = false;
				}
			}
		}

		private void textBox4_TextChanged(object sender, System.EventArgs e)
		{
			if (this.textBox4.Text.Trim().Length > 30)
			{
				MessageBox.Show("输入的编号无效!");
				this.textBox4.Text = "";
				this.textBox4.Focus();
			}
		}

		private void textBox5_TextChanged(object sender, System.EventArgs e)
		{
			string s = "";
			if (this.textBox5.Text.Trim().Length > 8)
			{
				MessageBox.Show("输入的编号无效!");
				this.textBox5.Text = "";
				this.textBox5.Focus();
			}
			else
			{
				if (this.textBox5.Text.Trim() != "")
				{
					s = this.textBox5.Text.Trim();
					for (int i = 0;i < s.Length;i++)
					{
						if (s[i] >= '0'&&s[i] <= '9')
						{
							continue;
						}
						else
						{
							MessageBox.Show(" 费用为数字!");
							this.textBox5.Text = "";
							this.textBox5.Focus();
						}
					}
					if ((s.Length >= 2) && (s[0] == '0'))
					{
						MessageBox.Show("无效数据,请重输!");
						this.textBox5.Text = "";
						this.textBox5.Focus();
					}
				}
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			bool Check = false;
			bool check = true;
			Connection c = new Connection();
			maintenance main2 = new maintenance();
			//main2.Open();
			//(string maintenanceNo,string agentNo,string assetNo,string employeeNo,decimal maintenanceDate,string maintenanceDescription,float maintenanceCost)
			/*string constr = 	 "Data Source = (local);"+
				"Integrated Security = SSPI;"+
				"Initial Catalog = "+"资产管理";*/
			if (this.textBox1.Text == "")
			{
				MessageBox.Show("资产号不能为空!");
			}
			else
			{
				SqlConnection conn3 = new SqlConnection(c.getConnectionString);
				conn3.Open();
				string stt = "select * from maintenance";
				SqlCommand cmd5 = new SqlCommand(stt,conn3);
				SqlDataReader drr = cmd5.ExecuteReader();
				while (drr.Read())
				{
					if (this.textBox1.Text == Convert.ToString(drr["maintenanceNo"]))
					{
						MessageBox.Show("维护号已存在!");
						this.textBox1.Text = "";
						check = false;
						break;
					}
				}
				drr.Close();
				conn3.Close();
				if (check)
				{
					if (this.textBox2.Text == "")
					{
						MessageBox.Show("资产号不能为空!");
					}
					else
					{

						if (this.radioButton1.Checked == true)
						{ 
							Check = false;
							string strr  = "select * from asset";
							SqlConnection conn1 = new SqlConnection(c.getConnectionString);
							conn1.Open();
							SqlCommand cmd1 = new SqlCommand(strr,conn1);
							SqlDataReader dr1 = cmd1.ExecuteReader();
							while (dr1.Read())
							{
								if (this.textBox2.Text == Convert.ToString(dr1["assetNo"]))
								{
									Check = true;
								}
							}
							dr1.Close();
							if (Check)
							{
								main2.Open();
								Check = main2.addMaintenance1(this.textBox1.Text.Trim(),this.textBox2.Text.Trim(),this.employeeNo,this.dateTimePicker1.Value.ToShortDateString(),this.textBox4.Text,this.textBox5.Text.Trim());
								//addMaintenance(string maintenanceNo,string agentNo,string assetNo,string employeeNo,string maintenanceDate,string maintenanceDescription,float maintenanceCost)
								if (Check)
								{
									MessageBox.Show("添加成功");
								}
								else
								{
									try
									{
										float.Parse(this.textBox5.Text);
										MessageBox.Show("添加失败!");
									}
									catch
									{
										MessageBox.Show("维护费用以数字表示!");
										this.textBox5.Text = "";
										this.textBox5.Focus();
									}
								}
								main2.Close();
							}
							else
							{
								MessageBox.Show("资产号不存在!");
							}
							conn1.Close();       
						}
						else
						{
							this.label4.Visible = true;
							this.label8.Visible = true;
							this.textBox3.Visible = true;
							this.textBox3.Focus();
							if (this.textBox3.Text.Trim() == "")
							{
								MessageBox.Show("维护商不能为空!");
								this.textBox3.Focus();
							}
							else
							{
								string str1 = "select * from agent";
								string str  = "select * from asset";
								SqlConnection conn = new SqlConnection(c.getConnectionString);
								conn.Open();
								SqlCommand cmd = new SqlCommand(str1,conn);
								SqlDataReader dr = cmd.ExecuteReader();
								while (dr.Read())
								{
									if (this.textBox3.Text == Convert.ToString(dr["agentNo"]))
									{
										Check = true;
										break;
									}
								}
								dr.Close();
								conn.Close();
								if (Check)
								{
									Check = false;
									SqlConnection conn1 = new SqlConnection(c.getConnectionString);
									conn1.Open();
									SqlCommand cmd1 = new SqlCommand(str,conn1);
									SqlDataReader dr1 = cmd1.ExecuteReader();
									while (dr1.Read())
									{
										if (this.textBox2.Text == Convert.ToString(dr1["assetNo"]))
										{
											Check = true;
										}
									}
									dr1.Close();
									if (Check)
									{
										main2.Open();
										Check = main2.addMaintenance(this.textBox1.Text.Trim(),this.textBox3.Text.Trim(),this.textBox2.Text.Trim(),this.employeeNo,this.dateTimePicker1.Value.ToShortDateString(),this.textBox4.Text,this.textBox5.Text.Trim());
											//addMaintenance(string maintenanceNo,string agentNo,string assetNo,string employeeNo,string maintenanceDate,string maintenanceDescription,float maintenanceCost)
										if (Check)
										{
											MessageBox.Show("添加成功");
										}
										else
										{
											try
											{
												float.Parse(this.textBox5.Text);
												MessageBox.Show("添加失败!");
											}
											catch
											{
												MessageBox.Show("维护费用以数字表示!");
												this.textBox5.Text = "";
												this.textBox5.Focus();
											}
										}
										main2.Close();
									}
									else
									{
										MessageBox.Show("资产号不存在!");
									}
									conn1.Close();
								}
								else
								{
									MessageBox.Show("维护商号不存在!");
								}
							}
						}
					}
				}
			}
		}

		private void addMaintenance_Load(object sender, System.EventArgs e)
		{
			this.radioButton1.Checked = true;
			this.radioButton2.Checked = false;
			this.label4.Visible = false;
			this.panel2.Visible = false;
			this.textBox1.Text = "";
			this.textBox2.Text = "";
			this.textBox3.Text = "";
			this.textBox4.Text = "";
			this.textBox5.Text = "";
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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