C # paging logic processing class

the System the using; 
the using the System.Collections.Generic; 
the using the System.Linq; 
the using the System.Text; 

namespace the Common 
{ 
    /// <Summary> 
    /// tab logical processing based 
    /// </ Summary> 
    public class PageCollection 
    { 
        /// <Summary> 
        /// pages 
        /// </ Summary> 
        public int {GET TotalPages; SET;} 
        /// <Summary> 
        /// current page 
        /// </ Summary> 
        public int CurrentPage {GET; SET ;} 
        /// <Summary> 
        /// the number of records per 
        /// </ Summary> 
        public int OnePageSize {GET; SET;}  
        /// <summary>
        /// total number of records
        /// </ Summary> 
        public Long totalRows {GET; SET;} 
        /// <Summary> 
        /// sorted 
        /// </ Summary> 
        public String the OrderBy {GET; SET;} 

        /// <Summary> 
        // / default configuration of the maximum number of non-reference 
        /// </ Summary> 
        public PageCollection () 
        { 
            this.CurrentPage = 0; 
            this.OnePageSize = 20 is; // default maximum number of rows 20 
        } 
    } 
    /// <Summary> 
    // / paging logic based processing to entites LINQ 
    /// </ Summary> 
    public class PageInfo <TEntity> WHERE TEntity: class 
    {
        PageInfo public (int index, the pageSize int, int COUNT, List <TEntity> List, String URL = "") 
        { 
            Index = index; 
            the PageSize = the pageSize; 
            the Count = COUNT; 
            List List =; 
            the Url = URL; 
            // calculate stripes number from the beginning to a value of the end of the 
            IF (COUNT == 0) 
            { 
                BeginPage = 0; 
                the EndPage = 0; 
            } 
            the else 
            { 
                int maxPage = COUNT / the pageSize; 

                IF (COUNT% the pageSize> 0) 
                { 
                    maxPage ++;  
                }
                IF (index> = maxPage )
                {
                    index = maxpage;

                    BeginPage = pageSize * index - pageSize + 1;
                    EndPage = count;
                }
                else
                {
                    BeginPage = pageSize * index - pageSize + 1;
                    EndPage = pageSize * index;
                }
            }
        }

        public int Index { get; private set; }
        public int PageSize { get; private set; }
        public int Count { get; private set; }
        public List<TEntity> List { get; set; }
        the Url GET String {public; SET;} 
            }
        public int BeginPage { get; private set; }
        {int the EndPage GET public; Private SET;} 
    } 

    /// <Summary> 
    /// tab logical processing based Dynamic 
    /// </ Summary> 
    public class PageInfo 
    { 
        public PageInfo (int index, the pageSize int, int COUNT, Dynamic List , URL String = "") 
        { 
            index = index; 
            the PageSize = the pageSize; 
            the Count = COUNT; 
            List List =; 
            the Url = URL; 
            // calculate the number of pieces of data values from the start to the end of the 
            IF (COUNT == 0) 
            { 
                BeginPage = 0; 
                the EndPage = 0; 
            the else 
            {
                int maxpage = count / pageSize;

                if (count % pageSize > 0)
                {
                    maxpage++;
                }
                if (index >= maxpage)
                {
                    index = maxpage;

                    BeginPage = pageSize * index - pageSize + 1;
                    EndPage = count;
                }
                else
                {
                    BeginPage = pageSize * index - pageSize + 1;
                    EndPage = pageSize * index;
                }
            }
        }

        public int Index { get; private set; }
        public int PageSize { get; private set; }
        public int Count { get; private set; }
        public dynamic List { get; private set; }
        public string Url { get; set; }
        public int BeginPage { get; private set; }
        public int EndPage { get; private set; }
    }

    /// <summary>
    /// Eazyui分页处理逻辑类
    /// </summary>
    public class PageEazyUi 
    {
        public PageEazyUi(int _page, int _pagesize, int _total, object _rows)
        {
            page = _page;
            pagesize = _pagesize;
            total = _total;
            rows = _rows;
        }

        public int page { get; private set; }
        public int pagesize { get; private set; }
        public int total { get; private set; }
        public object rows { get; private set; }
    }
}

  

Guess you like

Origin www.cnblogs.com/fengyh/p/12016117.html