private void addUser()
        {
            try
            {
                String   nombre      = txt_nombre.Text;                //nombre
                String   dni         = txt_dni.Text;                   //dni
                DateTime fechaNac    = txt_fechaNacimiento.Value.Date; //fechaNac
                String   cvv         = txt_cvv.Text;
                int      tarjetaCvv  = Convert.ToInt32(cvv);           //Cvv
                int      telefonoInt = Convert.ToInt32(txt_telefono.Text);

                //String telefono = txt_telefono.Text;
                //int telefonoInt = int.Parse(telefono);  //telefono

                String   email            = txt_correo.Text;               //email
                DateTime fechaCaducidad   = txt_fechaCaducidad.Value.Date; //caducidad de la tarjeta
                String   contraseña       = txt_contraseña.Text;           //password
                int      numeroTarjetaInt = Convert.ToInt32(txt_tarjetaCredito.Text);

                //String numeroTarjeta = txt_tarjetaCredito.Text;
                //int numeroTarjetaInt = int.Parse(numeroTarjeta);  //numero tarjeta

                String login = txt_login.Text;  //login
                User   u1    = new User(fechaNac, dni, email, nombre, telefonoInt, tarjetaCvv, fechaCaducidad, login, numeroTarjetaInt, contraseña);
                service.registerUser(u1);
                service.saveChanges();
            }
            catch (ServiceException ex)
            { MessageBox.Show(ex.Message); }
        }
예제 #2
0
        void addUsers()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING USERS...");

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/2001"), "11111111A", "*****@*****.**", "First User", 606123123, 123, Convert.ToDateTime("01/01/2025"), "user1", 12345678, "user1");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/2010"), "22222222B", "*****@*****.**", "Second User", 605321321, 321, Convert.ToDateTime("01/01/2025"), "user2", 12345679, "user2");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/2000"), "33333333B", "*****@*****.**", "Third User", 604321321, 321, Convert.ToDateTime("01/01/2025"), "user1", 12345670, "user3");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/2001"), "44444444A", "*****@*****.**", "Fourth User", 606456123, 133, Convert.ToDateTime("31/10/2019"), "user4", 15345678, "user4");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/1989"), "55555555A", "*****@*****.**", "Fifth User", 608123888, 123, Convert.ToDateTime("01/01/2025"), "user5", 12435678, "user5");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/1989"), "66666666A", "*****@*****.**", "Sixth User", 606666888, 623, Convert.ToDateTime("01/01/2024"), "user6", 12466676, "user6");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // public User(DateTime birthDate, String dni, String email, String name, int telephon, int cvv, DateTime expirationDate, string login, int number, string password)
                User u1 = new User(Convert.ToDateTime("01/01/1988"), "77777777G", "*****@*****.**", "Seventh User", 606677888, 627, Convert.ToDateTime("01/01/2023"), "user7", 17467676, "user7");
                service.registerUser(u1);
            }
            catch (Exception e)
            {
                printError(e);
            }

            foreach (User u in service.getAllUsers())
            {
                Console.WriteLine(userToString(u));
            }
        }