Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //LoginUser loginUser = new LoginUser();
            //loginUser.ValidatePageVisitPermission("DivisionSetup");
            //权限验证
            var loginUser = new LoginUser();
            if (!loginUser.userRole.CompanySetup)
            {
                Response.Redirect("../Unauthorize.aspx");
                return;
            }
        }
        catch (Exception exception)
        {
            LPLog.LogMessage(exception.Message);
        }
        if (!IsPostBack)
        {
            BindDivNames();

            string sErrorMsg   = "Failed to load current page: invalid DivisionID.";
            string sReturnPage = "DivisionSetup.aspx";
            if (this.Request.QueryString["DivisionID"] != null) // 如果有GroupID
            {
                string sDivisionID = this.Request.QueryString["DivisionID"].ToString();
                if (PageCommon.IsID(sDivisionID) == false)
                {
                    PageCommon.WriteJsEnd(this, sErrorMsg, "window.location.href='" + sReturnPage + "'");
                }

                this.iDivisionID = Convert.ToInt32(sDivisionID);
                // 设置Selected
            }
            else // 如果没有Division,初始化时
            {
                // 取第一个 Division的ID
                if (ddlDivision.Items.Count > 0)
                {
                    this.iDivisionID = Convert.ToInt32(ddlDivision.Items[0].Value);
                }
            }
            if (!divManager.ExistDivision(iDivisionID))
            {
                return;
            }
            ViewState["divisionid"]        = iDivisionID.ToString();
            this.ddlDivision.SelectedValue = iDivisionID.ToString();
            LoadControls();
        }
        iDivisionID = int.Parse(ViewState["divisionid"].ToString());
    }