Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                if (Roles.IsUserInRole("organization"))
                {
                    Session["currentUserRole"] = "organization";
                }
                else if (Roles.IsUserInRole("employee"))
                {
                    Session["currentUserRole"] = "employee";
                }
            }
            //FormsAuthentication.RedirectToLoginPage("~/Account/Login.aspx?r=e");
            try
            {
                Assembly ass = Assembly.Load("App_GlobalResources");
                rm = new ResourceManager("Resources.Resource", ass);
                facade = new BusinessFacade(myConn);
                //Page.Form.DefaultButton = btn_Search.UniqueID;

                if (Request.Params["r"] == "e")
                {
                    btn_CandidateSite.Visible = true;
                    btn_EmployerSite.Visible = false;
                }
                if (Roles.IsUserInRole("Organization"))
                {
                    btn_CandidateSite.Visible = true;
                    btn_EmployerSite.Visible = false;

                    //invi candidate site
                    hpl_SchoolJob.Visible = false;
                    hpl_ExecJob.Visible = false;
                    htlHomeMenu2.Visible = false;
                    hplmyAccountMenu2.Visible = false;
                    HyperLink2.Visible = false;
                    btn_Search.Visible = false;
                    lbl_AvaiJob.Visible = false;
                    hpl_AdvanceSearch.Visible = false;

                    //show emp site
                    hpl_CvSearch.Visible = true;
                    HyperLink1.Visible = true;
                    hpl_em_myAccount.Visible = true;
                    HyperLink3.Visible = true;
                    HyperLink4.Visible = true;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "<script>document.getElementById('li4').style.display = 'none';document.getElementById('li5').style.display = 'none';</script>");
                    //Panel1.Visible = false;
                    btn_Search_Cv.Visible = true;
                    //Other
                    lbl_SearchLabel.Text = rm.GetString("ResumesSearch");
                    //Panel_Gallery.Visible = false;
                    //Panel_PhongBi_emp.Visible = true;
                    int avaiResumes = facade.GetAvaiResumes();
                    lbl_AvaiResumes.Text = avaiResumes + " " + rm.GetString("resumesavailable"); ;
                    lbl_AvaiResumes.Visible = true;
                    hpl_AdvanceSearchCV.Visible = true;
                }

                AvailableJobCount = facade.GetAvailableJobCount();
                lbl_AvaiJob.Text = AvailableJobCount.ToString() + " " + rm.GetString("jobAvai");
                if (!IsPostBack)
                {
                    Page.Header.DataBind();
                }
                repeater_GetOrgType.DataSource = facade.GetAllOrganizationType();
                repeater_GetOrgType.DataBind();
                Repeater_Footer.DataSource = repeater_GetOrgType.DataSource;
                Repeater_Footer.DataBind();
                if (!Session.IsNewSession && !IsPostBack)
                {
                    try
                    {
                        setKeyword(Session["keyword"].ToString());
                        //setCitizenship(Session["citizenship"].ToString());
                    }
                    catch (NullReferenceException)
                    {

                    }
                }

                MasterDataBind();
                //else
                //{
                //ClearSession();
                //}
                //ClearSession();

                if (Roles.IsUserInRole("admin") || Roles.IsUserInRole("superadmin"))
                {
                    hpl_adminsite.Visible = true;
                    hpl_adminsite.Text = "Back end";
                    hpl_adminsite.NavigateUrl = "~/admintj/User.aspx";
                    hpl_TeacherTraining.Visible = true;
                    hpl_List.Visible = true;
                }
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopupScript", "<script>alert('" + ex.Message + "');</script>");
            }
        }