/// <summary>
 /// Raises the SaveStudentTimetable event safely.
 /// </summary>
 /// <param name="studentTimetable"></param>
 private void RaiseSaveStudentTimetableEvent(StudentTimetable studentTimetable)
 {
     if (SaveStudentTimetable != null)
     {
         SaveStudentTimetable(studentTimetable);
     }
 }
        private void okButton_Click(object sender, EventArgs e)
        {
            if (AreFieldsComplete())
            {
                Time fromTime = new Time(fromTimePicker.Value.Hour, fromTimePicker.Value.Minute);
                Time toTime   = new Time(toTimePicker.Value.Hour, toTimePicker.Value.Minute);

                List <string> studentNameList = new List <string>();
                for (int i = 0; i < studentListBox.Items.Count; i++)
                {
                    studentNameList.Add(studentListBox.GetItemText(studentListBox.Items[i]));
                }


                switch (personType)
                {
                case PersonType.Student:
                    StudentTimetable studentTimetable;
                    switch (lessonType)
                    {
                    case LessonType.Private:
                        studentTimetable = new StudentTimetable((DayOfWeek)dayCbox.SelectedIndex, fromTime, toTime, (byte)tennisCourtNumUpDown.Value, InputInformation.CorrectInputFormat(coachNameSurnameTbox.Text), lessonType);
                        RaiseSaveStudentTimetableEvent(studentTimetable);
                        break;

                    case LessonType.Group:
                        studentTimetable = new StudentTimetable((DayOfWeek)dayCbox.SelectedIndex, fromTime, toTime, (byte)tennisCourtNumUpDown.Value, studentNameList, InputInformation.CorrectInputFormat(coachNameSurnameTbox.Text), lessonType);
                        RaiseSaveStudentTimetableEvent(studentTimetable);
                        break;

                    case LessonType.SemiPrivate:
                        studentTimetable = new StudentTimetable((DayOfWeek)dayCbox.SelectedIndex, fromTime, toTime, (byte)tennisCourtNumUpDown.Value, studentNameList, InputInformation.CorrectInputFormat(coachNameSurnameTbox.Text), lessonType);
                        RaiseSaveStudentTimetableEvent(studentTimetable);
                        break;
                    }
                    break;

                case PersonType.Coach:
                    CoachTimetable coachTimetable = new CoachTimetable((DayOfWeek)dayCbox.SelectedIndex, fromTime, toTime, (byte)tennisCourtNumUpDown.Value, studentNameList, lessonType);
                    RaiseSaveCoachTimetableEvent(coachTimetable);
                    break;
                }

                this.Close();
            }
        }
 /// <summary>
 /// Fills the information of the form.
 /// Specifically designed for the Student.
 /// </summary>
 /// <param name="studentTimetable"></param>
 private void FillStudentInformation(StudentTimetable studentTimetable)
 {
     FillInformation(studentTimetable);
     coachNameSurnameTbox.Text = studentTimetable.CoachName;
 }