Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // ***** ESTADO DEL SERVIDOR WEB ******
        Boolean _AccesoWeb = _G._Get_Estado_Servidor();

        if (!_AccesoWeb)
        {
            Response.Redirect("Mantenedores/MantencionServidor.aspx");
            return;
        }

        //Valida si el usuario logeado se o no admin
        if ((String)Session["Rut"] == null || (String)Session["Rut"] == "")
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            Boolean _Admin = _U._Get_Admin((String)Session["Rut"]);
            if (!_Admin)
            {
                Response.Redirect("Menu.aspx");
                return;
            }
        }

        lbl_session.Text = (String)Session["Usuario"];

        try
        {
            String _Id = _U._Get_Id_Pagina(Request.Url.Segments[Request.Url.Segments.Length - 1]);
            _G._Set_Insert_Logs(Session["Id_Usuario"].ToString(), DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), "SELECCION VISTA", _Id, "", "");
        }
        catch (Exception) { }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // ***** ESTADO DEL SERVIDOR WEB ******
        Boolean _AccesoWeb = _G._Get_Estado_Servidor();

        if (!_AccesoWeb)
        {
            Response.Redirect("Mantenedores/MantencionServidor.aspx");
            return;
        }

        if (!IsPostBack)
        {
            //Valida si el usuario logeado se o no admin
            if ((String)Session["Rut"] == null || (String)Session["Rut"] == "")
            {
                Response.Redirect("~/Login.aspx");
            }
            else
            {
                Boolean _Admin = _U._Get_Admin((String)Session["Rut"]);
                if (!_Admin)
                {
                    Response.Redirect("~/Menu.aspx");
                    return;
                }
            }

            lbl_session.Text = (String)Session["Usuario"];

            DataSet _Ds_Coordinador = _U._Get_Todos_Usuarios();
            if (_Ds_Coordinador.Tables[0].Rows.Count > 0)
            {
                cbo_usuario.DataSource     = _Ds_Coordinador.Tables[0];
                cbo_usuario.DataValueField = _Ds_Coordinador.Tables[0].Columns[1].ToString();
                cbo_usuario.DataTextField  = _Ds_Coordinador.Tables[0].Columns[0].ToString();
                cbo_usuario.DataBind();
            }
        }
    }
Пример #3
0
    protected void btn_login_Click1(object sender, EventArgs e)
    {
        int _Estado = _G._Login(txt_user.Text, txt_pass.Text);

        if (_Estado == 1)
        {
            Response.Cache.SetExpires(DateTime.Now.AddMinutes(60));
            Session["Id_Usuario"] = _G._Get_Id_User(txt_user.Text);
            Session["Usuario"]    = _G._Get_Nombre_Usuario(txt_user.Text);
            Session["Rut"]        = txt_user.Text;

            try
            {
                String _Id = _U._Get_Id_Pagina(Request.Url.Segments[Request.Url.Segments.Length - 1]);
                _G._Set_Insert_Logs(Session["Id_Usuario"].ToString(), DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), "LOGIN", _Id, "", "");
            }
            catch (Exception) { }

            FormsAuthentication.SetAuthCookie(txt_user.Text, true);
            try
            {
                //**** USUARIO ADMIN *****
                Boolean _Admin = _U._Get_Admin(Session["Rut"].ToString());
                if (_Admin)
                {
                    Response.Redirect("MenuAdmin.aspx", false);
                    return;
                }

                String _Url = Request.UrlReferrer.ToString();
                int    B    = _Url.IndexOf("?ReturnUrl");
                if (B != -1)
                {
                    _Url = _Url.Substring(B + 10);
                    _Url = _Url.Replace("=/Site_Supi_Master/", "");
                    _Url = _Url.Replace("=/", "");
                    if (_Url == "")
                    {
                        Response.Redirect("Menu.aspx", false);
                    }
                    else
                    {
                        Response.Redirect(_Url, false);
                    }
                }
                else
                {
                    Response.Redirect("Menu.aspx", false);
                }
            }
            catch (Exception)
            {
                Response.Redirect("Menu.aspx", false);
            }
        }
        else if (_Estado == 4)
        {
            //Usuario Inahibilato..
            Response.Cache.SetExpires(DateTime.Now.AddMinutes(60));
            Session["Id_Usuario"] = _G._Get_Id_User(txt_user.Text);
            Session["Usuario"]    = _G._Get_Nombre_Usuario(txt_user.Text);
            Session["Rut"]        = txt_user.Text;

            try
            {
                String _Id = _U._Get_Id_Pagina(Request.Url.Segments[Request.Url.Segments.Length - 1]);
                _G._Set_Insert_Logs(Session["Id_Usuario"].ToString(), DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), "LOGIN", _Id, "", "");
            }catch (Exception) { }

            FormsAuthentication.SetAuthCookie(txt_user.Text, true);
            Response.Redirect("SinAcceso.aspx", false);
        }
        else if (_Estado == 3)
        {
            //Error de servidor...
            Response.Cookies.Clear();
            lbl_error.Text    = "No se puede conectar con el servidor";
            lbl_error.Visible = true;
            ClientScript.RegisterStartupScript(this.GetType(), "Acceso", "swal('Error de RED', 'No se puede conectar con el servidor', 'error');", true);
        }
        else if (_Estado == 2)
        {
            //Usuario No existe...
            Response.Cookies.Clear();
            lbl_error.Text = "El usuario o contraseña no son validos";
            ClientScript.RegisterStartupScript(this.GetType(), "Acceso", "swal('Usuario no valido', 'El usuario o contraseña no son validos', 'error');", true);
            lbl_error.Visible = true;
        }
    }