Ejemplo n.º 1
0
        private void BindData()
        {
            #region 权限检查
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }
            AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
            if (user.HasPermissionID(PermId_Modify))
            {
                gridView.Columns[5].Visible = true;
            }
            if (user.HasPermissionID(PermId_Delete))
            {
                gridView.Columns[6].Visible = true;
            }
            #endregion


            Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product();

            string strWhere = "";
            if (Session["strWhereProduct"] != null && Session["strWhereProduct"].ToString() != "")
            {
                strWhere += Session["strWhereProduct"].ToString();
            }
            DataSet ds = new DataSet();
            ds = bll.GetList(strWhere);
            DataView dv = ds.Tables[0].DefaultView;
            gridView.DataSource = dv;
            gridView.DataBind();

            //分页
            int rows_Count   = ds.Tables[0].Rows.Count;
            int page_Size    = gridView.PageSize;
            int page_Count   = gridView.PageCount;
            int page_Current = gridView.PageIndex + 1;

            lblRowsCount.Text   = rows_Count.ToString();
            lblPageCount.Text   = page_Count.ToString();
            lblCurrentPage.Text = page_Current.ToString();


            #region 显示页导航

            btnFirst.Enabled = true;
            btnPrev.Enabled  = true;
            btnNext.Enabled  = true;
            btnLast.Enabled  = true;
            if (gridView.PageIndex == 0)
            {
                btnFirst.Enabled = false;
                btnPrev.Enabled  = false;
                if (gridView.PageCount == 1)
                {
                    btnLast.Enabled = false;
                    btnNext.Enabled = false;
                }
            }
            else if (gridView.PageIndex == gridView.PageCount - 1)
            {
                btnLast.Enabled = false;
                btnNext.Enabled = false;
            }

            #endregion
        }
Ejemplo n.º 2
0
        private void BindData()
        {
            #region Ȩ�޼��
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }
            AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
            if (user.HasPermissionID(PermId_Modify))
            {
                gridView.Columns[5].Visible = true;
            }
            if (user.HasPermissionID(PermId_Delete))
            {
                gridView.Columns[6].Visible = true;
            }
            #endregion

            Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product();

            string strWhere = "";
            if (Session["strWhereProduct"] != null && Session["strWhereProduct"].ToString() != "")
            {
                strWhere += Session["strWhereProduct"].ToString();
            }
            DataSet ds = new DataSet();
            ds = bll.GetList(strWhere);
            DataView dv = ds.Tables[0].DefaultView;
            gridView.DataSource = dv;
            gridView.DataBind();

            //��ҳ
            int rows_Count = ds.Tables[0].Rows.Count;
            int page_Size = gridView.PageSize;
            int page_Count = gridView.PageCount;
            int page_Current = gridView.PageIndex + 1;

            lblRowsCount.Text = rows_Count.ToString();
            lblPageCount.Text = page_Count.ToString();
            lblCurrentPage.Text = page_Current.ToString();

            #region ��ʾҳ����

            btnFirst.Enabled = true;
            btnPrev.Enabled = true;
            btnNext.Enabled = true;
            btnLast.Enabled = true;
            if (gridView.PageIndex == 0)
            {
                btnFirst.Enabled = false;
                btnPrev.Enabled = false;
                if (gridView.PageCount == 1)
                {
                    btnLast.Enabled = false;
                    btnNext.Enabled = false;
                }
            }
            else if (gridView.PageIndex == gridView.PageCount - 1)
            {
                btnLast.Enabled = false;
                btnNext.Enabled = false;
            }

            #endregion
        }