Beispiel #1
0
        static void MakeChoice(ref Laboratory laboratory)
        {
            int  choice    = int.Parse(Console.ReadLine());
            bool isCorrect = false;

            if (CurrentUser == null)
            {
                switch (choice)
                {
                case 1:
                    isCorrect   = true;
                    CurrentUser = Login(ref laboratory);
                    break;

                case 0:
                    isCorrect = true;
                    Environment.Exit(0);
                    break;

                default:
                    if (!isCorrect)
                    {
                        Console.WriteLine("Некорректный ввод! \nНажмите любую клавишу и попробуйте снова.");
                        Console.ReadKey();
                    }
                    break;
                }
            }
            else
            {
                switch (choice)
                {
                case 1:
                    isCorrect = true;
                    Console.Clear();
                    CurrentUser.Print();
                    Console.ReadKey();
                    break;

                case 2:
                    isCorrect = true;
                    laboratory.PrintInfoAboutLaboratory();
                    break;

                case 3:
                    isCorrect = true;
                    Console.Clear();
                    if (CurrentUser.CurrentPermissions == Person.Permissions.student)
                    {
                        Console.WriteLine("Простите, у Вас нет зарплаты");
                    }
                    else
                    {
                        Console.WriteLine("Ваша зарплата {0} руб.", CurrentUser.GetSalary());
                    }
                    Console.ReadKey();
                    break;

                case 0:
                    isCorrect = true;
                    Logout();
                    break;

                default:
                    if (CurrentUser.CurrentPermissions == Person.Permissions.teacher)
                    {
                        switch (choice)
                        {
                        case 4:
                            isCorrect = true;
                            AddGrade(ref laboratory);
                            break;
                        }
                    }
                    else if (CurrentUser.CurrentPermissions == Person.Permissions.manager || CurrentUser.CurrentPermissions == Person.Permissions.admin)
                    {
                        switch (choice)
                        {
                        case 4:
                            isCorrect = true;
                            AddTeacher(ref laboratory);
                            break;

                        case 5:
                            isCorrect = true;
                            DeleteTeacher(ref laboratory);
                            break;

                        case 6:
                            isCorrect = true;
                            AddStudent(ref laboratory);
                            break;

                        case 7:
                            isCorrect = true;
                            DeleteStudent(ref laboratory);
                            break;

                        default:
                            if (CurrentUser.CurrentPermissions == Person.Permissions.admin)
                            {
                                switch (choice)
                                {
                                case 8:
                                    isCorrect = true;
                                    AddManager(ref laboratory);
                                    break;

                                case 9:
                                    isCorrect = true;
                                    DeleteManager(ref laboratory);
                                    break;

                                default:
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    if (!isCorrect)
                    {
                        Console.WriteLine("Некорректный ввод! \nНажмите любую клавишу и попробуйте снова.");
                        Console.ReadKey();
                    }
                    break;
                }
            }
        }