コード例 #1
0
        public static void mainMenu()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("This is the Marina Berth Booking System, input the number of your preferred option:" + Environment.NewLine);
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("1) Record a new booking");
            Console.WriteLine("2) Delete a record");
            Console.WriteLine("3) Display all records and availability");
            Console.WriteLine("4) Exit" + Environment.NewLine);

            bool repeat = false;

            do
            {
                string inputUser;
                int    option;
                inputUser = Console.ReadLine();
                int.TryParse(inputUser, out option);


                switch (option)
                {
                case 1:
                    Console.Clear();
                    NewRecords.recordValidation();
                    break;

                case 2:
                    Console.Clear();
                    DeleteRecords.DeletingMenu();
                    break;

                case 3:
                    Console.Clear();
                    DisplayRecords.DisRec();
                    break;

                case 4:
                    Environment.Exit(0);
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Input a valid option number" + Environment.NewLine);
                    Console.ForegroundColor = ConsoleColor.White;
                    repeat = true;
                    break;
                }
            } while (repeat == true);

            Console.ReadLine();
        }
コード例 #2
0
        public static void finalDelCheck(int number, RecordList list)          // the user is asked to confirm the deleting
        {
            bool repeat = false;

            do
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Are you sure to delete record number " + number + " ? Typet Y to confirm or N to go back to the main menu.");
                Console.ForegroundColor = ConsoleColor.White;
                string inputDecision = Console.ReadLine();
                //converting every input to low case to avoid errors due to input format
                string lowDecision = inputDecision.ToLower(new CultureInfo("en-US", false));
                char   decision    = lowDecision[0];

                switch (decision)
                {
                case 'n':
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("No record has been deleted. Press enter to go back to the main menu. Thank you");
                    MarinaTools.goBackMainMenu();
                    break;

                case 'y':

                    DeleteRecords.deleteRecord(number, list);

                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("You did not insert a valid option. Try again");
                    Console.ForegroundColor = ConsoleColor.White;
                    repeat = true;
                    break;
                }
            }while (repeat == true);
        }