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
}
}
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
}
}