<!--#include file="setup.asp" -->
<%
Dim Rs1, Rs2, selSoftid, i
Dim CurrentPage, maxperpage, totalnumber, Pcount
Dim strclassname, keyword, findword
NC_Admin.AdminChk = "16"
NC_Admin.Check
DownsysClass.admin_header
Set Rs = CreateObject("adodb.recordset")
Set Rs1 = CreateObject("adodb.recordset")
Select Case Trim(Request("Action"))
	Case "save"
		Call saveAdd
	Case "modify"
		Call saveModify
	Case "update"
		Call UpdateAllSoft
	Case Else
		Call SoftMain
End Select
If founderr = True Then
	NC_Admin.Error_msg (ErrMsg)
End If
DownsysClass.admin_footer
NothingObject

Private Sub SoftMain()
	Dim bookmark
	If Not IsEmpty(Request("selSoftid")) Then
		selSoftid = Request("selSoftid")
		Select Case Request("action")
			Case "del"
				Call delsoft
			Case "dele"
				Call comeback
			Case "amend"
				Call AmendSoftErr
			Case Else
				Response.Write "无效参数！"
				Err.Raise -19691969
		End Select
	End If
	Response.Write "<script language=""JavaScript"">" & vbCrLf
	Response.Write "<!--//" & vbCrLf
	Response.Write "function Selectbox() {" & vbCrLf
	Response.Write "for (var i=0;i<document.form1.selSoftid.length;i++) {" & vbCrLf
	Response.Write "var e=document.form1.selSoftid[i];" & vbCrLf
	Response.Write "e.checked=!e.checked;" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "//-->"
	Response.Write "</script>" & vbCrLf
	Response.Write "<SCRIPT language = ""JavaScript"">" & vbCrLf
	Response.Write "<!--//" & vbCrLf
	Response.Write "function unselectall()" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write " if(document.myform.chkAll.checked){" & vbCrLf
	Response.Write "document.myform.chkAll.checked = document.myform.chkAll.checked&0;" & vbCrLf
	Response.Write " } " & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "function CheckAll(form)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write " for (var i=0;i<form.elements.length;i++)" & vbCrLf
	Response.Write " {" & vbCrLf
	Response.Write " var e = form.elements[i];" & vbCrLf
	Response.Write " if (e.Name != ""chkAll"")" & vbCrLf
	Response.Write " e.checked = form.chkAll.checked;" & vbCrLf
	Response.Write " }" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "//-->" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" class=""tableBorder"">" & vbCrLf
	Response.Write " <tr>" & vbCrLf
	Response.Write " <th width=""5%"" nowrap>选择</th><th width=""80%"">错误软件管理</th><th width=""20%"" nowrap>查看软件</th></tr>" & vbCrLf
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CInt(Request("page"))
	Else
		CurrentPage = 1
	End If
	maxperpage = 20 '###每页显示数
	If Not IsNumeric(Request("page")) And Request("page") <> "" Then
		Response.Write "错误的系统参数!请输入整数"
		Err.Raise -19691969
	End If
	SQL = "select * from NC_SoftInfo where isLock=0 and Errcode>0 order by softTime desc"
	Rs.Open SQL, conn, 1, 1
	DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td colspan=3 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
		Response.Write "<form name=""form1"" method=""post"">" & vbCrLf
		Response.Write " <tr align=""right"">" & vbCrLf
		Response.Write " <td height=""22"" colspan=""3"" class=""forumRowHighlight"">"
		Call showpage
		Response.Write "</td></tr>" & vbCrLf
		Do While Not Rs.EOF And i < CLng(maxperpage)
			Response.Write " <tr>" & vbCrLf
			Response.Write " <td class=forumrow align=""center""><input type=""checkbox"" name=""selSoftid"" id=""selSoftid"" value="""
			Response.Write Rs("softid")
			Response.Write """></td>" & vbCrLf
			Response.Write " <td height=""22"" class=""forumrow"">["
			Response.Write Rs("sortname")
			Response.Write "] <a href="
			If CInt(DownsysClass.Setting(5)) = 0 Then
				Response.Write "../software/catalog"
				Response.Write Rs("sortid")
				Response.Write "/"
				Response.Write Rs("softid")
				Response.Write ".html"
			Else
				Response.Write "../software.asp?id="
				Response.Write Rs("softid")
			End If
			Response.Write " target=_blank>"
			Response.Write Rs("softname")
			Response.Write "　"
			Response.Write Rs("softver")
			Response.Write "</a></u></td>" & vbCrLf
			Response.Write " <td class=forumrow align=""center"" nowrap><a href=admin_Software.Asp?action=edit&softid="
			Response.Write Rs("softid")
			Response.Write "&sortid="
			Response.Write Rs("sortid")
			Response.Write ">查看编辑</a></td></tr>" & vbCrLf
			Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close
	Response.Write " <tr>" & vbCrLf
	Response.Write " <td height=""22"" colspan=""3"" class=""forumRowHighlight"">"
	Call showpage
	Response.Write "</td></tr>" & vbCrLf
	Response.Write " <tr>" & vbCrLf
	Response.Write " <td height=""22"" class=""forumrow"">管理</td>" & vbCrLf
	Response.Write " <td height=""22"" colspan=""2"" class=""forumrow""><input name=""chkAll"" type=""checkbox"" id=""chkAll"" onclick=CheckAll(this.form) value=""checkbox"">全选/反选 " & vbCrLf
	Response.Write "<input type=""radio"" name=""action"" value=""del"">删除" & vbCrLf
	Response.Write "<input type=""radio"" name=""action"" value=""dele"">放入回收站" & vbCrLf
	Response.Write "<input type=""radio"" name=""action"" value=""amend"">修正错误" & vbCrLf
	Response.Write "[<a href=?action=update>更新所有软件</a>]" & vbCrLf
	Response.Write "　<input type=""submit"" name=""Submit"" value=""执行操作"" class=button onclick=""{if(confirm('您确定执行的操作吗?')){this.document.form1.submit();return true;}return false;}""></td>" & vbCrLf
	Response.Write " </tr></form>" & vbCrLf
	Response.Write "</table>" & vbCrLf
End Sub


Private Sub showpage()
	Dim filename
	Dim ii
	Dim n
	filename = "admin_softerror.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><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		Response.Write " 共有软件 <font COLOR=#FF0000>" & totalnumber & "</font> 个&nbsp;&nbsp;首 页&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;"
	Else
		Response.Write "共有软件 <font COLOR=#FF0000>" & totalnumber & "</font> 个&nbsp;&nbsp;<a href=" & filename & "?page=1>首 页</a>&nbsp;&nbsp;"
		Response.Write "<a href=" & filename & "?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;&nbsp;&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		Response.Write "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		Response.Write "<a href=" & filename & "?page=" & (CurrentPage + 1) & ">下一页</a>"
		Response.Write "&nbsp;&nbsp;<a href=" & filename & "?page=" & n & ">尾 页</a>" & vbCrLf
	End If
	Response.Write "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	Response.Write "</td></tr></table>" & vbCrLf
End Sub


Private Sub delsoft()
	DownsysClass.Execute ("delete from NC_SoftInfo where softid in (" & selSoftid & ")")
	Response.Write ("批量删除操作成功！HTML文件同时也被删除！")
End Sub


Private Sub comeback()
	DownsysClass.Execute ("update NC_SoftInfo set isLock=1 where softid in (" & selSoftid & ")")
	Response.Write ("你选择的文件已成功还原！")
End Sub


Private Sub AmendSoftErr()
	DownsysClass.Execute ("update NC_SoftInfo set Errcode=0 where softid in (" & selSoftid & ")")
	Response.Write ("你选择的文件已成功修正！")
End Sub


Private Sub UpdateAllSoft()
	DownsysClass.Execute ("update NC_SoftInfo set isUpdate=1")
	Response.Redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub
%>
