?? endowmentrecord.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace PM
{
/// <summary>
/// EndowmentRecord 的摘要說明。
/// </summary>
public class EndowmentRecord : 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.TextBox EId_txt;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.DateTimePicker Time_dtp;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox Exp_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 EndowmentRecord()
{
//
// 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(EndowmentRecord));
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.EId_txt = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.Time_dtp = new System.Windows.Forms.DateTimePicker();
this.label5 = new System.Windows.Forms.Label();
this.Exp_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(200, 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(256, 16);
this.Name_txt.Name = "Name_txt";
this.Name_txt.TabIndex = 3;
this.Name_txt.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 4;
this.label3.Text = "養(yǎng)老保險號";
//
// EId_txt
//
this.EId_txt.Location = new System.Drawing.Point(80, 56);
this.EId_txt.Name = "EId_txt";
this.EId_txt.TabIndex = 5;
this.EId_txt.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(192, 64);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 6;
this.label4.Text = "發(fā)放時間";
//
// Time_dtp
//
this.Time_dtp.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.Time_dtp.Location = new System.Drawing.Point(256, 56);
this.Time_dtp.Name = "Time_dtp";
this.Time_dtp.Size = new System.Drawing.Size(100, 21);
this.Time_dtp.TabIndex = 7;
//
// label5
//
this.label5.Location = new System.Drawing.Point(72, 104);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 16);
this.label5.TabIndex = 8;
this.label5.Text = "養(yǎng)老保險金";
//
// Exp_txt
//
this.Exp_txt.Location = new System.Drawing.Point(152, 96);
this.Exp_txt.Name = "Exp_txt";
this.Exp_txt.TabIndex = 9;
this.Exp_txt.Text = "";
this.Exp_txt.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Exp_txt_KeyPress);
//
// button1
//
this.button1.Location = new System.Drawing.Point(32, 136);
this.button1.Name = "button1";
this.button1.TabIndex = 10;
this.button1.Text = "確定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(240, 136);
this.button2.Name = "button2";
this.button2.TabIndex = 10;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// EndowmentRecord
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(392, 189);
this.Controls.Add(this.button1);
this.Controls.Add(this.Exp_txt);
this.Controls.Add(this.label5);
this.Controls.Add(this.Time_dtp);
this.Controls.Add(this.label4);
this.Controls.Add(this.EId_txt);
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 = "EndowmentRecord";
this.Closing += new System.ComponentModel.CancelEventHandler(this.EndowmentRecord_Closing);
this.Load += new System.EventHandler(this.EndowmentRecord_Load);
this.ResumeLayout(false);
}
#endregion
private void EndowmentRecord_Load(object sender, System.EventArgs e)
{
if(EndowmentInfoForm.ewID == "insert")
{
DBNo_cb();
this.EId_txt.Enabled = false;
}
if(EndowmentInfoForm.ewID == "update")
{
string []ss = EndowmentInfoForm.emf.sb.ToString().Split('#');
this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
this.No_cb.Enabled = false;
this.ID = ss[0];
this.No_cb.Text = ss[1];
this.Name_txt.Text = ss[2];
this.EId_txt.Text = ss[3];
this.Time_dtp.Text = ss[4];
this.Exp_txt.Text = ss[5];
}
}
private void DBNo_cb()
{
string s = "select EmployInfo.*,EndowmentInfo.* from EmployInfo,EndowmentInfo where EndowmentInfo.endId=EmployInfo.endId order by eId asc";
Base b = new Base();
this.dt = b.ExeSQLdt(s);
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.dt.Rows[i]["eId"].ToString() == this.No_cb.Text)
{
this.Name_txt.Text = this.dt.Rows[i]["eName"].ToString();
this.EId_txt.Text = this.dt.Rows[i]["enId"].ToString();
break;
}
}
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string exp = String.Format("{0:c}",this.Exp_txt.Text.Trim());
if(EndowmentInfoForm.ewID == "insert")
{
string s = "insert into EndowmentInfo (endId,enId,enDate,enMonney) values (" + int.Parse(this.No_cb.Text.Trim()) + "," + int.Parse(this.EId_txt.Text.Trim());
s += ",'" + this.Time_dtp.Value.ToShortDateString() + "'," + Convert.ToDecimal(exp) + ")";
Base bb = new Base();
bb.ExeSQL(s);
MessageBox.Show("添加成功!");
}
if(EndowmentInfoForm.ewID == "update")
{
string s = "update EndowmentInfo set enId=" + int.Parse(this.EId_txt.Text.Trim()) + ",enDate='" + this.Time_dtp.Value.ToShortDateString() + "',enMonney=";
s += Convert.ToDecimal(exp) + " where eeeId=" + int.Parse(this.ID);
Base bb = new Base();
bb.ExeSQL(s);
MessageBox.Show("修改成功!");
}
this.Close();
}
catch
{
MessageBox.Show("貨幣格式錯誤!");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
EndowmentInfoForm.emf.Enabled = true;
EndowmentInfoForm.emf.DBDataGrid();
this.Close();
}
private void EndowmentRecord_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
EndowmentInfoForm.emf.Enabled = true;
EndowmentInfoForm.emf.DBDataGrid();
}
private void Exp_txt_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == (char)13)
{
this.button1_Click(sender,e);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -