Exemplo n.º 1
0
 protected void btnDepartment_Click(object sender, EventArgs e)
 {
     //this sets all buttons to secondary and makes this one primary to show its selected.
     Session["tab"] = "dept";
     clearButtons();
     btnDepartment.CssClass  = "tabSelected leftMenuButton";
     accordContent.InnerHtml = CompanyDepartment.getDepartmentsForLeftMenu();
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //this defaults to false because we should assume people are not allowed in.
        btnAdmin.Visible = false;
        try
        {
            //this makes sure the ticket they have is vaild
            if (!Request.IsAuthenticated)
            {
                //if ticket not vaild goto login.
                Response.Redirect("~/login.aspx");
            }
            //this decrpyts the ticket in order to retrive the userId and Role.
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies["mysite.ASPXAUTH"].Value);
            //this makes sure the user is still allowed on the website.
            if (!SystemUser.userVaildCheck(Int32.Parse(ticket.Name), Session["key"].ToString()))
            {
                //if not allowed goto login.
                Response.Redirect("~/login.aspx");
            }
            //this gets the user role out of ticket.
            int userRole = Int32.Parse(ticket.UserData);
            //check to see if admin tab should be shown
            if (userRole == 1 || userRole == 4)
            {
                //shows tab
                btnAdmin.Visible = true;
            }
            //puts the persons name on screen...makes them feel like a person....not a number i guess.
            menuPersonName.InnerText = Request.Cookies["name"].Value;
        }
        catch (Exception ex)
        {
            //if anything goes wrong here i assume they are not allowed and force them to login.
            Response.Redirect("~/login.aspx");
        }
        clearButtons();
        //this bit of code. gets the session that remembers what tab you were on between pages.
        //its almost like we care about people...
        //the only 3 options for this
        // dept
        // staff
        // admin
        switch (Session["tab"].ToString())
        {
        case "dept":
            btnDepartment.CssClass  = "tabSelected leftMenuButton";
            accordContent.InnerHtml = CompanyDepartment.getDepartmentsForLeftMenu();
            break;

        case "staff":
            btnStaff.CssClass       = "tabSelected leftMenuButton leftMenuButtonMoveLeft";
            accordContent.InnerHtml = CompanyStaffMember.getStaffMembersForLeftMenu();
            break;

        case "admin":
            btnAdmin.CssClass       = "tabSelected leftMenuButton leftMenuButtonMoveLeft";
            accordContent.InnerHtml = SystemMethods.adminLeftMenu();
            break;
        }
    }