Exemplo n.º 1
0
        private void tsPoblarBaseDatos_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show(this, "¿Seguro que quiere poblar la base de datos?", "Insercion de datos", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    // service.removeAllData();
                    service.RegisterUser(DateTime.Now.AddYears(-20), "1562738A", "*****@*****.**", "Andrea Villalba", 671299400, 344, DateTime.Now.AddYears(2), "andrea", 12345678, "hola");
                    service.RegisterUser(DateTime.Now.AddYears(-20), "1562338A", "*****@*****.**", "Ana Villalba", 67123400, 544, DateTime.Now.AddYears(3), "ana", 12345638, "hola");
                    service.RegisterEmployee(DateTime.Now.AddYears(-25), "12341234A", "*****@*****.**", "Juan Gonzalez", 635289102, "ES6621000418401234567891", 1234, "manager", 1200);
                    service.RegisterEmployee(DateTime.Now.AddYears(-25), "11111111A", "*****@*****.**", "Joaquin Gonzalez", 625289102, "ES6621033418401234567891", 1234, "manager", 1200);

                    MessageBox.Show(this, "Base de datos poblada con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                MessageBox.Show(this, "Ya has poblado anteriormente la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void cmdRegistroUsuario_Click(object sender, EventArgs e)

        {
            try
            {
                service.RegisterUser(dateBirth.Value, txtDNI.Text, txtEmail.Text, txtNombre.Text, Convert.ToInt32(txtTelephon.Text.Replace(" ", "")),
                                     Convert.ToInt32(txtCVV.Text), dateExpiration.Value, txtLogin.Text, Convert.ToInt32(txtCardNumber.Text.Replace(" - ", "")), txtPassword.Text);
                MessageBox.Show(this, "Registro exitoso", "Bienvenido", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
                formInicioSesion formInicioSesion = new formInicioSesion(service);
                formInicioSesion.Show();
            }
            catch (ServiceException serviceException)
            {
                MessageBox.Show(this, serviceException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }