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

📄 formnewemployee.cs

📁 蓝山人事管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.buttonUploadPhoto.Name = "buttonUploadPhoto";
			this.buttonUploadPhoto.TabIndex = 1;
			this.buttonUploadPhoto.Text = "上传照片";
			this.buttonUploadPhoto.Click += new System.EventHandler(this.buttonUploadPhoto_Click);
			// 
			// chkPrint
			// 
			this.chkPrint.Location = new System.Drawing.Point(64, 296);
			this.chkPrint.Name = "chkPrint";
			this.chkPrint.TabIndex = 22;
			this.chkPrint.Text = "打印报到单";
			// 
			// btnNewEmployee
			// 
			this.btnNewEmployee.Location = new System.Drawing.Point(312, 344);
			this.btnNewEmployee.Name = "btnNewEmployee";
			this.btnNewEmployee.TabIndex = 23;
			this.btnNewEmployee.Text = "新建";
			this.btnNewEmployee.Click += new System.EventHandler(this.btnNewEmployee_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(432, 344);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 24;
			this.btnCancel.Text = "取消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.buttonUploadPhoto);
			this.groupBox1.Controls.Add(this.picPhoto);
			this.groupBox1.Location = new System.Drawing.Point(336, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(176, 192);
			this.groupBox1.TabIndex = 25;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "照片";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(48, 240);
			this.label6.Name = "label6";
			this.label6.TabIndex = 26;
			this.label6.Text = "级别";
			// 
			// cbDepartment
			// 
			this.cbDepartment.Location = new System.Drawing.Point(176, 176);
			this.cbDepartment.Name = "cbDepartment";
			this.cbDepartment.Size = new System.Drawing.Size(121, 20);
			this.cbDepartment.TabIndex = 27;
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(8, 8);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(24, 32);
			this.pictureBox1.TabIndex = 28;
			this.pictureBox1.TabStop = false;
			// 
			// pictureBox2
			// 
			this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
			this.pictureBox2.Location = new System.Drawing.Point(8, 48);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(24, 24);
			this.pictureBox2.TabIndex = 29;
			this.pictureBox2.TabStop = false;
			// 
			// pictureBox4
			// 
			this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
			this.pictureBox4.Location = new System.Drawing.Point(8, 288);
			this.pictureBox4.Name = "pictureBox4";
			this.pictureBox4.Size = new System.Drawing.Size(32, 32);
			this.pictureBox4.TabIndex = 31;
			this.pictureBox4.TabStop = false;
			// 
			// pictureBox5
			// 
			this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
			this.pictureBox5.Location = new System.Drawing.Point(312, 280);
			this.pictureBox5.Name = "pictureBox5";
			this.pictureBox5.Size = new System.Drawing.Size(40, 32);
			this.pictureBox5.TabIndex = 32;
			this.pictureBox5.TabStop = false;
			// 
			// pictureBox3
			// 
			this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
			this.pictureBox3.Location = new System.Drawing.Point(8, 136);
			this.pictureBox3.Name = "pictureBox3";
			this.pictureBox3.Size = new System.Drawing.Size(24, 32);
			this.pictureBox3.TabIndex = 33;
			this.pictureBox3.TabStop = false;
			// 
			// pictureBox6
			// 
			this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
			this.pictureBox6.Location = new System.Drawing.Point(8, 200);
			this.pictureBox6.Name = "pictureBox6";
			this.pictureBox6.Size = new System.Drawing.Size(32, 32);
			this.pictureBox6.TabIndex = 34;
			this.pictureBox6.TabStop = false;
			// 
			// FormNewEmployee
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(606, 379);
			this.Controls.Add(this.pictureBox6);
			this.Controls.Add(this.pictureBox3);
			this.Controls.Add(this.pictureBox5);
			this.Controls.Add(this.pictureBox4);
			this.Controls.Add(this.pictureBox2);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.cbDepartment);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnNewEmployee);
			this.Controls.Add(this.chkPrint);
			this.Controls.Add(this.numLevel);
			this.Controls.Add(this.txtTel);
			this.Controls.Add(this.txtPos);
			this.Controls.Add(this.txtBaseSalary);
			this.Controls.Add(this.txtEmail);
			this.Controls.Add(this.txtBirthday);
			this.Controls.Add(this.txtPassword);
			this.Controls.Add(this.txtUserName);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.label10);
			this.Controls.Add(this.txtPos1);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FormNewEmployee";
			this.Text = "新建员工";
			((System.ComponentModel.ISupportInitialize)(this.numLevel)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

			if(IsNumber(this.txtBaseSalary.Text)&&IsNumber(this.txtTel.Text))
			{
				if(this.txtName.Text=="" || this.txtUserName.Text=="" || this.txtEmail.Text=="" || this.txtBirthday.Text=="" || this.txtBaseSalary.Text=="" || this.txtTel.Text==""|| this.txtPos.Text=="")
				{
					MessageBox.Show("请正确完整输入!");
				}
				else
				{
					try
					{
						conn=new SqlConnection("Initial Catalog=BlueHill;Data Source=(local);Trusted_Connection=Yes");
						adp=new SqlDataAdapter("select * from tblEmployee",conn);
						conn.Open();
						string notimgb="insert into tblEmployee(Name,LoginName,Password,Email,DeptID,BasicSalary,Telephone,OnboardDate,EmployeeLevel,Title) values(@cName,@cLoginName,@cPassword,@cEmail,@cDeptID,@cBasicSalary,@cTelephone,@cOnboardDate,@cEmployeeLevel,@cTitle)";
						string haveimgb="insert into tblEmployee(Name,LoginName,Password,Email,DeptID,BasicSalary,Telephone,OnboardDate,EmployeeLevel,PhotoImage,Title) values(@cName,@cLoginName,@cPassword,@cEmail,@cDeptID,@cBasicSalary,@cTelephone,@cOnboardDate,@cEmployeeLevel,@cPhoto,@cTitle)";
						if(imgb==null)
						{
							com=new SqlCommand(notimgb,conn);
						}
						else
						{
							com=new SqlCommand(haveimgb,conn);
							com.Parameters.Add("@cPhoto",SqlDbType.Image);
							com.Parameters["@cPhoto"].Value=imgb;

						}

						UnicodeEncoding UE=new UnicodeEncoding();
						byte [] pwd = UE.GetBytes(this.txtPassword.Text); 
						SHA1Managed sha =new SHA1Managed();
						byte[] HashedPwd = sha.ComputeHash(pwd);

						com.Parameters.Add("@cName",SqlDbType.NVarChar,24);
						com.Parameters.Add("@cLoginName",SqlDbType.NVarChar,20);
						com.Parameters.Add("@cEmail",SqlDbType.NVarChar,50);
						com.Parameters.Add("@cOnboardDate",SqlDbType.DateTime,20);
						com.Parameters.Add("@cBasicSalary",SqlDbType.Int,4);
						com.Parameters.Add("@cDeptID",SqlDbType.Int,4);
						com.Parameters.Add("@cTelephone",SqlDbType.NVarChar,20);	
						com.Parameters.Add("@cEmployeeLevel",SqlDbType.Int,4);
						com.Parameters.Add("@cTitle",SqlDbType.NVarChar,50);				
						com.Parameters.Add("@cPassword",SqlDbType.Binary,20);

						com.Parameters["@cName"].Value=this.txtName.Text;
						com.Parameters["@cLoginName"].Value=this.txtUserName.Text;
						com.Parameters["@cEmail"].Value=this.txtEmail.Text;
						com.Parameters["@cOnboardDate"].Value=this.txtBirthday.Text;			
						com.Parameters["@cBasicSalary"].Value=this.txtBaseSalary.Text;
						com.Parameters["@cTelephone"].Value=this.txtTel.Text;
						com.Parameters["@cTitle"].Value=this.txtPos.Text;
						com.Parameters["@cEmployeeLevel"].Value=this.numLevel.Value;
						com.Parameters["@cDeptID"].Value=(int)this.cbDepartment.SelectedValue;						
				
						com.Parameters["@cPassword"].Value=HashedPwd;

						int i=com.ExecuteNonQuery();
						if(i>0)
						{
							MessageBox.Show("插入成功");
						}

						if(chkPrint.Checked)
						{
							MessageBox.Show("打印到报单");
							conn=new SqlConnection("Initial Catalog=BlueHill;Data Source=(local);Trusted_Connection=Yes");
							conn.Open();
							adp=new SqlDataAdapter("select * from tblemployee where Name=@Name",conn);
							adp.SelectCommand.Parameters.Add("@Name",SqlDbType.NVarChar,24);
							adp.SelectCommand.Parameters["@Name"].Value=this.txtName.Text;					
							DataSet ds = new DataSet();
							DataTable dt =new DataTable();
							adp.Fill(ds,"tblemployee");
							
							
						    this.Close();
						}
						else
						{
							this.Close();
						}	
					}
					catch(Exception)
					{
						MessageBox.Show("登录名相同!请重新输入登录名!");
					}
					finally
					{
						conn.Close();
					}
				
								
				}
				
			}
			else
			{
				MessageBox.Show("请输入正确字符!");
			}
		}

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

		private void buttonUploadPhoto_Click(object sender, System.EventArgs e)
		{
			FormPhotoPath frmPhotoPath = new FormPhotoPath();
			frmPhotoPath.ShowDialog();
			imgb=frmPhotoPath.imgb;
			picPhoto.Image=frmPhotoPath.picPhoto.Image;
		
		}


			

			          
			
				

		




		
	}
}


⌨️ 快捷键说明

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