コード例 #1
0
ファイル: listdept.aspx.cs プロジェクト: Marveliu/erp
        /// <summary>
        /// 模拟数据库分页
        /// </summary>
        /// <returns></returns>
        private DataTable GetPagedDataTable1()
        {
            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            int pageIndex = Grid1.PageIndex;
            int pageSize  = Grid1.PageSize;

            string sortField     = Grid1.SortField;
            string sortDirection = Grid1.SortDirection;

            DataTable table3 = bll.GetList("").Tables[0];

            DataView view3 = table3.DefaultView;

            view3.Sort = String.Format("{0} {1}", sortField, sortDirection);

            DataTable table = view3.ToTable();

            DataTable paged = table.Clone();

            int rowbegin = pageIndex * pageSize;
            int rowend   = (pageIndex + 1) * pageSize;

            if (rowend > table.Rows.Count)
            {
                rowend = table.Rows.Count;
            }

            for (int i = rowbegin; i < rowend; i++)
            {
                paged.ImportRow(table.Rows[i]);
            }

            return(paged);
        }
コード例 #2
0
        /// <summary>
        /// 模拟数据库分页
        /// </summary>
        /// <returns></returns>
        private DataTable GetPagedDataTable(int pageIndex, int pageSize)
        {
            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();
            DataTable source = bll.GetList("").Tables[0];

            DataTable paged = source.Clone();

            int rowbegin = pageIndex * pageSize;
            int rowend   = (pageIndex + 1) * pageSize;

            if (rowend > source.Rows.Count)
            {
                rowend = source.Rows.Count;
            }

            for (int i = rowbegin; i < rowend; i++)
            {
                paged.ImportRow(source.Rows[i]);
            }

            return(paged);
        }
コード例 #3
0
 /// <summary>
 /// 模拟返回总项数
 /// </summary>
 /// <returns></returns>
 private int GetTotalCount()
 {
     Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();
     return(bll.GetList("").Tables[0].Rows.Count);
 }