Esempio n. 1
0
        public static void addUser(MultipleAddressBook MultAddObj)
        {
            Console.Write("Enter FirstName: ");
            string firstName = Console.ReadLine();

            Console.Write("Enter LastName: ");
            string lastName = Console.ReadLine();

            Console.Write("Enter Address : ");
            string address = Console.ReadLine();

            Console.Write("Enter State : ");
            string state = Console.ReadLine();

            Console.Write("Enter Contact No: ");
            string contact = Console.ReadLine();

            Console.Write("Enter zip : ");
            string zip = Console.ReadLine();

            MultAddObj.AddContact(firstName, lastName, address, state, contact, zip);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            bool flag = true;

            while (flag)
            {
                Console.WriteLine();
                Console.WriteLine("********WELCOME TO ADDRESS BOOK********");
                Console.WriteLine("1. Create_AddressBooks \n2. Open_AddressBooks \n3. Count_TotalContacts \n4. Serch_FromAllContact \n5. DeletAddressBook " +
                                  "\n6. StoreContactsIn_TextFile \n7. ReadContactsFrom_TextFile \n8. StoreContactsIn_CsvFile \n9. ReadContactsFrom_CsvFile \n10. StoreContactsIn_JsonFile \n11. ReadConatctsFrom_JsonFile \n12. Exit");
                int choice = Convert.ToInt32(Console.ReadLine());
                int size   = addressBookDict.Count;
                switch (choice)
                {
                case 1:
                    Console.Write("Enter AddressBook Name : ");
                    string book  = Console.ReadLine();
                    bool   check = DuplicatAddress(book);

                    if (check)
                    {
                        Console.Write("Enter AddressBook Name again : ");
                        book = Console.ReadLine();
                    }
                    MultipleAddressBook admain = new MultipleAddressBook();
                    addressBookDict.Add(book, admain);
                    Console.Clear();
                    Console.WriteLine("AddressBook_Created successfully...");
                    break;

                case 2:
                    Console.WriteLine($"You have {size} AddressBook.");

                    foreach (var address in addressBookDict.Keys)
                    {
                        Console.WriteLine(address);
                    }
                    Console.Write("Enter Address_BookName : ");
                    string bookname = Console.ReadLine();
                    int    ch       = 0;
                    foreach (var address in addressBookDict)
                    {
                        ch++;
                        if (addressBookDict.ContainsKey(bookname))
                        {
                            Console.Clear();
                            Console.WriteLine("Opened Address_Book :-->" + bookname);
                            MainMenu(bookname);
                        }
                        else if (size == ch)
                        {
                            Console.Clear();
                            Console.WriteLine("AddressBook not present!!!!!");
                        }
                    }
                    break;

                case 3:
                    Console.Write("Enter City or State want to Count : ");
                    string countplace = Console.ReadLine();
                    foreach (var addbook in addressBookDict.Keys)
                    {
                        Console.WriteLine("Contacts From AddressBook : " + addbook);
                        addressBookDict[addbook].CountContact(countplace);
                    }
                    Console.WriteLine("----------------------------------------");
                    break;

                case 4:
                    Console.Write("Enter City Or State name U want To Serch : ");
                    string place = Console.ReadLine();
                    Console.WriteLine("----------------------------------------");
                    foreach (var addbook in addressBookDict.Keys)
                    {
                        Console.WriteLine("Contacts From AddressBook : " + addbook);
                        addressBookDict[addbook].SerchContact(place);
                        Console.WriteLine("----------------------------------------");
                    }
                    break;

                case 5:
                    Console.WriteLine($"You have {size} AddressBook.");
                    foreach (var address in addressBookDict)
                    {
                        Console.WriteLine(address.Key);
                    }
                    Console.Write("Enter Address_BookName  : ");
                    string name = Console.ReadLine();

                    int signal = 0;
                    Console.Clear();
                    foreach (var address in addressBookDict)
                    {
                        signal++;
                        if (addressBookDict.Remove(name))
                        {
                            Console.Clear();
                            Console.WriteLine($"Address_Book {name} Deleted...");
                            break;
                        }
                        else if (size == signal)
                        {
                            Console.Clear();
                            Console.WriteLine("AddressBook not present!!!!!");
                        }
                    }
                    break;

                case 6:
                    Console.WriteLine($"You have {size} AddressBook.");

                    foreach (var address in addressBookDict.Keys)
                    {
                        Console.WriteLine(address);
                    }
                    Console.Write("Enter Address_BookName : ");
                    string addressBokk = Console.ReadLine();
                    addressBookDict[addressBokk].writeInTxtFile();
                    break;

                case 7:
                    Console.WriteLine($"You have {size} AddressBook.");

                    foreach (var address in addressBookDict.Keys)
                    {
                        Console.WriteLine(address);
                    }
                    Console.Write("Enter Address_BookName : ");
                    string readContacts = Console.ReadLine();
                    addressBookDict[readContacts].readFromTxtFile();
                    break;

                case 8:
                    Console.WriteLine($"You have {size} AddressBook.");

                    foreach (var address in addressBookDict.Keys)
                    {
                        Console.WriteLine(address);
                    }
                    Console.Write("Enter Address_BookName : ");
                    string writeInCsv = Console.ReadLine();
                    addressBookDict[writeInCsv].writeInCsvFile();
                    break;

                case 9:
                    Console.WriteLine($"You have {size} AddressBook.");

                    foreach (var address in addressBookDict.Keys)
                    {
                        Console.WriteLine(address);
                    }
                    Console.Write("Enter Address_BookName : ");
                    string readContact = Console.ReadLine();
                    addressBookDict[readContact].readFromCsvFile();
                    break;

                case 10:
                    Console.Write("Enter Address_BookName : ");
                    string writeJson = Console.ReadLine();
                    addressBookDict[writeJson].writeInJsonFile();
                    break;

                case 11:
                    Console.Write("Enter Address_BookName : ");
                    string readJson = Console.ReadLine();
                    addressBookDict[readJson].readInJsonFile();
                    break;

                case 12:
                    flag = false;
                    break;

                default:
                    Console.WriteLine("Invalid Option...");
                    break;
                }
            }
        }