public void Menu()
        {
            Console.WriteLine("Size of List is " + store.ContactListSize);

            int flag = 1;

            while (flag != 0)
            {
                Console.WriteLine("\nType keywords to perform Action\n Add \tDisplay Search \tUpdate \tRemove \tExit");
                string choice = Console.ReadLine();
                switch (choice.ToLower())
                {
                case "add":
                    store.Add(ContactDetails());
                    break;

                case "display":
                    Display(store.ContactList);
                    break;

                case "search":
                    try
                    {
                        List <Contact> matching = store.Search(Console.ReadLine());
                        Display(matching);
                    }
                    catch (StudentNotFoundException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    break;

                case "update":
                    Console.WriteLine("Ënter the name you want to update");
                    store.Update(Console.ReadLine());
                    break;

                case "remove":
                    store.Remove(Console.ReadLine());
                    Display(store.ContactList);
                    break;

                case "exit":
                    store.Serialize();
                    flag = 0;
                    break;

                default:
                    Console.WriteLine("Enter Proper KeyWord");
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Button myBtn = (Button)sender;

            switch (myBtn.Name)
            {
            case "button1":
                UpdateGrid();
                break;

            case "button2":
                string  name       = textBox1.Text;
                string  number     = textBox2.Text;
                Contact addContact = new Contact();
                addContact.Name   = name;
                addContact.Number = number;
                addContact.GetGuid();
                cs.Add(addContact);
                cs.Serialize();
                UpdateGrid();
                break;
            }
        }