<!--#include file = "Startup.asp"-->
<!-- #include file="Function.asp" -->
<%
call adminer()
call Header()
Call ComeUrl()
%>
<%
Dim Action,FoundErr,ErrMsg
Dim Id,ComName,ComUrl,ComKEY,ComAdd,LanXiRen,ComCode,ComTel,ComFax,ComMail

Action=Trim(Request("Action"))
if Action="" Or Action="Manage" then
	call Main()
elseif Action="AddAnnounce" then
	call AddAnnounce()
elseif Action="AddSaveAnnounce" then
	call AddSaveAnnounce()
elseif Action="ModifyAnnounce" then
	call ModifyAnnounce()
elseif Action="ModifySaveAnnounce" then
	call ModifySaveAnnounce()
elseif Action="DelAnnounce" then
	call DelAnnounce()
Else
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数错误！</li>"
end if

if founderr=true then
	call WriteErrMsg()
End if
%>





<%
Sub Main
%>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled==false)
       e.checked = form.chkAll.checked;
    }
  }
  

function ConfirmDel()
{
	if(document.myform.Action.value=="Del")
	{
		if(confirm("确定要删除选中的新闻吗？一但删除将无法恢复！"))
		    return true;
		else
			return false;
	}
}
</SCRIPT>
<table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
  <form name="myform" method="post" action="FreeWordPingLun.asp?Action=DelAnnounce" onsubmit="return ConfirmDel();"><tr>
    <td width="40" bgcolor="#F7F7F7"><div align="center"><strong>选中</strong>
      
      
    </div></td>
    <td bgcolor="#F7F7F7"><div align="center"><strong>评论内容</strong></div></td>
    <td bgcolor="#F7F7F7"><div align="center"><strong>评论人</strong></div></td>
    <td bgcolor="#F7F7F7"><div align="center"><strong>添加时间</strong></div></td>
    <td bgcolor="#F7F7F7"><div align="center"><strong>删除</strong></div></td>
    </tr>
  
<%
sSql="Select * From FreeWordReply Order By ID Desc"
oRs.Open sSql,oConn,1,3
If oRs.Eof Then
	Response.Write "<tr><td colspan='6' bgcolor='#FFFFFF'><div align='center'>暂无新闻信息！</div></td></tr></form></table>"
Else

const MaxPerPage=15   '单独页最大记录数 const 用来申明常量
dim totalPut   '总记录
dim CurrentPage  '当前页次
dim TotalPages   '总页数
dim i



'!-- 分页功能代码块,可独立使用
if not ors.eof then
  ors.MoveFirst  '注意放到前面来,否则到任何页总是在第一个记录上
  end if
  ors.pagesize=MaxPerPage  '设置每页最多显示多少条记录
  If trim(Request("Page"))<>"" then  '如果请求的页次不为空
	CurrentPage= CLng(request("Page"))   'clng是转换成长整型数据类型,并赋值到当前页次上
	If CurrentPage> ors.PageCount then  '如果当前页次大于总页数,则将最大页次赋值到当前页次上
		CurrentPage = ors.PageCount 
	End If 
Else 
	CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If 

 totalPut=ors.recordcount '将总记录赋值于TOTALPUT
	if CurrentPage<>1 then '如果当前页数不等于第一页
		if (currentPage-1)*MaxPerPage<totalPut then  '如果当前页减一乘以每页最大的记录数小于总记录的话
			ors.move(currentPage-1)*MaxPerPage  '相对当前记录数向后移动
			dim bookmark  '定义书签变量
			bookmark=ors.bookmark '将当前记录的标签赋于变量BOOKMARK上
		end if 
	end if

	dim n,k
	if (totalPut mod MaxPerPage)=0 then  '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
		n= totalPut \ MaxPerPage
	else  
		n= totalPut \ MaxPerPage + 1  
	end if

	Do While Not oRs.Eof and i<maxperpage
%>  
  <tr>
    <td width="40" bgcolor="#FFFFFF"><div align="center">
      <input name="AnnID" type="checkbox" onClick="unselectall()" id="AnnID" value="<%=oRs("ID")%>">
    </div></td>
    <td bgcolor="#FFFFFF"><%=gotTopic(oRs("Content"),150)%></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=oRs("PersonName")%></div></td>    
    <td bgcolor="#FFFFFF"><div align="center"><%=oRs("DateTime")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%If session("userclass")=1 Then%>[<span onClick='return ConfirmDel()'><a href="FreeWordPingLun.asp?Action=DelAnnounce&AnnID=<%=oRs("ID")%>">删除</a></span>]<%End If%>
    </div></td>
    </tr>
  
  <%
  oRs.MoveNext
  i=i+1
  Loop
  %>
  
  <tr>
    <td colspan="5" bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="40"><div align="center">
            <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
        </div></td>
        <td>选中本页显示的所有新闻</td>
        <td><div align="right">
		<input name="Action" type="hidden" id="Action2" value="Del">
        <input type="submit" name="Submit1" value=" 删　除 " onClick="document.myform.Action.value='Del'" class="input_submit">
&nbsp;&nbsp; </div></td>
      </tr>
    </table></td>
  </tr></form>
</table>

<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30"><div align="center">
        <%
	Response.Write "共 <font color='#FF0000'>"&totalPut&"</font> 条新闻　" 
          k=currentPage
		if k<>1 then
			response.write "[<b>"+"<a href='FreeWordPingLun.asp?page=1'>首页</a></b>] "
			response.write "[<b>"+"<a href='FreeWordPingLun.asp?page="&cstr(k-1)&"'>上一页</a></b>] "
		else
			Response.Write "[首页] [上一页]"
		end if
		if k<>n then
			response.write "[<b>"+"<a href='FreeWordPingLun.asp?page="&cstr(k+1)&"'>下一页</a></b>] "
			response.write "[<b>"+"<a href='FreeWordPingLun.asp?page="&cstr(n)&"'>尾页</a></b>] "
		else
			Response.Write "[下一页] [尾页]"
		end if	
		Response.Write "　页次：<font color='#ff0000'>"&currentpage&"</font>/"&n&"页　15条新闻/页"
		%>
　转到：
<select name="select" onchange="javascript:window.location='FreeWordPingLun.asp?page='+this.options[this.selectedIndex].value;">
<option>跳转页</option>
<%
Dim z
For z=1 To n%>
  <option value="<%=z%>" selected="selected">第<%=z%>页</option>
<%
Next
%> 
</select>
        </div></td>
  </tr></table>
<%
End If
End Sub
%>
<%
Sub DelAnnounce()

dim AnnID
AnnID=trim(Request("AnnID"))
if AnnID="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足</li>"
	exit sub
end if
sSql="Select * From FreeWordReply Where ID In ("&AnnID&")"
oRs.Open sSql,oConn,1,1
If oRs.Eof Then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>无此新闻！</li>"
	exit sub
End If
oRs.Close
sSql = "DELETE From FreeWordReply WHERE ID In ("&AnnID&")"
oConn.Execute sSql
	
Response.Write "<p align=center>评论删除成功，3秒后自动返回评论管理页！<script>window.setTimeout(""location.href='FreeWordPingLun.asp'"",3000);</script></p>"

End Sub
%>