<%@ codepage=936%><% Const dode="About" %>
<!--#include file="Config.asp" -->
<div class='menu'>&nbsp;查看 &gt; 单页</div>
<%
ListUrl = dode&".asp"
EditUrl = dode&"Edit.asp"
'------------------------------------------------
KeyWord = Trim(Request.QueryString("KeyWord"))
'================================================
'删除单个数据
'================================================
If Action="Del" Then
Conn.Execute "delete from ["&dodeTable&"] where ItemID="&ItemID
Response.Redirect Request.Servervariables("Http_Referer")
End If
'================================================
'更改状态 - 显示
'================================================
If Action="yes" Then
Conn.Execute "update ["&dodeTable&"] set "&ItemRecT&" where ItemID="&ItemID
Response.Redirect Request.Servervariables("Http_Referer")
End If
'================================================
'更改状态 - 隐藏
'================================================
If Action="no" Then
'------------------------------------------------
Conn.Execute "update ["&dodeTable&"] set "&ItemRecF&" where ItemID="&ItemID
Response.Redirect Request.Servervariables("Http_Referer")
End If
%>
<div class="title">
  <table width="98%" border="0" cellspacing="1" cellpAdding="1">
    <form method='post' name='ListForm' action="<%=ListUrl%>?Action=DelM">
    <tr>
      <td></td>
      <td align="right"><!-- Search Begin -->
        标题 <input type='text' name='KeyWord' value="<%=KeyWord%>">
        <input type='button' value='搜索' name='Search' onClick='GoSearch();'>
        <!-- Search end -->
      </td>
    </tr>
  </table>
</div>
<div class="content" align="center">
<table width="98%" border="0" cellspacing="1" cellpAdding="1" bgcolor="#d4d0c8">
<tr bgcolor="#FFFFFF" align="center">
<td width='50'><div class='title'>ID</div></td>
<td><div class='title'>标题</div></td>
<td width='50'><div class='title'>查看</div></td>
<td width='100' align='center'><div class='title'>操作</div></td>
<td width='35'><div class='title'>状态</div></td>
</tr>
<%
'分类显示及参数获取
'================================================
  Dim PageUrl:PageUrl = ListUrl&"?KeyWord="&KeyWord&"&"
  Dim idCount'记录总数
  Dim pages:pages=ProListNum
  Dim pagec'总页数
  Dim page:page=clng(Request("Page"))
  Dim pagenc:pagenc=pagencc
  Dim pagenmax'每页显示的分页的最大页码
  Dim pagenmin'每页显示的分页的最小页码
  Dim Datawhere:Datawhere = " where ItemID > 0 "
	  If KeyWord<>"" Then Datawhere=Datawhere&" and Item1 like '%"&KeyWord&"%' "
  Dim SqlID'本页需要用到的id
  Dim Taxis:Taxis="order by ItemID desc "
