private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 9) // 修改员工 { if (MessageBox.Show("确定要修改此员工信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //int Id = Convert.ToInt32(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value); //string result = await _sc.ModifyEmployee(Id); int row = Convert.ToInt32(e.RowIndex); // 获取当前的信息行 Employee employee = UserHelper.EmpList[row]; // 获取数据源中第row个员工的信息 EditEmployee editEmployee = new EditEmployee(employee, _sc); editEmployee.ShowDialog(); if (editEmployee.DialogResult == DialogResult.OK) { editEmployee.Close(); BindEmployee(0); } } } else if (e.ColumnIndex == 10) // 重置密码 { String Name = this.dataGridView3.Rows[e.RowIndex].Cells[1].Value.ToString(); if (MessageBox.Show("确定重置员工" + Name + "的密码?员工密码将被重置为111", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int Id = Convert.ToInt32(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value); String Username = this.dataGridView3.Rows[e.RowIndex].Cells[2].Value.ToString(); String Password = "******"; User user = new User { Username = Username, Password = Password }; string result = _sc.ModifyEmployeePassword(user); // 重置员工密码 if (result == Response.MODIFY_EMP_PWD_SUCCESS.ToString()) { MessageBox.Show("重置密码成功!", "提示", MessageBoxButtons.OK); } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,重置密码失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("重置密码成功失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } BindEmployee(0); } } else if (e.ColumnIndex == 11) // 删除员工 { if (MessageBox.Show("确定要删除此人员?\n危险操作,谨慎进行\n由于该员工可能关联了很多会签单模版以及会签单信息,请谨慎操作", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int Id = Convert.ToInt32(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value); string result = _sc.DeleteEmployee(Id); if (result == Response.DELETE_EMPLOYEE_SUCCESS.ToString()) { MessageBox.Show("删除人员成功!", "提示", MessageBoxButtons.OK); } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == Response.DELETE_EMPLOYEE_EXIST_CONTRACT.ToString()) { MessageBox.Show("该人员存在会签单信息中,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result == Response.DELETE_EMPLOYEE_EXIST_CONTEMP.ToString()) { MessageBox.Show("该人员存在会签单模版信息中,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("删除人员失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } BindEmployee(0); } } }