📄 frmemployeeinfo.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PMS.PMSClass;
using System.IO;
namespace PMS
{
public partial class frmEmployeeInfo : Form
{
public frmEmployeeInfo()
{
InitializeComponent();
}
DBOperate operate = new DBOperate();
public string YGName;
public string YGID;
private void frmEmployeeInfo_Load(object sender, EventArgs e)
{
operate.BindDropdownlist("tb_department", cbbYGBumen, 1);
operate.BindDropdownlist("tb_userJob", txtYGZhiwu, 1);//绑定所有的职务列表
this.Text = "[ "+YGName+" ]的个人信息";
string sql = "select * from tb_employee where employeeID='" + YGID + "'";
DataSet ds = operate.GetTable(sql);
ds.Dispose();
txtYGNum.Text = ds.Tables[0].Rows[0][1].ToString();
txtYGName.Text = ds.Tables[0].Rows[0][2].ToString();
cbbYGSex.SelectedItem = ds.Tables[0].Rows[0][3].ToString();
cbbYGBumen.SelectedItem = ds.Tables[0].Rows[0][4].ToString();
txtYGBirthday.Text = ds.Tables[0].Rows[0][5].ToString();
txtYGminzu.SelectedItem = ds.Tables[0].Rows[0][6].ToString();
cbbYGHunyin.SelectedItem = ds.Tables[0].Rows[0][7].ToString();
txtYGZhiwu.SelectedItem = ds.Tables[0].Rows[0][8].ToString();
txtYGPhone.Text = ds.Tables[0].Rows[0][9].ToString();
txtYGJiuzhi.Text = ds.Tables[0].Rows[0][10].ToString();
txtYGPay.Text = ds.Tables[0].Rows[0][12].ToString();
operate.Get_Image(YGID,pictureBox1);
}
private void toolStripLabel2_Click(object sender, EventArgs e)
{
try
{
string DelSql = "delete from tb_employee where employeeID='" + YGID + "'";
operate.OperateData(DelSql);
operate.DeleUserInfo(YGID);
MessageBox.Show("删除成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
}
catch
{
MessageBox.Show("删除操作失败","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private void toolStripLabel4_Click(object sender, EventArgs e)
{
this.Close();
}
private void toolStripLabel1_Click(object sender, EventArgs e)
{
try
{
if (txtYGBirthday.Text.Trim() == "" || txtYGJiuzhi.Text.Trim() == "" || txtYGminzu.Text.Trim() == "" || txtYGName.Text.Trim() == "" || txtYGNum.Text.Trim() == "" || txtYGPhone.Text.Trim() == "" || txtYGZhiwu.Text.Trim() == ""||txtYGPay.Text.Trim()=="")
{
MessageBox.Show("请将信息填写完整", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
if (txtYGPhone.Text.Length != 11)
{
MessageBox.Show("手机号码为11位");
return;
}
else
{
string strUpdateSql = "update tb_employee set employeeName='" + txtYGName.Text.Trim() + "',employeeSex='" + cbbYGSex.Text + "',employeeDept='" + cbbYGBumen.Text + "',employeeBirthday='" + txtYGBirthday.Text + "',employeeNation='" + txtYGminzu.Text.Trim() + "',employeeMarriage='" + cbbYGHunyin.Text + "',employeeDuty='" + txtYGZhiwu.Text.Trim() + "',employeePhone='" + txtYGPhone.Text.Trim() + "',employeeAccession='" + txtYGJiuzhi.Text + "',employeePay='"+txtYGPay.Text.Trim()+"' where employeeID='" + YGID + "'";
int num = operate.OperateData(strUpdateSql);
if (openFileDialog1.FileName == "openFileDialog1")
{ }
else
{
operate.SaveImage(this.txtYGNum.Text.Trim(), openFileDialog1);
}
if (num > 0)
{
string update1 = "update tb_redeploy set UName='" + txtYGName.Text + "',UOldDep='" + cbbYGBumen.Text + "',UOldJob='" + txtYGZhiwu.Text + "',UOldPay='"+txtYGPay.Text+"' where UID='" + txtYGNum.Text + "'";
string update2 = "update tb_prize set UserName='" + txtYGName.Text + "',UserDep='"+cbbYGBumen.Text+"' where UserID='" + txtYGNum.Text + "'";
string update3 = "update tb_pay set YName='" + txtYGName.Text + "',YSex='" + cbbYGSex.Text + "',Ydep='" + cbbYGBumen.Text + "',YZhiwu='" + txtYGZhiwu.Text + "',YBasePay='"+txtYGPay.Text+"' where YID='" + txtYGNum.Text + "'";
string update4 = "update tb_check set Pname='" + txtYGName.Text + "',Pdep='"+cbbYGBumen.Text+"' where PID='" + txtYGNum.Text + "'";
operate.OperateData(update1);
operate.OperateData(update2);
operate.OperateData(update3);
operate.OperateData(update4);
MessageBox.Show("员工信息修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
}
}
}
catch (Exception EX)
{
MessageBox.Show(EX.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
operate.Read_Image(openFileDialog1, pictureBox1);
}
catch
{
MessageBox.Show("加载图片出错");
}
}
private void txtYGPhone_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
}
private void txtYGPay_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
}
private void toolStripLabel3_Click(object sender, EventArgs e)
{
PrintForm.frmUserPrint userprint = new PMS.PrintForm.frmUserPrint();
userprint.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
string strg = Application.StartupPath.ToString();
strg = strg.Substring(0, strg.LastIndexOf("\\"));
strg = strg.Substring(0, strg.LastIndexOf("\\"));
strg += @"\PMSImage";
strg += @"\default.jpg";
openFileDialog1.FileName = strg;
pictureBox1.Image=System.Drawing.Image.FromFile(openFileDialog1.FileName);
}
private void txtYGName_TextChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -