<%@language=vbscript codepage=936 %>
<!--#include file="Conn.asp"-->
<!--#include file ="Check_Manager.asp"-->
<%
Sub delrep
Set del=Conn.Execute("Delete * From [Book_Reply] Where [Book_ID]="&Cint(Request("id")))
Set del=Conn.Execute("Delete * From [Book] Where ID="&Cint(Request("id")))
JaSys("管理员" & session("ManagerUser") & "<font color=red>删除留言ID"&Request("id")&"</font>成功")
Response.Redirect "Book_Manage.asp"
End Sub
If Request.QueryString("action")="pass" Then
Dim cid
cid = Request.QueryString("id")
Conn.ExeCute("Update [Book] Set [MCheck]=1 Where id="&cid&"")
JaSys("管理员" & session("ManagerUser") & "<font color=red>通过ID为"&cid&"的留言审核</font>")
 Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('通过审核成功!');" & Chr(13)
		Response.write "window.document.location.href='Book_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
    Response.End
End If
If Request.QueryString("action")="close" Then
cid = Request.QueryString("id")
Conn.ExeCute("Update [Book] Set [MCheck]=0 Where id="&cid&"")
JaSys("管理员" & session("ManagerUser") & "<font color=red>取消ID为"&cid&"的留言审核</font>")
 Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('取消审核成功!');" & Chr(13)
		Response.write "window.document.location.href='Book_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
    Response.End
End If

If Request.QueryString("action")="del" Then
Call delrep() 
End if
If Request.Form("cndok") Then Response.Redirect "Book_Manage.asp?page="&Trim(Request.Form("pp"))
Set rs=Server.CreateObject("Adodb.Recordset")
Sql="Select * From Book Order By ID desc"
rs.Open Sql,Conn,1,1

dim MaxPerPage
MaxPerPage=20

Dim text,checkpage
text="0123456789"
Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next

If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if
%>
<script language=javascript>
function ConfirmDel()
{
   if(confirm("确定要删除此留言吗？"))
     return true;
   else
     return false;
}
</script>
<html>
<head>
<titel></titel>
<LINK href="admin/admin.css" type=text/css rel=stylesheet>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="10" cellspacing="10">
  <tr>
    <td><div align="center"><strong>留言管理</strong></div></td>
  </tr>
</table>
<table width="700" border="0" align="center" cellpadding="2" cellspacing="0" class=tableBorder>
  <tr> 
    <td width="34" height="25" align="center" background="admin/admin_bg_1.gif"><strong> 
      <font color="#FFFFFF">ID</font></strong></td>
    <td width="130" height="25" align="center" background="admin/admin_bg_1.gif"><strong><font color="#FFFFFF">留言人</font> 
      </strong></td>
    <td width="286" height="25" align="center" background="admin/admin_bg_1.gif"><strong> 
      <font color="#FFFFFF">留言主题</font></strong></td>
    <td width="83" align="center" background="admin/admin_bg_1.gif"><strong><font color="#FFFFFF">留言时间</font></strong></td>
    <td width="83" align="center" background="admin/admin_bg_1.gif"><strong><font color="#FFFFFF">审核情况</font></strong></td>
    <td width="48" align="center" background="admin/admin_bg_1.gif"><strong><font color="#FFFFFF">回复数</font></strong></td>
    <td width="200" height="25" align="center" background="admin/admin_bg_1.gif"><strong> 
      <font color="#FFFFFF">操作</font></strong></td>
  </tr>
  <%If rs.Eof or rs.Bof Then
Response.Write "<center>没有留言</center>"
Else
i=0
Do While Not rs.Eof
%>
  <tr> 
    <td height="22" align="center"><%=rs("ID")%></td>
    <td align="center"><%=rs("Name")%></td>
    <td><a href="../BookShow.asp?id=<%=rs("ID")%>" target="_blank"><%=rs("Title")%></a></td>
    <td align="center"><%=rs("Time")%></td>
    <td align="center"><%If Cint(Rs("MCheck"))=1 Then Response.Write "已审核" Else Response.Write "未审核" End if%></td>
    <td align="center"><%=rs("Reply")%></td>
    <td align="center"><a href="Book_Reply.asp?action=rep&id=<%=rs("ID")%>">回复</a> | &nbsp;<a href="Book_Manage.asp?action=del&id=<%=rs("ID")%>" onClick="return ConfirmDel();">删除</a>|&nbsp;&nbsp;<%If int(Rs("MCheck"))=1 Then%><a href="?action=close&id=<%=rs("ID")%>">取消审核</a><%Else%><a href="?action=pass&id=<%=rs("ID")%>">通过审核</a><%End If%></td>
  </tr>
  <%
i=i+1 
If i >= MaxPerpage Then Exit do 
rs.MoveNext
 Loop
 End if
 %>
</table>
    </td>
  </tr>
</table>
 
<table width="700" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
                  <td> 
                    <form name="form1" method="post" action="">
<%
Response.write "全部"
Response.write "共 </font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'> 个留言</font></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
Response.write "第</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) &  "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font></strong>&nbsp;"
If currentpage > 1 Then
response.write "<a href='Book_Manage.asp?&page="+cstr(1)+"'>首页 </a>"
Response.write "<a href='Book_Manage.asp?page="+Cstr(currentpage-1)+"'> 上一页 </a>"
Else
Response.write " 上一页 "
End if
If currentpage < Rs.PageCount Then
Response.write "<a href='Book_Manage.asp?page="+Cstr(currentPage+1)+"'> 下一页 "
Response.write "<a href='Book_Manage.asp?page="+Cstr(Rs.PageCount)+"'> 尾页</a>&nbsp;&nbsp;"
Else
Response.write "下一页&nbsp;&nbsp;"
End if
response.write "</td><td align='right'>"
response.write "转到：<input type='text' name='pp' size=4 maxlength=4 class=smallInput value="&Currentpage&">&nbsp;"
response.write "<input type='submit'  value='Go'  name='cndok'>&nbsp;&nbsp;"
%>
                    </form> </td>
                </tr>
              </table>
</body>
</html>
<%rs.Close
Conn.Close
%>