Пример #1
0
        public void AddClient(object sender, ChoiceEventArgs e)
        {
            Client.InputClient(out client);
            one.Add(client);

            Console.WriteLine("New Client Added");
        }
Пример #2
0
        public void SortClient(object sender, ChoiceEventArgs e)
        {
            ConsoleKey keyBefor;

            ListSort.SortMenu(out keyBefor);
            switch (keyBefor)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                ListSort.SortByName(one);
                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                ListSort.SortByLastName(one);
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                ListSort.SortByFhone(one);
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                ListSort.SortByadress(one);
                break;
            }
            Console.WriteLine("Sort Is done");
        }
Пример #3
0
        public void OnSomeEvent(int choice)
        {
            ChoiceEventArgs arg = new ChoiceEventArgs();

            if (SomeEvent != null)
            {
                arg.EventNum = choice;
                SomeEvent(this, arg);
            }
        }
Пример #4
0
        public void ChangeInformation(object sender, ChoiceEventArgs e)
        {
            var key = new ConsoleKey();

            Console.WriteLine("Search Client For change");
            Console.WriteLine("1) First name");
            Console.WriteLine("2) Last name");
            Console.WriteLine("3) Phone namber");
            Console.Write("Your choice : ");
            do
            {
                Console.CursorLeft = 15;
                key = Console.ReadKey().Key;
            } while (key < ConsoleKey.D1 || key > ConsoleKey.D3 &&
                     key < ConsoleKey.NumPad1 || key > ConsoleKey.NumPad3);

            Console.WriteLine();
            int index = -1;


            switch (key)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                Client.InputClientName(ref client);
                index = Search.SearchByName(client, one);
                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                Client.InputClientLastName(ref client);
                index = Search.SearchByLastName(client, one);
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                Client.InputClientFoneNumber(ref client);
                index = Search.SearchByFhone(client, one);
                break;
            }

            try
            {
                one.PrintByIndex(index);
                Client.InputClient(out client);
                one.PhonesBook[index] = client;
                Console.WriteLine("Change Is Done");
            }
            catch
            {
                Console.WriteLine("No have this Client in Phone book");
            }
        }
Пример #5
0
 public void PrintByIndex(object sender, ChoiceEventArgs e)
 {
     try
     {
         int index = Convert.ToInt32(Console.ReadLine());
         one.PrintByIndex(index);
     }
     catch
     {
         Console.WriteLine("Non-Book Index");
         Console.WriteLine($"Index Min {0}, Index Max {one.PhonesBook.Count - 1}");
     }
 }
Пример #6
0
        public void DeleteClient(object sender, ChoiceEventArgs e)
        {
            search.MenuSearchDelete();
            try
            {
                if (search.ItemMenuDelete == ConsoleKey.D1 || search.ItemMenuDelete == ConsoleKey.NumPad1)  // Choice delete by name or by phone
                {
                    one.DeleteAt(Search.SearchByLastName(search.GetSearchClient(), one));
                }
                else
                {
                    one.DeleteAt(Search.SearchByFhone(search.GetSearchClient(), one));
                }

                Console.WriteLine("Delete Is Done");
            }
            catch
            {
                Console.WriteLine("So sorry but in this book no have this client");
            }
        }
Пример #7
0
        public void SearchClientByPhone(object sender, ChoiceEventArgs e)
        {
            Client.InputClientFoneNumber(ref client);

            search.SetSearchClient(client);
            List <int> list = new List <int>();

            Search.SearchByFhone(list, search.GetSearchClient(), one);

            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    one.PrintByIndex(list[i]);
                }
            }
            else
            {
                Console.WriteLine("In your phone book no have Client with this phone");
            }
        }
Пример #8
0
 public void Exit(object sender, ChoiceEventArgs e)
 {
     Console.WriteLine("GOOD BAY BAY");
     FileManager.SaveSerialization(one);
 }
Пример #9
0
 public void PrintAll(object sender, ChoiceEventArgs e)
 {
     one.PrintAllBook();
 }