当前位置: 移动技术网 > IT编程>开发语言>.net > Pagination

Pagination

2018年11月14日  | 移动技术网IT编程  | 我要评论

验孕棒什么时候用最准确,丹普热水器,托班育儿知识

using system.collections.generic;

namespace oyang.tool
{
    public interface ipagination
    {
        int pageindex { get; set; }
        int pagesize { get; set; }
        int totalcount { get; set; }
        string sortfield { get; set; }
        bool isasc { get; set; }
    }

    public interface ifullpagination : ipagination
    {
        int pagecount { get; }
        int buttoncount { get; set; }
        list<int> listpagebutton { get; }
        list<int> calcpagebutton();
    }

    public class pagination : ipagination
    {
        public int pageindex { get; set; }
        public int pagesize { get; set; }
        public int totalcount { get; set; }
        public string sortfield { get; set; }
        public bool isasc { get; set; }
    }

    public class fullpagination : pagination, ifullpagination
    {
        public int pagecount
        {
            get { return totalcount % pagesize == 0 ? totalcount / pagesize : totalcount / pagesize + 1; }
        }
        public int buttoncount { get; set; } = 5;

        list<int> _listpagebutton = null;
        public list<int> listpagebutton { get; }

        public list<int> calcpagebutton()
        {
            _listpagebutton = new list<int>();
            int temp1 = (buttoncount - 1) / 2;
            int temp2 = buttoncount - 1 - temp1;
            int startpageindex = 1;
            int endpageindex = 1;
            if (pagecount <= buttoncount)
            {
                startpageindex = 1;
                endpageindex = pagecount;
            }
            else if (pageindex <= temp1)
            {
                startpageindex = 1;
                endpageindex = startpageindex + buttoncount - 1;
            }
            else if (pageindex + temp2 > pagecount)
            {
                endpageindex = pagecount;
                startpageindex = endpageindex - buttoncount + 1;
            }
            else
            {
                startpageindex = pageindex - temp1;
                endpageindex = pageindex + temp2;
            }

            for (int i = startpageindex; i <= endpageindex; i++)
            {
                _listpagebutton.add(i);
            }
            return _listpagebutton;
        }
    }

}

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网