| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- namespace HySoft.DBUtility
- {
- /// <summary>
- /// 信息分页 张国杰
- /// Edition 1.1
- /// </summary>
- public class Pagination
- {
- private string pageBar = ""; //分页功能条
- private int pageBarSize = 1; //分页功能条页码数
- private string urlStr = ""; //分页链接字符串
- private int pageSize = 0; //每页显示记录的数量
- private int recordCount = 0; //记录总数
- private int sequence = 0; //当前页次
- private string searchField = ""; //查询字段
- private string searchSentence = ""; //查询语句
- private string sortSentence = ""; //排序语句
- private string primarykey = ""; //主键
- private string tableName = ""; //要查询表的名称
- private string itemUnit = ""; //单位
- private string imagesPath = ""; //分页功能条按钮图片存放地址 如: "../_imgs/"
- #region 属性
- /// <summary>
- /// 分页功能条
- /// </summary>
- public string PageBar
- {
- get { return pageBar; }
- set { pageBar = value; }
- }
- /// <summary>
- /// 分页功能条
- /// </summary>
- public int PageBarSize
- {
- get { return pageBarSize; }
- set { pageBarSize = value; }
- }
- /// <summary>
- /// 分页链接字符串,例 "default.aspx?id=3&cid=4"
- /// </summary>
- public string UrlStr
- {
- get { return urlStr; }
- set { urlStr = value; }
- }
- /// <summary>
- /// 每页显示记录的数量
- /// </summary>
- public int PageSize
- {
- get { return pageSize; }
- set { pageSize = value; }
- }
- /// <summary>
- /// 记录总数
- /// </summary>
- public int RecordCount
- {
- get { return recordCount; }
- set { recordCount = value; }
- }
- /// <summary>
- /// 当前页次/页码
- /// </summary>
- public int Sequence
- {
- get
- {
- return (sequence != 0) ? sequence : 1;
- }
- set
- { sequence = value; }
- }
- /// <summary>
- /// 查询语句,例: "AND Keywords = '' AND ID = 2"
- /// </summary>
- public string SearchSentence
- {
- get { return searchSentence; }
- set { searchSentence = value; }
- }
- /// <summary>
- /// 排序语句,例: " ORDER BY MCardID DESC"
- /// </summary>
- public string SortSentence
- {
- get { return sortSentence; }
- set { sortSentence = value; }
- }
- /// <summary>
- /// 查询主体表的主键
- /// </summary>
- public string Primarykey
- {
- get { return primarykey; }
- set { primarykey = value; }
- }
- /// <summary>
- /// 查询主体表,例: "News"
- /// </summary>
- public string TableName
- {
- get { return tableName; }
- set { tableName = value; }
- }
- /// <summary>
- /// 查询字段,例: "*" 或者 "UserName,UserPassword,RealName,..."
- /// </summary>
- public string SearchField
- {
- get { return searchField; }
- set { searchField = value; }
- }
- /// <summary>
- /// 记录的单位名称,例:"条记录" 或 "件商品"
- /// </summary>
- public string ItemUnit
- {
- get { return itemUnit; }
- set { itemUnit = value; }
- }
- /// <summary>
- /// 分页功能条按钮图片存放地址 如: "../Images/"
- /// </summary>
- public string ImagesPath
- {
- get { return (string.IsNullOrEmpty(imagesPath)) ? "../Images/" : imagesPath; }
- set { imagesPath = value; }
- }
- #endregion
- #region 方法
- /// <summary>
- /// 匹配当前页次、查询条件、排序语句等参数,获取数据表
- /// </summary>
- /// <returns></returns>
- public DataTable GetDataTable()
- {
- SqlParameter[] parms = new SqlParameter[]
- {
- new SqlParameter("@SqlWhere", SqlDbType.VarChar,8000),
- new SqlParameter("@PageSize", SqlDbType.Int),
- new SqlParameter("@PageIndex", SqlDbType.Int),
- new SqlParameter("@SqlTable", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlField", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlPK", SqlDbType.VarChar,50),
- new SqlParameter("@SqlOrder", SqlDbType.VarChar,200),
- new SqlParameter("@Count", SqlDbType.Int),
- };
- parms[0].Value = searchSentence;
- parms[1].Value = pageSize;
- parms[2].Value = sequence;
- parms[3].Value = tableName;
- parms[4].Value = searchField;
- parms[5].Value = primarykey;
- parms[6].Value = sortSentence;
- parms[7].Direction = ParameterDirection.Output;
- DataTable dt = new DataTable(); ;
- using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
- {
- dt = DbHelperSQL.ExecuteDataTable(conn, CommandType.StoredProcedure, "PaginationData", parms);
- RecordCount = int.Parse((parms[7].Value.ToString()));
- conn.Close();
- conn.Dispose();
- }
- return dt;
- }
- /// <summary>
- /// 匹配当前页次、查询条件、排序语句等参数,获取数据表
- /// </summary>
- /// <returns></returns>
- public DataTable GetDataTables()
- {
- SqlParameter[] parms = new SqlParameter[]
- {
- new SqlParameter("@SqlWhere", SqlDbType.VarChar,8000),
- new SqlParameter("@PageSize", SqlDbType.Int),
- new SqlParameter("@PageIndex", SqlDbType.Int),
- new SqlParameter("@SqlTable", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlField", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlPK", SqlDbType.VarChar,50),
- new SqlParameter("@SqlOrder", SqlDbType.VarChar,200),
- new SqlParameter("@Count", SqlDbType.Int),
- };
- parms[0].Value = searchSentence;
- parms[1].Value = pageSize;
- parms[2].Value = sequence;
- parms[3].Value = tableName;
- parms[4].Value = searchField;
- parms[5].Value = primarykey;
- parms[6].Value = sortSentence;
- parms[7].Direction = ParameterDirection.Output;
- DataTable dt = new DataTable();
- using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
- {
- dt = DbHelperSQL.ExecuteDataTable(conn, CommandType.StoredProcedure, "PaginationData", parms);
- RecordCount = int.Parse((parms[7].Value.ToString()));
- conn.Close();
- conn.Dispose();
- }
- return dt;
- }
- /// <summary>
- /// 匹配当前页次、查询条件、排序语句等参数,获取数据表
- /// </summary>
- /// <returns></returns>
- public DataTable GetDataTable3()
- {
- SqlParameter[] parms = new SqlParameter[]
- {
- new SqlParameter("@SqlWhere", SqlDbType.VarChar,8000),
- new SqlParameter("@PageSize", SqlDbType.Int),
- new SqlParameter("@PageIndex", SqlDbType.Int),
- new SqlParameter("@SqlTable", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlField", SqlDbType.VarChar,8000),
- new SqlParameter("@SqlPK", SqlDbType.VarChar,50),
- new SqlParameter("@SqlOrder", SqlDbType.VarChar,200),
- new SqlParameter("@Count", SqlDbType.Int),
- };
- parms[0].Value = searchSentence;
- parms[1].Value = pageSize;
- parms[2].Value = sequence;
- parms[3].Value = tableName;
- parms[4].Value = searchField;
- parms[5].Value = primarykey;
- parms[6].Value = sortSentence;
- parms[7].Direction = ParameterDirection.Output;
- DataTable dt = new DataTable(); ;
- using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
- {
- dt = DbHelperSQL.ExecuteDataTable(conn, CommandType.StoredProcedure, "PaginationData", parms);
- RecordCount = int.Parse((parms[7].Value.ToString()));
- conn.Close();
- conn.Dispose();
- }
- return dt;
- }
- /// <summary>
- /// 获取分页功能条 模式: 首页 | 上一页 | 下一页 | 尾页 第 Sequence 页 | 共 RecordCount / PageSize 页 | 每页 PageSize
- /// </summary>
- public void PageBarByStyle1()
- {
- string htmlText = "<table class=\"pageBar\" cellspacing=\"0\" cellpadding=\"5\">";
- htmlText += "<tr><td style=\"width:18%\" bgcolor=\"#ffffff\" align=\"center\">";
- htmlText += "<font color=\"#00000\"><span class=\"fonten_amount\">{0} {1}</span></font></td>";
- htmlText += "<td bgcolor=\"#ffffff\" style=\"width:32%\">第<b>{2}</b>页 | 共<b>{3}</b>页 | 每页<b>{4}</b>{1}</td>";
- htmlText += "<td bgcolor=\"#ffffff\" style=\"width:32%\" align=\"center\">{5}</td>";
- htmlText += "</td></tr></table>";
- int PageCount = 0;
- if ((RecordCount % PageSize) == 0)
- PageCount = RecordCount / PageSize;
- else
- PageCount = RecordCount / PageSize + 1;
- if (PageCount < Sequence)
- Sequence = PageCount;
- if (PageCount <= 0)
- Sequence = 1;
- string str = "";
- if (Sequence < 2)
- str += "首页 | 上一页 | ";
- else
- {
- str += "<a href=\"" + UrlStr + "page=1\" class=\"link_page\">首页</a> | ";
- str += "<a href=\"" + UrlStr + "page=" + (Sequence - 1) + "\" class=\"link_page\">上一页</a> | ";
- }
- if ((PageCount - Sequence) < 1)
- str += "下一页 | 尾页 ";
- else
- {
- str += "<a href=\"" + UrlStr + "page=" + (Sequence + 1) + "\" class=\"link_page\">下一页</a> | ";
- str += "<a href=\"" + UrlStr + "page=" + PageCount + "\" class=\"link_page\">尾页</a>";
- }
- PageBar = string.Format(htmlText, RecordCount.ToString(), ItemUnit, Sequence.ToString(), PageCount.ToString(), PageSize.ToString(), str);
- }
- /// <summary>
- /// 获取分页功能条 模式: 首页 | 上一页 | 下一页 | 尾页 第 Sequence 页 | 共 RecordCount / PageSize 页 | 每页 PageSize
- /// </summary>
- public void PageBarByStyles1()
- {
- string htmlText = "<table class=\"pageBar\" cellspacing=\"0\" cellpadding=\"5\">";
- htmlText += "<tr><td bgcolor=\"#ffffff\" style=\"width:32%\">第<b>{2}</b>页 | 共<b>{3}</b>页 | 每页<b>{4}</b>{1}</td>";
- htmlText += "<td bgcolor=\"#ffffff\" style=\"width:32%\" align=\"center\">{5}</td>";
- htmlText += "</td></tr></table>";
- int PageCount = 0;
- if ((RecordCount % PageSize) == 0)
- PageCount = RecordCount / PageSize;
- else
- PageCount = RecordCount / PageSize + 1;
- if (PageCount < Sequence)
- Sequence = PageCount;
- if (PageCount <= 0)
- Sequence = 1;
- string str = "";
- if (Sequence < 2)
- str += "首页 | 上一页 | ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(1);\" class=\"link_page\">首页</a> | ";
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence - 1) + ");\" class=\"link_page\">上一页</a> | ";
- }
- if ((PageCount - Sequence) < 1)
- str += "下一页 | 尾页 ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence + 1) + ");\" class=\"link_page\">下一页</a> | ";
- str += "<a href=\"#\" onclick=\"return pagination(" + PageCount + ");\" class=\"link_page\">尾页</a>";
- }
- PageBar = string.Format(htmlText, RecordCount.ToString(), ItemUnit, Sequence.ToString(), PageCount.ToString(), PageSize.ToString(), str);
- }
- /// <summary>
- /// 数字模式分页功能条,如 << 1 2 3 4 5 6 7 8 9 >>
- /// </summary>
- public void NumeberPageBar()
- {
- int PageCount = 0;
- if ((RecordCount % PageSize) == 0)
- PageCount = RecordCount / PageSize;
- else
- PageCount = RecordCount / PageSize + 1;
- if (PageCount < Sequence)
- Sequence = PageCount;
- if (PageCount <= 0)
- Sequence = 1;
- string str = "Page {0} of {1} {2} {3} {4}", temp = "", previous = "", next = "";
- int areaS = 1, areaE = PageCount;
- if (PageCount > 10 && Sequence > 4)
- {
- areaS = Sequence - 4;
- areaE = Sequence - 4 + 9;
- }
- if (Sequence > 1)
- {
- previous = "<a href=\"" + UrlStr + "page=" + (Sequence + 1) + "\">Previous</a>";
- next = "<a href=\"" + UrlStr + "page=" + (Sequence - 1) + "\">Next</a>";
- }
- else
- {
- previous = "Previous";
- next = "Next";
- }
- for (int i = areaS; i <= areaE; i++)
- {
- if (i == Sequence)
- temp += "<a href=\"" + UrlStr + "page=" + i.ToString() + "\"><font color=\"#FF6600\">" + i.ToString() + "</a></font> ";
- else
- temp += "<a href=\"" + UrlStr + "page=" + i.ToString() + "\">" + i.ToString() + "</a> ";
- }
- str = string.Format(str, Sequence.ToString(), PageCount.ToString(), previous, temp, next);
- PageBar = str;
- }
- /// <summary>
- /// 类似百度 google的分页,如 <<{0} 上一页{1} 1 2 3 4 5 6 7 8 9{2} 下一页{3} >>{4} 跳转[8]{5}
- /// </summary>
- public void GoNumeberPageBar1()
- {
- string pageHtml = "{0} {1} {2} {3} {4} {5}";
- string page0 = "", page1 = "", page2 = "", page3 = "", page4 = "", page5 = "";
- int tempallpage = 1;
- if ((RecordCount % PageSize) == 0)
- tempallpage = RecordCount / PageSize;
- else
- tempallpage = RecordCount / PageSize + 1;
- page5 = " <input id='goPageNumTemp' value='" + Sequence + "' style='width:40px;height:16px;BORDER-RIGHT: #7b9ebd 1px solid; BORDER-TOP: #7b9ebd 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #7b9ebd 1px solid; BORDER-BOTTOM: #7b9ebd 1px solid;' onkeyup=\"this.value=this.value.replace(/\\D/g,'')\" onafterpaste=\"this.value=this.value.replace(/\\D/g,'')\" /> <button onclick=\"var strgonum=document.getElementById('goPageNumTemp').value;if(strgonum!=''){if(strgonum>" + tempallpage + "){pagination(" + tempallpage + ");}else{pagination(strgonum);}}else{pagination(" + Sequence + ");}\" class='btn' style='width:30px;'>Go</button> 共 " + tempallpage + " 页";
- if (Sequence <= PageBarSize)
- {
- page0 = "<<";
- page1 = "上一页";
- }
- else
- {
- if ((Sequence - PageBarSize) > 0)
- {
- page0 = "<a href=\"#\" onclick=\"pagination(" + (Sequence - PageBarSize) + ");\"><<</a>";
- }
- else
- {
- page0 = "<a href=\"#\" onclick=\"pagination(1);\"><<</a>";
- }
- page1 = "<a href=\"#\" onclick=\"pagination(" + (Sequence - 1) + ");\">上一页</a>";
- }
- if ((tempallpage - Sequence + 1) < PageBarSize)
- {
- page3 = "下一页";
- page4 = ">>";
- }
- else
- {
- page3 = "<a href=\"#\" onclick=\"pagination(" + (Sequence + 1) + ");\">下一页</a>";
- if ((Sequence + PageBarSize) > tempallpage)
- {
- page4 = "<a href=\"#\" onclick=\"pagination(" + tempallpage + ");\">>></a>";
- }
- else
- {
- page4 = "<a href=\"#\" onclick=\"pagination(" + (Sequence + PageBarSize) + ");\">>></a>";
- }
- }
- if (tempallpage < PageSize)
- {
- for (int i = 1; i <= tempallpage; i++)
- {
- if (i == Sequence)
- {
- page2 += " <font color=Red>" + i + "</font> ";
- }
- else
- {
- page2 += " <a href=\"#\" onclick=\"pagination(" + i + ");\">" + i + "</a> ";
- }
- }
- }
- else
- {
- int tempcount = 1;
- if (Sequence % PageBarSize == 0)
- {
- tempcount = Sequence / PageBarSize - 1;
- }
- else
- {
- tempcount = Sequence / PageBarSize;
- }
- tempcount = tempcount * PageBarSize;
- for (int i = 1; i <= PageBarSize; i++)
- {
- tempcount++;
- if (tempcount <= tempallpage)
- {
- if (tempcount == Sequence)
- {
- page2 += " <font color=Red>" + tempcount + "</font> ";
- }
- else
- {
- page2 += " <a href=\"#\" onclick=\"pagination(" + tempcount + ");\">" + tempcount + "</a> ";
- }
- }
- }
- }
- PageBar = string.Format(pageHtml, page0, page1, page2, page3, page4, page5);
- }
- /// <summary>
- /// 类似百度 google的分页,如 <<{0} 上一页{1} 1 2 3 4 5 6 7 8 9{2} 下一页{3} >>{4} 跳转[8]{5}
- /// </summary>
- public void GoNumeberPageBar()
- {
- string pageHtml = "{0} {1} {2}";
- string page0 = "", page2 = "", page4 = "";
- int tempallpage = 1;
- if ((RecordCount % PageSize) == 0)
- tempallpage = RecordCount / PageSize;
- else
- tempallpage = RecordCount / PageSize + 1;
- if (Sequence <= PageBarSize)
- {
- page0 = "";
- }
- else
- {
- if ((Sequence - PageBarSize) > 0)
- {
- page0 = "<span><a href=\"#\" title='Previous Group' onclick=\"pagination(" + (Sequence - PageBarSize) + ");\"><<</a></span>";
- }
- else
- {
- page0 = "<span><a href=\"#\" title='Previous Group' onclick=\"pagination(1);\"><<</a></span>";
- }
- }
- if ((tempallpage - Sequence + 1) < PageBarSize)
- {
- page4 = "";
- if (tempallpage != Sequence)
- {
- page4 = "<span><a href=\"#\" title='Next Group' onclick=\"pagination(" + tempallpage + ");\">>></a></span>";
- }
- }
- else
- {
- if ((Sequence + PageBarSize) > tempallpage)
- {
- page4 = "<span><a href=\"#\" title='Next Group' onclick=\"pagination(" + tempallpage + ");\">>></a></span>";
- }
- else
- {
- page4 = "<span><a href=\"#\" title='Next Group' onclick=\"pagination(" + (Sequence + PageBarSize) + ");\">>></a></span>";
- }
- }
- if (tempallpage < PageSize)
- {
- for (int i = 1; i <= tempallpage; i++)
- {
- if (i == Sequence)
- {
- page2 += " <span class=\"cp\"><strong>" + i + "</strong></span> ";
- }
- else
- {
- page2 += " <span><a href=\"#\" onclick=\"pagination(" + i + ");\">" + i + "</a></span> ";
- }
- }
- }
- else
- {
- int tempcount = 1;
- if (Sequence % PageBarSize == 0)
- {
- tempcount = Sequence / PageBarSize - 1;
- }
- else
- {
- tempcount = Sequence / PageBarSize;
- }
- tempcount = tempcount * PageBarSize;
- for (int i = 1; i <= PageBarSize; i++)
- {
- tempcount++;
- if (tempcount <= tempallpage)
- {
- if (tempcount == Sequence)
- {
- page2 += " <span class=\"cp\"><strong>" + tempcount + "</strong></span> ";
- }
- else
- {
- page2 += " <span><a href=\"#\" onclick=\"pagination(" + tempcount + ");\">" + tempcount + "</a></span> ";
- }
- }
- }
- }
- if (PageBarSize >= tempallpage)
- {
- page0 = "";
- page4 = "";
- }
- PageBar = string.Format(pageHtml, page0, page2, page4);
- }
- /// <summary>
- /// 类似百度 google的分页,如 <<{0} 上一页{1} 1 2 3 4 5 6 7 8 9{2} 下一页{3} >>{4} 跳转[8]{5}
- /// </summary>
- public void GoNumeberPageBar2()
- {
- string pageHtml = "{6} {0} {1} {2} {3} {4} {5}";
- string page0 = "", page1 = "", page2 = "", page3 = "", page4 = "", page5 = "", page6 = "";
- int tempallpage = 1;
- if ((RecordCount % PageSize) == 0)
- tempallpage = RecordCount / PageSize;
- else
- tempallpage = RecordCount / PageSize + 1;
- page5 = " All <strong>" + tempallpage + "</strong> Pages";// " <input id='goPageNumTemp' value='" + Sequence + "' style='width:40px;height:16px;BORDER-RIGHT: #7b9ebd 1px solid; BORDER-TOP: #7b9ebd 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #7b9ebd 1px solid; BORDER-BOTTOM: #7b9ebd 1px solid;' onkeyup=\"this.value=this.value.replace(/\\D/g,'')\" onafterpaste=\"this.value=this.value.replace(/\\D/g,'')\" /> <button onclick=\"var strgonum=document.getElementById('goPageNumTemp').value;if(strgonum!=''){if(strgonum>" + tempallpage + "){pagination(" + tempallpage + ");}else{pagination(strgonum);}}else{pagination(" + Sequence + ");}\" class='btn' style='width:30px;'>Go</button> 共 " + tempallpage + " 页";
- if (tempallpage != 1)
- {
- int start = 1;
- int end = tempallpage;
- //tempallpage % PageBarSize
- if (PageBarSize < tempallpage)
- {
- if (Sequence <= PageBarSize)
- {
- end = PageBarSize;
- }
- else
- {
- if ((Sequence % PageBarSize) == 0)
- {
- start = ((Sequence / PageBarSize) - 1) * PageBarSize + 1;
- end = Sequence;
- }
- else
- {
- start = ((Sequence / PageBarSize)) * PageBarSize + 1;
- end = (Sequence / PageBarSize + 1) * PageBarSize;
- if (end > tempallpage)
- {
- end = tempallpage;
- }
- }
- }
- }
- page6 = "<strong>" + start.ToString() + " - " + end.ToString() + "</strong> Pages";
- }
- if (Sequence <= PageBarSize)
- {
- page0 = "";
- page1 = "";
- }
- else
- {
- if ((Sequence - PageBarSize) > 0)
- {
- page0 = "<span><a href=\"#\" onclick=\"pagination(" + (Sequence - PageBarSize) + ");\"><<</a></span>";
- }
- else
- {
- page0 = "<span><a href=\"#\" onclick=\"pagination(1);\"><<</a></span>";
- }
- page1 = "<span><a href=\"#\" onclick=\"pagination(" + (Sequence - 1) + ");\">Previous</a></span>";
- }
- if ((tempallpage - Sequence + 1) < PageBarSize)
- {
- page3 = "";
- page4 = "";
- if (tempallpage != Sequence)
- {
- page3 = "<span><a href=\"#\" onclick=\"pagination(" + (Sequence + 1) + ");\">Next</a></span>";
- page4 = "<span><a href=\"#\" onclick=\"pagination(" + tempallpage + ");\">>></a></span>";
- }
- }
- else
- {
- page3 = "<span><a href=\"#\" onclick=\"pagination(" + (Sequence + 1) + ");\">Next</a></span>";
- if ((Sequence + PageBarSize) > tempallpage)
- {
- page4 = "<span><a href=\"#\" onclick=\"pagination(" + tempallpage + ");\">>></a></span>";
- }
- else
- {
- page4 = "<span><a href=\"#\" onclick=\"pagination(" + (Sequence + PageBarSize) + ");\">>></a></span>";
- }
- }
- if (tempallpage < PageSize)
- {
- for (int i = 1; i <= tempallpage; i++)
- {
- if (i == Sequence)
- {
- page2 += " <span class=\"cp\"><strong>" + i + "</strong></span> ";
- }
- else
- {
- page2 += " <span><a href=\"#\" onclick=\"pagination(" + i + ");\">" + i + "</a></span> ";
- }
- }
- }
- else
- {
- int tempcount = 1;
- if (Sequence % PageBarSize == 0)
- {
- tempcount = Sequence / PageBarSize - 1;
- }
- else
- {
- tempcount = Sequence / PageBarSize;
- }
- tempcount = tempcount * PageBarSize;
- for (int i = 1; i <= PageBarSize; i++)
- {
- tempcount++;
- if (tempcount <= tempallpage)
- {
- if (tempcount == Sequence)
- {
- page2 += " <span class=\"cp\"><strong>" + tempcount + "</strong></span> ";
- }
- else
- {
- page2 += " <span><a href=\"#\" onclick=\"pagination(" + tempcount + ");\">" + tempcount + "</a></span> ";
- }
- }
- }
- }
- if (PageBarSize >= tempallpage)
- {
- page0 = "";
- page1 = "";
- page3 = "";
- page4 = "";
- }
- PageBar = string.Format(pageHtml, page0, page1, page2, page3, page4, page5, page6);
- }
- /// <summary>
- /// 无刷新分页模式 当前第 {0} 页. 共 {1} 页. 每页 {2} 条. 共 {3} 条. 首页 上一页 下一页 末页 转到 页
- /// </summary>
- public void GoPageBarStyle1()
- {
- string pageHtml = "<div style=\"float:left; width:48%;\">当前第 {0}/{1} 页. 每页 {2} 条. 共 {3} 条</div><div style=\"float:right; width:48%; text-align:right;\">{4} {5}</div>";
- string page0 = "", page1 = "", page2 = "", page3 = "", page4 = "", page5 = "";
- page0 = Sequence.ToString();
- int tempallpage = 1;
- if ((RecordCount % PageSize) == 0)
- tempallpage = RecordCount / PageSize;
- else
- tempallpage = RecordCount / PageSize + 1;
- page1 = tempallpage.ToString();
- page2 = PageSize.ToString();
- page3 = RecordCount.ToString();
- page5 = "<span onclick=\"var strgonum=document.getElementById('goPageNumTemp').value;if(strgonum!=''){if(strgonum>" + tempallpage + "){pagination(" + tempallpage + ");}else{pagination(strgonum);}}else{pagination(" + Sequence + ");}\" style='width:30px;cursor:hand;'>转到</span> <input id='goPageNumTemp' value='" + Sequence + "' style='width:40px;height:16px;BORDER-RIGHT: #7b9ebd 1px solid; BORDER-TOP: #7b9ebd 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #7b9ebd 1px solid; BORDER-BOTTOM: #7b9ebd 1px solid;' onkeyup=\"this.value=this.value.replace(/\\D/g,'')\" onafterpaste=\"this.value=this.value.replace(/\\D/g,'')\" /> 页";
- if (Sequence < 2)
- page4 += "<a href=\"javascript:void(null)\">首页</a> <a href=\"javascript:void(null)\">上一页</a>";
- else
- {
- page4 += "<a href=\"javascript:void(null)\" onclick=\"pagination(1);\">首页</a> ";
- page4 += "<a href=\"javascript:void(null)\" onclick=\"pagination(" + (Sequence - 1) + ");\">上一页</a> ";
- }
- if ((tempallpage - Sequence) < 1)
- page4 += " <a href=\"javascript:void(null)\">下一页</a> <a href=\"javascript:void(null)\">末页</a>";
- else
- {
- page4 += " <a href=\"javascript:void(null)\" onclick=\"pagination(" + (Sequence + 1) + ");\">下一页</a> ";
- page4 += "<a href=\"javascript:void(null)\" onclick=\"pagination(" + tempallpage + ");\">末页</a>";
- }
- PageBar = string.Format(pageHtml, page0, page1, page2, page3, page4, page5);
- }
- /// <summary>
- /// 无刷新分页模式 当前第 {0} 页. 共 {1} 页. 每页 {2} 条. 共 {3} 条. 首页 上一页 下一页 末页 转到 页
- /// </summary>
- public void GoPageBarStyle1(string funname)
- {
- string pageHtml = "<div style=\"float:left; width:48%;\">当前第 {0}/{1} 页. 每页 {2} 条. 共 {3} 条</div><div style=\"float:right; width:48%; text-align:right;\">{4} {5}</div>";
- string page0 = "", page1 = "", page2 = "", page3 = "", page4 = "", page5 = "";
- page0 = Sequence.ToString();
- int tempallpage = 1;
- if ((RecordCount % PageSize) == 0)
- tempallpage = RecordCount / PageSize;
- else
- tempallpage = RecordCount / PageSize + 1;
- page1 = tempallpage.ToString();
- page2 = PageSize.ToString();
- page3 = RecordCount.ToString();
- page5 = "<span onclick=\"var strgonum=document.getElementById('goPageNumTemp').value;if(strgonum!=''){if(strgonum>" + tempallpage + "){" + funname + "(" + tempallpage + ");}else{" + funname + "(strgonum);}}else{" + funname + "(" + Sequence + ");}\" style='width:30px;cursor:hand;'>转到</span> <input id='goPageNumTemp' value='" + Sequence + "' style='width:40px;height:16px;BORDER-RIGHT: #7b9ebd 1px solid; BORDER-TOP: #7b9ebd 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #7b9ebd 1px solid; BORDER-BOTTOM: #7b9ebd 1px solid;' onkeyup=\"this.value=this.value.replace(/\\D/g,'')\" onafterpaste=\"this.value=this.value.replace(/\\D/g,'')\" /> 页";
- if (Sequence < 2)
- page4 += "<a href=\"javascript:void(null)\">首页</a> <a href=\"javascript:void(null)\">上一页</a>";
- else
- {
- page4 += "<a href=\"javascript:void(null)\" onclick=\"" + funname + "(1);\">首页</a> ";
- page4 += "<a href=\"javascript:void(null)\" onclick=\"" + funname + "(" + (Sequence - 1) + ");\">上一页</a> ";
- }
- if ((tempallpage - Sequence) < 1)
- page4 += " <a href=\"javascript:void(null)\">下一页</a> <a href=\"javascript:void(null)\">末页</a>";
- else
- {
- page4 += " <a href=\"javascript:void(null)\" onclick=\"" + funname + "(" + (Sequence + 1) + ");\">下一页</a> ";
- page4 += "<a href=\"javascript:void(null)\" onclick=\"" + funname + "(" + tempallpage + ");\">末页</a>";
- }
- PageBar = string.Format(pageHtml, page0, page1, page2, page3, page4, page5);
- }
- /// <summary>
- /// 分页功能条(无刷新模式)
- /// </summary>
- public void PageBarUnRefresh()
- {
- string htmlText = "<div>";
- htmlText += "<h1 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">{0}</h1>";
- htmlText += "<h2 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">共计: {1} {2} {3}</h2>";
- htmlText += "</div>";
- int intPageCount = 0;
- if ((RecordCount % PageSize) == 0)
- intPageCount = RecordCount / PageSize;
- else
- intPageCount = RecordCount / PageSize + 1;
- string str = "";
- if (Sequence < 2)
- str += "<img src=\"" + ImagesPath + "page_FL0.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /> <img src=\"" + ImagesPath + "page_L0.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(1);\"><img src=\"" + ImagesPath + "page_FL1.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence - 1) + ");\"><img src=\"" + ImagesPath + "page_L1.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /></a> ";
- }
- if ((intPageCount - Sequence) < 1)
- str += "<img src=\"" + ImagesPath + "page_R0.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /> <img src=\"" + ImagesPath + "page_LL0.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence + 1) + ");\"><img src=\"" + ImagesPath + "page_R1.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return pagination(" + intPageCount + ");\"><img src=\"" + ImagesPath + "page_LL1.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /></a> ";
- }
- string strPage = Sequence.ToString() + "/" + intPageCount.ToString();
- PageBar = string.Format(htmlText, str, RecordCount, ItemUnit, strPage);
- }
- /// <summary>
- /// 分页功能条(无刷新模式)
- /// </summary>
- public void PageBarUnRefreshbak()
- {
- string htmlText = "<div>";
- htmlText += "<h1 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">{0}</h1>";
- htmlText += "<h2 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">共计: {1} {2} {3} {4}</h2>";
- htmlText += "</div>";
- int intPageCount = 0;
- if ((RecordCount % PageSize) == 0)
- intPageCount = RecordCount / PageSize;
- else
- intPageCount = RecordCount / PageSize + 1;
- string str = "";
- if (Sequence < 2)
- str += "<img src=\"" + ImagesPath + "page_FL0.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /> <img src=\"" + ImagesPath + "page_L0.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(1);\"><img src=\"" + ImagesPath + "page_FL1.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence - 1) + ");\"><img src=\"" + ImagesPath + "page_L1.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /></a> ";
- }
- if ((intPageCount - Sequence) < 1)
- str += "<img src=\"" + ImagesPath + "page_R0.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /> <img src=\"" + ImagesPath + "page_LL0.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return pagination(" + (Sequence + 1) + ");\"><img src=\"" + ImagesPath + "page_R1.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return pagination(" + intPageCount + ");\"><img src=\"" + ImagesPath + "page_LL1.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /></a> ";
- }
- string page5 = "";
- string strPage = Sequence.ToString() + "/" + intPageCount.ToString();
- page5 = "<input id='goPageNumTemp' value='" + Sequence + "' style='width:40px;height:16px;BORDER-RIGHT: #7b9ebd 1px solid; BORDER-TOP: #7b9ebd 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #7b9ebd 1px solid; BORDER-BOTTOM: #7b9ebd 1px solid;' onkeyup=\"this.value=this.value.replace(/\\D/g,'')\" onafterpaste=\"this.value=this.value.replace(/\\D/g,'')\" /> 页 <button style='width:50px;height:18px;' onclick=\"var strgonum=document.getElementById('goPageNumTemp').value;if(strgonum!=''){if(strgonum>" + intPageCount + "){pagination(" + intPageCount + ");}else{pagination(strgonum);}}else{pagination(" + Sequence + ");}\">转到</button>";
- PageBar = string.Format(htmlText, str, RecordCount, ItemUnit, strPage, page5);
- }
- /// <summary>
- /// 分页功能条(无刷新模式)
- /// </summary>
- /// <param name="i">子列表分页编序paginationNum,子列表上级ID</param>
- public void ChildPageBarUnRefresh(int i)
- {
- string htmlText = "<div>";
- htmlText += "<h1 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">{0}</h1>";
- htmlText += "<h2 style=\"float: left; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; font-size: 12px;font-weight: normal;\">共计: {1} {2} {3}</h2>";
- htmlText += "</div>";
- int intPageCount = 0;
- if ((RecordCount % PageSize) == 0)
- intPageCount = RecordCount / PageSize;
- else
- intPageCount = RecordCount / PageSize + 1;
- string str = "";
- if (Sequence < 2)
- str += "<img name=\"none\" src=\"" + ImagesPath + "page_FL0.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /> <img name=\"none\" src=\"" + ImagesPath + "page_L0.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return paginationNum(" + i + ",1);\"><img src=\"" + ImagesPath + "page_FL1.gif\" style=\"border:0px; margin: 0 5px 0 25px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return paginationNum(" + i + "," + (Sequence - 1) + ");\"><img src=\"" + ImagesPath + "page_L1.gif\" style=\"border:0px; margin: 0 10px 0 5px;\" /></a> ";
- }
- if ((intPageCount - Sequence) < 1)
- str += "<img name=\"none\" src=\"" + ImagesPath + "page_R0.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /> <img name=\"none\" src=\"" + ImagesPath + "page_LL0.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /> ";
- else
- {
- str += "<a href=\"#\" onclick=\"return paginationNum(" + i + "," + (Sequence + 1) + ");\"><img name=\"none\" src=\"" + ImagesPath + "page_R1.gif\" style=\"border:0px; margin: 0 5px 0 10px;\" /></a> ";
- str += "<a href=\"#\" onclick=\"return paginationNum(" + i + "," + intPageCount + ");\"><img name=\"none\" src=\"" + ImagesPath + "page_LL1.gif\" style=\"border:0px; margin: 0 25px 0 5px;\" /></a> ";
- }
- string strPage = Sequence.ToString() + "/" + intPageCount.ToString();
- PageBar = string.Format(htmlText, str, RecordCount, ItemUnit, strPage);
- }
- #region 分页 法拉利模式分页
- public void PageBarFerrari()
- {
- int intPageCount = 0;
- if ((RecordCount % PageSize) == 0)
- intPageCount = RecordCount / PageSize;
- else
- intPageCount = RecordCount / PageSize + 1;
- string str = "";
- if (Sequence < 2)
- {
- str += "<a class=\"toolbarbutton\" id=\"f_fastRewind\" disabled onclick=\"return false;\" href=\"javascript:onclick();\" target=\"_self\"><img id=\"f_page_FL0\" disabled alt=\"加载首页\" src=\"" + ImagesPath + "page_FL0.gif\" align=\"absMiddle\"></a>";
- str += "<a class=\"toolbarbutton\" id=\"f__prevPageImg\" disabled onclick=\"return false;\" href=\"javascript:onclick();\" target=\"_self\"><img id=\"f_page_L0\" disabled alt=\"加载上一页\" hspace=\"6\" src=\"" + ImagesPath + "page_L0.gif\" align=\"absMiddle\"></a>";
- }
- else
- {
- str += "<a class=\"toolbarbutton\" id=\"f_fastRewind\" onclick=\"return pagination(1);\" href=\"javascript:onclick();\" target=\"_self\" ><img id=\"f_page_FL1\" alt=\"加载首页\" src=\"" + ImagesPath + "page_FL1.gif\" align=\"absMiddle\"></a>";
- str += "<a class=\"toolbarbutton\" id=\"f__prevPageImg\" onclick=\"return pagination(" + (Sequence - 1) + ");\" href=\"javascript:onclick();\" target=\"_self\" ><img id=\"f_page_L1\" alt=\"加载上一页\" hspace=\"6\" src=\"" + ImagesPath + "page_L1.gif\" align=\"absMiddle\"></a>";
- }
- str += "第 <span id=\"f__PageNum\">" + Sequence + "</span> 页";
- if ((intPageCount - Sequence) < 1)
- {
- str += "<a class=\"toolbarbutton\" id=\"f__nextPageImg\" disabled onclick=\"return false;\" href=\"javascript:onclick();\" target=\"_self\"><img id=\"f_page_R0\" disabled alt=\"加载下一页\" hspace=\"6\" src=\"" + ImagesPath + "page_R0.gif\" align=\"absMiddle\"></a>";
- str += "<a class=\"toolbarbutton\" id=\"f_lastPageImg\" disabled onclick=\"return false;\" href=\"javascript:onclick();\" target=\"_self\"><img id=\"f_page_LR0\" disabled alt=\"加载尾页\" hspace=\"6\" src=\"" + ImagesPath + "page_LR0.gif\" align=\"absMiddle\"></a>";
- }
- else
- {
- str += "<a class=\"toolbarbutton\" id=\"f__nextPageImg\" onclick=\"return pagination(" + (Sequence + 1) + ");\" href=\"javascript:onclick();\" target=\"_self\" ><img id=\"f_page_R1\" alt=\"加载下一页\" hspace=\"6\" src=\"" + ImagesPath + "page_R1.gif\" align=\"absMiddle\" /></a>";
- str += "<a class=\"toolbarbutton\" id=\"f_lastPageImg\" onclick=\"return pagination(" + intPageCount + ");\" href=\"javascript:onclick();\" target=\"_self\" ><img id=\"f_page_LR1\" alt=\"加载尾页\" hspace=\"6\" src=\"" + ImagesPath + "page_LR1.gif\" align=\"absMiddle\" /></a>";
- }
- //string strPage = Sequence.ToString() + "/" + intPageCount.ToString();
- PageBar = str + " ";//string.Format(htmlText, str, RecordCount, ItemUnit, strPage);
- }
- #endregion
- #endregion
- #region 构造
- public Pagination()
- {
- }
- #endregion
- }
- }
|