📄 querypersonnelform.cs
字号:
//文件名:QueryPersonnelForm.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;
namespace MyPersonnel
{
public partial class QueryPersonnelForm : Form
{
public QueryPersonnelForm()
{
InitializeComponent();
}
private DataTable MyPersonnelTable ;
private DataTable MyFamilyTable ;
private DataTable MyTrainingTable ;
private DataTable MyArchievementTable;
private DataTable MyRewardsTable ;
private DataTable MyLeaveTable ;
private DataTable MyResumeTable;
public string MyCompany;
private void 查询ToolStripButton_Click(object sender, EventArgs e)
{
String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
MyPersonnelTable = new DataTable();
string MySQL = "Select * From 基本档案 Where 姓名 LIKE '" + this.姓名ToolStripTextBox.Text + "'";
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyPersonnelTable);
this.基本档案DataGridView.DataSource = MyPersonnelTable;
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
private void 基本档案DataGridView_SelectionChanged(object sender, EventArgs e)
{
string My员工编号 = this.基本档案DataGridView.CurrentRow.Cells[1].Value.ToString();
String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
MyFamilyTable = new DataTable();
string MySQL = "Select 家庭成员姓名,与员工关系,工作单位,担任职务,政治面貌,联系电话,其他 From 员工家庭成员 Where 员工编号= '" + My员工编号 + "'";
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyFamilyTable);
this.家庭成员DataGridView.DataSource = MyFamilyTable;
MyTrainingTable = new DataTable();
MySQL = "Select 开始时间,结束时间,培训单位,培训地点,培训内容,培训经费,证书名称,说明 From 培训记录 Where 员工编号= '" + My员工编号 + "'";
MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyTrainingTable);
this.培训记录DataGridView.DataSource = MyTrainingTable;
MyArchievementTable = new DataTable();
MySQL = "Select 工作业绩,专长描述,说明 From 工作业绩 Where 员工编号= '" + My员工编号 + "'";
MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyArchievementTable);
this.工作业绩DataGridView.DataSource = MyArchievementTable;
MyRewardsTable = new DataTable();
MySQL = "Select 奖惩日期,奖惩类型,奖惩原因,奖惩批准单位,解除处分日期,说明 From 奖惩记录 Where 员工编号= '" + My员工编号 + "'";
MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyRewardsTable);
this.奖惩记录DataGridView.DataSource = MyRewardsTable;
MyResumeTable = new DataTable();
MySQL = "Select 开始时间,结束时间,单位名称,担任职务,所在部门,说明 From 工作简历 Where 员工编号= '" + My员工编号 + "'";
MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyResumeTable);
this.工作简历DataGridView.DataSource = MyResumeTable;
MyLeaveTable = new DataTable();
MySQL = "Select 离职时间,离职原因,批准人,说明 From 离职管理 Where 员工编号= '" + My员工编号 + "'";
MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyLeaveTable);
this.离职原因DataGridView.DataSource = MyLeaveTable;
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
private void 打印基本档案ToolStripButton_Click(object sender, EventArgs e)
{
this.printPreviewDialog1.Document = this.printDocument1;
this.printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//打印员工人事档案
e.Graphics.DrawString(this.MyCompany + "员工人事档案", new Font("宋体", 20), Brushes.Black, 150, 80);
e.Graphics.DrawString("单位公章:", new Font("宋体", 12), Brushes.Black, 100, 145);
e.Graphics.DrawString("打印日期:" + DateTime.Now.ToString(), new Font("宋体", 12), Brushes.Black, 450, 145);
e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 165, 720, 165);
e.Graphics.DrawString("员工编号:" +this.基本档案DataGridView.CurrentRow.Cells[1].Value.ToString(), new Font("宋体", 12), Brushes.Black, 110, 175);
e.Graphics.DrawString("部门:" + this.基本档案DataGridView.CurrentRow.Cells[2].Value.ToString(), new Font("宋体", 12), Brushes.Black, 300, 175);
e.Graphics.DrawString("姓名:" + this.基本档案DataGridView.CurrentRow.Cells[3].Value.ToString(), new Font("宋体", 12), Brushes.Black, 450, 175);
e.Graphics.DrawString("性别:" + this.基本档案DataGridView.CurrentRow.Cells[4].Value.ToString(), new Font("宋体", 12), Brushes.Black, 620, 175);
e.Graphics.DrawLine(new Pen(Color.Black), 100, 195, 720, 195);
e.Graphics.DrawString("出生年月:" + ((DateTime)this.基本档案DataGridView.CurrentRow.Cells[5].Value).ToShortDateString(), new Font("宋体", 12), Brushes.Black, 110, 200);
e.Graphics.DrawString("身份证号码:" + this.基本档案DataGridView.CurrentRow.Cells[6].Value.ToString(), new Font("宋体", 12), Brushes.Black, 300, 200);
e.Graphics.DrawString("民族:" + this.基本档案DataGridView.CurrentRow.Cells[7].Value.ToString(), new Font("宋体", 12), Brushes.Black, 620, 200);
e.Graphics.DrawLine(new Pen(Color.Black), 100, 220, 720, 220);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -