예제 #1
0
        public static void SortAndShowEmployees()
        {
            int ourInput;

            WriteLine("Выберите один из вариантов : ");
            WriteLine("\t1. По возростанию");
            WriteLine("\t2. По убыванию");
            Write("\tВвод : ");

            ourInput = MainActions.GetCorrectPositiveInt(1, 2);

            switch (ourInput)
            {
            case 1:
            {
                ListOfEmployees.SortByWorkExperience(TypeOfSort.Increase);
            }
            break;

            case 2:
            {
                ListOfEmployees.SortByWorkExperience(TypeOfSort.Decrease);
            }
            break;
            }
        }
예제 #2
0
        // Using delegate.
        public static void AddEmployee()
        {
            Employee ourEmployee;
            int      choice;

            WriteLine("\tВыберите один из возможных вариантов : ");
            WriteLine("\t1. Преподаватель");
            WriteLine("\t2. Администрация");
            WriteLine("\t3. Другое");

            Write("\tВвод : ");
            choice = MainActions.GetCorrectPositiveInt(1, 3);

            switch (choice)
            {
            case 1:
            {
                ourEmployee = new Teacher();
                Set ourSet = ourEmployee.SetInfo;
                ourSet?.Invoke();

                ListOfEmployees.Add(ourEmployee);
            }
            break;

            case 2:
            {
                ourEmployee = new Administration();
                Set ourSet = ourEmployee.SetInfo;
                ourSet?.Invoke();

                ListOfEmployees.Add(ourEmployee);
            }
            break;

            case 3:
            {
                ourEmployee = new OtherEmployees();
                Set ourSet = ourEmployee.SetInfo;
                ourSet?.Invoke();
                ListOfEmployees.Add(ourEmployee);
            }
            break;
            }
        }
예제 #3
0
        public static void RemoveEmployee()
        {
            bool flag = false;
            int  ourInputID;

            Write("Введите ID сотрудника : ");
            ourInputID = MainActions.GetCorrectPositiveInt();

            foreach (Employee ourEmployee in ListOfEmployees.Journal.ToArray()) //that's possible if List -> Array ... but for my new class it isn't necc
            {
                if (ourInputID == ourEmployee.PersonID)
                {
                    ListOfEmployees.Remove(ourEmployee);
                    flag = true;
                }
            }

            MainActions.NoExistMassege(flag, TypeOfEntity.Employee, AmountOfEntities.One);
        }
