Advertisement
LeRoY_Go

Untitled

Jun 18th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] fullName = { "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
  10. string[] post = { "Специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
  11. string userInputFullName;
  12. while (true)
  13. {
  14.  
  15. Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск по фамилии\n5 - выход");
  16. Console.Write("Ввидите команду: ");
  17. string userInput = Console.ReadLine();
  18. Console.Clear();
  19. switch (userInput)
  20. {
  21. case "1":
  22. AddDossier(ref fullName, ref post);
  23. break;
  24. case "2":
  25. ShowDossier(fullName, post);
  26. break;
  27. case "3":
  28. DeleteDossier(ref fullName, ref post);
  29. break;
  30. case "4":
  31. SearchDossier(fullName, post, out userInputFullName);
  32. break;
  33. case "5":
  34. Environment.Exit(50);
  35. break;
  36.  
  37. }
  38. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  39. Console.ReadLine();
  40. Console.Clear();
  41. }
  42. }
  43.  
  44. static void AddDossier(ref string[] fullName, ref string[] post)
  45. {
  46. string[] Arrey;
  47. string userInput;
  48. for (int j = 0; j < 2; j++)
  49. {
  50. if (j == 0)
  51. {
  52. Arrey = fullName;
  53. Console.Write("Ввидите фомилию: ");
  54. string userInputSurname = Console.ReadLine();
  55. Console.Write("Ввидите имя: ");
  56. string userInputName = Console.ReadLine();
  57. Console.Write("Ввидите отчество: ");
  58. string userInputPatronymic = Console.ReadLine();
  59. userInput = userInputSurname + " " + userInputName + " " + userInputPatronymic;
  60. }
  61. else
  62. {
  63. Arrey = post;
  64. Console.Write("Ввидите должность: ");
  65. userInput = Console.ReadLine();
  66. }
  67. string[] tempArrey = new string[Arrey.Length + 1];
  68.  
  69. tempArrey[tempArrey.Length - 1] = userInput;
  70.  
  71. for (int i = 0; i < Arrey.Length; i++)
  72. {
  73. tempArrey[i] = Arrey[i];
  74. }
  75. if (j == 0)
  76. {
  77. fullName = tempArrey;
  78. }
  79. else
  80. {
  81. post = tempArrey;
  82. }
  83. }
  84. Console.WriteLine("Новое досье создано.");
  85. }
  86.  
  87. static void ShowDossier(string[] fullName, string[] post)
  88. {
  89. for (int i = 0; i < fullName.Length; i++)
  90. {
  91. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  92. }
  93. }
  94.  
  95. static void DeleteDossier(ref string[] fullName, ref string[] post)
  96. {
  97. string[] Arrey;
  98. Console.Write("Ввидите номер досье: ");
  99. int index = Convert.ToInt32(Console.ReadLine()) - 1;
  100. for (int j = 0; j < 2; j++)
  101. {
  102. if (j == 0)
  103. {
  104. Arrey = fullName;
  105. }
  106. else
  107. {
  108. Arrey = post;
  109. }
  110. string[] tempArrey = new string[Arrey.Length - 1];
  111. for (int i = 0; i < index; i++)
  112. {
  113. tempArrey[i] = Arrey[i];
  114. }
  115. for (int i = index; i < tempArrey.Length; i++)
  116. {
  117. tempArrey[i] = Arrey[i + 1];
  118. }
  119. Arrey = tempArrey;
  120. if (j == 0)
  121. {
  122. fullName = Arrey;
  123. }
  124. else
  125. {
  126. post = Arrey;
  127. }
  128. }
  129. Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
  130. }
  131.  
  132. static void SearchDossier(string[] fullName, string[] post, out string userInputFullName)
  133. {
  134. bool employeeFound = false;
  135. Console.Write("Введите ФИО сотрудника через пробел: ");
  136. userInputFullName = Console.ReadLine();
  137. for (int i = 0; i < fullName.Length; i++)
  138. {
  139. if (userInputFullName.ToLower() == fullName[i].ToLower())
  140. {
  141. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  142. employeeFound = true;
  143. break;
  144. }
  145. }
  146. if (employeeFound == false)
  147. {
  148. Console.WriteLine("Сотрудника с токой ФИО нету.");
  149. }
  150. }
  151. }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement