分页对象

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

namespace Tscc.Model
{
    /// <summary>
    /// 分页属性实体类
    /// </summary>
    [Serializable()]
    public  class PageModel
    {
        public PageModel()
        {
        }
        public PageModel(string table,string sortField,int direction,string whereStr,int index,int pageSize,int returnCount)
        {
            this.Table = table;
            this.SortField = sortField;
            this.Direction = direction;
            this.WhereStr = whereStr;
            this.Index = index;
            this.PageSize = pageSize;
            this.ReturnCount = returnCount;
        }
        public PageModel(string table, string sortField, int direction,  int index, int pageSize)
        {
            this.Table = table;
            this.SortField = sortField;
            this.Direction = direction;
            this.Index = index;
            this.PageSize = pageSize;
        }
        public PageModel( string sortField, int direction, int index, int pageSize)
        {
            this.SortField = sortField;
            this.Direction = direction;
            this.Index = index;
            this.PageSize = pageSize;
        }
        #region Fields
        private string _table;
        /// <summary>
        /// 表名称或查询语句
        /// </summary>
        public string Table
        {
            get { return _table; }
            set { _table = value; }
        }
        private string _sortField = "Id";
        /// <summary>
        /// 排序字段(不能为空)
        /// </summary>
        public string SortField
        {
            get
            {
                if (string.IsNullOrEmpty(_sortField))
                    _sortField = "Id";
                return _sortField;
            }
            set { _sortField = value; }
        }
        private int _direction=0;
        /// <summary>
        /// 倒序还是正序(0正序,1倒序)
        /// </summary>
        public int Direction
        {
            get { return _direction; }
            set { _direction = value; }
        }
        private string _whereStr="";
        /// <summary>
        /// 查询条件
        /// </summary>
        public string WhereStr
        {
            get { return _whereStr; }
            set { _whereStr = value; }
        }
        private int _index=1;
        /// <summary>
        /// 页码
        /// </summary>
        public int Index
        {
            get { return _index; }
            set {
                if (value < 1)
                {
                    _index = 1;
                }
                else
                {
                    _index = value;
                }
            }
        }
        private int _pageSize=2;
        /// <summary>
        /// 显示条数
        /// </summary>
        public int PageSize
        {
            get { return _pageSize; }
            set { _pageSize = value; }
        }
        private int _ReturnCount=0;
        /// <summary>
        /// 返回记录总数
        /// </summary>
        public int ReturnCount
        {
            get { return _ReturnCount; }
            set { _ReturnCount = value; }
        }
        private int _pageTotal = 1;
        /// <summary>
        /// 查询的记录总页数,默认为1
        /// </summary>
        public int PageTotal
        {
            get
            {
                return _pageTotal = Convert.ToInt32(Math.Ceiling(ReturnCount * 1.0 / PageSize)) == 0 ? 1 : Convert.ToInt32(Math.Ceiling(ReturnCount * 1.0 / PageSize));

            }
            set
            {
                _ReturnCount = value;
            }

        }
        #endregion
        

    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值