#region +AJAX获得功能页码条
/// <summary>
/// AJAX获得功能页码条
/// </summary>
/// <param name="funName">js方法名</param>
/// <param name="allrecord">全部记录条数</param>
/// <param name="allpage">全部页面数</param>
/// <param name="curpage">当前页码</param>
/// <param name="groupsize">页码组大小</param>
/// <param name="pagesize">页容量</param>
public static string GetPageTxtAjax(string funName, int allrecord, int allpage, int curpage, int groupsize, int pagesize)
{
int curGroupPage = 0;
StringBuilder test = new StringBuilder();
StringBuilder test2 = new StringBuilder();
StringBuilder pagetxt = new StringBuilder();
if (curpage.Equals("") || curpage < 1) curpage = 1;
if (allrecord.Equals("") || allrecord < 1) allrecord = 1;
if (pagesize.Equals("") || pagesize < 1) pagesize = 1;
if (allrecord == 0) { pagetxt.Append("页码:0/0 │ 共0条</TD> <td align='left'> 首页 << 上一页 | 1 Next | >> 尾页 </td></tr></table>"); }
else
{
test2.Append(allpage.ToString());
if (allpage.Equals("") || allpage < 1) allpage = 1;
pagetxt.Append("页码:" + curpage.ToString() + "/" + allpage.ToString() + " │ 共" + allrecord.ToString() + "条");
pagetxt.Append("<A href='javascript:" + funName+"(1)' title='首页'>1</A> ");
curGroupPage = (((curpage - 1) / groupsize) * groupsize) + 1;
if (curGroupPage <= 1) pagetxt.Append("<a href='javascript:" + funName + "(" + curGroupPage + ")' title='回到首页'><<</A> ");
else pagetxt.Append("<a href='javascript:" + funName + "(" + (curGroupPage - 1) + ")' title='前 " + groupsize + " 页'><<</A> ");
if (curpage <= 1) pagetxt.Append("<A href='javascript:" + funName + "(" + curpage + ")' title='首页'>Prev</A> ");
else pagetxt.Append("<A href='javascript:" + funName + "(" + (curpage - 1) + ")' title='前一页'>Prev</A> ");
int tempI = 0;
tempI = curGroupPage;
do
{
if (tempI == curpage) pagetxt.Append("<span class='nowpage'>" + tempI + "</span> ");
else pagetxt.Append("<A href='javascript:" + funName + "(" + tempI + ")'>" + tempI + "</A> ");
tempI = tempI + 1;
} while (tempI < curGroupPage + groupsize && tempI <= allpage);
if (curpage < allpage) pagetxt.Append("<A href='javascript:" + funName + "(" + (curpage + 1) + ")' title='后一页'>Next</A> ");
else pagetxt.Append("<A href='javascript:" + funName + "(" + curpage + ")' title='后一页'>Next</A> ");
if (curGroupPage + groupsize > allpage) pagetxt.Append("<a href='javascript:" + funName + "(" + allpage + ")' title='后 " + groupsize + " 页'>>></A> ");
else pagetxt.Append("<a href='javascript:" + funName + "(" + (curGroupPage + groupsize) + ")' title='后" + groupsize + "页'>>></A> ");
pagetxt.Append("<A href='javascript:" + funName + "(" + allpage + ")' title='最后一页'>" + allpage + "</A>");
}
test.Append("allpage=" + allpage + ",allrecord=" + allrecord + ",pagesize=" + pagesize + ",groupsize=" + groupsize + ",curGroupPage=" + curGroupPage + ",curpage=" + curpage);
return pagetxt.ToString();
}
#endregion
#region +WEBFORM获得功能页码条
/// <summary>
/// WEBFORM获得功能页码条
/// </summary>
/// <param name="url">页码连接地址</param>
/// <param name="searcheurl">搜索url</param>
/// <param name="allrecord">全部记录条数</param>
/// <param name="allpage">全部页面数</param>
/// <param name="curpage">当前页码</param>
/// <param name="groupsize">页码组大小</param>
/// <param name="pagesize">页容量</param>
public static string GetPageTxt(string url, string searcheurl, int allrecord, int allpage, int curpage, int groupsize, int pagesize)
{
int curGroupPage = 0;
StringBuilder test = new StringBuilder();
StringBuilder test2 = new StringBuilder();
StringBuilder pagetxt = new StringBuilder();
if (curpage.Equals("") || curpage < 1) curpage = 1;
if (allrecord.Equals("") || allrecord < 1) allrecord = 1;
if (pagesize.Equals("") || pagesize < 1) pagesize = 1;
if (allrecord == 0) { pagetxt.Append("页码:0/0 │ 共0条</TD> <td align='left'> 首页 << 上一页 | 1 Next | >> 尾页 </td></tr></table>"); }
else
{
test2.Append(allpage.ToString());
if (allpage.Equals("") || allpage < 1) allpage = 1;
pagetxt.Append("页码:" + curpage.ToString() + "/" + allpage.ToString() + " │ 共" + allrecord.ToString() + "条");
pagetxt.Append("<A href='" + url + "1' title='首页'>1</A> ");
curGroupPage = (((curpage - 1) / groupsize) * groupsize) + 1;
if (curGroupPage <= 1) pagetxt.Append("<a href='" + url + curGroupPage + searcheurl + "' title='回到首页'><<</A> ");
else pagetxt.Append("<a href='" + url + (curGroupPage - 1) + searcheurl + "' title='前 " + groupsize + " 页'><<</A> ");
if (curpage <= 1) pagetxt.Append("<A href='" + url + curpage + searcheurl + "' title='首页'>Prev</A> ");
else pagetxt.Append("<A href='" + url + (curpage - 1) + searcheurl + "' title='前一页'>Prev</A> ");
int tempI = 0;
tempI = curGroupPage;
do
{
if (tempI == curpage) pagetxt.Append("<span class='nowpage'>" + tempI + "</span> ");
else pagetxt.Append("<A href='" + url + tempI + searcheurl + "'>" + tempI + "</A> ");
tempI = tempI + 1;
} while (tempI < curGroupPage + groupsize && tempI <= allpage);
if (curpage < allpage) pagetxt.Append("<A href='" + url + (curpage + 1) + searcheurl + "' title='后一页'>Next</A> ");
else pagetxt.Append("<A href='" + url + curpage + searcheurl + "' title='后一页'>Next</A> ");
if (curGroupPage + groupsize > allpage) pagetxt.Append("<a href='" + url + allpage + searcheurl + "' title='后 " + groupsize + " 页'>>></A> ");
else pagetxt.Append("<a href='" + url + (curGroupPage + groupsize) + searcheurl + "' title='后" + groupsize + "页'>>></A> ");
pagetxt.Append("<A href='" + url + allpage + searcheurl + "' title='最后一页'>" + allpage + "</A>");
}
test.Append("allpage=" + allpage + ",allrecord=" + allrecord + ",pagesize=" + pagesize + ",groupsize=" + groupsize + ",curGroupPage=" + curGroupPage + ",curpage=" + curpage);
return pagetxt.ToString();
}