📄 formaddwork.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 FormAddWork : Form
{
public FormAddWork()
{
InitializeComponent();
}
//初始化
private void FormAddWork_Load(object sender, EventArgs e)
{
HRMan.HROper.FormWorkInfo.workinfoform.Enabled = false; // WorkInfoForm.wif.Enabled = false;
if (HRMan.HROper.FormWorkInfo.wID =="insert") //WorkInfoForm.wID == "insert")
{
DBNo_cb();
}
if (HRMan.HROper.FormWorkInfo.wID == "update")
{
string[] ss = HRMan.HROper.FormWorkInfo.workinfoform.sb.ToString().Split('#'); // WorkInfoForm.wif.sb.ToString().Split('#');
this.No_cb.Enabled = false;
this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
this.ID = ss[0];
this.No_cb.Text = ss[1];
this.Name_txt.Text = ss[2];
this.wName_txt.Text = ss[3];
this.Job_txt.Text = ss[4];
this.Start_dtp.Text = ss[5];
this.Stop_dtp.Text = ss[6];
this.Remark_txt.Text = ss[7];
}
}
//加载ID
private void DBNo_cb()
{
string SqlText = "select * from EmployInfo order by eId asc";
DataAccess DA = new DataAccess(); // Base b = new Base();
this.dt = DA.ExeSQLdt(SqlText);
for (int i = 0; i < this.dt.Rows.Count; i++)
{
this.No_cb.Items.Add(this.dt.Rows[i]["eId"].ToString());
}
}
private void FormAddWork_FormClosed(object sender, FormClosedEventArgs e)
{
HRMan.HROper.FormWorkInfo.workinfoform.Enabled = true; // WorkInfoForm.wif.Enabled = true;
HRMan.HROper.FormWorkInfo.workinfoform.DBDataGrid(); // WorkInfoForm.wif.DBDataGrid();
}
//填充
private void No_cb_SelectedIndexChanged(object sender, 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();
break;
}
}
}
//取消
private void button2_Click(object sender, EventArgs e)
{
HRMan.HROper.FormWorkInfo.workinfoform.Enabled = true; // WorkInfoForm.wif.Enabled = true;
HRMan.HROper.FormWorkInfo.workinfoform.DBDataGrid(); // WorkInfoForm.wif.DBDataGrid();
this.Close();
}
//确认
private void button1_Click(object sender, EventArgs e)
{
if (HRMan.HROper.FormWorkInfo.wID == "insert") //WorkInfoForm.wID == "insert")
{
string SqlText = "insert into WorkInfo (wId,wName,wJob,wFdate,wLdate,wRemarks) values (" + int.Parse(this.No_cb.Text.Trim()) + ",'";
SqlText += this.wName_txt.Text + "','" + this.Job_txt.Text + "','" + this.Start_dtp.Value.ToShortDateString() + "','";
SqlText += this.Stop_dtp.Value.ToShortDateString() + "','" + this.Remark_txt.Text + "')";
DataAccess DA = new DataAccess(); // Base bb = new Base();
DA.ExeSQL(SqlText);
HRMan.HROper.FormWorkInfo.workinfoform.DBDataGrid();
MessageBox.Show("添加成功!");
}
if (HRMan.HROper.FormWorkInfo.wID == "update")
{
string SqlText = "update WorkInfo set wName='" + this.wName_txt.Text + "',wJob='" + this.Job_txt.Text + "',wFdate='";
SqlText += this.Start_dtp.Value.ToShortDateString() + "',wLdate='" + this.Stop_dtp.Value.ToShortDateString() + "',wRemarks='";
SqlText += this.Remark_txt.Text + "' where wwId=" + int.Parse(this.ID.Trim());
DataAccess DA = new DataAccess(); // Base bb = new Base();
DA.ExeSQL(SqlText);
HRMan.HROper.FormWorkInfo.workinfoform.DBDataGrid();
MessageBox.Show("修改成功!");
}
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -