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

📄 leavesearchframe.cs

📁 独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 
💻 CS
📖 第 1 页 / 共 2 页
字号:
		}
		#endregion
		#region 光标移动变化...
		private void resultText_MouseLeave(object sender, System.EventArgs e)
		{
		    ComboBox con=(ComboBox)sender;
			con.DropDownStyle=System.Windows.Forms.ComboBoxStyle.Simple;
		}

		private void resultText_MouseEnter(object sender, System.EventArgs e)
		{
			ComboBox con=(ComboBox)sender;
			con.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDown;
		}
		#endregion
		#region 如果选择改变事件...
		private void searchText_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(this.searchText.Text.Equals("当天"))
			{
				int year=System.DateTime.Now.Year;
				int month=System.DateTime.Now.Month;
				int day=System.DateTime.Now.Day;
                this.startDateTime.Text=year.ToString()+"-"+month.ToString()+"-"+day.ToString();
				this.EndDateTime.Text=year.ToString()+"-"+month.ToString()+"-"+day.ToString();
			}
			else if(this.searchText.Text.Equals("本周"))
			{
			   string temp=this.startDateTime.Value.DayOfWeek.ToString();
			   int year=year=System.DateTime.Now.Year;
			   int month=System.DateTime.Now.Month;
			   int day=System.DateTime.Now.Day;
			   string str=returnWeekSeveral(temp,year,month,day);
			   this.startDateTime.Text=str;
			   this.EndDateTime.Text=year.ToString()+"-"+month.ToString()+"-"+day.ToString();
			}
			else if(this.searchText.Text.Equals("上周"))
			{
				try
				{
					int year=System.DateTime.Now.Year;
					int month=System.DateTime.Now.Month;
					int day=System.DateTime.Now.Day;
					string temps=this.startDateTime.Value.DayOfWeek.ToString();
					this.startDateTime.Text=returnString(temps,year, month, day);
					this.EndDateTime.Text=this.returnWeekSeveral(temps,year,month,day);
				}
				catch(Exception ele)
				{
					MessageBox.Show(ele.ToString());
				}
			}
		}
		#endregion
		#region 结果集合...
		private void resultText_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			for(int i=0;i<this.resultText.Items.Count;i++)
			{
				if(this.resultText.Text.Equals(this.resultText.Items[i].ToString()))
				{
                     sqlSearch="'"+this.resultText.Items[i].ToString()+"'";
				}
			}
		}
		#endregion
		#region DataConnectionTable
		private void returnDataTable()
		{
			try
			{

			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
		#endregion
		#region  返回是星期日是哪一天...
		private String returnWeekSeveral(string strweek,int year,int month,int day)
		{
			string strDateTime="";
			try
			{
				if(strweek.Equals("Sunday"))
				{
                    int lastday=day-0;
					strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
				}
				else if(strweek.Equals("Monday"))
				{
					if(day<=1)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-1;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-1;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Tuesday"))
				{
					if(day<=2)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-2;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-2;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Wednesday"))
				{
					if(day<=3)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-3;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-3;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Thursday"))
				{
					if(day<=4)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-4;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-4;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Friday"))
				{
					if(day<=5)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-5;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-5;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				else if(strweek.Equals("Saturday"))
				{
					if(day<=6)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-6;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-6;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return strDateTime;
		}
		#endregion
		#region 判断当前月份是哪个月...并返回此月的天数....
		private int ReturnMonthDays (int month,int year)
		{
			int days=0;
			#region 月为1,3,5,7,8,10,12
			//判断这个月是一,三,五,七,八,十,十二。那么这个月有31天
			if(month.Equals(1) || month.Equals(3)|| month.Equals(5)|| month.Equals(7)|| month.Equals(8)|| month.Equals(10)|| month.Equals(12))
			{
				days=31; 
			}
			#endregion
			#region	判断是否为二月
			else if (month.Equals(2))
			{
                #region 判断是否为润年
				if(year % 4 ==0)
				{
					days=29;
				}
				else
				{
					days=28;
				}
				#endregion
			}
			#endregion
            #region 如果月为大于12,那么将出错啦!!!
			else if(month>12)
			{
				MessageBox.Show(this,"出现错误啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			#endregion
			#region 判断月为4,6,9,11
			else if(month.Equals(4)|| month.Equals(6) || month.Equals(9)|| month.Equals(11))
			{
				days=30;
			}
			#endregion
			return days;
		}
		#endregion
		#region 取消事件...
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
            DialogResult result=MessageBox.Show(this,"是否要关闭窗体呢???","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Information);	
			if(result.Equals(DialogResult.Yes))
			{
				Close();
			}
			else 
			{
				return;
			}
		}
		#endregion
		#region 历史记录...
		private void btnHistory_Click(object sender, System.EventArgs e)
		{
		
		}
		#endregion
		#region 返回上一周的函数...
		private String returnString(string strweek,int year,int month,int day)
		{
			string strDateTime="";
			try
			{
				if(strweek.Equals("Sunday"))
				{
					if(day<=7)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-7;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					int lastday=day-7;
					strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
				}
				else if(strweek.Equals("Monday"))
				{
					if(day<=8)
					{
						int lastmonth=month-1;
						int days=ReturnMonthDays(lastmonth,year);
						int temp=day+days;
						int lastweekday=temp-8;
						strDateTime=year.ToString()+"-"+lastmonth.ToString()+"-"+lastweekday.ToString();
					}
					else
					{
						int lastday=day-8;
						strDateTime=year.ToString()+"-"+month.ToString()+"-"+lastday.ToString();
					}
				}
				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
	}
}

⌨️ 快捷键说明

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