kaqintongjiframe.cs

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

CS
1,262
字号
				else if(strweek.Equals("Tuesday"))
				{
					if(day<=9)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-9;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-9;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Wednesday"))
				{
					if(day<=10)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-10;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-10;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Thursday"))
				{
					if(day<=11)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-11;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-11;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Friday"))
				{
					if(day<=12)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-12;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-12;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Saturday"))
				{
					if(day<=13)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-13;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-13;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return strDateTime;
		}
		#endregion
		#region 填充下拉表框...
		private void FillComboBox()
		{
			try
			{
                string selectEmployeeName="select distinct 职工名称 from Employee";
                DataTable employeeName=new DataTable();
				employeeName=ExcuteSql(selectEmployeeName,"Employee");
				for(int i=0;i<employeeName.Rows.Count;i++)
				{
					emp_NameComboBox.Items.Add(employeeName.Rows[i][0].ToString());
				}
				emp_NameComboBox.SelectedIndex=0;
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
		#endregion
		#region 未到统计
		private String StaticUnCome()
		{
			string temp="";
			try
			{
                string selectcountUnCome="select count(状态)状态 from Employee_UnCome where 职工名称='"+this.emp_NameComboBox.Text.ToString().Trim()+"' and 状态='未到' and 日期='"+this.EndDateTime.Text.ToString().Trim()+"'";
				DataTable CountUnCometable=new DataTable();
				CountUnCometable=ExcuteSql(selectcountUnCome,"Employee_UnCome");
				for(int i=0;i<CountUnCometable.Rows.Count;i++)
				{
					temp=CountUnCometable.Rows[i][0].ToString().Trim();
					MessageBox.Show(this.emp_NameComboBox.Text.ToString().Trim()+":未到次数:"+temp);
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return temp;
		}
		#endregion
		#region 迟到统计
		private String StaticLate()
		{
			string temp="";
			try
			{
				string selectcountUnCome="select count(状态)状态 from Employee_UnCome where 职工名称='"+this.emp_NameComboBox.Text.ToString().Trim()+"' and 状态='迟到' and 日期='"+this.EndDateTime.Text.ToString().Trim()+"'";
				DataTable CountUnCometable=new DataTable();
				CountUnCometable=ExcuteSql(selectcountUnCome,"Employee_UnCome");
				for(int i=0;i<CountUnCometable.Rows.Count;i++)
				{
					temp=CountUnCometable.Rows[i][0].ToString().Trim();
					MessageBox.Show(this.emp_NameComboBox.Text.ToString().Trim()+":迟到次数:"+temp);
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return temp;
		}
		#endregion
		#region 请假统计
		private String StaticLeave()
		{
			string temp="";
			try
			{

			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return temp;
		}
		#endregion
		#region 职工迟到月统计
		private String  returnLateMonthTable()
		{
			string LateStr="";
			try
			{
				DataTable dataLate=new DataTable();
                dataLate=ExcuteSql("select count(状态)状态 from Employee_Late where  日期 between('"+this.startDateTime.Text.ToString().Trim()+"')and('"+this.EndDateTime.Text.ToString()+"') and 职工名称='"+this.emp_NameComboBox.Text.ToString()+"'","Employee_Late");
				for(int p=0;p<dataLate.Rows.Count;p++)
				{
					LateStr=dataLate.Rows[p][0].ToString().Trim();
					MessageBox.Show("迟到次数:"+LateStr+"次");
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return LateStr;
		}
		#endregion
		#region 职工未到月统计
		private String  returnUncomeSet()
		{
			string UnComeStr="";
			DataTable dataTable=new DataTable();
			try
			{
                dataTable=ExcuteSql("select count(状态)状态 from Employee_UnCome where  日期 between('"+this.startDateTime.Text.ToString()+"')and('"+this.EndDateTime.Text.ToString().Trim()+"') and 职工名称='"+this.emp_NameComboBox.Text.ToString()+"'","Employee_UnCome");
				for(int i=0;i<dataTable.Rows.Count;i++)
				{
                    UnComeStr=dataTable.Rows[i][0].ToString().Trim();
					MessageBox.Show("迟到次数:"+UnComeStr+"次");
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return UnComeStr;
		}
		#endregion
		#region 操作员
		private String returnString()
		{
			string temp="";
			temp=landFrame.strName;
			return temp;
		}
		#endregion
		#region 返回星期几的函数...
		private String returnWeekDay()
		{
			string temp="";
            string tempweek=this.EndDateTime.Value.DayOfWeek.ToString().Trim();
			if(tempweek.Equals("Sunday"))
			{
				temp="星期日";
			}
			else if(tempweek.Equals("Monday"))
			{
				temp="星期一";
			}
			else if(tempweek.Equals("Tuesday"))
			{
				temp="星期二";
			}
			else if(tempweek.Equals("Wednesday"))
			{
				temp="星期三";
			}
			else if(tempweek.Equals("Thursday"))
			{
				temp="星期四";
			}
			else if(tempweek.Equals("Saturday"))
			{
				temp="星期六";
			}
			else if(tempweek.Equals("Friday"))
			{
				temp="星期五";
			}
			return temp;
		}
		#endregion
		#region 统计月考勤事件...
		private void btnMonth_Click(object sender, System.EventArgs e)
		{
			#region  职工名称月考勤统计
			string emps_Name=this.emp_NameComboBox.Text.ToString().Trim();//职工名称
			string emps_Month=this.EndDateTime.Value.Month.ToString();//月份
			string emps_late=returnLateMonthTable();//月考勤迟到次数...
			string emps_UnCome= returnUncomeSet();//月考勤未到次数...
			string emps_Autor=returnString();//备注...
			string emps_Date=System.DateTime.Now.ToLongDateString();//统计日期...
			string insertMonthStatictisStr="Insert into Month_statictis_Table(职工名称,统计日期,月份,迟到次数,未到次数,备注)values('"+emps_Name+"','"+emps_Date+"','"+emps_Month+"','"+emps_late+"','"+emps_UnCome+"','"+emps_Autor+"')";
			int u=conn.ExcuteStrSql(insertMonthStatictisStr);
			if(u>0)
			{
				MessageBox.Show(this,"统计月考勤成功啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			else 
			{
				MessageBox.Show(this,"统计月考勤失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			#endregion
		
		}
		#endregion
		#region 考勤统计历史
		private void kaoqintongjihistory(string str)
		{
			try
			{
				this.sqlConnection.Open();
				this.sqlInsertCommand1.Parameters["日期"].Value=DateTime.Now.ToString("yyyy-MM-dd");
				this.sqlInsertCommand1.Parameters["时间"].Value=WindowsApplication.dealTime.dealTime.dealTimeString(System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second);
				this.sqlInsertCommand1.Parameters["@早退人数"].Value=zhaoTuiFrame.intZhaoTui;
				this.sqlInsertCommand1.Parameters["@迟到人数"].Value=Emp_LateManager.intLate;
				this.sqlInsertCommand1.Parameters["@未到人数"].Value=Emp_UnComeFrame.UnComeCount;
				this.sqlInsertCommand1.Parameters["@请假人数"].Value=LeaveFreamSearch.intLeave;
				this.sqlInsertCommand1.Parameters["@状态"].Value=str;
				int k=this.sqlInsertCommand1.ExecuteNonQuery();
				if(k>0)
				{}
				else
				{
					MessageBox.Show(this,"记录失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			finally
			{
				if(this.sqlConnection.State.Equals(ConnectionState.Open))
				{
					this.sqlConnection.Close();
				}
			}
		}
		#endregion
	}
}

⌨️ 快捷键说明

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