private void btnAdd_Click(object sender, EventArgs e) { var addDepartment = new AddDepartmentForm(false); addDepartment.CallBack += BindData; addDepartment.ShowDialog(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int columnIndex = e.ColumnIndex; int rowIndex = e.RowIndex; if (rowIndex == -1) { return; } if (this.dgvDepartment.Columns[columnIndex] == this.dgvDepartment.Columns["Delete"]) { var dialogResult = DlgHelper.ShowConfirmMsgBox("确定要删除吗?"); if (dialogResult == DialogResult.Yes) { var id = (int)dgvDepartment.Rows[rowIndex].Cells["DepartmentID"].Value; var result = new DepartmentBLL().DeleteDepartmentByID(id); if (result.Code > 0) { DlgHelper.ShowAlertMsgBox(result.Msg); return; } BindData(); } } else if (this.dgvDepartment.Columns[columnIndex] == this.dgvDepartment.Columns["Edit"]) { var id = (int)dgvDepartment.Rows[rowIndex].Cells["DepartmentID"].Value; var name = dgvDepartment.Rows[rowIndex].Cells["DepartmentName"].Value.ToString(); var departmentForm = new AddDepartmentForm(true, id, name); departmentForm.CallBack += BindData; departmentForm.ShowDialog(); } }