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 = false;
- List<string> fullNames = new List<string> { "Гришин Аверьян Вячеславович", "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
- List<string> positionsEmployee = new List<string> { "Специалист", "Старшый специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
- while (isExit == false)
- {
- Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск досье\n5 - выход");
- Console.Write("Введите команду: ");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- PreparingDossier(fullNames, positionsEmployee);
- break;
- case "2":
- ShowDossier(fullNames, positionsEmployee);
- break;
- case "3":
- SelectingDossierDelete(fullNames, positionsEmployee);
- break;
- case "4":
- SearchDossier(fullNames, positionsEmployee);
- break;
- case "5":
- isExit = true;
- break;
- }
- Console.Write("Нажмите Enter чтобы вернуться в меню.");
- Console.ReadLine();
- }
- }
- static void PreparingDossier(List<string> fullName, 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(fullName, userInputFullName);
- Console.Write("Введите должность: ");
- string userInputPost = Console.ReadLine();
- AddDossier(positionEmployee, userInputPost);
- Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
- }
- static void AddDossier(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(List<string> fullNames, List<string> positionsEmployee)
- {
- Console.Write("Введите номер досье: ");
- bool isNumber = int.TryParse(Console.ReadLine(), out int number);
- int index = number - 1;
- if (isNumber == true && index >= 0 && index < fullNames.Count)
- {
- DeleteDossier(fullNames, index);
- DeleteDossier(positionsEmployee, index);
- Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
- }
- else
- {
- Console.WriteLine("Досье с таким номером нет.");
- }
- }
- static void DeleteDossier(List<string> array, int index)
- {
- array.RemoveAt(index);
- }
- static void SearchDossier(List<string> fullName, List<string> post)
- {
- Console.Write("Введите № досье сотрудника: ");
- bool isNumber = int.TryParse(Console.ReadLine(), out int number);
- int numberDossier = number - 1;
- if (isNumber == true && numberDossier > 0 && numberDossier <= fullName.Count)
- {
- Console.WriteLine("Досье сотрудника: №" + (numberDossier + 1) + " " + fullName[numberDossier] + " - " + post[numberDossier]);
- }
- else
- {
- Console.WriteLine("Досье с таким номером нет.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement