Пример #1
0
        private void getUserImput(ref bool exit)
        {
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey(true);
            } while (Console.KeyAvailable);

            switch (key.Key)
            {
            case ConsoleKey.D0:
                exit = true;
                Clientes.Save();
                break;

            case ConsoleKey.D1:
                if (Index > 1)
                {
                    Index--;
                }
                break;

            case ConsoleKey.D2:
                if (Index < Clientes.Count)
                {
                    Index++;
                }
                break;

            case ConsoleKey.D3:
                Index = JumpIntoClient();
                break;

            case ConsoleKey.D4:
                Index = searchText();
                break;

            case ConsoleKey.D5:
                Clientes.Add(newClient());
                break;

            case ConsoleKey.D6:
                Clientes.Clientes[Index - 1] = modifyClient(Clientes.Get(Index));
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void drawActualClient()
        {
            resetConsole();

            string line      = new string('-', Console.WindowWidth);
            string emptyLine = new string(' ', Console.WindowWidth - 2);
            string helpLine1 = "1-Anterior  2-Posterior  3-Número  4-Buscar  " +
                               "5-Añadir  6-Modificar  B-Borrar";
            string helpLine2 = "7-Listados  F1-Ayuda  0-Terminar";
            string topLine   = "Clientes (ficha actual: " + Index + "/" + Clientes.Count + ")";
            string date      = (DateTime.Now.Date + "").Substring(0, 11) + "       " +
                               (DateTime.Now.Date + "").Substring(11);

            //Cuadrado de arriba
            Console.SetCursorPosition(0, 0);
            Console.Write(line);
            Console.Write("|" + emptyLine + "|");
            Console.Write(line);
            Console.SetCursorPosition(1, 1);
            Console.Write(topLine);
            Console.SetCursorPosition(Console.WindowWidth / 2, 1);
            Console.Write(date);

            //Cuerpo del programa
            Console.SetCursorPosition(0, 4);
            Console.Write("Nombre: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Nombre));
            Console.Write("DNI / CIF: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Cif));
            Console.WriteLine();
            Console.Write("Domicilio: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Domicilio));
            Console.Write("Ciudad: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Ciudad));
            Console.Write("Cod.Postal: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).CodigoPostal.ToString("00000")));
            Console.Write("Pais: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Pais));
            Console.Write("Teléfono: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Telefono));
            Console.Write("E-mail: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Email));
            Console.Write("Contacto: ");
            Console.CursorLeft = 11;
            Console.WriteLine(checkVacio(Clientes.Get(Index).Contacto));
            Console.WriteLine();
            Console.WriteLine("Observaciones: ");
            Console.CursorLeft = 11;
            Console.CursorLeft = 3;
            Console.WriteLine(Clientes.Get(Index).Observaciones);

            //Parte de abajo
            Console.SetCursorPosition(0, Console.WindowHeight - 4);
            Console.Write(line);
            Console.SetCursorPosition(Console.WindowWidth / 2 -
                                      (helpLine1.Length / 2), Console.WindowHeight - 3);
            Console.WriteLine(helpLine1);
            Console.SetCursorPosition(Console.WindowWidth / 2 -
                                      (helpLine2.Length / 2), Console.WindowHeight - 2);
            Console.WriteLine(helpLine2);


            Console.ResetColor();
        }
Пример #3
0
        private int searchText()
        {
            resetConsole();
            Console.Write("Text to search: ");
            string text = Console.ReadLine().ToLower();

            Console.WriteLine("From this file or begining? file/begining");
            string index = Console.ReadLine();

            Console.WriteLine("Stop when finding a file o when finish? finding/finish");
            string stop = Console.ReadLine();

            int        actualPos      = 1;
            List <int> foundPositions = new List <int>();

            if (index == "file")
            {
                actualPos = Index;
            }

            bool find = false;

            do
            {
                Cliente clienteActual = Clientes.Get(actualPos);
                if (clienteActual.Nombre.ToLower().Contains(text) ||
                    clienteActual.Cif.ToLower().Contains(text) ||
                    clienteActual.Ciudad.ToLower().Contains(text) ||
                    clienteActual.CodigoPostal.ToString("00000").ToLower().Contains(text) ||
                    clienteActual.Pais.ToLower().Contains(text) ||
                    clienteActual.Telefono.ToString().ToLower().Contains(text) ||
                    clienteActual.Email.ToLower().Contains(text) ||
                    clienteActual.Contacto.ToLower().Contains(text) ||
                    clienteActual.Observaciones.ToLower().Contains(text))

                {
                    if (stop == "finding")
                    {
                        find = true;
                    }
                    foundPositions.Add(actualPos);
                }
                if (!find && actualPos < Clientes.Count)
                {
                    actualPos++;
                }
            } while (!find && actualPos < Clientes.Count);

            if (foundPositions.Count > 1)
            {
                Console.Write("Found at positions: ");
                Console.Write(foundPositions[0]);
                for (int i = 1; i < foundPositions.Count; i++)
                {
                    Console.Write(", " + foundPositions[i]);
                }
                Console.WriteLine();
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(Index);
            }

            return(actualPos);
        }