示例#1
0
        public void Start()
        {
            Console.Title = "BlueMoon - Delete Contacts";

            Console.Clear();
            AsciiClass ac = new AsciiClass();

            ac.BlueMoon(3);


            Console.SetCursorPosition(37, 13);
            Console.WriteLine("==========PERSONAL ASSISTANT APPLICATION==========");


            Console.SetCursorPosition(37, 15);
            Console.WriteLine("Press BackSpace to go to previous menu or any key to start delete....");

            Console.CursorVisible = false;
            ConsoleKeyInfo key1;

            key1 = Console.ReadKey(true);

            if (key1.Key == ConsoleKey.Backspace)
            {
                ContactDetails cd2 = new ContactDetails();
                cd2.Start();
                return;
            }

            Console.SetCursorPosition(37, 15);
            Console.WriteLine("                                                                           ");


            Console.SetCursorPosition(37, 15);
            Console.WriteLine("Delete contact Menu");



            Console.SetCursorPosition(39, 17);
            Console.WriteLine("       ======Contact Details======");


            bool writeRow;



            string curPath = Directory.GetCurrentDirectory();

            string path = curPath + "\\Contacts.ebase";

            string tempPath = curPath + "\\temp.txt";

            string[] EbRows = File.ReadAllLines(path);



            Console.SetCursorPosition(39, 19);
            Console.WriteLine("enter the name of the contact to delete");

            Console.SetCursorPosition(39, 20);
            // Start add
            string name = Station.MeteredInput(12, 39, 20);


            name = name.ToLower();


            bool editer = true;
            bool found  = false;

            // end add

            string[] fieldName = { "Name", "Phone Number", "Email", "State", "City", "Address" };

            List <string> newData = new List <string>();



            while (editer)
            {
                newData = new List <string>();
                //add
                found = false;

                for (int i = 0; i < EbRows.Length; i++)
                {
                    string[] EbCol = EbRows[i].Split('~');
                    writeRow = true;

                    for (int j = 0; j < EbCol.Length; j++)
                    {
                        //Start add
                        if (editer)
                        {
                            string EbColtemp = EbCol[0].ToLower();

                            if (name == EbColtemp || EbColtemp.Contains(name))
                            {
                                found = true;
                                // End add make sure to complete }

                                Console.SetCursorPosition(39, 22);
                                Console.WriteLine("=======Contact Found=======");

                                EditContactsClear();

                                Console.SetCursorPosition(39, 24);
                                Console.WriteLine("{0,-12} : {1}", fieldName[0], EbCol[0]);

                                Console.SetCursorPosition(39, 25);
                                Console.WriteLine("{0,-12} : {1}", fieldName[1], EbCol[1]);

                                Console.SetCursorPosition(39, 26);
                                Console.WriteLine("{0,-12} : {1}", fieldName[2], EbCol[2]);

                                Console.SetCursorPosition(39, 27);
                                Console.WriteLine("{0,-12} : {1}", fieldName[3], EbCol[3]);

                                Console.SetCursorPosition(39, 28);
                                Console.WriteLine("{0,-12} : {1}", fieldName[4], EbCol[4]);

                                Console.SetCursorPosition(39, 29);
                                Console.WriteLine("{0,-12} : {1}", fieldName[5], EbCol[5]);



                                Console.SetCursorPosition(15, 31);
                                Console.WriteLine("(Y) Delete Contact  --  (N) Next Search  --  (AnyKey) Start Again -- (BackSpace) to Return to Menu");


                                Console.CursorVisible = false;
                                ConsoleKeyInfo key;
                                key = Console.ReadKey(true);

                                if (key.Key == ConsoleKey.Y)
                                {
                                    Station.clearRow(15, 31, 105);
                                    Console.SetCursorPosition(30, 31);
                                    Console.WriteLine("Are you sure you want to delete contact !! (Y). Yes or anykey to Cancel ?");

                                    Console.CursorVisible = false;
                                    ConsoleKeyInfo key2;
                                    key2 = Console.ReadKey(true);

                                    if (key2.Key == ConsoleKey.Y)
                                    {
                                        writeRow = false;
                                        editer   = false;
                                        Station.clearRow(30, 31, 90);
                                    }
                                    else if (key2.Key != ConsoleKey.Y)
                                    {
                                        MainMenu ddc = new MainMenu();
                                        ddc.Start();
                                    }
                                }
                                else if (key.Key == ConsoleKey.N)
                                {
                                    break;
                                }
                                else if (key.Key == ConsoleKey.Backspace)
                                {
                                    ContactDetails ccdc = new ContactDetails();
                                    ccdc.Start();
                                }
                                else
                                {
                                    DeleteContacts ddc = new DeleteContacts();
                                    ddc.Start();
                                }
                            }
                        }
                    }

                    if (writeRow)
                    {
                        newData.Add(EbRows[i]);
                    }
                }

                if (!found)
                {
                    Console.SetCursorPosition(48, 27);
                    Console.Write("Contact Not Found");
                    Thread.Sleep(500);
                    Start();
                }
            }

            string[] newDataarr = newData.ToArray();



            File.WriteAllLines(tempPath, newDataarr);

            File.Delete("Contacts.ebase");
            Station.Blink("Deleting Contact Information.............", 5000, 39, 33);
            File.Move("temp.txt", "Contacts.ebase");


            ContactDetails cd = new ContactDetails();

            cd.Start();
        }
