//method to input variables before being adds to the student list using AddStudent() private void StudentInput() { int id = IdGenerator(); Console.Clear(); Console.WriteLine("********************Welcome to DBS Management Software********************\n\n"); string fname, lname, phone, email, status = ""; //taking info to put in constructor for student class fname = generalMethod.EmptyEntryPreventer("Please input student's first name").ToUpper(); lname = generalMethod.EmptyEntryPreventer("Please input student's last name").ToUpper(); phone = generalMethod.EmptyEntryPreventer("Please input student's phone number"); emailreenter: Console.WriteLine("Please input student's email address"); email = Console.ReadLine(); if (generalMethod.IsValidEmail(email)) { Console.WriteLine("Is the student enrolling to a undergraduate or postgraduate course?"); if (generalMethod.YesNo("Undergraduate", "Postgraduate")) { status = "UNDER"; } else { status = "POST"; } Console.WriteLine("Student ID generated is {0}", id); } else { Console.WriteLine("\nInvalid email entered\n"); goto emailreenter; } //using below method to construct student class AddStudent(fname, lname, phone, email, id, status); Console.WriteLine("Student added to list."); generalMethod.AnyKey(); // return to student menu upon completion StudentMenu(); }
// search teachers by first name private void SearchFname() { generalMethod.Header(); bool foundmatch = false; string fname; Console.WriteLine("Search Teacher Name"); fname = Console.ReadLine().ToUpper(); Console.WriteLine("Matches:"); Console.WriteLine("*******************************************\n"); foreach (Teacher t in teacherList) { if (t.Fname == fname) { Console.WriteLine(t.ToString()); foundmatch = true; Console.WriteLine("\n\n\n\nDo you wish to delete this teacher from the list?"); if (generalMethod.YesNo("Yes", "No")) { teacherList.Remove(t); Console.WriteLine("\n\nTeacher Deleted"); break; } } } if (!foundmatch) { Console.WriteLine("No Teacher matching that first name"); } generalMethod.AnyKey(); TeacherMenu(); }
private void StudentInput() { int id = IdGenerator(); Console.Clear(); Console.WriteLine("********************Welcome to DBS Management Software********************\n\n"); string fname, lname, phone, email, status = ""; //taking info to put in constructor for student class Console.WriteLine("Please input student's first name"); fname = Console.ReadLine().ToUpper(); Console.WriteLine("Please input student's last name"); lname = Console.ReadLine().ToUpper(); Console.WriteLine("Please input student's phone number"); phone = Console.ReadLine(); Console.WriteLine("Please input student's email address"); email = Console.ReadLine().ToUpper(); Console.WriteLine("Is the student enrolling to a undergraduate or postgraduate course?"); if (gm.YesNo("Undergraduate", "Postgraduate")) { status = "UNDER"; } else { status = "POST"; } Console.WriteLine("Student ID generated is {0}", id); //using below method to construct student class AddStudent(fname, lname, phone, email, id, status); gm.AnyKey(); StudentMenu(); }
static void Main(string[] args) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; //instantiate classes that contain the methods used in the main class GeneralMethods generalMethod = new GeneralMethods(); StudentMethods studentMethod = new StudentMethods(); TeacherMethods teacherMethod = new TeacherMethods(); // variable choice to determine main switch menu int choice = 1; // variable bool access to determine if login password has been correct or not bool access; //Header method to give appearance generalMethod.Header(); //Option to choose to login or exit; if (generalMethod.YesNo("Login", "Exit")) { choice = 1; } else { choice = 0; } while (choice == 1) { //assigning bool value to the returned value of the login method access = generalMethod.Login(); if (access == true) { //Populate lists with example items for demonstrative purposes studentMethod.PopulateStudentList(); teacherMethod.PopulateTeacherList(); Console.WriteLine("Lists have been populated with example entries"); //Method for any key to continue generalMethod.AnyKey(); while (choice != 0) { menu: Console.WriteLine("********************Welcome to DBS Management Software********************\n\n"); Console.WriteLine("Please select choice\n\n*********************\n1: Student Options.\n2: Teacher Options\n3: Compare Teachers to Students\n0: Exit."); //user inputs choice to select menu option. try catch to ensure input is int format, if 0 is entered the program will complete and close try { choice = int.Parse(Console.ReadLine()); } catch { Console.WriteLine("\nInvalid input\n"); generalMethod.AnyKey(); goto menu; } // switch statement to call different menu methods in different classes or to exit switch (choice) { case 1: studentMethod.StudentMenu(); break; case 2: teacherMethod.TeacherMenu(); break; case 3: generalMethod.Comparison(); break; case 0: break; default: Console.WriteLine("\nInvalid input\n"); generalMethod.AnyKey(); goto menu; } } } //if login method returns false (invalid login) then this else statement will run else { Console.WriteLine("********************Welcome to DBS Management Software********************\n\n"); Console.WriteLine("Do you wish to try login again?\n"); if (generalMethod.YesNo("Yes", "No")) { choice = 1; } else { choice = 0; } Console.Clear(); } } }