📄 frmpersonelinfo.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.Data.SqlClient;
using System.IO;
namespace HRP.Personnel
{
public partial class frmPersonelInfo : Form
{
public frmPersonelInfo()
{
InitializeComponent();
}
BaseClass.SqlClass sqlclass = new HRP.BaseClass.SqlClass();
BaseClass.PersonnelClass persomclass = new HRP.BaseClass.PersonnelClass();
frmMain frm_main = new frmMain();
public byte[] bytes;
public string strUserName;
public DataSet ds;
private void frmPersonelInfo_Load(object sender, EventArgs e)
{
this.tlbtnYes.Enabled = false;
this.tlbtnReturn.Enabled = false;
this.Bind();
//部门
this.cbbEmployeeDept.DataSource = sqlclass.SqlDaAd("select DeptName from tb_Dept", "tb_Dept").Tables["tb_Dept"];
this.cbbEmployeeDept.DisplayMember = "DeptName";
//职务
this.cbbEmployeeDutyType.DataSource = sqlclass.SqlDaAd("select Name from tb_DutyType", "tb_DutyType").Tables["tb_DutyType"];
this.cbbEmployeeDutyType.DisplayMember = "Name";
//民族
this.cbbEmployeeFolk.DataSource = sqlclass.SqlDaAd("select Name from tb_Folk", "tb_Folk").Tables["tb_Folk"];
this.cbbEmployeeFolk.DisplayMember = "Name";
//职称
this.cbbEmployeePostTitle.DataSource = sqlclass.SqlDaAd("select Name from tb_PostTitle", "tb_PostTitle").Tables["tb_PostTitle"];
this.cbbEmployeePostTitle.DisplayMember = "Name";
//工种
this.cbbEmployeeWorkType.DataSource = sqlclass.SqlDaAd("select Name from tb_WorkType", "tb_WorkType").Tables["tb_WorkType"];
this.cbbEmployeeWorkType.DisplayMember = "Name";
//文化程度
this.cbbEmployeeKultuLevel.DataSource = sqlclass.SqlDaAd("select Name from tb_KultuLevel", "tb_KultuLevel").Tables["tb_KultuLevel"];
this.cbbEmployeeKultuLevel.DisplayMember = "Name";
//政治面貌
this.cbbEmployeePoliticsVisage.DataSource = sqlclass.SqlDaAd("select Name from tb_PoliticsVisage", "tb_PoliticsVisage").Tables["tb_PoliticsVisage"];
this.cbbEmployeePoliticsVisage.DisplayMember = "Name";
}
public void Bind()
{
ds = sqlclass.SqlDaAd("select * from tb_Personnel", "tb_Personnel");
dgvPersonnelManage.AutoGenerateColumns = false;
dgvPersonnelManage.DataSource = ds.Tables["tb_Personnel"];
}
private void dgvPersonnelManage_MouseClick(object sender, MouseEventArgs e)
{
try
{
string strid = dgvPersonnelManage[0, dgvPersonnelManage.CurrentCell.RowIndex].Value.ToString();
if (strid != "")
{
DataRowView rowview = sqlclass.SqlDaAd("select * from tb_Personnel where EmployeeID=" + strid, "tb_Personnel").Tables["tb_Personnel"].DefaultView[0];
this.txtBooker.Text = rowview["Booker"].ToString();
this.txtEmployeeAddress.Text = rowview["EmployeeAddress"].ToString();
this.txtEmployeeAge.Text = rowview["EmployeeAge"].ToString();
this.txtEmployeeCollege.Text = rowview["EmployeeCollege"].ToString();
this.txtEmployeeID.Text = rowview["EmployeeID"].ToString();
this.txtEmployeeIDcard.Text = rowview["EmployeeIDcard"].ToString();
this.cbbEmployeeKultuLevel.Text = rowview["EmployeeKultuLevel"].ToString();
this.txtEmployeeLongSuit.Text = rowview["EmployeeLongSuit"].ToString();
this.txtEmployeeMobileTel.Text = rowview["EmployeeMobileTel"].ToString();
this.txtEmployeeName.Text = rowview["EmployeeName"].ToString();
this.txtEmployeeNativePlace.Text = rowview["EmployeeNativePlace"].ToString();
this.txtEmployeeOther.Text = rowview["EmployeeOther"].ToString();
this.txtEmployeeResume.Text = rowview["EmployeeResume"].ToString();
this.txtEmployeeSpeciality.Text = rowview["EmployeeSpeciality"].ToString();
this.txtEmployeeTel.Text = rowview["EmployeeTel"].ToString();
this.txtEmployeeUnitWorkAge.Text = rowview["EmployeeUnitWorkAge"].ToString();
this.txtEmployeeWorkAge.Text = rowview["EmployeeWorkAge"].ToString();
this.txtEmployeeBasePay.Text = rowview["EmployeeBasePay"].ToString();
this.cbbEmployeeDept.Text = rowview["EmployeeDept"].ToString();
this.cbbEmployeeDutyType.Text = rowview["EmployeeDutyType"].ToString();
this.cbbEmployeeFolk.Text = rowview["EmployeeFolk"].ToString();
this.cbbEmployeeMarriage.Text = rowview["EmployeeMarriage"].ToString();
this.cbbEmployeePoliticsVisage.Text = rowview["EmployeePoliticsVisage"].ToString();
this.cbbEmployeePostTitle.Text = rowview["EmployeePostTitle"].ToString();
this.cbbEmployeeSex.Text = rowview["EmployeeSex"].ToString();
this.cbbEmployeeWorkType.Text = rowview["EmployeeWorkType"].ToString();
this.dtpBookInTime.Text = rowview["BookinTime"].ToString();
this.dtpEmployeeBirth.Text = rowview["EmployeeBirth"].ToString();
this.dtpEmployeePartyTime.Text = rowview["EmployeePartyTime"].ToString();
this.dtpEmployeeFoldTime.Text = rowview["EmployeeFoldTime"].ToString();
if (rowview["EmployeePhoto"].ToString() != "")
{
bytes = (byte[])rowview["EmployeePhoto"];
this.image((byte[])rowview["EmployeePhoto"]);
}
else
{
this.ptbEmployeePhoto.Image = null;
}
}
}
catch
{
MessageBox.Show("请选择一条记录");
}
}
public void empty()
{
this.txtBooker.Text = "";
this.txtEmployeeAddress.Text = "";
this.txtEmployeeAge.Text = "";
this.txtEmployeeCollege.Text = "";
this.txtEmployeeID.Text = "";
this.txtEmployeeIDcard.Text = "";
this.cbbEmployeeKultuLevel.Text = "";
this.txtEmployeeLongSuit.Text = "";
this.txtEmployeeMobileTel.Text = "";
this.txtEmployeeName.Text = "";
this.txtEmployeeNativePlace.Text = "";
this.txtEmployeeOther.Text = "";
this.txtEmployeeResume.Text = "";
this.txtEmployeeSpeciality.Text = "";
this.txtEmployeeTel.Text = "";
this.txtEmployeeUnitWorkAge.Text = "";
this.txtEmployeeWorkAge.Text = "";
this.txtEmployeeBasePay.Text = "";
this.cbbEmployeeDept.Text = "";
this.cbbEmployeeDutyType.Text = "";
this.cbbEmployeeFolk.Text = "";
this.cbbEmployeeMarriage.Text = "";
this.cbbEmployeePoliticsVisage.Text = "";
this.cbbEmployeePostTitle.Text = "";
this.cbbEmployeeSex.Text = "";
this.cbbEmployeeWorkType.Text = "";
this.dtpBookInTime.Text = "";
this.dtpEmployeeBirth.Text = "";
this.dtpEmployeePartyTime.Text = "";
this.dtpEmployeeFoldTime.Text = "";
}
private void tlbtnAdd_Click(object sender, EventArgs e)
{
this.tlbtnAdd.Enabled = false;
this.tlbtnEdit.Enabled = false;
this.tlbtnDelete.Enabled = false;
this.tlbtnAll.Enabled = false;
this.tlbtnSearch.Enabled = false;
this.tlbtnPrint.Enabled = false;
this.tlbtnYes.Enabled = true;
this.tlbtnReturn.Enabled = true;
this.empty();
string strid;
try
{
strid = Convert.ToString(Convert.ToInt32(dgvPersonnelManage.Rows[dgvPersonnelManage.Rows.Count - 2].Cells[0].Value) + 1);
}
catch
{
strid = "";
}
string strCultivateID = strid;
if (strCultivateID == "")
{
strCultivateID = "1";
}
strCultivateID = Convert.ToString(Convert.ToInt32(strCultivateID) + 1);
for (int i = 1; i < Convert.ToInt32(6 - strid.Length); i++)
{
strCultivateID = "0" + strCultivateID;
}
this.txtEmployeeID.Text = strCultivateID;
this.txtBooker.Text = strUserName;
}
private void tlbtnReturn_Click(object sender, EventArgs e)
{
this.tlbtnAdd.Enabled = true;
this.tlbtnEdit.Enabled = true;
this.tlbtnDelete.Enabled = true;
this.tlbtnAll.Enabled = true;
this.tlbtnSearch.Enabled = true;
this.tlbtnPrint.Enabled = true;
this.tlbtnYes.Enabled = false;
this.tlbtnReturn.Enabled = false;
}
private void tlbtnYes_Click(object sender, EventArgs e)
{
try
{
SqlDataAdapter sda = sqlclass.sqlsda("select * from tb_Personnel");
DataSet ds = new DataSet();
SqlCommandBuilder sb = new SqlCommandBuilder(sda);
sda.Fill(ds, "tb_Personnel");
DataRow newrow = ds.Tables["tb_Personnel"].NewRow();
newrow["EmployeeID"] = this.txtEmployeeID.Text;
newrow["Booker"] = this.txtBooker.Text;
newrow["EmployeeAddress"] = this.txtEmployeeAddress.Text;
newrow["EmployeeAge"] = Convert.ToInt16(this.txtEmployeeAge.Text);
newrow["EmployeeCollege"] = this.txtEmployeeCollege.Text;
newrow["EmployeeIDcard"] = this.txtEmployeeIDcard.Text;
newrow["EmployeeKultuLevel"] = this.cbbEmployeeKultuLevel.Text;
newrow["EmployeeLongSuit"] = this.txtEmployeeLongSuit.Text;
newrow["EmployeeMobileTel"] = this.txtEmployeeMobileTel.Text;
newrow["EmployeeName"] = this.txtEmployeeName.Text;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -