Advertisement
TwinFrame

WorkerDosie

Jan 15th, 2020
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clight_15_HumanUchet
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. bool isWork = true;
  10. string tempFio;
  11. string tempJob;
  12. int numMenu;
  13. string[] fioDosie = new string[0];
  14. string[] jobDosie = new string[0];
  15.  
  16.  
  17. while (isWork == true)
  18. {
  19. Console.WriteLine("Меню кадрового учёта:");
  20. Console.WriteLine("1 - Добавить досье");
  21. Console.WriteLine("2 - Вывести досье");
  22. Console.WriteLine("3 - Удалить досье");
  23. Console.WriteLine("4 - Поиск по фамилии");
  24. Console.WriteLine("5 - Выход");
  25.  
  26. Console.Write("\nВведите номер меню: ");
  27. numMenu = Convert.ToInt32(Console.ReadLine());
  28.  
  29. switch (numMenu)
  30. {
  31. case 1:
  32. Console.SetCursorPosition(0, 9);
  33. Console.Write("Введите фамилию сотрудника: ");
  34. tempFio = Console.ReadLine();
  35. Console.Write("Введите должность сотрудника: ");
  36. tempJob = Console.ReadLine();
  37.  
  38. fioDosie = AddDosie(fioDosie, tempFio);
  39. jobDosie = AddDosie(jobDosie, tempJob);
  40. break;
  41.  
  42. case 2:
  43. Console.SetCursorPosition(0, 9);
  44. ViewDosie(fioDosie, jobDosie);
  45. break;
  46.  
  47. case 3:
  48. fioDosie = new string[0];
  49. jobDosie = new string[0];
  50. Console.SetCursorPosition(0, 9);
  51. Console.WriteLine("Досье сотрудников удалено.");
  52. Console.ReadKey();
  53. break;
  54. case 4:
  55. Console.SetCursorPosition(0, 9);
  56. FindWorker(fioDosie, jobDosie);
  57. break;
  58. case 5:
  59. isWork = false;
  60. break;
  61. }
  62. Console.Clear();
  63. }
  64. Console.WriteLine("До свидания!");
  65. Console.ReadKey();
  66.  
  67.  
  68. static string[] AddDosie(string[] currentMassive, string temp)
  69. {
  70.  
  71. string[] tempMassive = new string[currentMassive.Length + 1];
  72. for (int i = 0; i < currentMassive.Length; i++)
  73. {
  74. tempMassive[i] = currentMassive[i];
  75. }
  76. tempMassive[tempMassive.Length - 1] = temp;
  77. return currentMassive = tempMassive;
  78. }
  79.  
  80. static void ViewDosie(string[] fioDosie, string[] jobDosie)
  81. {
  82. Console.WriteLine("Досье сотрудников:");
  83. for (int i = 0; i < fioDosie.Length; i++)
  84. {
  85. Console.WriteLine($"{i + 1}. {fioDosie[i]} - {jobDosie[i]}");
  86. }
  87. Console.ReadKey();
  88. }
  89.  
  90. static void FindWorker(string[] fioDosie, string[] jobDosie)
  91. {
  92. Console.Write("Введите фамилию: ");
  93. string fioFind = Console.ReadLine();
  94. Console.WriteLine("\nНайдены сотрудники: \n");
  95. int j = 0;
  96. for (int i = 0; i < fioDosie.Length; i++)
  97. {
  98. if (fioDosie[i] == fioFind)
  99. {
  100. Console.WriteLine($"{i + 1}. {fioDosie[i]} - {jobDosie[i]}");
  101. j++;
  102. }
  103. }
  104. if (j == 0)
  105. {
  106. Console.WriteLine($"Сотрудников с фамилией {fioFind} не найдено.");
  107. }
  108. Console.ReadKey();
  109. }
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement