Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace C_Sharp_Junior
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isExit = true;
- List<string> fullNames = new List<string> { "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
- List<string> positionsEmployee = new List<string> { "Специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
- while (isExit == true)
- {
- Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск по фамилии\n5 - выход");
- Console.Write("Введите команду: ");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- PreparingDossier(ref fullNames, ref positionsEmployee);
- break;
- case "2":
- ShowDossier(fullNames, positionsEmployee);
- break;
- case "3":
- SelectingDossierDelete(ref fullNames, ref positionsEmployee);
- break;
- case "4":
- SearchDossier(fullNames, positionsEmployee);
- break;
- case "5":
- isExit = false;
- break;
- }
- Console.Write("Нажмите Enter чтобы вернуться в меню.");
- Console.ReadLine();
- }
- Environment.Exit(50);
- }
- static void PreparingDossier(ref List<string> fullName, ref List<string> positionEmployee)
- {
- Console.Write("Введите фамилию: ");
- string userInputSurname = Console.ReadLine();
- Console.Write("Введите имя: ");
- string userInputName = Console.ReadLine();
- Console.Write("Введите отчество: ");
- string userInputPatronymic = Console.ReadLine();
- string userInputFullName = userInputSurname + " " + userInputName + " " + userInputPatronymic;
- AddDossier(ref fullName, userInputFullName);
- Console.Write("Введите должность: ");
- string userInputPost = Console.ReadLine();
- AddDossier(ref positionEmployee, userInputPost);
- Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
- }
- static void AddDossier(ref List<string> array, string userInput)
- {
- array.Add(userInput);
- }
- static void ShowDossier(List<string> fullName, List<string> post)
- {
- for (int i = 0; i < fullName.Count; i++)
- {
- Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
- }
- }
- static void SelectingDossierDelete(ref List<string> fullNames, ref List<string> positionsEmployee)
- {
- Console.Write("Введите номер досье: ");
- int index = Convert.ToInt32(Console.ReadLine()) - 1;
- DeleteDossier(fullNames, index);
- DeleteDossier(positionsEmployee, index);
- Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
- }
- static void DeleteDossier(List<string> array, int index)
- {
- if (index >= 0 && index <= array.Count - 1)
- {
- array.RemoveAt(index);
- }
- else
- {
- Console.WriteLine("Досье с таким номером нет.");
- }
- }
- static void SearchDossier(List<string> fullName, List<string> post)
- {
- bool employeeFound = false;
- Console.Write("Введите ФИО сотрудника через пробел: ");
- string userInputFullName = Console.ReadLine();
- for (int i = 0; i < fullName.Count; i++)
- {
- if (userInputFullName.ToLower() == fullName[i].ToLower())
- {
- Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
- employeeFound = true;
- break;
- }
- }
- if (employeeFound == false)
- {
- Console.WriteLine("Сотрудника с такой ФИО нету.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement