private void dataGridView1_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.CateId.SelectedItem).Text; string projectName = this.SelectedProject.Text; ContractItem item = UserHelper.ContractItemList[e.RowIndex]; EditItem ei = new EditItem(categoryName, projectName, item, _sc); ei.ShowDialog(); if (ei.DialogResult == DialogResult.OK) { this.BindItem(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 itemId = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex].Cells[0].Value); string result = _sc.DeleteItem(itemId); if (result == Response.DELETE_ITEM_SUCCESS.ToString()) { MessageBox.Show("删除工作量成功!", "提示", MessageBoxButtons.OK); this.BindItem(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); } } } }