private void buttonDelete_Click(object sender, EventArgs e) { try { DialogResult dialogResult = new DialogResult(); if (cbComfirmDelete.Checked == true) { dialogResult = MessageBox.Show("Do you want to delete this record?", "Confirm Record Deletion", MessageBoxButtons.YesNo); } if (dialogResult == DialogResult.No) { //Close dialogResult } else { Customer customer = customerVM.GetDisplayCustomer(); CustomerValidation.DeleteCustomer(customer); customerVM.Customers = CustomerRepository.GetCustomer(); dataGridViewCustomer.DataSource = customerVM.Customers; } } catch (SqlException ex) { MessageBox.Show(ex.Message, "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Processing Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }