private void ManageClass() { bool validDecision = false; int decision = 0; while (!validDecision) { Console.Clear(); Console.WriteLine("\t\t* You are working on class management *"); Console.WriteLine("\t\t* 1. Add class *"); Console.WriteLine("\t\t* 2. Modify class *"); Console.WriteLine("\t\t* 3. Display classes *"); Console.WriteLine("\t\t* 4. Back to main menu *"); Console.WriteLine("\t\t***************************************"); Console.Write("Enter an option(1-4): "); try { decision = int.Parse(Console.ReadLine()); } catch (Exception) { decision = 0; } if (decision >= 1 && decision <= 4) { validDecision = true; } Console.WriteLine(); switch (decision) { case 1: classManagementView.AddClass(); ManageClass(); break; case 2: classManagementView.EditClass(); ManageClass(); break; case 3: classManagementView.DisplayClasses(); Console.Write("[Enter] to continue..."); Console.ReadLine(); ManageClass(); break; case 4: decision = 4; Console.WriteLine("You select backing to main management selection"); ProcessManagementSelection(); break; } } }
internal void WithdrawStudent() { //ConsoleKeyInfo keypress; if (studentController.StudentCount() == 0) { Console.WriteLine("Student list is empty. Please add some student first!"); Console.WriteLine("[Enter] to continue..."); Console.ReadLine(); } else if (classController.ClassesCount() == 0) { Console.WriteLine("Please come back and add class first!"); Console.WriteLine("[Enter] to continue..."); Console.ReadLine(); } else { DisplayStudent(); Console.Write("Enter only one student id as shown above to make change for that student: "); string studentIdChange = Console.ReadLine(); while (studentController.SearchStudent(studentIdChange) == null) { Console.Write("Not found student! Enter student id again: "); studentIdChange = Console.ReadLine(); //found = controller.FindStudent(studentIdChange); } Student student = studentController.SearchStudent(studentIdChange); List <Class> studentClassList = student.GetMyClasses(); if (studentClassList.Count > 0) { for (int i = 0; i < studentClassList.Count; i++) { Console.WriteLine("Class name: {0}", studentClassList[i].ToString()); Class myEnrolClass = studentClassList[i]; bool validDecision = false; while (!validDecision) { Console.WriteLine("\t\t* 1. Edit class"); Console.WriteLine("\t\t* 2. Delete class"); Console.Write("Enter an option(1-2): "); int decision = 0; try { decision = System.Int32.Parse(Console.ReadLine()); } catch (Exception) { decision = 0; } if (decision >= 1 && decision <= 2) { validDecision = true; } Console.WriteLine(); switch (decision) { case 1: ClassManagementView cmv = new ClassManagementView(classController, courseController, lecturerController, roomController); cmv.DisplayClasses(); Console.Write("Enter an above class name to enrol it: "); string classname = Console.ReadLine(); while (classController.SearchClass(classname) == null) { Console.Write("Not found class! Try again: "); classname = Console.ReadLine(); } Class foundClass = classController.SearchClass(classname); while (studentController.CheckClashTime(foundClass, student, classController)) { Console.WriteLine("You selected a class that has clashed with other classes."); Console.Write("Enter class name again: "); classname = Console.ReadLine(); while (classController.SearchClass(classname) == null) { Console.Write("Not found class! Try again: "); classname = Console.ReadLine(); } foundClass = classController.SearchClass(classname); } myEnrolClass.WithDrawStudent(student); student.RemoveClass(myEnrolClass); if (studentController.EnrolClass(foundClass, student, classController)) { Console.WriteLine("You are enrolled that class."); } else { myEnrolClass.EnrolStudent(student); student.AddClass(myEnrolClass); Console.WriteLine("You could not enrol to that class."); } break; case 2: myEnrolClass.WithDrawStudent(student); student.RemoveClass(myEnrolClass); Console.WriteLine("You are withdrawn from that class."); break; } } } } else { Console.WriteLine("There are no enrolment records for \"{0}\" student", student.Id); } } }