示例#2
0
        public void Start()
        {
            Console.Title = "BlueMoon - Contacts Application";

            Console.Clear();
            AsciiClass ac = new AsciiClass();

            ac.BlueMoon(3);

            int left = 37;
            int top  = 14;

            Console.SetCursorPosition(left, top);
            Console.WriteLine("PERSONAL ASSISTANT APPLICATION");

            top++;
            Console.SetCursorPosition(37, top);
            Console.WriteLine("Contact Details Page.");

            top += 3;
            int topA = top;

            Console.SetCursorPosition(39, top);
            String textA = "(A). Add contacts";

            Console.WriteLine(textA);

            top += 2;
            int topE = top;

            Console.SetCursorPosition(39, top);
            string textE = "(E). Edit Contacts";

            Console.WriteLine(textE);

            top += 2;
            int topV = top;

            Console.SetCursorPosition(39, top);
            string textV = "(V). View Contacts ";

            Console.WriteLine(textV);

            top += 2;
            int topS = top;

            Console.SetCursorPosition(39, top);
            string textS = "(S). Search Contacts ";

            Console.WriteLine(textS);

            top += 2;
            int topD = top;

            Console.SetCursorPosition(39, top);
            string textD = "(D). Delete Contacts ";

            Console.WriteLine(textD);

            top += 2;
            int topR = top;

            Console.SetCursorPosition(39, top);
            string textR = "(R). Return to Main Page ";

            Console.WriteLine(textR);


            Station.StartTimeThread();

            Console.CursorVisible = false;
            ConsoleKeyInfo key;

            key = Console.ReadKey(true);

            if (key.Key == ConsoleKey.A)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topA, textA);
                AddContacts ad = new AddContacts();
                ad.Start();
            }
            else if (key.Key == ConsoleKey.E)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topE, textE);
                EditContacts ec = new EditContacts();
                ec.Start();
            }
            else if (key.Key == ConsoleKey.V)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topV, textV);
                ViewContacts vc = new ViewContacts();
                vc.Start();
            }
            else if (key.Key == ConsoleKey.S)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topS, textS);
                SearchContacts sc = new SearchContacts();
                sc.Start();
            }
            else if (key.Key == ConsoleKey.D)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topD, textD);
                DeleteContacts dc = new DeleteContacts();
                dc.Start();
            }
            else if (key.Key == ConsoleKey.R)
            {
                Station.StopTimeThread();
                Station.BeepClick();
                Station.Highlight(39, topR, textR);
                PersonalAssistant pa = new PersonalAssistant();
                pa.Start();
            }
            else
            {
                Station.StopTimeThread();
                top += 4;
                Station.BeepError();
                Console.SetCursorPosition(39, top);
                Console.WriteLine("Invalid Key.");
                Thread.Sleep(200);
                Console.Clear();
                Start();
            }
        }