예제 #4
0
파일: MainClass.cs 프로젝트: Miuroku/LabsCS
        static void Main(string[] args)
        {
            WriteLine("\t\t--------------BSUIR Students, employees and book List --------------");

            while (true)
            {
                int mainChoice;

GotoMainMenu:
                Clear();
                WriteLine("Menu:");
                WriteLine("1. Списки студентов");
                WriteLine("2. Списки сотрудников");
                WriteLine("3. Библиотека");
                WriteLine("4. Научные обьединения");
                WriteLine("5. Выход.");

                Write("\nВыберите пункт: ");
                mainChoice = MainActions.GetCorrectPositiveInt(1, 5);
                // Clear console.
                Clear();

                switch (mainChoice)
                {
                case 1:
                {
                    ListOfStudents listOfStudents = new ListOfStudents();

                    while (true)
                    {
                        int firstChoice;

                        WriteLine("Students Menu:");
                        WriteLine("1. Добавить студента");
                        WriteLine("2. Удалить студента");
                        WriteLine("3. Показать список студентов");
                        WriteLine("4. Найти студента по ID");
                        WriteLine("5. Вывести всех студентов с учетом успеваемости");
                        WriteLine("6. Вернуться в главное меню");
                        WriteLine("7. Выход.");

                        Write("\nВыберите пункт: ");
                        firstChoice = MainActions.GetCorrectPositiveInt(1, 7);

                        Write("\n");

                        switch (firstChoice)
                        {
                        case 1:
                        {
                            SwitchCaseActions.AddStudent();
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveStudent();
                        }
                        break;

                        case 3:
                        {
                            int ourChoice3;

                            WriteLine("\tВыберите один из пунктов: ");
                            WriteLine("\t1. Показать всех студентов в университете");
                            WriteLine("\t2. Показать всех студентов факультета");
                            WriteLine("\t3. Показать всех студентов специальности");
                            WriteLine("\t4. Показать всех студентов группы");

                            Write("\tВвод : ");
                            ourChoice3 = MainActions.GetCorrectPositiveInt(1, 4);

                            switch (ourChoice3)
                            {
                            case 1:
                            {
                                ListOfStudents.ShowAll();
                            }
                            break;

                            case 2:
                            {
                                ListOfStudents.ShowAll(UniversityElements.Faculty);
                            }
                            break;

                            case 3:
                            {
                                ListOfStudents.ShowAll(UniversityElements.Specialty);
                            }
                            break;

                            case 4:
                            {
                                ListOfStudents.ShowAll(UniversityElements.Group);
                            }
                            break;
                            }
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.FindStudentByID();
                        }
                        break;

                        case 5:
                        {
                            // Increase or Decrease.
                            SwitchCaseActions.SortAndShowStudents();
                        }
                        break;

                        case 6:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 7:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 2:
                {
                    while (true)
                    {
                        int secondChoice;

                        WriteLine("Employees Menu:");
                        WriteLine("1. Добавить сотрудника");
                        WriteLine("2. Удалить сотрудника");
                        WriteLine("3. Показать список сотрудников");
                        WriteLine("4. Найти сотрудника по ID");
                        WriteLine("5. Вывести всех сотрудников с учетом стажа работы");
                        WriteLine("6. Вернуться в главное меню");
                        WriteLine("7. Выход.");

                        Write("\nВыберите пункт: ");
                        secondChoice = MainActions.GetCorrectPositiveInt(1, 7);

                        switch (secondChoice)
                        {
                        case 1:
                        {
                            SwitchCaseActions.AddEmployee();
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveEmployee();
                        }
                        break;

                        case 3:
                        {
                            ListOfEmployees.ShowAll();
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.FindEmployeeByID();
                        }
                        break;

                        case 5:
                        {
                            // Increase or Decrease.
                            SwitchCaseActions.SortAndShowEmployees();
                        }
                        break;

                        case 6:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 7:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 3:
                {
                    List <Book> listOfBooks = new List <Book>();

                    while (true)
                    {
                        int thirdChoice;

                        WriteLine("Libruary Menu : ");
                        WriteLine("1. Добавить книгу");
                        WriteLine("2. Удалить книгу");
                        WriteLine("3. Показать все книги");
                        WriteLine("4. Показать информацию о книге");
                        WriteLine("5. В главное меню");
                        WriteLine("6. Выход.");

                        Write("Ввод : ");
                        thirdChoice = MainActions.GetCorrectPositiveInt(1, 6);

                        switch (thirdChoice)
                        {
                        case 1:
                        {
                            SwitchCaseActions.AddBook(listOfBooks);
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveBook(listOfBooks);
                        }
                        break;

                        case 3:
                        {
                            SwitchCaseActions.ShowAllBooks(listOfBooks);
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.ShowBookInfo(listOfBooks);
                        }
                        break;

                        case 5:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 6:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 4:
                {
                    while (true)
                    {
                        int fourthChoice;

                        WriteLine("Association Menu : ");
                        WriteLine("1. Добавить обьединнение");
                        WriteLine("2. Удалить обьединение");
                        WriteLine("3. Вывести все обьединения");
                        WriteLine("4. Вывести участников обьединения ");
                        WriteLine("5. Вернуться в главное меню");
                        WriteLine("6. Выход.");

                        Write("\nВыберите пункт: ");

                        fourthChoice = MainActions.GetCorrectPositiveInt(1, 6);

                        switch (fourthChoice)
                        {
                        case 1:
                        {
                            SwitchCaseActions.AddAssocation();
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveAssociation();
                        }
                        break;

                        case 3:
                        {
                            ListOfAssociations.ShowAll();
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.ShowAssociationParticipants();
                        }
                        break;

                        case 5:
                        {
                            goto GotoMainMenu;
                        }
                        break;

                        case 6:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 5:
                {
                    Environment.Exit(0);
                }
                break;
                }
            }
        }
예제 #5
0
파일: MainClass.cs 프로젝트: Miuroku/LabsCS
        static void Main(string[] args)
        {
            WriteLine("\t\t--------------BSUIR Students, employees and book List --------------");


            while (true)
            {
                int mainChoice;

GotoMainMenu:
                WriteLine("Menu:");
                WriteLine("1. Списки студентов");
                WriteLine("2. Списки сотрудников");
                WriteLine("3. Библиотека");
                WriteLine("4. Выход.");

                Write("\nВыберите пункт: ");
                mainChoice = MainActions.GetCorrectPositiveInt(1, 4);

                switch (mainChoice)
                {
                case 1:
                {
                    ListOfStudents listOfStudents = new ListOfStudents();

                    while (true)
                    {
                        int firstChoice;

                        WriteLine("Students Menu:");
                        WriteLine("1. Добавить студента");
                        WriteLine("2. Удалить студента");
                        WriteLine("3. Показать список студентов");
                        WriteLine("4. Найти студента по ID");
                        WriteLine("5. Вывести всех студентов с учетом успеваемости");
                        WriteLine("6. Вернуться в главное меню");
                        WriteLine("7. Выход.");

                        Write("\nВыберите пункт: ");
                        firstChoice = MainActions.GetCorrectPositiveInt(1, 7);

                        Write("\n");

                        switch (firstChoice)
                        {
                        case 1:
                        {
                            Student addedStudent = new Student();

                            addedStudent.SetInfo();

                            ListOfStudents.Add(addedStudent);
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveStudent();
                        }
                        break;

                        case 3:
                        {
                            int ourChoice3;

                            WriteLine("\tВыберите один из пунктов: ");
                            WriteLine("\t1. Показать всех студентов в университете");
                            WriteLine("\t2. Показать всех студентов факультета");
                            WriteLine("\t3. Показать всех студентов специальности");
                            WriteLine("\t4. Показать всех студентов группы");

                            Write("\tВвод : ");
                            ourChoice3 = MainActions.GetCorrectPositiveInt(1, 4);                 // in range from 1 to 4

                            switch (ourChoice3)
                            {
                            case 1:
                            {
                                ListOfStudents.ShowAll();
                            }
                            break;

                            case 2:
                            {
                                bool   flag = false;
                                string ourFaculty;
                                int    ourFacultyNumber;

                                ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber);

                                WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)");

                                foreach (Student ourStudent in ListOfStudents.journal.ToArray())
                                {
                                    if (ourStudent.Faculty == ourFaculty)
                                    {
                                        MainActions.ShowStudentInfo(ourStudent);
                                        flag = true;
                                    }
                                }

                                MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several);
                            }
                            break;

                            case 3:
                            {
                                bool   flag = false;
                                string ourFaculty;
                                int    ourFacultyNumber;
                                string ourSpecialty;

                                ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber);

                                ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber);

                                WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)");

                                foreach (Student ourStudent in ListOfStudents.journal.ToArray())
                                {
                                    if (ourStudent.Specialty == ourSpecialty)
                                    {
                                        MainActions.ShowStudentInfo(ourStudent);
                                        flag = true;
                                    }
                                }

                                MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several);
                            }
                            break;

                            case 4:
                            {
                                bool   flag = false;
                                string ourFaculty;
                                int    ourFacultyNumber;
                                string ourSpecialty;
                                string ourGroup;
                                int    ourYear;

                                ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber);

                                ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber);

                                ourYear = MainActions.ChoosenYear();

                                ourGroup = MainActions.ChoosenGroup();

                                WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)");

                                foreach (Student ourStudent in ListOfStudents.journal.ToArray())
                                {
                                    if (ourStudent.Group == ourGroup && ourStudent.Year == ourYear && ourStudent.Specialty == ourSpecialty)
                                    {
                                        MainActions.ShowStudentInfo(ourStudent);
                                        flag = true;
                                    }
                                }

                                MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several);
                            }
                            break;
                            }
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.FindStudentByID();
                        }
                        break;

                        case 5:
                        {
                            ListOfStudents.SortByProgress();
                            ListOfStudents.ShowAll();

                            if (ListOfStudents.ActualNumberOfStudents == 0)
                            {
                                WriteLine("( There is no any students )");
                            }
                        }
                        break;

                        case 6:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 7:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 2:
                {
                    while (true)
                    {
                        int secondChoice;

                        WriteLine("Employees Menu:");
                        WriteLine("1. Добавить сотрудника");
                        WriteLine("2. Удалить сотрудника");
                        WriteLine("3. Показать список сотрудников");
                        WriteLine("4. Найти сотрудника по ID");
                        WriteLine("5. Вывести всех сотрудников с учетом стажа работы");
                        WriteLine("6. Вернуться в главное меню");
                        WriteLine("7. Выход.");

                        Write("\nВыберите пункт: ");
                        secondChoice = MainActions.GetCorrectPositiveInt(1, 7);

                        switch (secondChoice)
                        {
                        case 1:
                        {
                            SwitchCaseActions.AddEmployee();
                        }
                        break;

                        case 2:
                        {
                            SwitchCaseActions.RemoveEmployee();
                        }
                        break;

                        case 3:
                        {
                            ListOfEmployees.ShowAll();
                        }
                        break;

                        case 4:
                        {
                            SwitchCaseActions.FindEmployeeByID();
                        }
                        break;

                        case 5:
                        {
                            ListOfEmployees.SortByWorkExperience();
                            ListOfEmployees.ShowAll();
                        }
                        break;

                        case 6:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 7:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

                case 3:
                {
                    List <Book> listOfBooks = new List <Book>();

                    while (true)
                    {
                        int thirdChoice;

                        WriteLine("Libruary Menu : ");
                        WriteLine("1. Добавить книгу");
                        WriteLine("2. Удалить книгу");
                        WriteLine("3. Показать все книги");
                        WriteLine("4. В главное меню");
                        WriteLine("5. Выход.");

                        Write("Ввод : ");
                        thirdChoice = MainActions.GetCorrectPositiveInt(1, 5);

                        switch (thirdChoice)
                        {
                        case 1:
                        {
                            Book newBook = new Book(listOfBooks.Count);

                            newBook.SetInfo();

                            listOfBooks.Add(newBook);
                        }
                        break;

                        case 2:
                        {
                            Write("Введите ID книги : ");
                            int ourBookID = MainActions.GetCorrectPositiveInt();

                            bool flag = false;

                            foreach (Book ourBook in listOfBooks.ToArray())
                            {
                                if (ourBook.BookID == ourBookID)
                                {
                                    listOfBooks.Remove(ourBook);
                                    flag = true;
                                }
                            }

                            if (flag == false)
                            {
                                WriteLine("( There's no such book )");
                            }
                        }
                        break;

                        case 3:
                        {
                            bool flag = false;

                            WriteLine("( ID, title, year, price )");
                            foreach (Book ourBook in listOfBooks.ToArray())
                            {
                                ourBook.ShowInfo();
                                flag = true;
                            }

                            if (flag == false)
                            {
                                WriteLine("( There's no any book )");
                            }
                        }
                        break;

                        case 4:
                        {
                            goto GotoMainMenu;
                        }
                        //break;

                        case 5:
                        {
                            Environment.Exit(0);
                        }
                        break;
                        }
                    }
                }
                break;

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