//Deletes the selected student from the combobox from the databse private void ButtonDelete_Click(object sender, EventArgs e) { //Prompt the user if he wants to delete the student (for confirmation) DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this student?", "Delete Notice", MessageBoxButtons.YesNo); //If the user clicks Yes Button if (dialogResult == DialogResult.Yes) { Student student = (Student)comboBoxID.SelectedItem; //Delete All Related Records First //From Section Student Table sectionStudentList.Delete("StudentID", comboBoxID.SelectedItem.ToString()); //Delete Instructor From Instructor Table Second studentList.Delete(student); //Check if instructor is valid or not and show appropriate message if (student.getValid() == true) { MessageBox.Show("Student has been deleted successfully."); } else { MessageBox.Show("An error has occured. record was not added."); } } //Re-populate the comboboxes after the deletion PopulateStudents(); }