📄 formlistemployee.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 HumanResourceManagement
{
public partial class FormListEmployee : Form
{
SqlConnection cnBlueHill_HRM;
DataSet dsCustomers;
SqlDataAdapter daCustomers;
public FormListEmployee()
{
InitializeComponent();
}
private const int CP_NOCLOSE_BUTTON = 0x200;
protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
return myCp;
}
}
private void FormListEmployee_Load(object sender, EventArgs e)
{
cnBlueHill_HRM = new SqlConnection("Data Source=.;Initial Catalog=BlueHill_HRM;integrated security=true;");
dsCustomers = new DataSet();
daCustomers = new SqlDataAdapter();
SqlCommand cmSelect = new SqlCommand();
cmSelect.Connection = cnBlueHill_HRM;
cmSelect.CommandText = "select * from tblEmployee";
daCustomers.SelectCommand = cmSelect;
daCustomers.Fill(dsCustomers, "Customers");
grdEmployee.DataSource = dsCustomers.Tables["Customers"];
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
Main M = new Main();
M.Show();
}
private void btnNewEmployee_Click(object sender, EventArgs e)
{
this.Hide();
FormNewEmployee FNE = new FormNewEmployee();
FNE.Show();
}
private void btnEditEmployee_Click(object sender, EventArgs e)
{
string ss = grdEmployee[grdEmployee.CurrentCell].ToString();
DB.setA = ss;
this.Hide();
FormModifyEmployee FME = new FormModifyEmployee();
FME.Show();
}
private void btnQueryEmployee_Click(object sender, EventArgs e)
{
this.Hide();
FormQueryEmployee FQE = new FormQueryEmployee();
FQE.Show();
}
private void btnDeleteEmployee_Click(object sender, EventArgs e)
{
string ss = grdEmployee[grdEmployee.CurrentCell].ToString();
SqlConnection con = DB.connection();
con.Open();
SqlCommand cmd = new SqlCommand("delete from tblEmployee where EmployeeID='" + ss + "'", con);
int count = Convert.ToInt32(cmd.ExecuteNonQuery());
if (count > 0)
{
DialogResult = MessageBox.Show("删除成功!", "提示");
//this.Hide();
//FormListEmployee FE = new FormListEmployee();
//FE.Show();
}
else
DialogResult = MessageBox.Show("操作失败!", "提示");
con.Close();
}
private void btnEditEmployee_Click_1(object sender, EventArgs e)
{
this.Hide();
FormModifyEmployee FME = new FormModifyEmployee();
FME.Show();
}
private void button4_Click(object sender, EventArgs e)
{
this.Hide();
FormQueryEmployee FQE = new FormQueryEmployee();
FQE.Show();
}
private void button3_Click(object sender, EventArgs e)
{
string ss = grdEmployee[grdEmployee.CurrentCell].ToString();
cnBlueHill_HRM = new SqlConnection("data source=.;initial catalog=BlueHill_HRM;integrated security=true;");
cnBlueHill_HRM.Open();
SqlCommand cmd = new SqlCommand("delete from tblEmployee where EmployeeID='" + ss + "'", cnBlueHill_HRM);
int count = Convert.ToInt32(cmd.ExecuteNonQuery());
if (count > 0)
{
DialogResult = MessageBox.Show("删除成功!", "提示");
this.Hide();
FormVacationManagement FVM = new FormVacationManagement();
FVM.Show();
}
else
DialogResult = MessageBox.Show("操作失败!", "提示");
cnBlueHill_HRM.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -