Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        public void Start()
        {
            Console.Title = "BlueMoon - Edit 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 any Key to Edit Contacts....");
            Console.ReadKey(true);



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



            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 Edit");
            Console.SetCursorPosition(39, 20);
            string name = Station.MeteredInput(12, 39, 20);

            name = name.ToLower();

            bool editer = true;
            bool found  = false;

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

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

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

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

                    #region editer loop

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

                            if (name == EbColtemp || EbColtemp.Contains(name))
                            {
                                found = true;
                                Console.SetCursorPosition(39, 22);
                                Console.WriteLine("=======Contact==============");

                                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("(E). edit contact  --  (Backspace) to return  --  (N) to Next Search  --  (any key) to start again");


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

                                if (key.Key == ConsoleKey.E)
                                {
                                    Station.clearRow(15, 31, 105);


                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);


                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter Name :            ");
                                    Console.SetCursorPosition(39, 33);
                                    string newName = Console.ReadLine();

                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);

                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter Phone Number :         ");
                                    Console.SetCursorPosition(39, 33);
                                    string phoneNumber = Station.MeteredInputNum(11, 39, 33);


                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);


                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter Email :      ");
                                    Console.SetCursorPosition(39, 33);
                                    string email = Console.ReadLine();


                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);


                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter State : ");
                                    Console.SetCursorPosition(39, 33);
                                    string state = Console.ReadLine();


                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);


                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter City :    ");
                                    Console.SetCursorPosition(39, 33);
                                    string city = Console.ReadLine();


                                    Station.clearRow(39, 32, 30);
                                    Station.clearRow(39, 33, 30);


                                    Console.SetCursorPosition(39, 32);
                                    Console.WriteLine("Enter Street Address :          ");
                                    Console.SetCursorPosition(39, 33);
                                    string address = Console.ReadLine();


                                    EbRows[i] = newName + "~" + phoneNumber + "~" + email + "~" + state + "~" + city + "~" + address;


                                    editer = false;
                                }
                                else if (key.Key == ConsoleKey.Backspace)
                                {
                                    ContactDetails cd1 = new ContactDetails();
                                    cd1.Start();
                                }
                                else if (key.Key == ConsoleKey.N)
                                {
                                    break;
                                }
                                else
                                {
                                    EditContacts edc = new EditContacts();
                                    edc.Start();
                                }
                            }
                        }
                    }

                    #endregion

                    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("Editing Contact Information.............", 5000, 39, 35);
            File.Move("temp.txt", "Contacts.ebase");

            ContactDetails cd = new ContactDetails();
            cd.Start();
        }