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

📄 frmemployees.cs

📁 yongle jpscxsd j cxksk xdkl sna
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MyFirstProject
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class frmEmployees : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox grpMain;
		private System.Windows.Forms.ListBox lstCurrDeptName;
		private System.Windows.Forms.ComboBox cboDesig;
		private System.Windows.Forms.TextBox txtAddress;
		private System.Windows.Forms.TextBox txtEmpName;
		private System.Windows.Forms.Label lblCurrDept;
		private System.Windows.Forms.Label lblDesig;
		private System.Windows.Forms.Label lblAddress;
		private System.Windows.Forms.Label lblEmpName;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnExit;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmEmployees()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		[STAThread]
		static void Main()
		{
			Application.Run(new frmEmployees());
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 –不要使用代码编辑器修改
		/// 此方法的内容。

		/// </summary>
		private void InitializeComponent()
		{
			this.grpMain = new System.Windows.Forms.GroupBox();
			this.lstCurrDeptName = new System.Windows.Forms.ListBox();
			this.cboDesig = new System.Windows.Forms.ComboBox();
			this.txtAddress = new System.Windows.Forms.TextBox();
			this.txtEmpName = new System.Windows.Forms.TextBox();
			this.lblCurrDept = new System.Windows.Forms.Label();
			this.lblDesig = new System.Windows.Forms.Label();
			this.lblAddress = new System.Windows.Forms.Label();
			this.lblEmpName = new System.Windows.Forms.Label();
			this.btnAdd = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnExit = new System.Windows.Forms.Button();
			this.grpMain.SuspendLayout();
			this.SuspendLayout();
			// 
			// grpMain
			// 
			this.grpMain.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grpMain.Controls.Add(this.lstCurrDeptName);
			this.grpMain.Controls.Add(this.cboDesig);
			this.grpMain.Controls.Add(this.txtAddress);
			this.grpMain.Controls.Add(this.txtEmpName);
			this.grpMain.Controls.Add(this.lblCurrDept);
			this.grpMain.Controls.Add(this.lblDesig);
			this.grpMain.Controls.Add(this.lblAddress);
			this.grpMain.Controls.Add(this.lblEmpName);
			this.grpMain.Font = new System.Drawing.Font("宋体", 9F);
			this.grpMain.Location = new System.Drawing.Point(-8, -8);
			this.grpMain.Name = "grpMain";
			this.grpMain.Size = new System.Drawing.Size(416, 216);
			this.grpMain.TabIndex = 0;
			this.grpMain.TabStop = false;
			// 
			// lstCurrDeptName
			// 
			this.lstCurrDeptName.Enabled = false;
			this.lstCurrDeptName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.lstCurrDeptName.ItemHeight = 12;
			this.lstCurrDeptName.Items.AddRange(new object[] {
																 "软件部",
																 "硬件部",
																 "财务部",
																 "人事部"});
			this.lstCurrDeptName.Location = new System.Drawing.Point(136, 112);
			this.lstCurrDeptName.Name = "lstCurrDeptName";
			this.lstCurrDeptName.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
			this.lstCurrDeptName.Size = new System.Drawing.Size(232, 88);
			this.lstCurrDeptName.TabIndex = 21;
			// 
			// cboDesig
			// 
			this.cboDesig.Enabled = false;
			this.cboDesig.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.cboDesig.Items.AddRange(new object[] {
														  "总裁",
														  "副总裁",
														  "首席执行官",
														  "经理"});
			this.cboDesig.Location = new System.Drawing.Point(136, 80);
			this.cboDesig.Name = "cboDesig";
			this.cboDesig.Size = new System.Drawing.Size(232, 20);
			this.cboDesig.TabIndex = 20;
			this.cboDesig.Text = "经理";
			// 
			// txtAddress
			// 
			this.txtAddress.Enabled = false;
			this.txtAddress.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtAddress.Location = new System.Drawing.Point(136, 48);
			this.txtAddress.Name = "txtAddress";
			this.txtAddress.Size = new System.Drawing.Size(232, 21);
			this.txtAddress.TabIndex = 19;
			this.txtAddress.Text = "";
			// 
			// txtEmpName
			// 
			this.txtEmpName.Enabled = false;
			this.txtEmpName.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtEmpName.Location = new System.Drawing.Point(136, 16);
			this.txtEmpName.Name = "txtEmpName";
			this.txtEmpName.Size = new System.Drawing.Size(232, 21);
			this.txtEmpName.TabIndex = 18;
			this.txtEmpName.Text = "";
			// 
			// lblCurrDept
			// 
			this.lblCurrDept.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.lblCurrDept.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lblCurrDept.Location = new System.Drawing.Point(32, 112);
			this.lblCurrDept.Name = "lblCurrDept";
			this.lblCurrDept.Size = new System.Drawing.Size(96, 23);
			this.lblCurrDept.TabIndex = 17;
			this.lblCurrDept.Text = "当前部门名称:";
			this.lblCurrDept.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblDesig
			// 
			this.lblDesig.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.lblDesig.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lblDesig.Location = new System.Drawing.Point(32, 80);
			this.lblDesig.Name = "lblDesig";
			this.lblDesig.Size = new System.Drawing.Size(96, 23);
			this.lblDesig.TabIndex = 16;
			this.lblDesig.Text = "职务:";
			this.lblDesig.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblAddress
			// 
			this.lblAddress.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.lblAddress.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lblAddress.Location = new System.Drawing.Point(32, 48);
			this.lblAddress.Name = "lblAddress";
			this.lblAddress.Size = new System.Drawing.Size(96, 23);
			this.lblAddress.TabIndex = 15;
			this.lblAddress.Text = "地址:";
			this.lblAddress.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblEmpName
			// 
			this.lblEmpName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
			this.lblEmpName.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lblEmpName.Location = new System.Drawing.Point(32, 16);
			this.lblEmpName.Name = "lblEmpName";
			this.lblEmpName.Size = new System.Drawing.Size(96, 23);
			this.lblEmpName.TabIndex = 14;
			this.lblEmpName.Text = "职员姓名:";
			this.lblEmpName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// btnAdd
			// 
			this.btnAdd.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnAdd.ForeColor = System.Drawing.SystemColors.ControlText;
			this.btnAdd.Location = new System.Drawing.Point(128, 224);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.TabIndex = 23;
			this.btnAdd.Text = "添加";
			// 
			// btnCancel
			// 
			this.btnCancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnCancel.ForeColor = System.Drawing.SystemColors.ControlText;
			this.btnCancel.Location = new System.Drawing.Point(216, 224);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 24;
			this.btnCancel.Text = "取消";
			// 
			// btnExit
			// 
			this.btnExit.Font = new System.Drawing.Font("Tahoma", 8F);
			this.btnExit.ForeColor = System.Drawing.SystemColors.ControlText;
			this.btnExit.Location = new System.Drawing.Point(304, 224);
			this.btnExit.Name = "btnExit";
			this.btnExit.TabIndex = 25;
			this.btnExit.Text = "退出";
			// 
			// frmEmployees
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(7, 14);
			this.ClientSize = new System.Drawing.Size(392, 261);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.grpMain);
			this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ForeColor = System.Drawing.SystemColors.ControlText;
			this.MaximizeBox = false;
			this.Name = "frmEmployees";
			this.Text = "职员详细信息";
			this.grpMain.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点
		/// </summary>
		

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			this.txtEmpName.Enabled=true;
			this.txtAddress.Enabled=true;
			this.cboDesig.Enabled=true;
			this.lstCurrDeptName.Enabled=true;

		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.txtEmpName.Text="";
			this.txtAddress.Text="";
			this.cboDesig.Text="经理";
		}

		private void cboDesig_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			MessageBox.Show("您已经选择了" +this.cboDesig.SelectedItem.ToString());
		}

		private void btnExit_Click(object sender, System.EventArgs e)
		{
			string str="";
			for(int ctr=0;ctr<=this.lstCurrDeptName.SelectedItems.Count-1;ctr++)
				str+="\n"+this.lstCurrDeptName.SelectedItems[ctr].ToString();
			MessageBox.Show("选定的项目为 \n" +str);
			Application.Exit();
		}
	}
}

⌨️ 快捷键说明

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