'================================================
'获取记录总数
'================================================  
  Sql="select count(ItemID) as idCount from ["& dodeTable &"]" & Datawhere
  Set Rs=Server.Createobject("Adodb.RecordSet")
  Rs.Open Sql,Conn,0,1
  idCount=rs("idCount")
  if(idcount>0) then'如果记录总数=0,则不处理
    if(idcount mod pages=0)then'如果记录总数除以每页条数有余数,则=记录总数/每页条数+1
	  pagec=int(idcount/pages)'获取总页数
   	else
      pagec=int(idcount/pages)+1'获取总页数
    end if
	'获取本页需要用到的id============================================
    '读取所有记录的id数值,因为只有id所以速度很快
    Sql="select ItemID from ["& dodeTable &"] " & Datawhere & Taxis
    Set Rs=Server.Createobject("Adodb.RecordSet")
    Rs.Open Sql,Conn,1,1
    Rs.pagesize = pages '每页显示记录数
    if page < 1 then page = 1
    if page > pagec then page = pagec
    if pagec > 0 then rs.absolutepage = page
    for i=1 to rs.pagesize
	  if rs.eof then exit for  
	  if(i=1)then
	    SqlID=Rs("ItemID")
	  else
	    SqlID=SqlID &","&Rs("ItemID")
	  end if
	  rs.movenext
    next
  '获取本页需要用到的id结束============================================
  end if

  If(idcount>0 and SqlID<>"") then'如果记录总数=0,则不处理
    '用in刷选本页所语言的数据,仅读取本页所需的数据,所以速度快
    Sql="select * from ["& dodeTable &"] where ItemID in("& SqlID &") "&Taxis
    Set Rs=Server.Createobject("Adodb.RecordSet")
    Rs.Open Sql,Conn,1,1
    while not rs.eof '填充数据到表格
	'------------------------------------------------
	If Trim(Rs("ItemRec")) Then
	st = "<a href='"&ListUrl&"?Action=no&ItemID="&Trim(Rs("ItemID"))&"'><img src='Images/yes.gif'></a>"
	Else
	st = "<a href='"&ListUrl&"?Action=yes&ItemID="&Trim(Rs("ItemID"))&"'><img src='Images/no.gif'></a>"
	End If
	'------------------------------------------------
	Response.Write "<tr onMouseOver='trOver(this);' onMouseOut='trOut(this);' bgcolor='#ffffff'>"	
	'------------------------------------------------
	Response.Write "<td align='center'>"&Trim(Rs("ItemID"))&"</td>"
	Response.Write "<td><a href='"&EditUrl&"?Action=Edit&ItemID="&Rs("ItemID")&"'>"&Trim(Rs("Item1"))&"</a></td>"
	Response.Write "<td align='center'>"&Trim(Rs("ItemHit"))&"</td>"
	Response.Write "<td align='center'><a href='"&EditUrl&"?Action=Edit&ItemID="&Rs("ItemID")&"'>修改</a> | "
	Response.Write "<a href='"&ListUrl&"?Action=Del&ItemID="&Rs("ItemID")&"' onClick=""return confirm('确定要删除吗？')"">删除</a></td>"
	Response.Write "<td align='center'>"&st&"</td>"	
    Rs.movenext
    wend
  end if
    Response.Write "</tr></table></div>"
  Response.Write "<div align='right'>共计："&idcount&"条记录&nbsp;页次："&page&"/"&pagec&"&nbsp;每页："&pages&"条&nbsp;&nbsp;"
  pagenmin=page-pagenc '计算页码开始值
  pagenmax=page+pagenc '计算页码结束值
  if(pagenmin<1) then pagenmin=1 '如果页码开始值小于1则=1
  if(page>1) then response.write ("<a href='"& PageUrl &"Page=1'>首页</a>&nbsp;") '如果页码大于1则显示(第一页)
  if(pagenmax>pagec) then pagenmax=pagec '如果页码结束值大于总页数,则=总页数
  for i = pagenmin to pagenmax'循环输出页码
	if(i=page) then
	  response.write ("&nbsp;"& i &"&nbsp;")
	else
	  response.write ("[<a href="& PageUrl &"Page="& i &">"& i &"</a>]")
	end if
  next
  if(page<pagec) then response.write ("&nbsp;<a href='"& PageUrl &"Page="& pagec &"'>尾页</a>") '如果页码小于总页数则显示(最后页)	
  Response.Write "&nbsp;跳转：<input name='SkipPage' onKeyDown='if(event.keyCode==13)event.returnValue=false' onChange=""if(/\D/.test(this.value)){alert('只能在跳转目标页框内输入整数！');this.value='"&Page&"';}"" type='text' value='"&Page&"' size='2'>&nbsp;页" & vbCrLf
  Response.Write "<input name='submitSkip' type='button' onClick='GoPage("""&PageUrl&""");' value='转到该页'></div>"
Call CloseConn()
Response.Write "</form>"
%>
  <br>
</body>
</html>
<script language="javascript" type="text/javascript">
function GoSearch(){
var KeyWord=document.ListForm.KeyWord.value;
window.location.href="<%=ListUrl%>?KeyWord="+KeyWord;
}
</script>