码迷,mamicode.com
首页 > 其他好文 > 详细

DAL分页显示

时间:2018-07-29 21:11:54      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:dal   ndt   EDA   help   cut   com   params   set   command   

 public Pages<stuclass> GetStudetPage(PageParams pagePar)
        {
            int size = pagePar.PageSize;
            string sql = "[dbo].[p_paging]";
            SqlParameter[] par = new SqlParameter[]
                {
                new SqlParameter("@tableName", pagePar.TableName),
                new SqlParameter("@indexCol", pagePar.IndexCol),
                new SqlParameter("@pageSize", pagePar.PageSize),
                new SqlParameter("@pageIndex", pagePar.PageIndex),
                new SqlParameter("@orderCol", pagePar.OrderCol),
                new SqlParameter("@where", pagePar.Where),
                new SqlParameter("@columns", pagePar.Columns)
                };
            DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, sql, par);
            DataTable dt = ds.Tables[0];
            int count =Convert.ToInt32( ds.Tables[1].Rows[0] [0]);
            Pages<stuclass> pagse = new Pages<stuclass>();
            pagse.list = JsonConvert.DeserializeObject<List<stuclass>>(JsonConvert.SerializeObject(dt));
            pagse.SumCount = count;
            pagse.SumPage = (count % size > 0 ? ((count / size) + 1) : (count / size));
            return pagse;
        }

DAL分页显示

标签:dal   ndt   EDA   help   cut   com   params   set   command   

原文地址:https://www.cnblogs.com/fsl123/p/9387581.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!