Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] personalData = new string[0];
- string[] numberToFami = new string[0];
- bool exit = true;
- while (exit)
- {
- Console.SetCursorPosition(30, 0);
- Console.WriteLine("Базза данных");
- Console.WriteLine("Список комманд:\n");
- Console.WriteLine(" 1)Добавить досье");
- Console.WriteLine(" 2)Вывести досье");
- Console.WriteLine(" 3)Удалить досье");
- Console.WriteLine(" 4)Поиск по фамилии");
- Console.WriteLine(" 5)Выйти");
- Console.Write("Введите номер комманды:");
- int numberCommand = Convert.ToInt32(Console.ReadLine());
- switch (numberCommand)
- {
- case 1:
- Console.Write("Введите имя\nИмя:");
- string name = Console.ReadLine();
- Console.Write("Введите фамилию\nФамилия:");
- string fami = Console.ReadLine();
- Console.Write("Введите отчество\nОтчество:");
- string patronymic = Console.ReadLine();
- Console.Write("Введите должность\nДолжность:");
- string post = Console.ReadLine();
- addDossier(ref personalData, ref numberToFami, name, fami, patronymic, post);
- break;
- case 2:
- for (int i = 0; i < personalData.Length; i++)
- {
- Console.WriteLine("#" + (i + 1) + " " + personalData[i]);
- }
- break;
- case 3:
- Console.Write("Введите номер досье:");
- int numberDpssierDelete = Convert.ToInt32(Console.ReadLine()) - 1;
- deleteDossier(ref personalData, ref numberToFami, numberDpssierDelete);
- break;
- case 4:
- Console.Write("Введите фамилию\n Фамилия:");
- string searchByFami = Console.ReadLine();
- for (int i = 0; i < numberToFami.Length; i++)
- {
- if (numberToFami[i] == searchByFami)
- {
- Console.WriteLine(personalData[i]);
- break;
- }
- if (i == numberToFami.Length - 1)
- {
- Console.WriteLine("Нет досье с введённой фамилией...");
- }
- }
- break;
- case 5:
- exit = false;
- break;
- default:
- Console.Write("Вы ввели неправильный номер комманды...");
- break;
- }
- Console.ReadLine();
- Console.Clear();
- }
- }
- static void addDossier(ref string[] personalData, ref string[] numberToFami, string name, string fami, string patronymic, string post)
- {
- string[] array = new string[personalData.Length + 1];
- string[] addArrayNumberToFami = new string[personalData.Length + 1];
- for (int i = 0; i < personalData.Length; i++)
- {
- array[i] = personalData[i];
- }
- for (int i = 0; i < numberToFami.Length; i++)
- {
- addArrayNumberToFami[i] = numberToFami[i];
- }
- addArrayNumberToFami[numberToFami.Length] = fami;
- array[personalData.Length ] = ($"{fami} {name} {patronymic} - Должность {post}");
- numberToFami = addArrayNumberToFami;
- personalData = array;
- }
- static void deleteDossier(ref string[] personalData,ref string[] numberToFami, int numberDpssierDelete)
- {
- string[] arrayNumberToFamiEditor = numberToFami;
- string[] arrayNumberToFamiDeleteIndex = new string[numberToFami.Length - 1];
- for (int i = numberDpssierDelete; i < arrayNumberToFamiEditor.Length - 1; i++)
- {
- arrayNumberToFamiEditor[i] = arrayNumberToFamiEditor[i + 1];
- }
- for (int i = 0; i < arrayNumberToFamiDeleteIndex.Length; i++)
- {
- arrayNumberToFamiDeleteIndex[i] = arrayNumberToFamiEditor[i];
- }
- numberToFami = arrayNumberToFamiDeleteIndex;
- string[] arrayPersonalDataEditor = personalData;
- string[] arrayPersonalDateDeleteIndex = new string[personalData.Length - 1];
- for (int i = numberDpssierDelete; i < arrayPersonalDataEditor.Length - 1; i++)
- {
- arrayPersonalDataEditor[i] = arrayPersonalDataEditor[i+1] ;
- }
- for (int i = 0; i < arrayPersonalDateDeleteIndex.Length; i++)
- {
- arrayPersonalDateDeleteIndex[i] = arrayPersonalDataEditor[i];
- }
- personalData = arrayPersonalDateDeleteIndex;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement