📄 formaddempchange.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace HRMan.HROper
{
public partial class FormAddEmpChange : Form
{
public FormAddEmpChange()
{
InitializeComponent();
}
//初始化
private void FormAddEmpChange_Load(object sender, EventArgs e)
{
HRMan.HROper.FormEmpChange.employchange.Enabled = false;
if (HRMan.HROper.FormEmpChange.employId == "insert")
{
InitNum();
InitDep();
InitJob();
InitName();
}
if (HRMan.HROper.FormEmpChange.employId == "update")
{
string[] ss = HRMan.HROper.FormEmpChange.employchange.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];
InitDep();
InitJob();
InitName();
}
}
private void InitNum()
{
string SqlText = "select * from EmployInfo";
DataAccess DA = new DataAccess();
this.table = DA.ExeSQLdt(SqlText);
for (int i = 0; i < this.table.Rows.Count; i++)
{
this.No_cb.Items.Add(this.table.Rows[i]["traId"].ToString());
}
}
private void InitDep()
{
string SqlText = "select * from SectionInfo";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(SqlText);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Lsection_cb.Items.Add(dt.Rows[i]["sName"].ToString());
}
}
private void InitJob()
{
string SqlText = "select * from JobInfo";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(SqlText);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Ljob_cb.Items.Add(dt.Rows[i]["JName"].ToString());
}
}
private void InitName()
{
string SqlText = "select * from EmployInfo";
DataAccess DA = new DataAccess();
this.table = DA.ExeSQLdt(SqlText);
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, 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 SqlText = "select TransferInfo.lSection,TransferInfo.lJob from TransferInfo,EmployInfo where TransferInfo.traId=EmployInfo.traId and EmployInfo.eId=" + int.Parse(this.No_cb.Text);
SqlText += " order by tDate desc";
DataTable table = new DataTable();
DataAccess DA = new DataAccess();
table = DA.ExeSQLdt(SqlText);
this.Fsection_txt.Text = table.Rows[0]["lSection"].ToString();
this.Fjob_txt.Text = table.Rows[0]["lJob"].ToString();
}
//关闭
private void FormAddEmpChange_FormClosed(object sender, FormClosedEventArgs e)
{
HRMan.HROper.FormEmpChange.employchange.Enabled = true;
}
//取消
private void button2_Click(object sender, EventArgs e)
{
HRMan.HROper.FormEmpChange.employchange.Enabled = true;
this.Close();
}
//确定
private void button1_Click(object sender, EventArgs e)
{
if (HRMan.HROper.FormEmpChange.employId == "insert")
{
string SqlText = "insert into TransferInfo (traId,tDate,fSection,lSection,fJob,lJob,tReason,tApp,tRemarks) values (" + int.Parse(this.No_cb.Text) + ",'" + this.Trantime_dtp.Value.ToShortDateString() + "','";
SqlText += this.Fsection_txt.Text + "','" + this.Lsection_cb.Text + "','" + this.Fjob_txt.Text + "','" + this.Ljob_cb.Text + "','" + this.Reson_txt.Text + "','";
SqlText += this.App_cb.Text + "','" + this.Remarks_txt.Text + "')";
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
HRMan.HROper.FormEmpChange.employchange.DBDataGrid();
HRMan.HROper.FormEmpChange.employchange.Enabled = true;
MessageBox.Show("添加成功!");
}
if (HRMan.HROper.FormEmpChange.employId == "update")
{
string SqlText = "update TransferInfo set traId=" + int.Parse(this.No_cb.Text) + ",tDate='" + this.Trantime_dtp.Value.ToShortDateString() + "',fSection='" + this.Fsection_txt.Text + "',lSection='";
SqlText += 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='";
SqlText += this.Remarks_txt.Text + "' where aaId=" + int.Parse(this.ID);
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
HRMan.HROper.FormEmpChange.employchange.DBDataGrid();
HRMan.HROper.FormEmpChange.employchange.Enabled = true;
MessageBox.Show("修改成功!");
}
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -