<%
Class CGrid
Private mRecordset '表格记录集
Private mPage '记录集的当前页
Private mGridHtml '表格的HTML代码
Private mGridFrame '表格的框架
Private mHeadFrame '表格头框架
Private mCols '表格列数
Private mRows '表格行数
Private mHeadArray '描述表格头的数组
Private mDataArray '描述表格数据的数组
Private mDataLineStyle '行数据风格
Private mPageFile '页文件名
Private mPageNavStyle '导航条风格
Private mNoRecordStyle '没有记录集的风格
Private mNoRecordMsg '没有记录集的信息
Public Sub GenHtml()
dim iLoop,iLoopTmp,iPageCount
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mGridFrame & chr(34) & ">"
'头部
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mHeadFrame & chr(34) & ">"
for iLoop=0 to mCols-1
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mHeadArray(iLoop),"|")(1) & chr(34) & ">"
mGridHtml=mGridHtml & split(mHeadArray(iLoop),"|")(0)
mGridHtml=mGridHtml & "</DIV>"
next
mGridHtml=mGridHtml & "</DIV>"
'数据
if mRecordset.RecordCount>0 then
mRecordset.PageSize=mRows
iPageCount=mRecordset.PageCount
mRecordset.AbsolutePage=mPage
for iLoop=1 to mRows
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mDataLineStyle & chr(34) & ">"
for iLoopTmp=0 to mCols-1
select case split(mDataArray(iLoopTmp),"|")(0)
case "Field"
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mDataArray(iLoopTmp),"|")(2) & chr(34) & ">"
mGridHtml=mGridHtml & mRecordset(split(mDataArray(iLoopTmp),"|")(1))
mGridHtml=mGridHtml & "</DIV>"
case "Check"
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mDataArray(iLoopTmp),"|")(2) & chr(34) & ">"
mGridHtml=mGridHtml & "<INPUT type=CheckBox name=CheckRecord value=" & mRecordset(split(mDataArray(iLoopTmp),"|")(1)) & ">"
mGridHtml=mGridHtml & "</DIV>"
end select
next
mGridHtml=mGridHtml & "</DIV>"
mRecordset.Movenext
if mRecordset.EOF then exit for
next
'导航条
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mPageNavStyle & chr(34) & ">"
mGridHtml=mGridHtml & "共" & mRecordset.RecordCount & "条" & " "
mGridHtml=mGridHtml & "每页" & mRows & "条" & " "
mGridHtml=mGridHtml & "第" & mPage & "页/共" & iPageCount & "页" & " "
if iPageCount=1 then
mGridHtml=mGridHtml & "首页 前页 后页 末页"
elseif mPage=1 then
mGridHtml=mGridHtml & "首页 前页 <a href=" & mPageFile & "?page=" & (mPage+1) & ">后页</a> <a href=" & mPageFile & "?page=" & iPageCount & ">末页</a>"
elseif trim(mPage)=trim(iPageCount) then
mGridHtml=mGridHtml & "<a href=" & mPageFile & "?page=1>首页</a> <a href=" & mPageFile & "?page=" & (mPage-1) & ">前页</a> 后页 末页"
else
mGridHtml=mGridHtml & "<a href=" & mPageFile & "?page=1>首页</a> <a href=" & mPageFile & "?page=" & (mPage-1) & ">前页</a> <a href=" & mPageFile & "?page=" & (mPage+1) & ">后页</a> <a href=" & mPageFile & "?page=" & iPageCount & ">末页</a>"
end if
mGridHtml = mGridHtml & " "
mGridHtml=mGridHtml & "</DIV>"
else
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mNoRecordStyle & chr(34) & ">"
mGridHtml=mGridHtml & mNoRecordMsg
mGridHtml=mGridHtml & "</DIV>"
end if
mGridHtml=mGridHtml & "</DIV>"
End Sub
Public Property Let Recordset(ByVal vData)
set mRecordset=vData
End Property
Public Property Let GridHtml(ByVal vData)
mGridHtml=vData
End Property
Public Property Get GridHtml()
GridHtml=mGridHtml
End Property
Public Property Let GridFrame(ByVal vData)
mGridFrame=vData
End Property
Public Property Let HeadFrame(ByVal vData)
mHeadFrame=vData
End Property
Public Property Let Cols(ByVal vData)
mCols=vData
End Property
Public Property Let Rows(ByVal vData)
mRows=vData
End Property
Public Property Let HeadArray(ByVal vData)
mHeadArray=vData
End Property
Public Property Let DataArray(ByVal vData)
mDataArray=vData
End Property
Public Property Let Page(ByVal vData)
mPage=vData
End Property
Public Property Let DataLineStyle(ByVal vData)
mDataLineStyle=vData
End Property
Public Property Let PageFile(ByVal vData)
mPageFile=vData
End Property
Public Property Let PageNavStyle(ByVal vData)
mPageNavStyle=vData
End Property
Public Property Let NoRecordStyle(ByVal vData)
mNoRecordStyle=vData
End Property
Public Property Let NoRecordMsg(ByVal vData)
mNoRecordMsg=vData
End Property
End Class
%>
Class CGrid
Private mRecordset '表格记录集
Private mPage '记录集的当前页
Private mGridHtml '表格的HTML代码
Private mGridFrame '表格的框架
Private mHeadFrame '表格头框架
Private mCols '表格列数
Private mRows '表格行数
Private mHeadArray '描述表格头的数组
Private mDataArray '描述表格数据的数组
Private mDataLineStyle '行数据风格
Private mPageFile '页文件名
Private mPageNavStyle '导航条风格
Private mNoRecordStyle '没有记录集的风格
Private mNoRecordMsg '没有记录集的信息
Public Sub GenHtml()
dim iLoop,iLoopTmp,iPageCount
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mGridFrame & chr(34) & ">"
'头部
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mHeadFrame & chr(34) & ">"
for iLoop=0 to mCols-1
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mHeadArray(iLoop),"|")(1) & chr(34) & ">"
mGridHtml=mGridHtml & split(mHeadArray(iLoop),"|")(0)
mGridHtml=mGridHtml & "</DIV>"
next
mGridHtml=mGridHtml & "</DIV>"
'数据
if mRecordset.RecordCount>0 then
mRecordset.PageSize=mRows
iPageCount=mRecordset.PageCount
mRecordset.AbsolutePage=mPage
for iLoop=1 to mRows
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mDataLineStyle & chr(34) & ">"
for iLoopTmp=0 to mCols-1
select case split(mDataArray(iLoopTmp),"|")(0)
case "Field"
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mDataArray(iLoopTmp),"|")(2) & chr(34) & ">"
mGridHtml=mGridHtml & mRecordset(split(mDataArray(iLoopTmp),"|")(1))
mGridHtml=mGridHtml & "</DIV>"
case "Check"
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & split(mDataArray(iLoopTmp),"|")(2) & chr(34) & ">"
mGridHtml=mGridHtml & "<INPUT type=CheckBox name=CheckRecord value=" & mRecordset(split(mDataArray(iLoopTmp),"|")(1)) & ">"
mGridHtml=mGridHtml & "</DIV>"
end select
next
mGridHtml=mGridHtml & "</DIV>"
mRecordset.Movenext
if mRecordset.EOF then exit for
next
'导航条
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mPageNavStyle & chr(34) & ">"
mGridHtml=mGridHtml & "共" & mRecordset.RecordCount & "条" & " "
mGridHtml=mGridHtml & "每页" & mRows & "条" & " "
mGridHtml=mGridHtml & "第" & mPage & "页/共" & iPageCount & "页" & " "
if iPageCount=1 then
mGridHtml=mGridHtml & "首页 前页 后页 末页"
elseif mPage=1 then
mGridHtml=mGridHtml & "首页 前页 <a href=" & mPageFile & "?page=" & (mPage+1) & ">后页</a> <a href=" & mPageFile & "?page=" & iPageCount & ">末页</a>"
elseif trim(mPage)=trim(iPageCount) then
mGridHtml=mGridHtml & "<a href=" & mPageFile & "?page=1>首页</a> <a href=" & mPageFile & "?page=" & (mPage-1) & ">前页</a> 后页 末页"
else
mGridHtml=mGridHtml & "<a href=" & mPageFile & "?page=1>首页</a> <a href=" & mPageFile & "?page=" & (mPage-1) & ">前页</a> <a href=" & mPageFile & "?page=" & (mPage+1) & ">后页</a> <a href=" & mPageFile & "?page=" & iPageCount & ">末页</a>"
end if
mGridHtml = mGridHtml & " "
mGridHtml=mGridHtml & "</DIV>"
else
mGridHtml=mGridHtml & "<DIV style=" & chr(34) & mNoRecordStyle & chr(34) & ">"
mGridHtml=mGridHtml & mNoRecordMsg
mGridHtml=mGridHtml & "</DIV>"
end if
mGridHtml=mGridHtml & "</DIV>"
End Sub
Public Property Let Recordset(ByVal vData)
set mRecordset=vData
End Property
Public Property Let GridHtml(ByVal vData)
mGridHtml=vData
End Property
Public Property Get GridHtml()
GridHtml=mGridHtml
End Property
Public Property Let GridFrame(ByVal vData)
mGridFrame=vData
End Property
Public Property Let HeadFrame(ByVal vData)
mHeadFrame=vData
End Property
Public Property Let Cols(ByVal vData)
mCols=vData
End Property
Public Property Let Rows(ByVal vData)
mRows=vData
End Property
Public Property Let HeadArray(ByVal vData)
mHeadArray=vData
End Property
Public Property Let DataArray(ByVal vData)
mDataArray=vData
End Property
Public Property Let Page(ByVal vData)
mPage=vData
End Property
Public Property Let DataLineStyle(ByVal vData)
mDataLineStyle=vData
End Property
Public Property Let PageFile(ByVal vData)
mPageFile=vData
End Property
Public Property Let PageNavStyle(ByVal vData)
mPageNavStyle=vData
End Property
Public Property Let NoRecordStyle(ByVal vData)
mNoRecordStyle=vData
End Property
Public Property Let NoRecordMsg(ByVal vData)
mNoRecordMsg=vData
End Property
End Class
%>