Exemple #1
0
        /// <summary>
        /// Completes or denies lessons and closes the form
        /// </summary>
        /// <param name="sender">The object sender</param>
        /// <param name="e">The EventArgs</param>
        private void saveButton_Click(object sender, EventArgs e)
        {
            StringBuilder text = new StringBuilder();

            text.AppendLine("Are you sure you want to complete the lesson with the following attendees?");
            text.AppendLine();
            text.AppendLine("Attended:");
            // Lists All the students who attended the lesson
            for (int i = 0; i < attendingStudentsList.Items.Count; i++)
            {
                if (attendingStudentsList.Items[i].Checked)
                {
                    text.AppendLine(attendingStudentsList.Items[i].SubItems[1].Text);
                }
            }
            text.AppendLine();
            text.AppendLine("Did Not Attend:");
            // Lists All the students who did not attend the lesson
            for (int i = 0; i < attendingStudentsList.Items.Count; i++)
            {
                if (!attendingStudentsList.Items[i].Checked)
                {
                    text.AppendLine(attendingStudentsList.Items[i].SubItems[1].Text);
                }
            }

            // Show the dialog and save result
            DialogResult result = CustomMsgBox.ShowConfirm(text.ToString(), "Confirm Attendees", CustomMsgBoxIcon.Complete, 20 * attendingStudentsList.Items.Count + 80);

            if (result == DialogResult.OK)
            {
                for (int i = 0; i < attendingStudentsList.Items.Count; i++)
                {
                    // If row is checked then complete lesson else deny lesson
                    if (attendingStudentsList.Items[i].Checked)
                    {
                        DatabaseParser.SetLessonToStatus(_lessonList[i].StudentId, _lessonList[i].AppointmentID,
                                                         _lessonList[i].Progress, true);
                    }
                    else
                    {
                        List <Lesson> deleteList = DatabaseParser.FindLessonsToCancel(_lessonList[i].TemplateID,
                                                                                      _lessonList[i].Progress, _lessonList[i].StudentId);
                        DatabaseParser.DeleteLessons(deleteList);
                    }
                }
                this.DialogResult = DialogResult.Yes;
                this.Close();
            }
        }
Exemple #2
0
        /// <summary>
        /// Method used when the calendar button is clicked opening a window depending on the button text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bookingInformationButton_Click(object sender, EventArgs e)
        {
            if (bookingInformationButton.Text == BookingText)
            {
                BookAppointmentWindow bookingWindow = new BookAppointmentWindow(selectedAppointment, MousePosition);
                bookingWindow.ShowDialog();
                Session.GetProgress();
                UpdateCalendar(0);
            }
            else if (bookingInformationButton.Text == CancelBookingText)
            {
                if (Session.LoggedInUser.Sysmin)
                {
                    List <Lesson> cancelTheseLessons = new List <Lesson>();
                    List <Lesson> usersOnAppointment = DatabaseParser.GetUsersAndLessonsOnAppointmentID(selectedAppointment.Id);
                    foreach (Lesson lessonToCancel in usersOnAppointment)
                    {
                        cancelTheseLessons.AddRange(DatabaseParser.FindLessonsToCancel(lessonToCancel.TemplateID, lessonToCancel.Progress, lessonToCancel.UserID));
                    }
                    DialogResult result = CustomMsgBox.ShowYesNoInstructor("", "Cancel lesson", cancelTheseLessons, CustomMsgBoxIcon.Warrning);
                    if (result == DialogResult.Yes)
                    {
                        DatabaseParser.DeleteLessons(cancelTheseLessons);
                        DatabaseParser.DeleteAppointment(selectedAppointment.Id);
                        DeleteAppointment(selectedAppointment);
                        Session.LoggedInUser.GetLessonList();
                        Session.GetProgress();
                        UpdateCalendar(0);
                    }
                }
                else
                {
                    List <Lesson> cancelTheseLessons = DatabaseParser.FindLessonsToCancel(selectedAppointment.bookedLessons.First().TemplateID, selectedAppointment.bookedLessons.First().Progress, Session.LoggedInUser.Id);

                    DialogResult result = CustomMsgBox.ShowYesNo("", "Cancel lesson", cancelTheseLessons, CustomMsgBoxIcon.Warrning);
                    if (result == DialogResult.Yes)
                    {
                        DatabaseParser.DeleteLessons(cancelTheseLessons);
                        Session.LoggedInUser.GetLessonList();
                        Session.GetProgress();
                        UpdateCalendar(0);
                    }
                }
            }
        }