private void btnDelete_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are you to delete this record?", "Note", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bool deleted = courseCRUD.DeleteCourse(int.Parse(txtCId.Text)); if (deleted) { MessageBox.Show("Record deleted successfully"); } else { MessageBox.Show("Error while deleting record!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }