示例#1
0
    private string USERID()
    {
        // Извлекаем куку с аутентификационными данными
        HttpCookie cookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];

        // Дешифруем ее в тикет
        FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);

        // Создаем пользовательский контекст
        FormsIdentity identity = new FormsIdentity(ticket);


        //System.Security.Principal.GenericPrincipal principal = new System.Security.Principal.GenericPrincipal(identity, new string[] { AuthCookieParce.UserID(identity.Name).ToString() });
        return(AuthCookieParce.UserID(identity.Name).ToString());
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string name = "";

        if (Context.Request.Cookies[FormsAuthentication.FormsCookieName] != null)
        {
            HttpCookie cookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket   = FormsAuthentication.Decrypt(cookie.Value);
            FormsIdentity             identity = new FormsIdentity(ticket);
            name = AuthCookieParce.UserFIO(identity.Name);
        }
        else
        {
            Response.Redirect("Default.aspx");
            return;
        }
        if (name != "")
        {
            welcome_lb.Text = string.Format("<marquee loop='1' behavior='slide' direction='left' style='color:#00aa00'>Добро пожаловать, {0}</marquee>", name);
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;
        int a = 0;

        if (Context.Request.Cookies[FormsAuthentication.FormsCookieName] != null)
        {
            HttpCookie cookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket   = FormsAuthentication.Decrypt(cookie.Value);
            FormsIdentity             identity = new FormsIdentity(ticket);
            i = AuthCookieParce.UserID(identity.Name);
            a = AuthCookieParce.UserRoleID(identity.Name);
        }
        else
        {
            Response.Redirect("Default.aspx");
            return;
        }

        Error1_lb.Text      = "";
        Error1_lb.ForeColor = Color.Red;
        Error2_lb.Text      = "";
        Error2_lb.ForeColor = Color.Red;



        Categories_sds.ConnectionString = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
        Categories_sds.SelectCommand    = "SELECT ID, NAME FROM CATEGORIES WHERE ACTIVE='TRUE'";

        Clients_sds.ConnectionString = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
        Clients_sds.SelectCommand    = "SELECT ID, SURNAME+' '+NAME AS FIO FROM CUSTOMERS WHERE ACTIVE='TRUE'";

        Admingrid_sds.ConnectionString = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
        Admingrid_sds.SelectCommand    = @"SELECT P.ID AS ID, P.SERIAL AS SERIAL, C.SURNAME+' '+C.NAME AS INITIALS, CA.NAME AS CATEGORYNAME, P.DATESOLD AS DATESOLD, P.PRICE AS PRICE FROM CATEGORIES CA, CUSTOMERS C, PRODUCTS P
                                         WHERE  P.CUSTOMERSID=C.ID AND P.CATEGORIESID=CA.ID AND C.ACTIVE='TRUE' AND CA.ACTIVE='TRUE' AND P.ACTIVE='TRUE'";

        Admin_grid.DataSourceID  = "Admingrid_sds";
        Admin_grid.EmptyDataText = "Ни одной продажи";



        Clientsgrid_sds.ConnectionString = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
        Clientsgrid_sds.SelectCommand    = @"SELECT P.ID AS ID, C.SURNAME+' '+C.NAME AS INITIALS, C.PHONE, CA.NAME AS CATEGORY, P.MODELNAME,
                    P.DATESOLD, P.TIMESPENT AS TIMESPENT, P.PRICE,  P.SELFPRICECLIENT, P.HEIGHT, P.WEIGHT, 
                    P.VOLTAGE, P.RPM , P.PERFORMANCE,  P.ENGINEPOWER , P.HUMMERS, P.COMMENT 
                    FROM CATEGORIES CA, CUSTOMERS C, PRODUCTS P WHERE  P.CUSTOMERSID=C.ID AND P.CATEGORIESID=CA.ID AND P.ACTIVE='TRUE' AND CA.ACTIVE='TRUE' AND C.ACTIVE='TRUE'";

        Clients_grid.DataSourceID  = "Clientsgrid_sds";
        Clients_grid.EmptyDataText = "Ни одной продажи";



        if (a == 1)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            Panel3.Visible = true;
        }

        else
        {
            Customers_mgmt.Visible = false;
            Users_mgmt.Visible     = false;
            Cat_mgmt.Visible       = false;
            Products_lb.Visible    = false;

            Panel1.Visible = false;
            Panel2.Visible = true;
            Panel3.Visible = false;
        }
    }