📄 record.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using System.Text;
namespace PM
{
/// <summary>
/// Record 的摘要说明。
/// </summary>
public class Record : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox No_cb;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DateTimePicker Trantime_dtp;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox Lsection_cb;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ComboBox Ljob_cb;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox Reson_txt;
private System.Windows.Forms.TextBox Name_txt;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.ComboBox App_cb;
private System.Windows.Forms.Label label10;
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 System.Windows.Forms.TextBox Fsection_txt;
private System.Windows.Forms.TextBox Fjob_txt;
private DataTable table = new DataTable();
private string ID = string.Empty;
public Record()
{
//
// 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(Record));
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.No_cb = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.Trantime_dtp = new System.Windows.Forms.DateTimePicker();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.Lsection_cb = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.Ljob_cb = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.Reson_txt = new System.Windows.Forms.TextBox();
this.Name_txt = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.App_cb = new System.Windows.Forms.ComboBox();
this.label10 = 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.Fsection_txt = new System.Windows.Forms.TextBox();
this.Fjob_txt = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "员工编号";
//
// label2
//
this.label2.Location = new System.Drawing.Point(224, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "员工姓名";
//
// No_cb
//
this.No_cb.Location = new System.Drawing.Point(96, 24);
this.No_cb.Name = "No_cb";
this.No_cb.Size = new System.Drawing.Size(100, 20);
this.No_cb.TabIndex = 3;
this.No_cb.SelectedIndexChanged += new System.EventHandler(this.No_cb_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 4;
this.label3.Text = "调动时间";
//
// Trantime_dtp
//
this.Trantime_dtp.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.Trantime_dtp.Location = new System.Drawing.Point(96, 56);
this.Trantime_dtp.Name = "Trantime_dtp";
this.Trantime_dtp.Size = new System.Drawing.Size(100, 21);
this.Trantime_dtp.TabIndex = 5;
//
// label4
//
this.label4.Location = new System.Drawing.Point(216, 64);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 16);
this.label4.TabIndex = 6;
this.label4.Text = "调动前部门";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 96);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 16);
this.label5.TabIndex = 8;
this.label5.Text = "调动后部门";
//
// Lsection_cb
//
this.Lsection_cb.Location = new System.Drawing.Point(96, 88);
this.Lsection_cb.Name = "Lsection_cb";
this.Lsection_cb.Size = new System.Drawing.Size(100, 20);
this.Lsection_cb.TabIndex = 9;
//
// label6
//
this.label6.Location = new System.Drawing.Point(216, 96);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 16);
this.label6.TabIndex = 10;
this.label6.Text = "调动前职务";
//
// label7
//
this.label7.Location = new System.Drawing.Point(16, 128);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 16);
this.label7.TabIndex = 12;
this.label7.Text = "调动后职务";
//
// Ljob_cb
//
this.Ljob_cb.Location = new System.Drawing.Point(96, 120);
this.Ljob_cb.Name = "Ljob_cb";
this.Ljob_cb.Size = new System.Drawing.Size(100, 20);
this.Ljob_cb.TabIndex = 13;
//
// label8
//
this.label8.Location = new System.Drawing.Point(24, 160);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(56, 16);
this.label8.TabIndex = 14;
this.label8.Text = "调动原因";
//
// Reson_txt
//
this.Reson_txt.Location = new System.Drawing.Point(96, 152);
this.Reson_txt.Multiline = true;
this.Reson_txt.Name = "Reson_txt";
this.Reson_txt.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.Reson_txt.Size = new System.Drawing.Size(296, 64);
this.Reson_txt.TabIndex = 15;
this.Reson_txt.Text = "";
//
// Name_txt
//
this.Name_txt.Enabled = false;
this.Name_txt.Location = new System.Drawing.Point(288, 24);
this.Name_txt.Name = "Name_txt";
this.Name_txt.TabIndex = 16;
this.Name_txt.Text = "";
//
// label9
//
this.label9.Location = new System.Drawing.Point(232, 128);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(48, 16);
this.label9.TabIndex = 17;
this.label9.Text = "批准人";
//
// App_cb
//
this.App_cb.Location = new System.Drawing.Point(288, 120);
this.App_cb.Name = "App_cb";
this.App_cb.Size = new System.Drawing.Size(100, 20);
this.App_cb.TabIndex = 18;
//
// label10
//
this.label10.Location = new System.Drawing.Point(40, 240);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(32, 16);
this.label10.TabIndex = 19;
this.label10.Text = "备注";
//
// Remarks_txt
//
this.Remarks_txt.Location = new System.Drawing.Point(96, 224);
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(296, 72);
this.Remarks_txt.TabIndex = 20;
this.Remarks_txt.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 320);
this.button1.Name = "button1";
this.button1.TabIndex = 21;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(280, 320);
this.button2.Name = "button2";
this.button2.TabIndex = 22;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Fsection_txt
//
this.Fsection_txt.Enabled = false;
this.Fsection_txt.Location = new System.Drawing.Point(288, 56);
this.Fsection_txt.Name = "Fsection_txt";
this.Fsection_txt.TabIndex = 23;
this.Fsection_txt.Text = "";
//
// Fjob_txt
//
this.Fjob_txt.Enabled = false;
this.Fjob_txt.Location = new System.Drawing.Point(288, 88);
this.Fjob_txt.Name = "Fjob_txt";
this.Fjob_txt.TabIndex = 24;
this.Fjob_txt.Text = "";
//
// Record
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 357);
this.Controls.Add(this.Fjob_txt);
this.Controls.Add(this.Fsection_txt);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.Remarks_txt);
this.Controls.Add(this.label10);
this.Controls.Add(this.App_cb);
this.Controls.Add(this.label9);
this.Controls.Add(this.Name_txt);
this.Controls.Add(this.Reson_txt);
this.Controls.Add(this.label8);
this.Controls.Add(this.Ljob_cb);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.Lsection_cb);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.Trantime_dtp);
this.Controls.Add(this.label3);
this.Controls.Add(this.No_cb);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Record";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Record_Closing);
this.Load += new System.EventHandler(this.Record_Load);
this.ResumeLayout(false);
}
#endregion
//取消
private void button2_Click(object sender, System.EventArgs e)
{
TransferForm.tff.Enabled = true;
this.Close();
}
//确定
private void button1_Click(object sender, System.EventArgs e)
{
if(TransferForm.employId == "insert")
{
string str = "insert into TransferInfo (traId,tDate,fSection,lSection,fJob,lJob,tReason,tApp,tRemarks) values (" + int.Parse(this.No_cb.Text) + ",'" + this.Trantime_dtp.Value.ToShortDateString() + "','";
str += this.Fsection_txt.Text + "','" + this.Lsection_cb.Text + "','" + this.Fjob_txt.Text + "','" + this.Ljob_cb.Text + "','" + this.Reson_txt.Text + "','";
str += this.App_cb.Text + "','" + this.Remarks_txt.Text + "')";
Base bb = new Base();
bb.ExeSQL(str);
MessageBox.Show("添加成功!");
}
if(TransferForm.employId == "update")
{
string str = "update TransferInfo set traId=" + int.Parse(this.No_cb.Text) + ",tDate='" + this.Trantime_dtp.Value.ToShortDateString() + "',fSection='" + this.Fsection_txt.Text + "',lSection='";
str += this.Lsection_cb.Text + "',fJob='" + this.Fjob_txt.Text + "',lJob='" + this.Ljob_cb.Text + "',tReason='" + this.Reson_txt.Text + "',tApp='" + this.App_cb.Text + "',tRemarks='";
str += this.Remarks_txt.Text + "' where aaId=" + int.Parse(this.ID);
Base bb = new Base();
bb.ExeSQL(str);
MessageBox.Show("修改成功!");
}
}
private void Record_Load(object sender, System.EventArgs e)
{
TransferForm.tff.Enabled = false;
if(TransferForm.employId == "insert")
{
DBNo_cb();
DBLSection_cb();
DBLJob_cb();
DBApp_cb();
}
if(TransferForm.employId == "update")
{
string []ss = TransferForm.tff.sb.ToString().Split('#');
this.No_cb.Text = ss[1];
this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
this.Name_txt.Text = ss[2];
this.Trantime_dtp.Text = ss[3];
this.Fsection_txt.Text = ss[4];
this.Lsection_cb.Text = ss[5];
this.Fjob_txt.Text = ss[6];
this.Ljob_cb.Text = ss[7];
this.Reson_txt.Text = ss[8];
this.App_cb.Text = ss[9];
this.Remarks_txt.Text = ss[10];
this.ID = ss[0];
DBLSection_cb();
DBLJob_cb();
DBApp_cb();
}
}
private void DBNo_cb()
{
string str = "select * from EmployInfo";
Base bb = new Base();
this.table = bb.ExeSQLdt(str);
for(int i = 0 ; i < this.table.Rows.Count ; i ++)
{
this.No_cb.Items.Add(this.table.Rows[i]["traId"].ToString());
}
}
private void DBLSection_cb()
{
string str = "select * from SectionInfo";
DataTable dt = new DataTable();
Base bb = new Base();
dt = bb.ExeSQLdt(str);
for(int i = 0 ; i < dt.Rows.Count ; i ++ )
{
this.Lsection_cb.Items.Add(dt.Rows[i]["sName"].ToString());
}
}
private void DBLJob_cb()
{
string str = "select * from JobInfo";
DataTable dt = new DataTable();
Base bb = new Base();
dt = bb.ExeSQLdt(str);
for(int i = 0 ; i < dt.Rows.Count; i ++ )
{
this.Ljob_cb.Items.Add(dt.Rows[i]["JName"].ToString());
}
}
private void DBApp_cb()
{
string str = "select * from EmployInfo";
Base bb = new Base();
this.table = bb.ExeSQLdt(str);
for(int i = 0 ; i < this.table.Rows.Count ; i ++)
{
this.App_cb.Items.Add(this.table.Rows[i]["eName"].ToString());
}
}
private void No_cb_SelectedIndexChanged(object sender, System.EventArgs e)
{
for(int i = 0 ; i < this.table.Rows.Count ; i ++)
{
if(this.No_cb.Text == this.table.Rows[i]["eId"].ToString())
{
this.Name_txt.Text = this.table.Rows[i]["eName"].ToString();
break;
}
}
string str = "select TransferInfo.lSection,TransferInfo.lJob from TransferInfo,EmployInfo where TransferInfo.traId=EmployInfo.traId and EmployInfo.eId=" + int.Parse(this.No_cb.Text);
str += " order by tDate desc";
DataTable table = new DataTable();
Base bb = new Base();
table = bb.ExeSQLdt(str);
this.Fsection_txt.Text = table.Rows[0]["lSection"].ToString();
this.Fjob_txt.Text = table.Rows[0]["lJob"].ToString();
}
private void Record_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
TransferForm.tff.Enabled = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -