employeeleavemanager.cs

来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 525 行 · 第 1/2 页

CS
525
字号
			this.Controls.Add(this.label5);
			this.Controls.Add(this.textLeaveDays);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnHistory);
			this.Controls.Add(this.btnOk);
			this.Controls.Add(this.textReason);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.textCourseCom);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.textEmployeeName);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Cursor = System.Windows.Forms.Cursors.Hand;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "EmployeeLeaveManager";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "EmployeeLeaveManager";
			this.Load += new System.EventHandler(this.EmployeeLeaveManager_Load);
			this.ResumeLayout(false);

		}
		#endregion
		#region 事件初始化...
		private void EmployeeLeaveManager_Load(object sender, System.EventArgs e)
		{
			try
			{
				#region 初始化TextReseason
				this.textEmployeeName.Focus();
				this.textReason.Enabled=false;
				#endregion
				#region 初始化请假原因控件...
				this.textCourseCom.SelectedIndex=0;
				#endregion
				#region 初始化 TextEmployeeCombox
                UnCometable=returnDataTable();
				for(int k=0;k<UnCometable.Rows.Count;k++)
				{
					textEmployeeName.Items.Add(UnCometable.Rows[k][0].ToString().Trim());
				}
				#endregion
				#region 查询表中是否有记录

				#endregion
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
		#endregion
		#region returnDataTable
		private DataTable returnDataTable()
		{
			strUnComeSql="select distinct  职工名称 from Employee_UnCome where 状态='未到'and 日期='"+System.DateTime.Now.ToLongDateString()+"'";
			DataTable data=new DataTable();
			try
			{
				data=ExcuteSql(strUnComeSql,"Employee_UnCome");
			}
			catch(Exception els)
			{
				els.ToString();
			}
			return data;
		}
		#endregion
		#region DataFunction
		private DataTable ExcuteSql(string strSql,string tableName)
		{
			DataSet dsSet=new DataSet();
			DataTable dsTable=new DataTable();
			try
			{
				dsSet=conn.ExcuteDataSetResult(strSql,tableName);
				dsTable=dsSet.Tables[0];
			}
			catch(Exception eles)
			{
				MessageBox.Show(this,eles.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return dsTable;
		}
		#endregion
		#region 请假原因改变时发生变化...
		private void textCourseCom_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(this.textCourseCom.Text.ToString().Trim().Equals("其他"))
			{
				this.textReason.Enabled=true;
				this.textReason.Focus();
				this.textCourseCom.Text=this.textReason.Text.ToString().Trim();
			}
			else
			{
				this.textReason.Enabled=false;
			}
		}
		#endregion
		#region 光标移动变化...
		private void btnOk_MouseLeave(object sender, System.EventArgs e)
		{
		    Button button=(Button)sender;
			button.FlatStyle=FlatStyle.Flat;
			button.Font=new Font("宋体",10,FontStyle.Bold);
		}

		private void btnOk_MouseEnter(object sender, System.EventArgs e)
		{
			Button button=(Button)sender;
			button.FlatStyle=FlatStyle.Standard;
			button.Font=new Font("楷体",10,FontStyle.Underline);
		}
		private void textEmployeeName_MouseLeave(object sender, System.EventArgs e)
		{
			this.textEmployeeName.DropDownStyle=System.Windows.Forms.ComboBoxStyle.Simple;
		}

		private void textEmployeeName_MouseEnter(object sender, System.EventArgs e)
		{
			this.textEmployeeName.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDown;
		}
		private void textCourseCom_MouseLeave(object sender, System.EventArgs e)
		{
		    ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.Simple;
		}

		private void textCourseCom_MouseEnter(object sender, System.EventArgs e)
		{
			ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDownList;
		}
		#endregion
		#region 确定事件...
		private void btnOk_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(CheckNull().Equals(false))
				{
					return;
				}
				InsertEmployee_LeaveTable();
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
		#endregion
		#region 历史记录事件...
		private void btnHistory_Click(object sender, System.EventArgs e)
		{
		
		}
		#endregion
		#region 取消事件...
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
		    DialogResult result=MessageBox.Show(this,"是否关闭窗体啦!!!","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
			if(result.Equals(DialogResult.Yes))
			{
				Close();
			}
			else
			{
				return;
			}
		}
		#endregion
		#region CheckNull()
		private bool CheckNull()
		{
			bool f=true;
			if(this.textEmployeeName.Text.Equals(""))
			{
				MessageBox.Show(this,"职工名称不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.textEmployeeName.Focus();
				f=false;
			}
			else if(this.textCourseCom.Text.Equals(""))
			{
				MessageBox.Show(this,"请假原因不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.textCourseCom.Focus();
				f=false;
			}
			else if(this.textCourseCom.Text.Equals("其他"))
			{
				if(this.textReason.Text.Equals(""))
				{
					MessageBox.Show(this,"其他必须不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.textReason.Focus();
					f=false;
				}
			}
			else if(this.textLeaveDays.Text.Equals(""))
			{
				MessageBox.Show(this,"请假天数不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.textLeaveDays.Focus();
				f=false;
			}
//			else if("")
//			{
//                //表中如果存在该项记录应该怎么处理呢???
//			}
			return f;
		}
		#endregion
		#region ClearText()
		private void ClearText()
		{
			this.textCourseCom.Text="";
			this.textEmployeeName.Text="";
			this.textReason.Text="";
			this.textLeaveDays.Text="";
		}
		#endregion
		#region  InsertEmployee_LeaveTable()
		private void InsertEmployee_LeaveTable()
		{
			if(this.textCourseCom.Text.Equals("其他"))
			{
				string insertEmp_LeaveSql="Insert into Employee_LeaveTable(职工名称,日期,请假原因,请假天数)values('"+this.textEmployeeName.Text.ToString().Trim()+"','"+System.DateTime.Now.ToLongDateString().Trim()+"','"+this.textReason.Text.ToString().Trim()+"','"+this.textLeaveDays.Text.ToString()+"')";
				int k=conn.ExcuteStrSql(insertEmp_LeaveSql);
				if(k>0)
				{
					MessageBox.Show(this,"请假成功啦啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
				else
				{
					MessageBox.Show(this,"请假失败啦啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
			}
			else
			{
				string insertEmp_LeaveSql="Insert into Employee_LeaveTable(职工名称,日期,请假原因,请假天数)values('"+this.textEmployeeName.Text.ToString().Trim()+"','"+System.DateTime.Now.ToLongDateString().Trim()+"','"+this.textCourseCom.Text.ToString().Trim()+"','"+this.textLeaveDays.Text.ToString()+"')";
				int k=conn.ExcuteStrSql(insertEmp_LeaveSql);
				if(k>0)
				{
					MessageBox.Show(this,"请假成功啦啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
				else
				{
					MessageBox.Show(this,"请假失败啦啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
			}
		}
		#endregion
		#region 查询表中是否有记录

		#endregion
	}
	#endregion
}

⌨️ 快捷键说明

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