Exemple #1
0
        public static Client AskNewUserData(SQLDBConnection myDB)
        {
            Client clientToInsert = new Client();

            do
            {
                Console.Write("DNI: ");
                clientToInsert.DNI = Console.ReadLine().ToUpper();
                if (clientToInsert.DNI != "0" && clientToInsert.DNI.Length == 9 /*&& !HpClients.ClientExist(myDB, clientToInsert.DNI)*/)
                {
                    break;
                }
                else
                {
                    if (clientToInsert.DNI == "0")
                    {
                        Console.WriteLine("ERROR -> El DNI del cliente no puede ser Cero (0)", Color.Red);
                    }
                    else if (clientToInsert.DNI.Length != 9)
                    {
                        Console.WriteLine("ERROR -> El DNI del cliente debe contener 9 caracteres", Color.Red);
                    }
                    else
                    {
                        Console.WriteLine("ERROR -> El cliente Ya existe en la BD. Intente con otro DNI", Color.Red);
                        Menu.WriteContinue();
                    }
                }
            } while (true);

            //TODO: Este If se puede eliminar, ya que si llega aqui es porque evaluó esta condicion en el While
            if (clientToInsert.DNI != "0" && clientToInsert.DNI.Length == 9 && !HpClients.ClientExist(myDB, clientToInsert.DNI))
            {
                Console.Write("Name: ");
                clientToInsert.Name = Console.ReadLine();
                Console.Write("Last Name: ");
                clientToInsert.LastName = Console.ReadLine();
                Console.Write("BirtDate: ");
                clientToInsert.Birthdate = DateTime.Parse(Console.ReadLine());
                Console.Write("email: ");
                clientToInsert.email = Console.ReadLine();
                Console.Write("Password: ");
                clientToInsert.pass = Console.ReadLine();
            }
            return(clientToInsert);
        }
Exemple #2
0
        public static string[] PrintLogInMenu(SQLDBConnection myDB)
        {
            ColorAlternatorFactory alternatorFactory = new ColorAlternatorFactory();
            ColorAlternator        alternator        = alternatorFactory.GetAlternator(1, Color.Aqua, Color.Aquamarine);

            string[] userAndPass = new string[3];
            bool     exist;

            Console.Clear();
            //Console.WriteLine("SISTEMA RESERVA DE HOTEL BBKBOOTCAMP 2020 (6ta Edición)\n");
            HpVarious.WriteArt(APP_NAME);
            Console.WriteAlternating("Bienvenido, deberá contar con un usuario válido para acceder a las opciones del aplicativo\n\n", alternator);
            do
            {
                Console.WriteAlternating("Nombre Usuario (DNI): ", alternator);
                userAndPass[0] = Console.ReadLine();
                exist          = HpClients.ClientExist(myDB, userAndPass[0]);
                if (!exist)
                {
                    Console.WriteLine("ERROR. Usuario no existe. Indique un usuario válido!!!\n", Color.Red);
                }
            } while (!exist);

            do
            {
                Console.WriteAlternating("Contraseña: ", alternator);
                userAndPass[1] = HpVarious.ReadPassWord();
                exist          = HpClients.ClientPasswordExist(myDB, userAndPass);
                if (!exist)
                {
                    Console.WriteLine("\t\tERROR. Password Incorrecto. Introduzca nuevamente la contraseña", Color.Red);
                }
                else
                {
                    userAndPass[2] = "true";
                }
            } while (!exist);

            return(userAndPass);
        }