コード例 #1
0
    private void BindGridView(int index, string table, int pageSize, string where, string column, string order)
    {
        DataTable dt      = p.GetList(index, table, pageSize, where, column, order).Tables[0];
        int       dtcount = dt.Rows.Count;

        xgvPerson.DataSource = dt;
        xgvPerson.DataBind();
        AspNetPager1.RecordCount     = p.PersonCount();
        AspNetPager1.PageSize        = pageSize;
        AspNetPager1.CustomInfoHTML  = "记录总数:<font color=\"blue\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>";
        AspNetPager1.CustomInfoHTML += " 总页数:<font color=\"blue\"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>";
        AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!SessionBox.CheckUserSession())
            {
                Response.Redirect("~/Login.aspx");
            }
            else
            {
                SF_Role r = Rolebll.GetRoleModel(decimal.Parse(SessionBox.GetUserSession().CurrentRole[0].ToString().Split(',')[0]));
                rolelevel            = (int)r.LevelID;
                Session["rolelevel"] = r.LevelID;
                maindeptid           = SessionBox.GetUserSession().DeptNumber;
                switch ((int)rolelevel)
                {
                case 0:
                    BindGridView(0, "PERSON", _pageSize, "", "", "");
                    AspNetPager1.RecordCount = p.PersonCount();
                    BindDll(ddlDept, "ID", @"24\d\d0{5}", "NAME", "ID");
                    break;

                case 1:
                    BindGridView(0, "PERSON", _pageSize, "", "", "");
                    AspNetPager1.RecordCount = p.PersonCount();
                    BindDll(ddlDept, "ID", @"24\d\d0{5}", "NAME", "ID");
                    break;

                case 2:
                    BindGridView(0, "PERSON", _pageSize, string.Format("maindeptid='{0}'", SessionBox.GetUserSession().DeptNumber), "", "");
                    AspNetPager1.RecordCount = p.PersonCount();
                    BindDll(ddlDept, "ID", @"24\d\d0{5}", "NAME", "ID");
                    ddlDept.SelectedValue = SessionBox.GetUserSession().DeptNumber;
                    BindDll(ddlKQ, "ID", ddlDept.SelectedItem.Value.Remove(4), "NAME", "ID");
                    ddlKQ.Items.Insert(0, new ListItem("--全部--", "-1"));
                    ddlDept.Enabled = false;
                    break;

                default:
                    BindGridView(0, "PERSON", _pageSize, string.Format("maindeptid='{0}'", SessionBox.GetUserSession().DeptNumber), "", "");
                    AspNetPager1.RecordCount = p.PersonCount();
                    BindDll(ddlDept, "ID", @"24\d\d0{5}", "NAME", "ID");
                    ddlDept.SelectedValue = SessionBox.GetUserSession().DeptNumber;
                    BindDll(ddlKQ, "ID", ddlDept.SelectedItem.Value.Remove(4), "NAME", "ID");
                    ddlKQ.Items.Insert(0, new ListItem("--全部--", "-1"));
                    ddlDept.Enabled = false;
                    break;
                }

                //初始化模块权限
                UserHandle.InitModule(this.PageTag);
                //是否有浏览权限
                if (UserHandle.ValidationHandle(PermissionTag.Browse))
                {
                    GridViewCommandColumn colEdit = (GridViewCommandColumn)gvPerson.Columns["操作"];
                    if (!UserHandle.ValidationHandle(PermissionTag.Edit))
                    {
                        colEdit.EditButton.Visible = false;
                    }
                }
            }
        }
        //adsPosition.Where = "Maindeptid == \"" + SessionBox.GetUserSession().DeptNumber + "\"";
        //adsDept.Where = "Deptnumber.StartsWith(\"" + SessionBox.GetUserSession().DeptNumber.Remove(4) + "\")";
    }