日期:2012-09-06  浏览次数:21082 次

<%
REM -----------------------------------
REM 作 者:王勤军 qinjunit@yahoo.com
REm 创作日期:2004-10-12
REM 修改日期:2005年1月24日 星期一
REM -----------------------------------


'函数 实用数据分页显示函数
'参数:DataSQL ----------- 当前页面数据的SQL语句
'参数:CountSQL ----------- 查询总条数的SQL语句
'参数:Page ----------- 哪 页
'参数:PageSize ----------- 页 次
'参数:THeadStrings ------- 显示表头列名称定义,用“,”分隔,与DataSQL里面的列名对应。
'实 例:=======================================
'<!--#include virtual="inc/conn.asp"-->
'<!--#include virtual="inc/RW_DataPager.asp"-->
'<%
'dim iPageSize,CurPage
' iPageSize = 18
' CurPage = 1
'if (Request.Form <> "") then
' if IsEmpty(Request.Form("p")) then
' CurPage = 1
' elseif IsNumeric(Request.Form("p")) then
' CurPage = CLng(Request.Form("p"))
' end if
'end if
'ShowRecords "exec p_show accounts,"&iPageSize&","&CurPage&",'account_code,account_password,account_serial,account_type,account_money,stock_time'","select count(account_code) as total from [accounts]",CLng(CurPage),iPageSize,"卡号,密码,序列号,卡类型,卡金额,入库时间"

'CloseDB()
'% >
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ShowRecords(DataSQL,CountSQL,Page,PageSize,ModelStrings,THeadStrings)
dim total,rs,DatMessages
dim UseDataModel
if (Request.Form("pagerTotal") <> "") then
total = CLng(Request.Form("PagerTotal"))
else
total = conn.execute(CountSQL)(0)
end if
if Len(ModelStrings)<8 then '模版长度在此定义为8
UseDataModel = false
else
UseDataModel = true
end if
DatMessages = DatMessages & "<table width=""100%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""Border-Collapse:collapse;word-break:break-all"">"
DatMessages = DatMessages & "<form name=""frmPager"" id=""frmPager"" method=""post"">"

if Clng(total) <> 0 then
'set rs = conn.execute(DataSQL)
REM 非存储过程分页====================
set rs=server.createobject("ADODB.RECORDSET")
rs.Open DataSQL,conn,1,1
rs.PageSize=PageSize
rs.AbsolutePage=Page
REM ==================================

dim thArray,ColCount,k,thStr,i
i = 1 '初始化记数器
ColCount = rs.Fields.Count '获取总列数

if not UseDataModel then '不使用模版操作
if Len(THeadStrings)<1 then
for k = 0 to (rs.Fields.Count-1)
thStr = thStr & rs.Fields(k).name&","
next
thArray = Split((Mid(thStr,1,len(thStr)-1)),",")
else
thArray = Split(THeadStrings,",")
End if

DatMessages = DatMessages & "<tr bgcolor=""#BFE8FB"">"
for k=0 to (ColCount-1)
DatMessages = DatMessages & "<th class='hyxxtext'>"&thArray(k)&"</th>"
next
DatMessages = DatMessages & "</tr>"
else
DatMessages = DatMessages & "<tr><td>"
end if

'---------数据循环开始------------'
while (not rs.eof and i<PageSize)
if not UseDataModel then
if (i mod 2 =0 ) then
DatMessages = DatMessages & "<tr bgcolor=""#E1F4FD"">"
else
DatMessages = DatMessages & "<tr bgcolor=""#FFFFFF"">"
end if

for k=0 to (ColCount-1)