private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (IsUser) { DialogResult dResult = DialogResult.No; switch (myChoice) { case Choice.EDepartment: dResult = UtilityClass.GetDeleteDialog("Department"); if (dResult == DialogResult.Yes) { if (ActionClass.DeleteDepartment((Department)departmentBindingSource.Current)) { if (departmentDataGridView.CurrentRow != null) { departmentDataGridView.Rows.Remove(departmentDataGridView.CurrentRow); } } } break; case Choice.EPosition: dResult = UtilityClass.GetDeleteDialog("Position"); if (dResult == DialogResult.Yes) { if (ActionClass.DeletePosition((Position)positionsBindingSource.Current)) { if (positionsDataGridView.CurrentRow != null) { positionsDataGridView.Rows.Remove(positionsDataGridView.CurrentRow); } } } break; case Choice.EMisc: dResult = UtilityClass.GetDeleteDialog("Miscellaneous"); if (dResult == DialogResult.Yes) { if (ActionClass.DeleteMiscellaneous((Miscellaneous)miscellaneousBindingSource.Current)) { if (miscellaneousDataGridView.CurrentRow != null) { miscellaneousDataGridView.Rows.Remove(miscellaneousDataGridView.CurrentRow); } } } break; case Choice.Holiday: dResult = UtilityClass.GetDeleteDialog("Holiday"); if (dResult == DialogResult.Yes) { if (ActionClass.DeleteHoliday((Holiday)holidayBindingSource.Current)) { if (holidayDataGridView.CurrentRow != null) { holidayDataGridView.Rows.Remove(holidayDataGridView.CurrentRow); } } } break; case Choice.Company: if (companyBindingSource.Count > 1) { dResult = UtilityClass.GetDeleteDialog("Company"); if (dResult == DialogResult.Yes) { if (ActionClass.DeleteCompany((Company)companyBindingSource.Current)) { if (companyDataGridView.CurrentRow != null) { companyDataGridView.Rows.Remove(companyDataGridView.CurrentRow); } } } } else { MessageBox.Show("Cannot remove default company record.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; default: MessageBox.Show("Please select an item to delete.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } } else { MessageBox.Show("You have are not permitted to perform this operation.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }