📄 formaddemp.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;
namespace HRMan.HROper
{
public partial class FormAddEmp : Form
{
public FormAddEmp()
{
InitializeComponent();
openfile.Filter = "图像文件 (*.BMP;*.JPG;*.GIF;*.bmp;*.jpg;*.gif)|*.BMP;*.JPG;*.GIF;*.bmp;*.jpg;*.gif|所有文件 (*.*)|*.*";
}
//页面加载
private void FormAddEmp_Load(object sender, EventArgs e)
{
this.TopMost = true;
if (HRMan.HROper.FormEmpInfo.emploID == "insert")
{
InitNational();
InitSection();
InitJob();
InitTitle();
this.Text = "添加员工";
}
if (HRMan.HROper.FormEmpInfo.emploID == "update")
{
InitChange();
InitNational();
InitSection();
InitJob();
InitTitle();
DataAccess DA = new DataAccess();
DA.ReadImage(int.Parse(HRMan.HROper.FormEmpInfo.emploinfo.ID), this.pictureBox1);
this.Text = "修改员工信息";
}
}
private void InitNational()
{
string str = "select * from RaceInfo";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(str);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Race_cb.Items.Add(dt.Rows[i]["rName"].ToString());
}
}
private void InitSection()
{
string str = "select * from SectionInfo";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(str);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Section_cb.Items.Add(dt.Rows[i]["sName"].ToString());
}
}
private void InitJob()
{
string str = "select * from JobInfo";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(str);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Job_cb.Items.Add(dt.Rows[i]["JName"].ToString());
}
}
private void InitTitle()
{
string str = "select * from Title";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(str);
for (int i = 0; i < dt.Rows.Count; i++)
{
this.Title_cb.Items.Add(dt.Rows[i]["tName"].ToString());
}
}
//初始化修改
private void InitChange()
{
string SqlText = "select EmployInfo.rId,EmployInfo.eId as 员工编号,EmployInfo.eName as 员工姓名,EmployInfo.eSex as 性别,RaceInfo.rName as 民族,EmployInfo.eMarriage as 婚否,";
SqlText += "EmployInfo.eParty as 党派,EmployInfo.eBirth as 出生日期,EmployInfo.eNumber as 身份证号,EmployInfo.ePlace as 籍贯,EmployInfo.ePhone as 联系电话,EmployInfo.eAddress as 联系地址,";
SqlText += "EmployInfo.eEdu as 学历,EmployInfo.ePro as 专业,EmployInfo.eDegree as 学位,EmployInfo.eSchool as 毕业学校,EmployInfo.eDate as 毕业时间,";
SqlText += "EmployInfo.eEmpTime as 聘用时间,EmployInfo.eEmpType as 聘用方式,EmployInfo.eEmpDataSource as 聘用来源,EmployInfo.eApp as 员工状态,";
SqlText += "SectionInfo.sId,SectionInfo.sName as 所在部门,JobInfo.jId,JobInfo.JName as 所任职务,Title.tId,Title.tName as 所获职称,EndowmentInfo.endId,EndowmentInfo.enId as 养老保险号,";
SqlText += "MedicalInfo.meId,MedicalInfo.mId as 医疗保险号,WagesInfo.waId,WagesInfo.Id as 工资号 ";
SqlText += "from EmployInfo,RaceInfo,SectionInfo,JobInfo,Title,EndowmentInfo,MedicalInfo,WagesInfo ";
SqlText += "where EmployInfo.rId=RaceInfo.rId and EmployInfo.sId=SectionInfo.sId and JobInfo.jId=EmployInfo.jId and Title.tId=EmployInfo.tId and ";
SqlText += "EndowmentInfo.endId=EmployInfo.endId and MedicalInfo.meId=EmployInfo.meId and WagesInfo.waId=EmployInfo.waId and EmployInfo.eId=" + int.Parse(HRMan.HROper.FormEmpInfo.emploinfo.ID);
DataAccess DA = new DataAccess();
DataTable table = new DataTable();
table = DA.ExeSQLdt(SqlText);
this.RaceId_txt.Text = table.Rows[0]["rId"].ToString();
this.SectionId_txt.Text = table.Rows[0]["sId"].ToString();
this.TitleId_txt.Text = table.Rows[0]["tId"].ToString();
this.JobId_txt.Text = table.Rows[0]["jId"].ToString();
this.No_txt.Text = table.Rows[0]["员工编号"].ToString();
this.Name_txt.Text = table.Rows[0]["员工姓名"].ToString();
this.Sex_cb.Text = table.Rows[0]["性别"].ToString();
this.Party_cb.Text = table.Rows[0]["党派"].ToString();
this.Marrige_cb.Text = table.Rows[0]["婚否"].ToString();
this.Race_cb.Text = table.Rows[0]["民族"].ToString();
this.Birth_dtp.Text = table.Rows[0]["出生日期"].ToString();
this.Number_txt.Text = table.Rows[0]["身份证号"].ToString();
this.Place_cb.Text = table.Rows[0]["籍贯"].ToString();
this.Phone_txt.Text = table.Rows[0]["联系电话"].ToString();
this.Adress_txt.Text = table.Rows[0]["联系地址"].ToString();
this.Edu_cb.Text = table.Rows[0]["学历"].ToString();
this.Pro_cb.Text = table.Rows[0]["专业"].ToString();
this.Degree_cb.Text = table.Rows[0]["学位"].ToString();
this.School_txt.Text = table.Rows[0]["毕业学校"].ToString();
this.LeaveSchool_dtp.Text = table.Rows[0]["毕业时间"].ToString();
this.EmpTime_dtp.Text = table.Rows[0]["聘用时间"].ToString();
this.EmpType_cb.Text = table.Rows[0]["聘用方式"].ToString();
this.Source_cb.Text = table.Rows[0]["聘用来源"].ToString();
this.App_cb.Text = table.Rows[0]["员工状态"].ToString();
this.Section_cb.Text = table.Rows[0]["所在部门"].ToString();
this.Job_cb.Text = table.Rows[0]["所任职务"].ToString();
this.Title_cb.Text = table.Rows[0]["所获职称"].ToString();
this.EenMen_txt.Text = table.Rows[0]["养老保险号"].ToString();
this.Med_txt.Text = table.Rows[0]["医疗保险号"].ToString();
this.Wa_txt.Text = table.Rows[0]["工资号"].ToString();
}
//取消
private void button2_Click(object sender, EventArgs e)
{
HRMan.HROper.FormEmpInfo.emploinfo.Enabled = true;
HRMan.HROper.FormEmpInfo.emploinfo.Activate();
HRMan.HROper.FormEmpInfo.emploinfo.DBDataGrid();
this.Close();
}
//关闭窗体
private void FormAddEmp_FormClosing(object sender, FormClosingEventArgs e)
{
HRMan.HROper.FormEmpInfo.emploinfo.Enabled = true;
HRMan.HROper.FormEmpInfo.emploinfo.Activate();
HRMan.HROper.FormEmpInfo.emploinfo.DBDataGrid();
}
//上传图片
private void button3_Click(object sender, EventArgs e)
{
DataAccess DA = new DataAccess();
if (openfile.ShowDialog() == DialogResult.OK)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -