private void buttonDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + section.SectionName + "? Student list, classes and attendance data of this section will be permanently deleted", "Confirmation", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                SectionController        scontroller  = new SectionController();
                SectionTimeController    stcontroller = new SectionTimeController();
                SectionStudentController sscontroller = new SectionStudentController();
                try
                {
                    ClassController      ccontroller = new ClassController();
                    List <ClassModel>    classList   = ccontroller.GetBySectionId(section.Id);
                    AttendanceController acontroller = new AttendanceController();

                    foreach (ClassModel Class in classList)
                    {
                        acontroller.DeleteAllByClass(Class.Id);
                    }

                    ccontroller.DeleteAllBySection(section.Id);
                    sscontroller.RemoveAllBySection(section.Id);
                    stcontroller.RemoveAllBySection(section.Id);
                    scontroller.Delete(section);
                    MessageBox.Show("Deleted!");
                    buttonBack.PerformClick();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void Delete_Click(object sender, MouseEventArgs e, ClassModel model)
        {
            var confirmResult = MessageBox.Show("Are you sure you want to delete this class?",
                                                "Confirm Delete",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                ClassController ccontroller = new ClassController();
                try
                {
                    AttendanceController acontroller = new AttendanceController();
                    acontroller.DeleteAllByClass(model.Id);

                    ccontroller.Delete(model);
                    MessageBox.Show("Deleted!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }