private void addButton_Click(object sender, EventArgs e) { if (nameSurnameTbox.Text != string.Empty && !nameSurnameTbox.Text.StartsWith(" ") && !nameSurnameTbox.Text.Any(char.IsDigit)) { studentListBox.Items.Add(InputInformation.CorrectInputFormat(nameSurnameTbox.Text)); nameSurnameTbox.Text = string.Empty; } else { nameSurnameTbox.Text = string.Empty; } ChangeStudentPanelSetting(); }
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(); } }