Example #1
0
        // Registrar un cliente
        protected void btRegister_Click(object sender, EventArgs e)
        {
            try
            {
                Cliente registrar = new Cliente();

                if (inputPassword.Value == inputPasswordRepeat.Value)     //Verificamos error en la contraseƱa
                {
                    registrar.Nombre   = inputUsername.Value;
                    registrar.Apellido = inputApellido.Value;
                    byte[] stringAByte = System.Text.ASCIIEncoding.ASCII.GetBytes(inputPassword.Value);
                    string contrasenia = Convert.ToBase64String(stringAByte);

                    registrar.Contrasenia   = contrasenia;
                    registrar.Documento     = Convert.ToInt32(inputDocumento.Value);
                    registrar.UsuarioNombre = inputEmail.Value;
                    registrar.Tarjeta       = Convert.ToInt64(inputTarjeta.Value);
                    registrar.Calle         = inputCalle.Value;
                    registrar.Puerta        = inputPuerta.Value;

                    int resultado = LogicaUsuario.AgregarC(registrar);

                    if (resultado == -1)
                    {
                        lbError.Text = "El documento y nombre de logueo deben ser unicos..";
                    }

                    else if (resultado == 2)
                    {
                        lbError.Text = "Se ha registrado correctamente";
                        Response.Redirect("Default.aspx");
                    }

                    else
                    {
                        lbError.Text = resultado.ToString();
                    }
                }

                else
                {
                    lbError.Text = "La contraseƱa debe coicidir".ToString();
                }
            }

            catch (Exception ex)
            {
                lbError.Text = ex.Message;
            }
        }