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

📄 nameframe.cs

📁 独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 
💻 CS
字号:
#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{	#region SearchNameFrame	public class NameFrame : System.Windows.Forms.Form	{
		#region Controls Collection 
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ComboBox textName;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button btnSearch;
		private System.Windows.Forms.ImageList image;		private ConnectionData conn=new ConnectionData();		private string SelectStr="";		private System.ComponentModel.IContainer components = null;		#endregion		#region Contrction Function 		public NameFrame()		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		public NameFrame(string sql)		{            this.SelectStr=sql;            InitializeComponent();		}		/// <summary>		/// 清理所有正在使用的资源。		/// </summary>		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(NameFrame));
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.textName = new System.Windows.Forms.ComboBox();
			this.btnSearch = new System.Windows.Forms.Button();
			this.image = new System.Windows.Forms.ImageList(this.components);
			this.button2 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.label1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(272, 32);
			this.label1.TabIndex = 5;
			this.label1.Text = "查询姓名";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.ForeColor = System.Drawing.Color.Blue;
			this.label2.Location = new System.Drawing.Point(16, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 23);
			this.label2.TabIndex = 6;
			this.label2.Text = "姓名:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// textName
			// 
			this.textName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
			this.textName.Location = new System.Drawing.Point(88, 56);
			this.textName.Name = "textName";
			this.textName.Size = new System.Drawing.Size(136, 20);
			this.textName.TabIndex = 7;
			this.textName.MouseEnter += new System.EventHandler(this.textName_MouseEnter);
			this.textName.MouseLeave += new System.EventHandler(this.textName_MouseLeave);
			// 
			// btnSearch
			// 
			this.btnSearch.BackColor = System.Drawing.Color.White;
			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.image;
			this.btnSearch.Location = new System.Drawing.Point(40, 104);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(75, 24);
			this.btnSearch.TabIndex = 8;
			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);
			// 
			// image
			// 
			this.image.ImageSize = new System.Drawing.Size(16, 16);
			this.image.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("image.ImageStream")));
			this.image.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.Color.White;
			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.image;
			this.button2.Location = new System.Drawing.Point(152, 104);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(75, 24);
			this.button2.TabIndex = 9;
			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);
			// 
			// NameFrame
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Window;
			this.CancelButton = this.button2;
			this.ClientSize = new System.Drawing.Size(266, 143);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.textName);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Cursor = System.Windows.Forms.Cursors.Hand;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "NameFrame";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "searchNameDialog";
			this.Load += new System.EventHandler(this.NameFrame_Load);
			this.ResumeLayout(false);

		}		#endregion
		#region 初始化事件...
		private void NameFrame_Load(object sender, System.EventArgs e)
		{
			try
			{
				#region 填充下拉列表框...
				DataTable empTable=new DataTable();
				empTable=ExcuteSql("select distinct 职工名称 from Employee","Employee");
				for(int i=0;i<empTable.Rows.Count;i++)
				{
					this.textName.Items.Add(empTable.Rows[i][0].ToString().Trim());
				}
				this.textName.SelectedIndex=2;
				#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 textName_MouseLeave(object sender, System.EventArgs e)
		{
		    ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.Simple;
		}
		private void textName_MouseEnter(object sender, System.EventArgs e)
		{
			ComboBox com=(ComboBox)sender;
			com.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDown;
		}		#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 btnSearch_Click(object sender, System.EventArgs e)
		{
			try
			{

			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}		#endregion	}	#endregion}

⌨️ 快捷键说明

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