dateframe.cs

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

CS
265
字号
#region 命名空间...using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;#endregionnamespace WindowsApplication.EmployeeLeaveManager{	public class DateFrame : System.Windows.Forms.Form	{
		#region 控件及变量...
		private System.Windows.Forms.ComboBox textDate;		private System.ComponentModel.IContainer components = null;
		private System.Windows.Forms.Label TitleLabel;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnSearch;
		private System.Windows.Forms.ImageList imageList;		private ConnectionData conn=new ConnectionData();		private string SelectStr="";		#endregion
		#region 构造函数...		public DateFrame()		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		public DateFrame(string sql)		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();            this.SelectStr=sql;			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		#endregion		#region 清除函数...		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		#endregion		#region 设计器生成的代码		/// <summary>		/// 设计器支持所需的方法 - 不要使用代码编辑器修改		/// 此方法的内容。		/// </summary>		private void InitializeComponent()		{			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DateFrame));
			this.textDate = new System.Windows.Forms.ComboBox();
			this.TitleLabel = new System.Windows.Forms.Label();
			this.btnSearch = new System.Windows.Forms.Button();
			this.imageList = new System.Windows.Forms.ImageList(this.components);
			this.button2 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// textDate
			// 
			this.textDate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
			this.textDate.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.textDate.Location = new System.Drawing.Point(104, 56);
			this.textDate.Name = "textDate";
			this.textDate.Size = new System.Drawing.Size(152, 20);
			this.textDate.TabIndex = 4;
			this.textDate.SelectedIndexChanged += new System.EventHandler(this.textDate_SelectedIndexChanged);
			this.textDate.MouseEnter += new System.EventHandler(this.textDate_MouseEnter);
			this.textDate.MouseLeave += new System.EventHandler(this.textDate_MouseLeave);
			// 
			// TitleLabel
			// 
			this.TitleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.TitleLabel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.TitleLabel.Cursor = System.Windows.Forms.Cursors.Hand;
			this.TitleLabel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.TitleLabel.ForeColor = System.Drawing.Color.White;
			this.TitleLabel.Location = new System.Drawing.Point(0, 0);
			this.TitleLabel.Name = "TitleLabel";
			this.TitleLabel.Size = new System.Drawing.Size(296, 32);
			this.TitleLabel.TabIndex = 5;
			this.TitleLabel.Text = "查询日期";
			this.TitleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btnSearch
			// 
			this.btnSearch.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnSearch.ForeColor = System.Drawing.Color.Blue;
			this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnSearch.ImageIndex = 0;
			this.btnSearch.ImageList = this.imageList;
			this.btnSearch.Location = new System.Drawing.Point(64, 96);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(75, 24);
			this.btnSearch.TabIndex = 6;
			this.btnSearch.Text = "查询(&S)";
			this.btnSearch.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			this.btnSearch.MouseEnter += new System.EventHandler(this.btnSearch_MouseEnter);
			this.btnSearch.MouseLeave += new System.EventHandler(this.btnSearch_MouseLeave);
			// 
			// imageList
			// 
			this.imageList.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// button2
			// 
			this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button2.ForeColor = System.Drawing.Color.Blue;
			this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button2.ImageIndex = 1;
			this.button2.ImageList = this.imageList;
			this.button2.Location = new System.Drawing.Point(184, 96);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(75, 24);
			this.button2.TabIndex = 7;
			this.button2.Text = "取消(&C)";
			this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.button2.MouseEnter += new System.EventHandler(this.btnSearch_MouseEnter);
			this.button2.MouseLeave += new System.EventHandler(this.btnSearch_MouseLeave);
			// 
			// label1
			// 
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.label1.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.Color.Blue;
			this.label1.Location = new System.Drawing.Point(32, 56);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 23);
			this.label1.TabIndex = 8;
			this.label1.Text = "日期:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// DateFrame
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.CancelButton = this.button2;
			this.ClientSize = new System.Drawing.Size(290, 135);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.TitleLabel);
			this.Controls.Add(this.textDate);
			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 = "DateFrame";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "searchDateDialog";
			this.Load += new System.EventHandler(this.DateFrame_Load);
			this.ResumeLayout(false);

		}		#endregion
		#region 初始化事件...
		private void DateFrame_Load(object sender, System.EventArgs e)
		{
			try
			{
				#region 填充下拉列表框...
				DataTable tempTable=new DataTable();
				tempTable=ExcuteSql("select distinct 日期 from Emp_Time","Emp_Time");
				for(int i=0;i<tempTable.Rows.Count;i++)
				{
					this.textDate.Items.Add(tempTable.Rows[i][0].ToString().Trim());
				}
				#endregion
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}		#endregion
		#region 光标移动变化...
		private void btnSearch_MouseLeave(object sender, System.EventArgs e)
		{
			Button button=(Button)sender;
			button.FlatStyle=FlatStyle.Flat;
		}

		private void btnSearch_MouseEnter(object sender, System.EventArgs e)
		{
			Button button=(Button)sender;
			button.FlatStyle=FlatStyle.Standard;
		}
		private void textDate_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}		private void textDate_MouseLeave(object sender, System.EventArgs e)
		{
		    ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.Simple;
		}

		private void textDate_MouseEnter(object sender, System.EventArgs e)
		{
			ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDown;
		}		#endregion
		#region 查询...		private DataTable returnTable(string sql)		{			DataTable tempTable=new DataTable();			return tempTable;		}		#endregion
        #region 根据所有查询的条件来选择...
		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			try
			{
				
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}		#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	}}

⌨️ 快捷键说明

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