Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //prompts a validation message to ensure selection
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this taught course?",
                                                        "Delete Notice", MessageBoxButtons.YesNo);

            //if yes, the taught course object is created and passed to be deleted
            if (dialogResult == DialogResult.Yes)
            {
                TaughtCourse tCourse = (TaughtCourse)this.cmbTaughtID.SelectedItem;
                //Delete All Related Records First
                //From Schedule Table
                scheduleList.Delete("Section", "Section.SectionID", "Schedule.SectionID", "Section.TaughtCourseID", cmbTaughtID.SelectedItem.ToString());
                //From SectionStudent Table
                sectionStudentList.Delete("Section", "Section.SectionID", "SectionStudent.SectionID", "Section.TaughtCourseID", cmbTaughtID.SelectedItem.ToString());
                //From Section Table
                sectionList.Delete("TaughtCourseID", cmbTaughtID.SelectedItem.ToString());
                //Delete Taught Course From Taught Courses Table Second
                taughtCourses.Delete(tCourse);
                //checks if the execution was a seccuess or not
                if (tCourse.getValid() == true)
                {
                    MessageBox.Show("Taught Course has been deleted successfully.");
                }
                else
                {
                    MessageBox.Show("An error has occured. Record was not deleted.");
                }
                loadTCourses();
            }
        }
Пример #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this section?",
               "Delete Notice", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                Section section = (Section)cmbSectionID.SelectedItem;
                //Delete All Related Records First
                //From SectionStudent Table
                sectionStudentList.Delete("SectionID", cmbSectionID.SelectedItem.ToString());
                //From Schedule Table
                scheduleList.Delete("SectionID", cmbSectionID.SelectedItem.ToString());
                //Delete Section From Section Table Second
                sectionList.Delete(section);

                if (section.getValid() == true)
                {
                    MessageBox.Show("Section has been deleted successfully.");
                }
                else
                {
                    MessageBox.Show("An error has occured. record was not added.");
                }

            }
            PopulateSections();
        }
Пример #3
0
        //Deletes the selected instructor from the combobox from the databse
        private void ButtonDelete_Click(object sender, EventArgs e)
        {
            //Prompt the user if he wants to delete the instructor (for confirmation)
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this instructor?",
                                                        "Delete Notice", MessageBoxButtons.YesNo);

            //If the user clicks Yes Button
            if (dialogResult == DialogResult.Yes)
            {
                Instructor instructor = (Instructor)comboBoxID.SelectedItem;
                //Delete All Related Records First
                //From Schedule Table
                scheduleList.Delete("Section", "Section.SectionID", "Schedule.SectionID", "Section.InstructorID", comboBoxID.SelectedItem.ToString());
                //From SectionStudent Table
                sectionStudentList.Delete("Section", "Section.SectionID", "SectionStudent.SectionID", "Section.InstructorID", comboBoxID.SelectedItem.ToString());
                //From Section Table
                sectionList.Delete("InstructorID", comboBoxID.SelectedItem.ToString());
                //Delete Instructor From Instructor Table Second
                instructorList.Delete(instructor);

                //Check if instructor is valid or not and show appropriate message
                if (instructor.getValid() == true)
                {
                    MessageBox.Show("Instructor has been deleted successfully.");
                }
                else
                {
                    MessageBox.Show("An error has occured. record was not added.");
                }
            }
            //Re-populate the comboboxes after the deletion
            PopulateInstructors();
        }