コード例 #1
0
        //Student Methods----------------------------------------------------------------------------------------------------------

        //Student menu method, a public method called in teh main class, this switch statements calls methods in this class

        public void StudentMenu()
        {
            int select = 1;

start:
            generalMethod.Header();
            Console.WriteLine("Please select choice\n\n*********************\n1: Add student.\n2: Display Student.\n3: Search By Student ID.\n4: Save list to .csv file.\n5: Import a .csv file to list.\n0: Return to Main Menu.");

            try
            {
                select = int.Parse(Console.ReadLine());
            }
            catch
            {
                Console.WriteLine("Invalid input");
                generalMethod.AnyKey();
                goto start;
            }

            {
                switch (select)
                {
                case 1: StudentInput();
                    break;

                case 2: DisplayListReturn();
                    break;

                case 3: SearchId();
                    break;

                case 4: SaveToCsv();
                    break;

                case 5: ReadFromText();
                    break;

                case 0: break;
                }
            }
            Console.Clear();
        }
コード例 #2
0
        //teacher menu method called in main class which uses switch statement to call various methods in this class

        public void TeacherMenu()
        {
            int choice;

            generalMethod.Header();

            Console.WriteLine("Please select choice\n\n*********************\n1: Add Teacher To List.\n2: Display Working List Of Teachers.\n3: Search List By Teacher First Name.\n4: Save Working Teacher List To .csv File\n5: Import List From Existing .csv File\n0: Exit.");

            choice = int.Parse(Console.ReadLine());
            switch (choice)
            {
            case 1: TeacherInput();
                break;

            case 2: DisplayListReturn();
                break;

            case 3: SearchFname();
                break;

            case 4: SaveToCsv();
                break;

            case 5: ReadFromText();
                break;

            case 6: Console.WriteLine("hello");
                foreach (Teacher tit in GetTeacherList())
                {
                    Console.WriteLine(tit.ToString());
                }
                generalMethod.AnyKey();
                break;

            case 0: break;
            }
            Console.Clear();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
                }
            }
        }