<!--#include file="setup.asp" -->
<%
Const maxperpage = 15
Dim totalPut, CurrentPage, TotalPages
Dim j, i
Dim totalnumber, maxpagecount, Pcount, tempPcount
Dim filename, bookmark
NC_Admin.AdminChk = "17"
NC_Admin.Check
DownsysClass.admin_header
Select Case Trim(Request("action"))
	Case "del"
		Call DelEssay
	Case "delall"
		Call DelAllEssay
	Case Else
		Call EssayMain
End Select
If Founderr = True Then
	NC_Admin.Error_msg (ErrMsg)
End If
DownsysClass.admin_footer
NothingObject

Private Sub EssayMain()
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CLng(Request("page"))
	Else
		CurrentPage = 1
	End If
	If Not IsNumeric(Request("page")) And Request("page") <> "" Then
		Response.Write "错误的系统参数!请输入整数"
		Err.Raise -19691969
	End If
	Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" class=""tableBorder"">" & vbCrLf
	Response.Write " <tr>" & vbCrLf
	Response.Write " <th nowrap>选择</th><th>软件评论标题</th><th nowrap>评 论 人</th><th nowrap>E-Mail</th><th nowrap>评论人IP</th><th nowrap>评论时间</th>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <form name=""myform"" method=""post"" action=''>" & vbCrLf
	Set Rs = CreateObject("ADODB.Recordset")
	SQL = "select NC_SoftEssay.*,NC_SoftInfo.SoftName,NC_SoftInfo.SoftVer From NC_SoftEssay,NC_SoftInfo where NC_SoftEssay.softid = NC_SoftInfo.softid order by postime desc"
	Rs.Open SQL, conn, 1, 1
	DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td colspan=5 class=forumrow>还没有找到任何软件评论！</td></tr>"
	Else
		totalnumber = Rs.recordcount
		If (totalnumber Mod maxperpage) = 0 Then
			Pcount = totalnumber \ maxperpage
		Else
			Pcount = totalnumber \ maxperpage + 1
		End If
		Rs.MoveFirst
		If CurrentPage > Pcount Then CurrentPage = Pcount
		If CurrentPage < 1 Then CurrentPage = 1
		Rs.Move (CurrentPage - 1) * maxperpage
		bookmark = Rs.bookmark
		i = 0
		Do While Not Rs.EOF And i < CLng(maxperpage)
			Response.Write " <tr height=""21"">" & vbCrLf
			Response.Write " <td align=center class=forumRowHighlight><input type=checkbox name=Essayid value='"
			Response.Write Rs("id")
			Response.Write "'></td>" & vbCrLf
			Response.Write " <td class=forumRowHighlight><A HREF='../softessay.asp?id="
			Response.Write Rs("softid")
			Response.Write "' target=_blank>"
			Response.Write Rs("SoftName") & Rs("SoftVer")
			Response.Write "</A></td>" & vbCrLf
			Response.Write " <td nowrap class=forumRowHighlight align=center>"
			Response.Write Server.HTMLEncode(Rs("username"))
			Response.Write "</td>" & vbCrLf
			Response.Write " <td nowrap align=center class=forumRowHighlight><A HREF=""admin_mailist.asp?action=mail&useremail="
			Response.Write Rs("usermail")
			Response.Write """><img src=""images/email.gif"" border=0></A></td>" & vbCrLf
			Response.Write " <td nowrap class=forumRowHighlight align=center>"
			Response.Write Rs("postip")
			Response.Write "</td>" & vbCrLf
			Response.Write " <td nowrap class=forumRowHighlight align=center>"
			Response.Write FormatDateTime(Rs("postime"), 2)
			Response.Write "</td>" & vbCrLf
			Response.Write " </tr>" & vbCrLf
			Response.Write " <tr height=""21"">" & vbCrLf
			Response.Write " <td colspan=6 class=forumRow>"
			Response.Write DownsysClass.gotTopic(Rs("content"), 200)
			Response.Write "</td>" & vbCrLf
			Response.Write " </tr>" & vbCrLf
			Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close
	Set Rs = Nothing
	Response.Write " <tr height=""21"">" & vbCrLf
	Response.Write " <td align=center class=forumRowHighlight>管理</td>" & vbCrLf
	Response.Write " <td colspan=5 class=forumRow><input name=""chkAll"" type=""checkbox"" id=""chkAll"" onclick=CheckAll(this.form) value=""checkbox"">全选/反选　" & vbCrLf
	Response.Write " <input type=""radio"" name=""action"" value=""delall"">清空所有软件评论&nbsp;&nbsp;" & vbCrLf
	Response.Write " <input type=""radio"" name=""action"" value=""del"">批量删除&nbsp;&nbsp;" & vbCrLf
	Response.Write " <input type=submit name=Submit value=""执行操作"" class=button onclick=""{if(confirm('您确定执行此操作吗?')){this.document.myform.submit();return true;}return false;}""></td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " </form>" & vbCrLf
	Response.Write " <tr height=""21"">" & vbCrLf
	Response.Write " <td colspan=6 class=forumRowHighlight>"
	Call showpage
	Response.Write "</td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write "</table>" & vbCrLf
End Sub


Private Sub DelEssay()
	DownsysClass.Execute ("delete from NC_SoftEssay where id in (" & Request.Form("Essayid") & ")")
	Response.Redirect (Request.ServerVariables("HTTP_REFERER"))
	Err.Raise -19691969

End Sub


Private Sub DelAllEssay()
	DownsysClass.Execute ("delete from NC_SoftEssay")
	Response.Redirect (Request.ServerVariables("HTTP_REFERER"))
	Err.Raise -19691969
End Sub


Private Sub showpage()
	Dim filename
	Dim n
	Dim ii
	filename = "admin_softessay.asp"
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	Response.Write "<table cellspacing=1 width='100%' border=0><form method=Post action=" & filename & "><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		Response.Write "共有评论 <font COLOR=#FF0000><B>" & totalnumber & "</B></font> &nbsp;首 页&nbsp;上一页&nbsp;"
	Else
		Response.Write "共有评论 <font COLOR=#FF0000><B>" & totalnumber & "</B></font> &nbsp;<a href=" & filename & "?page=1>首 页</a>&nbsp;"
		Response.Write "<a href=" & filename & "?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		Response.Write "下一页&nbsp;尾 页 " & vbCrLf
	Else
		Response.Write "<a href=" & filename & "?page=" & (CurrentPage + 1) & ">下一页</a>"
		Response.Write "&nbsp;<a href=" & filename & "?page=" & n & ">尾 页</a>" & vbCrLf
	End If
	Response.Write "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	Response.Write "&nbsp;转到："
	Response.Write "&nbsp;<select name='page' size='1' style=""font-size: 9pt"" onChange='javascript:submit()'>" & vbCrLf
	For ii = 1 To n
		Response.Write "<option value='" & ii & "' "
		If CurrentPage = Int(ii) Then
			Response.Write "selected "
		End If
		Response.Write ">第" & ii & "页</option>"
	Next
	Response.Write "&nbsp;</select> " & vbCrLf
	Response.Write "</td></tr></FORM></table>" & vbCrLf
End Sub
%>
