static void Main(string[] args) { Console.WriteLine("==================================Welcome to Address Book System======================================"); AddPersonDetails personDetailsOBJ = new AddPersonDetails(); personDetailsOBJ.CreateMultipleUniqueAddressBook(); /* * * InterfaceDetails details = new AddPersonDetails(); * bool check = true; * while (check == true) * { * Console.WriteLine("=============================Welcome ToAddress Book Program=========================="); * Console.WriteLine("==========Please Enter Your Choice=========="); * Console.WriteLine("1. Add Details"); * Console.WriteLine("2. Display Details"); * Console.WriteLine("3. Edit Details"); * Console.WriteLine("4. Delete Details"); * Console.WriteLine("5. Exit"); * Console.WriteLine("============================================="); * * * string choice = Console.ReadLine(); * int ch = Convert.ToInt32(choice); * * switch (ch) * { * case 1: * details.AddDetails(); * break; * case 2: * details.Display(); * break; * case 3: * Console.WriteLine("Please Enter First Name : "); * string name = Console.ReadLine(); * details.Edit(name); * break; * case 4: * Console.WriteLine("Please Enter First Name : "); * string nameForDeletion = Console.ReadLine(); * details.Delete(nameForDeletion); * break; * case 5: * return; * } * } * */ }
public void CreateMultipleUniqueAddressBook() { while (true) { Console.WriteLine("Please enter your Choice......."); Console.WriteLine("1.Add Address Book"); Console.WriteLine("2.Use Existing Address Book"); Console.WriteLine("3.Exit"); String choice = Console.ReadLine(); int choice1 = Convert.ToInt32(choice); switch (choice1) { case 1: Console.WriteLine("Please Enter The Name Of Your Address Book : "); string name = Console.ReadLine(); if (dictionary.ContainsKey(name)) { Console.WriteLine("Address Book Already exists!!!"); } else { AddPersonDetails addressBook = new AddPersonDetails(); dictionary.Add(name, addressBook); Console.WriteLine("Your Address Book is Created."); addressBook.Menu(); } break; case 2: Console.WriteLine("Please enter Address book name : "); string addressBookName = Console.ReadLine(); if (dictionary.ContainsKey(addressBookName)) { dictionary[addressBookName].Menu(); } else { Console.WriteLine("Address book does not exists!!!"); } break; case 3: return; } } }
/// <summary> /// AddressBook Menu to show multiple choice /// </summary> public void Menu() { InterfaceDetails addressBookDetails = new AddPersonDetails(); bool check = true; while (check == true) { Console.WriteLine("*************PLEASE SELECT YOUR CHOICE**************"); Console.WriteLine("1. Add Details"); Console.WriteLine("2. Display Details"); Console.WriteLine("3. Edit Details"); Console.WriteLine("4. Delete Details"); Console.WriteLine("5. Search Person In The State or City"); Console.WriteLine("6. View Person By State or City"); Console.WriteLine("7. Ability To Count Person By State or City"); Console.WriteLine("8. Sort Details"); Console.WriteLine("9. Write Into File"); Console.WriteLine("10. Read From File"); Console.WriteLine("11. Exit"); string choice = Console.ReadLine(); int ch = Convert.ToInt32(choice); switch (ch) { case 1: addressBookDetails.AddDetails(); break; case 2: addressBookDetails.Display(); break; case 3: Console.WriteLine("Please Enter Your First Name : "); string firstName = Console.ReadLine(); addressBookDetails.Edit(firstName); break; case 4: Console.WriteLine("Please Enter Your First Name : "); string firstname = Console.ReadLine(); addressBookDetails.Delete(firstname); break; case 5: addressBookDetails.SearchPersonInStateOrCity(); break; case 6: addressBookDetails.ViewPersonsByStateOrCity(); break; case 7: addressBookDetails.PersonsCountByStateOrCity(); return; case 8: addressBookDetails.SortByName(); break; case 9: addressBookDetails.WriteIntoFileUsingFileIO(); break; case 10: addressBookDetails.ReadFromFileUsingFileIO(); break; case 11: return; } } }