Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp3
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- string[] appointment = new string[0];
- string[] fio = new string[0];
- int list;
- string menu;
- bool work = true;
- while (true)
- {
- Console.WriteLine("Список доступных команд: \nNew - добавить новое досье. \nList - вывести список досье. \nDel - удалить досье. \nEsc - выход.");
- Console.Write("Введите команду: ");
- menu = Console.ReadLine().ToLower();
- if (menu == "new")
- {
- New(ref fio, ref appointment);
- continue;
- }
- else if (menu == "list")
- {
- Console.Clear();
- for (int i = 0; i < fio.Length; i++)
- {
- Console.WriteLine(i + 1 + ". " + fio[i] + " - " + appointment[i]);
- }
- Console.WriteLine("Нажмите любую клавишу, чтобы вернуться в меню.");
- Console.ReadKey();
- Console.Clear();
- continue;
- }
- else if (menu == "del")
- {
- Delete(ref fio, ref appointment);
- continue;
- }
- else if (menu == "esc")
- {
- work = false;
- continue;
- }
- else
- {
- Console.Clear();
- Console.WriteLine("Я не знаю такой комманды!");
- Console.WriteLine();
- continue;
- }
- }
- }
- public static void New(ref string[] fio, ref string[] appointment)
- {
- Console.WriteLine("Введите имя, фамилию и отчество нового сотрудника: ");
- string menu = Console.ReadLine();
- string[] tempfio = new string[fio.Length + 1];
- for (int i = 0; i < fio.Length; i++)
- {
- tempfio[i] = fio[i];
- }
- tempfio[fio.Length] = menu;
- fio = tempfio;
- Console.WriteLine("Введите должность нового сотрудника: ");
- menu = Console.ReadLine();
- string[] tempappointment = new string[appointment.Length + 1];
- for (int i = 0; i < appointment.Length; i++)
- {
- tempfio[i] = appointment[i];
- }
- tempfio[appointment.Length] = menu;
- appointment = tempfio;
- Console.Clear();
- Console.WriteLine("Данные сохранены!");
- Console.WriteLine();
- }
- public static void Delete(ref string[] fio, ref string[] appointment)
- {
- Console.Clear();
- for (int i = 0; i < fio.Length; i++)
- {
- Console.WriteLine(i + 1 + ". " + fio[i] + " - " + appointment[i]);
- }
- Console.Write("Введите номер удаляемого досье: ");
- int list = Convert.ToInt32(Console.ReadLine());
- if (list <= fio.Length && list >= 1)
- {
- Console.WriteLine("Вы действительно хотиту удалить досье сотрудника\n" + fio[list - 1] + " - " + appointment[list - 1] + "?\nНажимте Y для подтверждения или N для отмены");
- string menu = Console.ReadLine().ToLower();
- if (menu == "n")
- {
- }
- else if (menu == "y")
- {
- for (int i = list - 1; i < fio.Length - 1; i++)
- {
- fio[i] = fio[i + 1];
- appointment[i] = appointment[i + 1];
- }
- string[] tempfio = new string[fio.Length - 1];
- string[] tempappointment = new string[appointment.Length - 1];
- for (int i = 0; i < tempfio.Length; i++)
- {
- tempfio[i] = fio[i];
- tempfio[i] = appointment[i];
- }
- fio = tempfio;
- appointment = tempfio;
- Console.WriteLine("Выбранное досье удалено");
- }
- else
- {
- Console.WriteLine("Что-то пошло не так.");
- }
- Console.WriteLine("Для продолжения нажмите любую колавишу.");
- Console.ReadKey();
- Console.Clear();
- }
- else
- {
- Console.Clear();
- Console.WriteLine("Что-то пошло не так. Возможно такого досье нет в базе.");
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement