コード例 #1
0
        protected void grdListadoUsuarios_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ControladorBLL objControlador = new ControladorBLL();

            string email  = e.CommandArgument.ToString();
            string accion = e.CommandName.ToString();

            UsuarioBEL objUsuarioBEL = objControlador.getUsuarioPorEmail(email);

            switch (accion)
            {
            case "Modificar":
                Response.Redirect("/vistas/SignUp.aspx?email=" + objUsuarioBEL.Email);
                break;

            case "Eliminar":
                bool eliminado = objControlador.eliminarUsuario(email);

                if (eliminado)
                {
                    Response.Redirect("/vistas/ListadoUsuarios.aspx?alert=usuario_eliminado");
                }
                else
                {
                    Response.Redirect("/vistas/ListadoUsuarios?alert=usuario_no_eliminado");
                }

                break;

            default:
                return;
            }
        }
コード例 #2
0
        private void cargarGrillaUsuarios()
        {
            ControladorBLL objControlador = new ControladorBLL();

            grdListadoUsuarios.DataSource = objControlador.listarUsuarios();
            grdListadoUsuarios.DataBind();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.txtEmail.Enabled = true;
                // es get
                lblMsg.Text    = "";
                lblMsg.Visible = false;
                string email = Request.Params["email"];

                if (email != null && email.Length > 0)
                {
                    //Asumo que estoy editando al usuario, lleno todos los datos previamente
                    ControladorBLL controlador   = new ControladorBLL();
                    UsuarioBEL     objUsuarioBEL = controlador.getUsuarioPorEmail(email);

                    if (objUsuarioBEL != null)
                    {
                        //rellener el formulario
                        this.txtNombre.Text   = objUsuarioBEL.Nombre;
                        this.txtApellido.Text = objUsuarioBEL.Apellido;
                        this.txtTelefono.Text = objUsuarioBEL.Telefono;
                        this.txtRut.Text      = objUsuarioBEL.Rut;
                        this.txtTurno.Text    = objUsuarioBEL.Turno;
                        this.txtEmail.Text    = objUsuarioBEL.Email;
                        this.txtPass.Text     = objUsuarioBEL.Password;
                        this.txtEmail.Enabled = false;
                    }
                }
            }
        }
コード例 #4
0
        protected void btnCrearCuenta_Click(object sender, EventArgs e)
        {
            try
            {
                string nom         = this.txtNombre.Text;
                string ape         = this.txtApellido.Text;
                string fono        = this.txtTelefono.Text;
                string rut         = this.txtRut.Text;
                string turno       = this.txtTurno.Text;
                string tipoUsuario = this.ddlTipoUsuario.SelectedItem.Text;
                string emial       = this.txtEmail.Text;
                string pass        = txtPass.Text;

                if (nom == string.Empty || ape == string.Empty || fono == string.Empty ||
                    rut == string.Empty || turno == string.Empty || emial == string.Empty || pass == string.Empty)
                {
                    lblMsg.Text    = "*No puede haber campos vacíos!";
                    lblMsg.Visible = true;
                    return;
                }


                UsuarioBEL objUsu = new UsuarioBEL {
                    Nombre       = nom,
                    Apellido     = ape,
                    Telefono     = fono,
                    Rut          = rut,
                    Turno        = turno,
                    Tipo_Usuario = tipoUsuario,
                    Email        = emial,
                    Password     = pass,
                };

                ControladorBLL objControl = new ControladorBLL();

                bool creacionExitosa = objControl.insertarUsuario(objUsu);

                if (!creacionExitosa)
                {
                    Response.Redirect("SignUp.aspx?alert=usuario_ya_existe");
                }

                Response.Redirect("Login.aspx?alert=usuario_creado");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = string.Format("Error al crear UsuarioBEL {0} ", ex.Message);
                return;
            }
        }
コード例 #5
0
        protected void btnEditar_Click(object sender, EventArgs e)
        {
            string nom         = this.txtNombre.Text;
            string ape         = this.txtApellido.Text;
            string fono        = this.txtTelefono.Text;
            string rut         = this.txtRut.Text;
            string turno       = this.txtTurno.Text;
            string tipoUsuario = this.ddlTipoUsuario.SelectedItem.Text;
            string emial       = this.txtEmail.Text;
            string pass        = txtPass.Text;

            if (nom == string.Empty || ape == string.Empty || fono == string.Empty ||
                rut == string.Empty || turno == string.Empty || emial == string.Empty || pass == string.Empty)
            {
                lblMsg.Text    = "*No puede haber campos vacíos!";
                lblMsg.Visible = true;
                return;
            }


            UsuarioBEL objUsu = new UsuarioBEL
            {
                Nombre       = nom,
                Apellido     = ape,
                Telefono     = fono,
                Rut          = rut,
                Turno        = turno,
                Tipo_Usuario = tipoUsuario,
                Email        = emial,
                Password     = pass,
            };

            ControladorBLL objControl = new ControladorBLL();

            string emailInicial         = Request.Params["email"];
            bool   actualizacionExitosa = objControl.editarUsuario(emailInicial, objUsu);

            if (actualizacionExitosa)
            {
                Response.Redirect("/vistas/ListadoUsuarios.aspx?alert=usuario_editado");
            }
            else
            {
                Response.Redirect("/vistas/ListadoUsuarios.aspx?alert=usuario_no_editado");
            }
        }
コード例 #6
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            string         email       = txtUsername.Text;
            string         password    = txtPassword.Text;
            ControladorBLL controlador = new ControladorBLL();

            UsuarioBEL objUsuarioBEL = controlador.validarLogin(email, password);

            if (email.Length == 0 || password.Length == 0)
            {
                Response.Redirect("/vistas/Login.aspx?alert=empty_fields", false);
            }
            else if (objUsuarioBEL == null)
            {
                Response.Redirect("/vistas/Login.aspx?alert=wrong_credentials", false);
            }
            else
            {
                Session["estadoLogin"] = "******";
                Response.Redirect("/vistas/ListadoUsuarios.aspx?alert=success");
            }
        }