📄 formaddpeninsure.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 FormAddPenInsure : Form
{
public FormAddPenInsure()
{
InitializeComponent();
}
//初始化
private void FormAddPenInsure_Load(object sender, EventArgs e)
{
if (HRMan.HROper.FormPenInsurInfo.peninsurID == "insert")
{
InitNum();
this.EId_txt.Enabled = false;
}
if (HRMan.HROper.FormPenInsurInfo.peninsurID == "update")
{
string[] ss = HRMan.HROper.FormPenInsurInfo.peninsurinfo.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 InitNum()
{
string SqlText = "select EmployInfo.*,EndowmentInfo.* from EmployInfo,EndowmentInfo where EndowmentInfo.endId=EmployInfo.endId order by eId asc";
DataAccess DA = new DataAccess();
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 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();
this.EId_txt.Text = this.dt.Rows[i]["enId"].ToString();
break;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string exp = String.Format("{0:c}", this.Exp_txt.Text.Trim());
if (HRMan.HROper.FormPenInsurInfo.peninsurID == "insert")
{
string SqlText = "insert into EndowmentInfo (endId,enId,enDate,enMonney) values (" + int.Parse(this.No_cb.Text.Trim()) + "," + int.Parse(this.EId_txt.Text.Trim());
SqlText += ",'" + this.Time_dtp.Value.ToShortDateString() + "'," + Convert.ToDecimal(exp) + ")";
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
HRMan.HROper.FormPenInsurInfo.peninsurinfo.DBDataGrid();
HRMan.HROper.FormPenInsurInfo.peninsurinfo.Enabled = true;
MessageBox.Show("添加成功!");
}
if (HRMan.HROper.FormPenInsurInfo.peninsurID == "update")
{
string SqlText = "update EndowmentInfo set enId=" + int.Parse(this.EId_txt.Text.Trim()) + ",enDate='" + this.Time_dtp.Value.ToShortDateString() + "',enMonney=";
SqlText += Convert.ToDecimal(exp) + " where eeeId=" + int.Parse(this.ID);
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
HRMan.HROper.FormPenInsurInfo.peninsurinfo.DBDataGrid();
HRMan.HROper.FormPenInsurInfo.peninsurinfo.Enabled = true;
MessageBox.Show("修改成功!");
}
this.Close();
}
catch
{
MessageBox.Show("货币格式错误!");
}
}
private void button2_Click(object sender, EventArgs e)
{
HRMan.HROper.FormPenInsurInfo.peninsurinfo.DBDataGrid();
HRMan.HROper.FormPenInsurInfo.peninsurinfo.Enabled = true;
this.Close();
}
private void FormAddPenInsure_FormClosing(object sender, FormClosingEventArgs e)
{
HRMan.HROper.FormPenInsurInfo.peninsurinfo.DBDataGrid();
HRMan.HROper.FormPenInsurInfo.peninsurinfo.Enabled = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -