using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace POSV.Utils
{
///
/// List分页
///
///
public class ListPager : List
{
///
/// 总记录
///
public int TotalCount { get; set; }
///
/// 总页数
///
public int PageCount { get; set; } //总页数
///
/// 当前页码
///
public int PageNumber { get; set; }
///
/// 每页显示记录数
///
public int PageSize { get; set; } //每页显示记录数
//是否有上一页
public bool HasPreviousPage
{
get { return PageNumber > 1; }
}
//是否有下一页
public bool HasNextPage
{
get { return PageNumber < this.PageCount; }
}
///
/// 构造方法
///
///
///
///
public ListPager(List data , int pageSize , int pageNumber)
{
this.PageSize = pageSize;
this.PageNumber = pageNumber;
this.TotalCount = data.Count;
this.PageCount = (this.TotalCount + this.PageSize - 1) / this.PageSize;
this.AddRange(data.Skip((pageNumber - 1) * pageSize).Take(pageSize));
}
}
}