新版支持多层架构,从原版中剥离
原版支持多页码显示,高亮显示当前页码,输入页码跳转,每页显示记录数,按钮,图片,css样式等外观功能
文件分三个:
Model层:MPageNav.cs
BLL层:BllPageNav.cs
Dal层:DalPageNav.cs
Interface层:IPageNav.cs
数据工厂层想加入的自己动手哈,今天先放个实体类
MPageNav.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
namespace SinaSNS.Model
{
/// <summary>
/// 分页实体类 MPageNav
/// </summary>
public class MPageNav
{
/// <summary>
/// 部署参数
/// </summary>
public DataTable dt;//数据集
private string _CtPageNextLabel = "下一页";//定义下一页标识
private string _CtPagePreLabel = "上一页";//定义上一页标识
private string _CtPageFirstLabel = "第一页";//定义第一页标识
private string _CtPageLastLabel = "最后页";//定义最后一页标识
// private string _CtPageTotalLabel = "共"+this.intPageCount+"页";//定义总页数标识
// private string _CtPageCurrtLabel = "当前第"+this.intGetPageNum+"页";//定义当前页标识
private string _CtPageNextCss = "12pxBlack";//定义下一页标识样式表
private string _CtPagePreCss = "12pxBlack";//定义上一页标识样式表
private string _CtPageFirstCss = "title_big";//定义第一页标识样式表
private string _CtPageLastCss = "title_big";//定义最后一页标识样式表
private string _CtPageButtonCss = "title_big";//定义页码样式表
private string _ImgNextSrc = "/NetBesttone/Iask/images/next.gif";//定义下一页图片路径
private string _ImgPreSrc = "/NetBesttone/Iask/images/pre.gif";//定义上一页图片路径
private int _ImgWidth = 16;//定义图片宽度
private int _ImgHeight = 17;//定义图片高度
public string _ImgNext = "<img border=0 src=sc width=wd height=ht alt=\"后一页\">";//输出下一页图片
public string _ImgPre = "<img border=0 src=sc width=wd height=ht alt=\"前一页\">";//输出上一页图片
public int _PageCount;//总页数
public int _RowsCount;//总数据行数
public string _PageNext = "<a href=\"#\" class=\"../Css/Base.css\"+\"css\" Target=_parent><b>text</b></a>";//输出下一页标识
public string _PagePre = "<a href=\"#\" class=\"../Css/Base.css\"+\"css\" Target=_parent><b>text</b></a>";//输出上一页标识
public string _PageButton = "<a href=# class=\"css\" Target=_parent>[$]</a>";
public string _PageNumsOut = String.Empty;//输出页码按钮
public int _PageNums = 10;//页码数
private int _PageGetNum = 0;//输入页码
public string _PageFirst = "<a href=# class=\"css\" Target=_parent>text</a>";//输出第一页标识
public string _PageLast = "<a href=# class=\"css\" Target=_parent>text</a>";//输出最后页标识
public int _PageMax = 10;//最大页码
public int _PageMin = 0;//最小页码
private int _PagePerPage = 10;//每页显示数据
private string _InputSql;//输入sql
private string _InputUrl;//输入url
public string _UrlType;//输入url类型,框架与非框架
private string _InputParms;//用户输入传递参数
private int _QueryType = 1;//查询类型:0为数据已更新,1为默认
private string _strOrderBy;//输入排序字段
private string _strOrderByCode = "ASC";//输入排序规则,默认为ASC,倒叙为DESC
#region 基本属性
/// <summary>
/// 输入SQL
/// </summary>
public string strIptSql
{
get { return this._InputSql; }
set { this._InputSql = value; }
}
/// <summary>
/// 输入页码
/// </summary>
public int intGetPageNum
{
get { return this._PageGetNum; }
set { this._PageGetNum = value; }
}
/// <summary>
/// 输出总页数
/// </summary>
public int intPageCount
{
get { return this._PageCount; }
set { this._PageCount = value; }
}
/// <summary>
/// 输入每页显示数据数
/// </summary>
public int intPagePerPage
{
get { return this._PagePerPage; }
set { this._PagePerPage = value; }
}
/// <summary>
/// 输出下一页
/// </summary>
public string strPageNext
{
get { return this._PageNext; }
set { this._PageNext = value; }
}
/// <summary>
/// 输出上一页
/// </summary>
public string strPagePre
{
get { return this._PagePre; }
set { this._PagePre = value; }
}
/// <summary>
/// 输出最后页
/// </summary>
public string strPageLast
{
get { return this._PageLast; }
set { this._PageLast = value; }
}
/// <summary>
/// 输出第一页
/// </summary>
public string strPageFirst
{
get { return this._PageFirst; }
set { this._PageFirst = value; }
}
/// <summary>
/// 输出数据源
/// </summary>
public DataTable dtSource
{
get { return this.dt; }
set { this.dt = value; }
}
/// <summary>
/// 1-10页码输出
/// </summary>
public string strPageNumsOut
{
get { return this._PageNumsOut; }
set { this._PageNumsOut = value; }
}
/// <summary>
/// 输入页面类型,Frame为框架页,Parent为默认
/// </summary>
public string strInputUrl
{
get { return this._InputUrl; }
set { this._InputUrl = value; }
}
/// <summary>
/// 输入Url参数,"?Parms=Values..."
/// </summary>
public string strInputParms
{
get { return this._InputParms; }
set { this._InputParms = value; }
}
/// <summary>
/// 输入排序字段
/// </summary>
public string strOrderBy
{
get { return this._strOrderBy; }
set { this._strOrderBy = value; }
}
/// <summary>
/// 输入排序规则,默认为ASC,倒叙为DESC
/// </summary>
public string strOrderByCode
{
get { return this._strOrderByCode; }
set { this._strOrderByCode = value; }
}
#endregion
#region 自定义属性
/// <summary>
/// 输入下一页标识
/// </summary>
public string strNextLabel
{
get { return this._CtPageNextLabel; }
set { this._CtPageNextLabel = value; }
}
/// <summary>
/// 输入上一页标识
/// </summary>
public string strPreLabel
{
get { return this._CtPagePreLabel; }
set { this._CtPagePreLabel = value; }
}
/// <summary>
/// 输入第一页标识
/// </summary>
public string strFirstLabel
{
get { return this._CtPageFirstLabel; }
set { this._CtPageFirstLabel = value; }
}
/// <summary>
/// 输入最后一页标识
/// </summary>
public string strLastLabel
{
get { return this._CtPageLastLabel; }
set { this._CtPageLastLabel = value; }
}
/// <summary>
/// 输入下一页标识样式表
/// </summary>
public string strNextCss
{
get { return this._CtPageNextCss; }
set { this._CtPageNextCss = value; }
}
/// <summary>
/// 输入上一页标识样式表
/// </summary>
public string strPreCss
{
get { return this._CtPagePreCss; }
set { this._CtPagePreCss = value; }
}
/// <summary>
/// 输入第一页标识样式表
/// </summary>
public string strFirstCss
{
get { return this._CtPageFirstCss; }
set { this._CtPageFirstCss = value; }
}
/// <summary>
/// 输入最后一页标识样式表
/// </summary>
public string strLastCss
{
get { return this._CtPageLastCss; }
set { this._CtPageLastCss = value; }
}
/// <summary>
/// 输入页码样式表
/// </summary>
public string strButtonCss
{
get { return this._CtPageButtonCss; }
set { this._CtPageButtonCss = value; }
}
/// <summary>
/// 输入下一页图片路径
/// </summary>
public string strImgNextSrc
{
get { return this._ImgNextSrc; }
set { this._ImgNextSrc = value; }
}
/// <summary>
/// 输入上一页图片路径
/// </summary>
public string strImgPreSrc
{
get { return this._ImgPreSrc; }
set { this._ImgPreSrc = value; }
}
/// <summary>
/// 输入图片宽度
/// </summary>
public int intImgWidth
{
get { return this._ImgWidth; }
set { this._ImgWidth = value; }
}
/// <summary>
/// 输入图片高度
/// </summary>
public int intImgHeight
{
get { return this._ImgHeight; }
set { this._ImgHeight = value; }
}
/// <summary>
/// 输出下一页图片
/// </summary>
public string strImgNext
{
get { return this._ImgNext; }
set { this._ImgNext = value; }
}
/// <summary>
/// 输出上一页图片
/// </summary>
public string strImgPre
{
get { return this._ImgPre; }
set { this._ImgPre = value; }
}
#endregion
#region 输入参数分析
/// <summary>
/// 设置请求分页参数Page
/// </summary>
public void vodSetGetPageNums()
{
if (HttpContext.Current.Request.QueryString["Page"] != null)
{
if (this._QueryType == 0)
{ this.intGetPageNum = 1; }
else
{
this.intGetPageNum = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
}
}
else
{
this.intGetPageNum = 1;
}
}
/// <summary>
/// 分析输入Url类型
/// </summary>
public void vodSetGetInputUrl()
{
switch (this.strInputUrl)
{
case "Frame":
this.strInputUrl = HttpContext.Current.Request.QueryString["Url"] + this._InputParms;
break;
case "Parent":
this.strInputUrl = HttpContext.Current.Request.FilePath.ToString() + this._InputParms;
break;
default:
this.strInputUrl = HttpContext.Current.Request.FilePath.ToString() + this._InputParms;
string strTemp = HttpContext.Current.Request.Url.ToString();
if (strTemp.IndexOf("&Page=", 1, strTemp.Length - 2) != -1)//判断数据是否更新
{
int intTempQuery = strTemp.IndexOf("&Page=", 1, strTemp.Length - 2);
string strRemoveUrl = strTemp.Substring(intTempQuery);
strTemp = strTemp.Remove(intTempQuery, strRemoveUrl.Length);
if (strTemp != "http://localhost" + this.strInputUrl)
this._QueryType = 0;
}
break;
}
}
#endregion
}
}