using
System;
using System.Data;
/**/ /// <summary>
/// pageContral 的摘要说明。
/// </summary>
/// <summary>
/// DataList分页操作类
/// </summary>
PageContral #region PageContral
public class pageContral
{
private int m_PageNow = 1 ; //当前页号
private DataSet m_ds = null; //传入的数据集合
private int m_PageSize = 5; //页面布局;
/**//// <summary>
/// 无参构造
/// </summary>
public pageContral()
{}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
public pageContral(DataSet ds)
{
DS = ds;
}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
/// <param name="pageNow">当前页</param>
/// <param name="pageSize">页面布局</param>
public pageContral( DataSet ds, int pageNow, int pageSize)
{
DS = ds;
PageNow = pageNow;
PageSize = pageSize;
}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
/// <param name="pageNow">当前页面</param>
public pageContral( DataSet ds, int pageNow )
{
DS = ds;
PageNow = pageNow;
}
/**//// <summary>
/// 当前页号码
/// </summary>
public int PageNow
{
get { return m_PageNow; }
set { m_PageNow = value;}
}
/**//// <summary>
/// 传入的数据集
/// </summary>
public DataSet DS
{
get { return m_ds; }
set { m_ds = value;}
}
/**//// <summary>
/// 页面布局
/// </summary>
public int PageSize
{
get { return m_PageSize; }
set { m_PageSize = value;}
}
/**//// <summary>
/// 打开一页
/// </summary>
/// <param name="pageNo">当前页</param>
/// <returns>返回操作的结果</returns>
public DataSet GotePageN(int pageNo)
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo <= a && pageNo >= 1)
{
int rowNum = ( pageNo - 1) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
if( DS.Tables[0].Rows[i] != null)
{
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
}
return dsA;
}
/**//// <summary>
/// 返回总页数
/// </summary>
/// <returns></returns>
public int PageCout()
{
int rowCount = DS.Tables[0].Rows.Count;
int PageTemp = (int)( rowCount / m_PageSize );
if( rowCount%m_PageSize == 0 )
return PageTemp;
else
return ( PageTemp + 1 );
}
/**//// <summary>
/// 下一页
/// </summary>
/// <param name="pageNo">当前页面</param>
/// <returns>返回结果</returns>
public DataSet PageNext( int pageNo )
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo < a)
{
int rowNum = pageNo * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 上一页
/// </summary>
/// <param name="pageNo">当前页面</param>
/// <returns></returns>
public DataSet PageUp( int pageNo )
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo >= 2 )
{
int rowNum = ( pageNo - 2 ) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 转到首页
/// </summary>
/// <returns>返回查询结果</returns>
public DataSet pageFirst()
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( a != 0 )
{
int rowNum = 0;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 最后一页
/// </summary>
/// <returns></returns>
public DataSet pageLast()
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( a != 0 )
{
int rowNum = ( a - 1) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
}
#endregion
using System.Data;
/**/ /// <summary>
/// pageContral 的摘要说明。
/// </summary>
/// <summary>
/// DataList分页操作类
/// </summary>
PageContral #region PageContral
public class pageContral
{
private int m_PageNow = 1 ; //当前页号
private DataSet m_ds = null; //传入的数据集合
private int m_PageSize = 5; //页面布局;
/**//// <summary>
/// 无参构造
/// </summary>
public pageContral()
{}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
public pageContral(DataSet ds)
{
DS = ds;
}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
/// <param name="pageNow">当前页</param>
/// <param name="pageSize">页面布局</param>
public pageContral( DataSet ds, int pageNow, int pageSize)
{
DS = ds;
PageNow = pageNow;
PageSize = pageSize;
}
/**//// <summary>
/// 有参构造
/// </summary>
/// <param name="ds">传入的数据集</param>
/// <param name="pageNow">当前页面</param>
public pageContral( DataSet ds, int pageNow )
{
DS = ds;
PageNow = pageNow;
}
/**//// <summary>
/// 当前页号码
/// </summary>
public int PageNow
{
get { return m_PageNow; }
set { m_PageNow = value;}
}
/**//// <summary>
/// 传入的数据集
/// </summary>
public DataSet DS
{
get { return m_ds; }
set { m_ds = value;}
}
/**//// <summary>
/// 页面布局
/// </summary>
public int PageSize
{
get { return m_PageSize; }
set { m_PageSize = value;}
}
/**//// <summary>
/// 打开一页
/// </summary>
/// <param name="pageNo">当前页</param>
/// <returns>返回操作的结果</returns>
public DataSet GotePageN(int pageNo)
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo <= a && pageNo >= 1)
{
int rowNum = ( pageNo - 1) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
if( DS.Tables[0].Rows[i] != null)
{
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
}
return dsA;
}
/**//// <summary>
/// 返回总页数
/// </summary>
/// <returns></returns>
public int PageCout()
{
int rowCount = DS.Tables[0].Rows.Count;
int PageTemp = (int)( rowCount / m_PageSize );
if( rowCount%m_PageSize == 0 )
return PageTemp;
else
return ( PageTemp + 1 );
}
/**//// <summary>
/// 下一页
/// </summary>
/// <param name="pageNo">当前页面</param>
/// <returns>返回结果</returns>
public DataSet PageNext( int pageNo )
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo < a)
{
int rowNum = pageNo * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 上一页
/// </summary>
/// <param name="pageNo">当前页面</param>
/// <returns></returns>
public DataSet PageUp( int pageNo )
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( pageNo >= 2 )
{
int rowNum = ( pageNo - 2 ) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 转到首页
/// </summary>
/// <returns>返回查询结果</returns>
public DataSet pageFirst()
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( a != 0 )
{
int rowNum = 0;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
/**//// <summary>
/// 最后一页
/// </summary>
/// <returns></returns>
public DataSet pageLast()
{
DataSet dsA = new DataSet();
dsA = DS.Clone();
int a = PageCout();//获取该记录集的总条数
if( a != 0 )
{
int rowNum = ( a - 1) * PageSize;
for(int i = rowNum; i < rowNum + PageSize;i ++ )
{
if( i >= DS.Tables[0].Rows.Count)
break;
dsA.Tables[0].ImportRow((DS.Tables[0].Rows[i]) as DataRow);
}
}
return dsA;
}
}
#endregion