2. 删除部门的界面设计及详细代码如下:(其他没有写在此说明书内)
◎ 用到的控件字段名、方法及变量有
※ 控件:
TableControl名称:tionNametb
删除部门ComboBox名称:SMF_Delete_SectionNamecom DataGridView名称:SMF_Delete_SectionMemberdgv 职工编号文本框名称:SMF_Delete_StaffIDtxt
调派部门ComboBox名称:SMF_Delete_SectionNewNamecom 调派按钮的名称:SMF_Delete_AssignBut 提交删除按钮的名称:SMF_Delete_Yesbut
※ 变量:
SectionOpt Sopt = new SectionOpt();//处理部门业务
Section oldsec = new Section(); //旧部门
※ 调用方法:
Sopt.GetSections(); //得到部门的所有记录
Sopt.GetStaffs_BySection(oldsec.SectionName); //根据部门名称得到员工 Sopt.DelectSection(oldsec); //删除部门
Sopt.GetOtherSections(oldsec.SectionID); //得到除此之外所有部门的记录
◎ TableControl的SelectedIndexChanged事件:
private void tionNametb_SelectedIndexChanged(object sender, EventArgs e)
{
SMF_Delete_SectionNamecom.DataSource = Sopt.GetSections(); SMF_Delete_SectionNamecom.DisplayMember = \ SMF_Delete_SectionNamecom.ValueMember = \ this.SMF_Delete_SectionNamecom.SelectedIndexChanged +=
- 21 -
new
System.EventHandler(this.SMF_Delete_SectionNamecom_SelectedIndexChanged); oldsec.SectionName = SMF_Delete_SectionNamecom.Text;
oldsec.SectionID = SMF_Delete_SectionNamecom.SelectedValue.ToString(); }
◎ 删除部门ComboBox的SelectedIndexChanged事件:
private void SMF_Delete_SectionNamecom_SelectedIndexChanged(object sender,
EventArgs e) {
oldsec.SectionName = SMF_Delete_SectionNamecom.Text;
oldsec.SectionID = SMF_Delete_SectionNamecom.SelectedValue.ToString(); SMF_Delete_SectionMemberdgv.DataSource = Sopt.GetStaffs_BySection(oldsec.SectionName);
SMF_Delete_SectionNewNamecom.DataSource = Sopt.GetOtherSections(oldsec.SectionID);
SMF_Delete_SectionNewNamecom.DisplayMember = \ SMF_Delete_SectionNewNamecom.ValueMember = \ SMF_Delete_StaffIDtxt.Clear(); }
◎ DataGridView的SectionMemberdgv_CellClick事件
private void SMF_Delete_SectionMemberdgv_CellClick(object sender,
DataGridViewCellEventArgs e) {
if (e.RowIndex >= 0) {
SMF_Delete_StaffIDtxt.Text = SMF_Delete_SectionMemberdgv.Rows[e.RowIndex].Cells[0].Value.ToString(); } }
◎ 调派按钮的单击事件
private void SMF_Delete_AssignBut_Click(object sender, EventArgs e)
{
if (SMF_Delete_StaffIDtxt.Text != \ {
string staffid = SMF_Delete_StaffIDtxt.Text;
string sectionid = SMF_Delete_SectionNewNamecom.SelectedValue.ToString(); if (Sopt.AssignStaff(staffid, sectionid)) {
MessageBox.Show(\调派成功!\
SMF_Delete_SectionMemberdgv.DataSource = Sopt.GetStaffs_BySection(oldsec.SectionName);
- 22 -
} else {
MessageBox.Show(\职工\已不在\ } } }
◎ 提交删除按钮的单击事件
private void SMF_Delete_Yesbut_Click(object sender, EventArgs e)
{
if (Sopt.DelectSection(oldsec)) {
MessageBox.Show(\删除成功!\
SMF_Delete_SectionNamecom.DataSource = Sopt.GetSections(); SMF_Delete_SectionNamecom.DisplayMember = \ SMF_Delete_SectionNamecom.ValueMember = \ } else {
MessageBox.Show(\操作失败,未分配该部门的员工或部门已被删除!\ } }
4.6 职工管理模块
1. 流程图: 超级管理 员和管理 员登录系 统
- 23 -
添加职工 修改职工 职工管理 删除职工 查询职工 ◆ 管理员和超级管理员成功登录系统后可以执行对职工的增删改查操作。
2. 界面设计截图如下:
(1)添加职工
(2)修改职工
- 24 -
(3)删除职工
(4)查询职工
- 25 -