} // R public void AddClass() { // Grade { if (GradeComboBox.SelectedItem != null) { string SelectedGrade = GradeComboBox.SelectedItem.ToString(); teacherController.SetCurrentClassGrade(SelectedGrade); } else { MessageBox.Show("No grade selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Letter { if (Letter.Length <= 2 && Letter.Length >= 1) { if (Letter.Length == 1 && Letter[0] >= 'A' && Letter[0] <= 'Z') { teacherController.SetCurrentClassLetter(Letter); if (teacherController.CheckIfClassAlreadyExists()) { MessageBox.Show("Class already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { if (Letter.Length == 2 && Letter[0] >= 'A' && Letter[0] <= 'Z' && Letter[1] >= 'A' && Letter[1] <= 'Z') { teacherController.SetCurrentClassLetter(Letter); if (teacherController.CheckIfClassAlreadyExists()) { MessageBox.Show("Class already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Invalid Letter Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } else { MessageBox.Show("Invalid Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // HeadTeacher { if (NonHeadTeacherComboBox.SelectedItem != null) { string testString = NonHeadTeacherComboBox.SelectedItem.ToString(); teacherController.SetCurrentClassTeacherId(testString); } else { MessageBox.Show("No head teacher selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } teacherController.CommitChangedCurrentClassed(); MessageBox.Show("Success!", "Operation Completed", MessageBoxButtons.OK); // Load default values for gradeComboBox, letterTextBox and nonHeadTeacherComboBox { GradeComboBox.SelectedItem = null; Letter = "AA"; NonHeadTeacherComboBox.Items.Clear(); List <string> nonHeadTeachers = teacherController.NonHeadTeachers(); nonHeadTeachers.ForEach(w => nonHeadTeacherComboBox.Items.Add(w)); NonHeadTeacherComboBox.Text = String.Empty; } } // R