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

📄 holidayrecord.cs

📁 c#_cs数据库开发_人事管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Data.OleDb;
namespace PM
{
	/// <summary>
	/// HolidayRecord 的摘要说明。
	/// </summary>
	public class HolidayRecord : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ComboBox No_cb;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox Name_txt;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.ComboBox Type_cb;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.ComboBox App_cb;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.DateTimePicker Starttime_dtp;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.DateTimePicker Stoptime_dtp;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.TextBox Remarks_txt;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		private DataTable dt = new DataTable();
		private string ID = string.Empty;
		public HolidayRecord()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(HolidayRecord));
			this.label1 = new System.Windows.Forms.Label();
			this.No_cb = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.Name_txt = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.Type_cb = new System.Windows.Forms.ComboBox();
			this.label4 = new System.Windows.Forms.Label();
			this.App_cb = new System.Windows.Forms.ComboBox();
			this.label5 = new System.Windows.Forms.Label();
			this.Starttime_dtp = new System.Windows.Forms.DateTimePicker();
			this.label6 = new System.Windows.Forms.Label();
			this.Stoptime_dtp = new System.Windows.Forms.DateTimePicker();
			this.label7 = new System.Windows.Forms.Label();
			this.Remarks_txt = new System.Windows.Forms.TextBox();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "员工编号";
			// 
			// No_cb
			// 
			this.No_cb.Location = new System.Drawing.Point(80, 16);
			this.No_cb.Name = "No_cb";
			this.No_cb.Size = new System.Drawing.Size(100, 20);
			this.No_cb.TabIndex = 1;
			this.No_cb.SelectedIndexChanged += new System.EventHandler(this.No_cb_SelectedIndexChanged);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(208, 24);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "员工姓名";
			// 
			// Name_txt
			// 
			this.Name_txt.Enabled = false;
			this.Name_txt.Location = new System.Drawing.Point(264, 16);
			this.Name_txt.Name = "Name_txt";
			this.Name_txt.TabIndex = 3;
			this.Name_txt.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 64);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(56, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "休假类型";
			// 
			// Type_cb
			// 
			this.Type_cb.Items.AddRange(new object[] {
														 "事假",
														 "产假",
														 "公假"});
			this.Type_cb.Location = new System.Drawing.Point(80, 56);
			this.Type_cb.Name = "Type_cb";
			this.Type_cb.Size = new System.Drawing.Size(100, 20);
			this.Type_cb.TabIndex = 5;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(216, 64);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(48, 16);
			this.label4.TabIndex = 6;
			this.label4.Text = "批准人";
			// 
			// App_cb
			// 
			this.App_cb.Location = new System.Drawing.Point(264, 56);
			this.App_cb.Name = "App_cb";
			this.App_cb.Size = new System.Drawing.Size(100, 20);
			this.App_cb.TabIndex = 7;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 104);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(56, 16);
			this.label5.TabIndex = 8;
			this.label5.Text = "开始时间";
			// 
			// Starttime_dtp
			// 
			this.Starttime_dtp.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.Starttime_dtp.Location = new System.Drawing.Point(80, 96);
			this.Starttime_dtp.Name = "Starttime_dtp";
			this.Starttime_dtp.Size = new System.Drawing.Size(100, 21);
			this.Starttime_dtp.TabIndex = 9;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(208, 104);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(56, 16);
			this.label6.TabIndex = 10;
			this.label6.Text = "结束时间";
			// 
			// Stoptime_dtp
			// 
			this.Stoptime_dtp.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.Stoptime_dtp.Location = new System.Drawing.Point(264, 96);
			this.Stoptime_dtp.Name = "Stoptime_dtp";
			this.Stoptime_dtp.Size = new System.Drawing.Size(100, 21);
			this.Stoptime_dtp.TabIndex = 11;
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(32, 144);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(32, 16);
			this.label7.TabIndex = 12;
			this.label7.Text = "备注";
			// 
			// Remarks_txt
			// 
			this.Remarks_txt.Location = new System.Drawing.Point(80, 144);
			this.Remarks_txt.Multiline = true;
			this.Remarks_txt.Name = "Remarks_txt";
			this.Remarks_txt.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.Remarks_txt.Size = new System.Drawing.Size(280, 72);
			this.Remarks_txt.TabIndex = 13;
			this.Remarks_txt.Text = "";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(88, 232);
			this.button1.Name = "button1";
			this.button1.TabIndex = 14;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(280, 232);
			this.button2.Name = "button2";
			this.button2.TabIndex = 14;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// HolidayRecord
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(400, 269);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.Remarks_txt);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.Stoptime_dtp);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.Starttime_dtp);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.App_cb);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.Type_cb);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.Name_txt);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.No_cb);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.button2);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "HolidayRecord";
			this.Text = "添加记录";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.HolidayRecord_Closing);
			this.Load += new System.EventHandler(this.HolidayRecord_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void HolidayRecord_Load(object sender, System.EventArgs e)
		{
			HolidayInfoForm.hif.Enabled = false;
			if(HolidayInfoForm.holidayID == "insert")
			{
				this.DBApp_cb();
				this.DBNo_cb();
			}
			if(HolidayInfoForm.holidayID == "update")
			{
			    string [] ss = HolidayInfoForm.hif.sb.ToString().Split('#');
				this.ID = ss[0];
				this.No_cb.Enabled = false;
				this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
				this.No_cb.Text = ss[1];
				this.Name_txt.Text = ss[2];
				this.Type_cb.Text = ss[3];
				this.App_cb.Text = ss[4];
				this.Starttime_dtp.Text = ss[5];
				this.Stoptime_dtp.Text = ss[6];
				this.Remarks_txt.Text = ss[7];
				this.DBApp_cb();
			}
		}
		#region  数据绑定
		//对 批准人 下拉列表进行数据绑定
		private void DBApp_cb()
		{
		    string str = "select * from EmployInfo";
			DataTable dt = new DataTable();
			Base bb = new Base();
			dt = bb.ExeSQLdt(str);
			for(int i  = 0 ; i < dt.Rows.Count ; i ++ )
			{
			    this.App_cb.Items.Add(dt.Rows[i]["eName"].ToString());
			}
		}

		//对 员工编号 下拉列表进行数据绑定
		private void DBNo_cb()
		{
			string str = "select * from EmployInfo";
			Base bb = new Base();
			this.dt = bb.ExeSQLdt(str);
			for(int i  = 0 ; i < this.dt.Rows.Count ; i ++ )
			{
				this.No_cb.Items.Add(this.dt.Rows[i]["eId"].ToString());
			}
		}

		//当 员工编号 下拉列表框 的值变化时,员工姓名的文本框相应的变化
		private void No_cb_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			for(int i = 0 ; i < this.dt.Rows.Count ; i ++)
			{
				if(this.No_cb.Text == this.dt.Rows[i]["eId"].ToString())
				{
				    this.Name_txt.Text = this.dt.Rows[i]["eName"].ToString();
					break;
				}
			}
		}
		#endregion


		//取消
		private void button2_Click(object sender, System.EventArgs e)
		{
		    HolidayInfoForm.hif.Enabled = true;
			this.Close();
		}

		//确定
		private void button1_Click(object sender, System.EventArgs e)
		{
			if(HolidayInfoForm.holidayID == "insert")
			{
			    string str = "insert into HolidayInfo (hId,hType,hReason,hfDate,hlDate,hRemarks) values (" + int.Parse(this.No_cb.Text.Trim()) + ",'" + this.Type_cb.Text;
				str += "','" + this.App_cb.Text + "','" + this.Starttime_dtp.Value.ToShortDateString() + "','" + this.Stoptime_dtp.Value.ToShortDateString();
				str += "','" + this.Remarks_txt.Text + "')";
				Base bb = new Base();
				bb.ExeSQL(str);
				MessageBox.Show("添加成功!");
			}
			if(HolidayInfoForm.holidayID == "update")
			{
			    string str = "update HolidayInfo set hType='" + this.Type_cb.Text + "',hReason='" + this.App_cb.Text + "',hfDate='" + this.Starttime_dtp.Value.ToShortDateString();
				str += "',hlDate='" + this.Stoptime_dtp.Value.ToShortDateString() + "',hRemarks='" + this.Remarks_txt.Text + "' where hhId=" + int.Parse(this.ID);
				Base bb = new Base();
				bb.ExeSQL(str);
				MessageBox.Show("修改成功!");
			}
		}

		private void HolidayRecord_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
		     HolidayInfoForm.hif.Enabled = true;
		}
		
	}
}

⌨️ 快捷键说明

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