Example #1
0
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryGroup();
            pagepara.OrderBy = "group_id";

            gvGroup.DataSource = xsPageHelper.BindPager(pagepara, e);
            gvGroup.DataBind();
        }
        /// <summary>
        /// 设置翻页
        /// </summary>
        /// <param name="gotoPage"></param>
        protected virtual void OnPageChanged(int gotoPage)
        {
            PageChangedEventArgs e = new PageChangedEventArgs(gotoPage);

            if (this.PageChanged != null)
            {
                PageChanged(this, e);

                CurrentPage = gotoPage;

                if (TotalPage < CurrentPage)
                { //删除的特殊情况
                    OnPageChanged(TotalPage);
                }
            }
        }
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryProducts(ddlType.SelectedValue, txtName.Text);
            pagepara.OrderBy = "product_id";

            DataTable dt = xsPageHelper.BindPager(pagepara, e);

            Nodata.Visible = false;
            if (dt.Rows.Count == 0)
            {
                Nodata.Visible = true;
            }

            rptProduct.DataSource = dt;
            rptProduct.DataBind();
        }
Example #4
0
        public static DataTable BindPager(PagerParameter pagePara, PageChangedEventArgs e)
        {
            #region datasafe
            if (pagePara.OrderBy.Length == 0)
            {
                throw new Exception(" must set groupby!");
            }

            #endregion

            //data sum count
            string         strCount = "select Count(*) from (" + pagePara.Sql + ")T";
            xsSqlParameter sqlpara  = new xsSqlParameter();
            sqlpara.SQL = strCount;
            sqlpara.SqlConnectString = pagePara.DbConn;
            DataTable dtCount   = SqlHelper.GetDataTable(sqlpara);
            int       DataCount = Convert.ToInt32(dtCount.Rows[0][0]);
            pagePara.XsPager.TotalCount = DataCount;//set total count
            if (DataCount <= 0)
            {
                return(new DataTable());
            }


            int pageSize = pagePara.XsPager.PageSize;

            pageSize = pageSize <= 0 ? 10 : pageSize;


            StringBuilder sbPageSql = new StringBuilder();
            sbPageSql.Append("SELECT * FROM(");
            sbPageSql.Append("SELECT *,ROW_NUMBER() OVER(ORDER BY " + pagePara.OrderBy + ") PID FROM (");
            sbPageSql.Append(pagePara.Sql);
            sbPageSql.Append(")Tsql )T WHERE PID between ");
            sbPageSql.Append(((e.CurrentPage - 1) * pageSize + 1).ToString());
            sbPageSql.Append(" AND ");
            sbPageSql.Append((e.CurrentPage - 1) * pageSize + pageSize);

            sqlpara.SQL = sbPageSql.ToString();
            return(SqlHelper.GetDataTable(sqlpara));
        }
Example #5
0
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryLeave();
            pagepara.OrderBy = "leave_time";
            DataTable dt = xsPageHelper.BindPager(pagepara, e);

            NoData.Visible = false;
            if (dt.Rows.Count == 0)
            {
                NoData.Visible = true;
            }
            else
            {
                rptLeave.DataSource = dt;
                rptLeave.DataBind();
            }
        }