📄 formmedinsure.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 FormMedInsure : Form
{
public FormMedInsure()
{
InitializeComponent();
HRMan.HROper.FormMedInsure.medinsureinfo = this;
this.Position = 0;
}
private void FormMedInsure_Load(object sender, EventArgs e)
{
DBDataGrid();
}
//显示
public void DBDataGrid()
{
string SqlText = "select MedicalInfo.mmmId,MedicalInfo.meId as 员工编号,EmployInfo.eName as 员工姓名,MedicalInfo.mId as 医疗保险号,MedicalInfo.enDate as 发放时间,";
SqlText += "MedicalInfo.enMonney as 养老保险金 from MedicalInfo,EmployInfo where MedicalInfo.meId=EmployInfo.meId order by MedicalInfo.meId asc";
DataAccess DA = new DataAccess();
this.dt = DA.ExeSQLdt(SqlText);
this.dataGrid1.DataSource = this.dt.DefaultView;
this.cm = (CurrencyManager)BindingContext[this.dt];
if (this.dataGrid1.Rows.Count != 0)
{
for (int i = 0; i < this.dataGrid1.Rows.Count; )
{
this.dataGrid1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Pink;
i += 2;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.groupBox1.Visible = false;
this.dataGrid1.Dock = DockStyle.Fill;
this.DBDataGrid();
}
private void button1_Click(object sender, EventArgs e)
{
string SqlText = "select MedicalInfo.mmmId,MedicalInfo.meId as 员工编号,EmployInfo.eName as 员工姓名,MedicalInfo.mId as 医疗保险号,MedicalInfo.enDate as 发放时间,";
SqlText += "MedicalInfo.enMonney as 医疗保险金 from MedicalInfo,EmployInfo where MedicalInfo.meId=EmployInfo.meId";
if (this.ID_txt.Text != "")
{
SqlText += " and MedicalInfo.meId=" + int.Parse(this.ID_txt.Text.Trim());
DataAccess DA = new DataAccess();
this.dt = DA.ExeSQLdt(SqlText);
this.dataGrid1.DataSource = this.dt.DefaultView;
this.cm = (CurrencyManager)BindingContext[this.dt];
if (this.dataGrid1.Rows.Count != 0)
{
for (int i = 0; i < this.dataGrid1.Rows.Count; )
{
this.dataGrid1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Pink;
i += 2;
}
}
}
if (this.name_txt.Text != "")
{
SqlText += " and EmployInfo.eName like '%[" + this.name_txt.Text + "]%'";
DataAccess DA = new DataAccess();
this.dt = DA.ExeSQLdt(SqlText);
this.dataGrid1.DataSource = this.dt.DefaultView;
this.cm = (CurrencyManager)BindingContext[this.dt];
if (this.dataGrid1.Rows.Count != 0)
{
for (int i = 0; i < this.dataGrid1.Rows.Count; )
{
this.dataGrid1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Pink;
i += 2;
}
}
}
if (this.Date_txt.Text != "")
{
if (Certification.IsValidData(this.Date_txt.Text.Trim()))
{
SqlText += " and MedicalInfo.enDate='" + this.Date_txt.Text.Trim() + "'";
DataAccess DA = new DataAccess();
this.dt = DA.ExeSQLdt(SqlText);
this.dataGrid1.DataSource = this.dt.DefaultView;
this.cm = (CurrencyManager)BindingContext[this.dt];
if (this.dataGrid1.Rows.Count != 0)
{
for (int i = 0; i < this.dataGrid1.Rows.Count; )
{
this.dataGrid1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Pink;
i += 2;
}
}
}
else
{
MessageBox.Show("发放时间格式错误,请输入(yyyy-mm-dd)");
}
}
}
//添加
private void InsertMedInsure(object sender, System.EventArgs e)
{
HRMan.HROper.FormMedInsure.meID = "insert";
this.Enabled = false;
if (FormMain.FM.CheckForm("FormAddMedInsure") == true)
{
return;
}
else
{
HRMan.HROper.FormAddMedInsure addmedinsure = new FormAddMedInsure();
addmedinsure.MdiParent = FormMain.FM;
addmedinsure.Show();
addmedinsure.Text = "添加医疗保险";
}
}
private void UpdateMedInsure(object sender, System.EventArgs e)
{
HRMan.HROper.FormMedInsure.meID = "update";
this.Enabled = false;
this.sb.Remove(0, this.sb.ToString().Length);
for (int i = 0; i < this.dt.Columns.Count; i++)
{
this.sb.Append(this.dataGrid1[i,this.dataGrid1.CurrentCellAddress.Y].Value.ToString() + "#");
}
if (FormMain.FM.CheckForm("FormAddMedInsure") == true)
{
return;
}
else
{
HRMan.HROper.FormAddMedInsure addmedinsure = new FormAddMedInsure();
addmedinsure.MdiParent = FormMain.FM;
addmedinsure.Show();
addmedinsure.Text = "修改医疗保险";
}
}
private void DeleteMedInsure(object sender, System.EventArgs e)
{
DialogResult result = MessageBox.Show("是否删除此记录?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string SqlText = "delete MedicalInfo where mmmId=" + int.Parse(this.dataGrid1[0,this.dataGrid1.CurrentCellAddress.Y].Value.ToString());
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
this.DBDataGrid();
MessageBox.Show("删除成功!");
}
if (result == DialogResult.No)
{
return;
}
}
private void Search(object sender, System.EventArgs e)
{
this.groupBox1.Visible = true;
this.dataGrid1.Dock = DockStyle.None;
this.dataGrid1.Height = 368;
this.dataGrid1.Location = new Point(0, 88);
}
private void ExitMedInsure(object sender, System.EventArgs e)
{
this.Close();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (this.Position != 0)
{
foreach (DataGridViewRow dvrow in this.dataGrid1.Rows)
{
dvrow.Selected = false;
}
this.dataGrid1.Rows[0].Selected = true;
this.Position = 0;
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (this.Position > 0)
{
foreach (DataGridViewRow dvrow in this.dataGrid1.Rows)
{
dvrow.Selected = false;
}
this.Position--;
this.dataGrid1.Rows[this.Position].Selected = true;
}
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
if (this.Position < this.dataGrid1.Rows.Count - 1)
{
foreach (DataGridViewRow dvrow in this.dataGrid1.Rows)
{
dvrow.Selected = false;
}
this.Position++;
this.dataGrid1.Rows[this.Position].Selected = true;
}
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
if (this.Position != this.dataGrid1.Rows.Count - 1)
{
foreach (DataGridViewRow dvrow in this.dataGrid1.Rows)
{
dvrow.Selected = false;
}
this.Position = this.dataGrid1.Rows.Count;
this.dataGrid1.Rows[this.Position - 1].Selected = true;
}
}
private void toolStripButton5_Click(object sender, EventArgs e)
{
this.InsertMedInsure(sender, e);
}
private void toolStripButton6_Click(object sender, EventArgs e)
{
this.UpdateMedInsure(sender, e);
}
private void toolStripButton7_Click(object sender, EventArgs e)
{
this.DeleteMedInsure(sender, e);
}
private void toolStripButton8_Click(object sender, EventArgs e)
{
this.Search(sender, e);
}
private void toolStripButton9_Click(object sender, EventArgs e)
{
this.ExitMedInsure(sender, e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -