예제 #1
0
        //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();
        }
예제 #2
0
        //method to input variables to put into AddTeacher method

        private void TeacherInput()
        {
            generalMethod.Header();

            string fname, lname, phone, email, subject, salarystring;
            double salary;

            //taking info to put in constructor for employee class

            fname = generalMethod.EmptyEntryPreventer("Please input employee's first name").ToUpper();


            lname = generalMethod.EmptyEntryPreventer("Please input employee's last name").ToUpper();

            phone = generalMethod.EmptyEntryPreventer("Please input employee's phone number");

            email = generalMethod.EmptyEntryPreventer("Please input employee's email address");

            if (generalMethod.IsValidEmail(email))
            {
salaryredo:
                salarystring = generalMethod.EmptyEntryPreventer("What is the employee's salary?");


                try
                {
                    salary = double.Parse(salarystring);
                }
                catch
                {
                    Console.WriteLine("Invalid input: Input should be in numeric form\n");
                    goto salaryredo;
                }

                Console.WriteLine("What subject does the employee teach?\n1: Maths.\n2: Science.\n3: English.\n");
                int choice;
subjredo:
                try
                {
                    choice = int.Parse(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Invalid input. Please reenter the number of the subject taught.");
                    goto subjredo;
                }

                switch (choice)
                {
                case 1: subject = "MATHS";
                    break;

                case 2: subject = "SCIENCE";
                    break;

                case 3: subject = "ENGLISH";
                    break;

                default: Console.WriteLine("Invalid input. Please reenter the number of the subject taught.");
                    goto subjredo;
                }



                //using below method to construct student class

                AddTeacher(fname, lname, phone, email, salary, subject);

                Console.WriteLine("\nSaved to list.\n");

                generalMethod.AnyKey();

                TeacherMenu();
            }
        }