예제 #1
0
        protected void btnInicio_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario objUsuario = UsuarioControlador.LogIn(txtEmail.Text, txtContraseña.Text);

                Session["usuario"] = objUsuario;
                string redirect = Request.QueryString["redirect"];
                if (objUsuario.TipoUsuario.nombre == "Administrador")
                {
                    Response.Redirect("principal.aspx");
                }
                else if (objUsuario.TipoUsuario.nombre == "Cliente")
                {
                    if (redirect != string.Empty)
                    {
                        Response.Redirect(redirect);
                    }
                    else
                    {
                        Response.Redirect("index.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "error(\"" + ex.Message + "\");", true);
            }
        }