private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 2) // 修改当前部门信息 { if (MessageBox.Show("确定要修改当前项目类别信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // BUG string categoryName = ((ComboboxItem)this.SelectedCategory.SelectedItem).Text; ContractProject project = UserHelper.ContractProjectList[e.RowIndex]; EditProject ep = new EditProject(categoryName, project, _sc); ep.ShowDialog(); if (ep.DialogResult == DialogResult.OK) { this.BindProject(true); } } } else if (e.ColumnIndex == 3) // 删除当前部门信息 { if (MessageBox.Show("确定要删除此项目类别信息?\n危险操作,请谨慎进行\n由于此项目类别下面可能有工作量集合,因此您的删除操作会将此项目下的所有工作量全部被删除,由此将引入很多不安全问题,请问您是否继续删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //MessageBox.Show(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value.ToString()); int projectId = Convert.ToInt32(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value); string result = _sc.DeleteProject(projectId); if (result == Response.DELETE_PROJECT_SUCCESS.ToString()) { MessageBox.Show("删除项目类别成功!", "提示", MessageBoxButtons.OK); BindProject(true); } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } //else if (result == Response.DELETE_DEPARTMENT_EXIST_EMPLOYEE.ToString()) //{ // MessageBox.Show("该部门下有人员存在,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} else { MessageBox.Show("删除项目类别失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }