public void DeleteLecturer(int userId) { var deleteLecturer = "DELETE FROM lecturers WHERE userId = @userId"; SqlCommand commandDeleteLecturer = new SqlCommand(deleteLecturer, connection); commandDeleteLecturer.Parameters.AddWithValue("@userId", userId); connection.Open(); commandDeleteLecturer.ExecuteNonQuery(); connection.Close(); var subjects = repository.GetLecturerSubjects(userId); foreach (Subject subject in subjects) { repository.DeleteSubject(subject.ID); } DeleteUser(userId); }
private void DeleteSubjectButton_Click(object sender, EventArgs e) { DeleteSubjectButton.Enabled = false; try { repository.DeleteSubject(Global.SubjectID); DisplayingSubjectsInListView(); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }