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

📄 formmoveemployeetodepartment.cs

📁 蓝山人事管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace BlueHill.BlueHillWindows.DepartmentManagement
{
	/// <summary>
	/// FormMoveEmployeeToDepartment 的摘要说明。
	/// </summary>
	public class FormMoveEmployeeToDepartment : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btncel;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.ComboBox cbDeptName;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private TreeView depttv;
		private System.Windows.Forms.Label label2;
		private string deptna;

		public FormMoveEmployeeToDepartment(TreeView tv1,string dn)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			depttv=tv1;
			deptna=dn;
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

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

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.btncel = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.btnOK = new System.Windows.Forms.Button();
			this.cbDeptName = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// btncel
			// 
			this.btncel.Location = new System.Drawing.Point(200, 104);
			this.btncel.Name = "btncel";
			this.btncel.TabIndex = 7;
			this.btncel.Text = "取消";
			this.btncel.Click += new System.EventHandler(this.btncel_Click);
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(24, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(184, 23);
			this.label1.TabIndex = 6;
			this.label1.Text = "删除部门前,请先移动员工";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(32, 104);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(72, 24);
			this.btnOK.TabIndex = 5;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// cbDeptName
			// 
			this.cbDeptName.Location = new System.Drawing.Point(136, 56);
			this.cbDeptName.Name = "cbDeptName";
			this.cbDeptName.Size = new System.Drawing.Size(121, 20);
			this.cbDeptName.TabIndex = 4;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(88, 23);
			this.label2.TabIndex = 8;
			this.label2.Text = "员工移动至:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// FormMoveEmployeeToDepartment
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(304, 165);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.btncel);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.cbDeptName);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "FormMoveEmployeeToDepartment";
			this.Text = "员工转移";
			this.Load += new System.EventHandler(this.FormMoveEmployeeToDepartment_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if(this.cbDeptName .Text != "")
			{
				MoveEmployee dept = new MoveEmployee ();
				
				dept.deptname=this.cbDeptName .SelectedItem.ToString();
				dept.deptname1 = deptna;
				dept.updateemployee();
				dept.com.ExecuteNonQuery();
				MessageBox.Show("删除部门成功!");
				depttv.Nodes.Remove(depttv.SelectedNode);
	
				dept.conn.Close();

				dept.deldept();
				dept.com1.ExecuteNonQuery();
				dept.conn1.Close();
				this.Close();
			}
			else
			{
				MessageBox.Show("请选择一个部门!");
			}
		}

		private void FormMoveEmployeeToDepartment_Load(object sender, System.EventArgs e)
		{
			int i=0;
			for(i=0;i<depttv.Nodes.Count;i++)
			{
				if(! string.Equals(deptna,depttv.Nodes[i].Text))
				{
					this.cbDeptName .Items.Add(depttv.Nodes[i].Text);
				}
			}
		}

		private void btncel_Click(object sender, System.EventArgs e)
		{
			this.Close ();
		}
	}
}

⌨️ 快捷键说明

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