<!--#include file="setup.asp" -->
<%
Server.ScriptTimeout = 9999999
NC_Admin.AdminChk = "16"
NC_Admin.Check
DownsysClass.admin_header
If request("action") = "yes" Then
	NC_Admin.Succeed_Msg("操作成功，各分类的软件数已经更新！")
	DownsysClass.admin_footer
	Response.End
End If
Response.Write "<table width=""400"" border=""0"" cellspacing=""1"" cellpadding=""1"">"& vbCrLf
Response.Write "<tr> "& vbCrLf
Response.Write "<td bgcolor=000000>"& vbCrLf
Response.Write " <table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""1"">"& vbCrLf
Response.Write "<tr> "& vbCrLf
Response.Write "<td bgcolor=ffffff height=9><img src=""images/bar9.gif"" width=0 height=16 id=img2 name=img2 align=absmiddle></td></tr></table>"& vbCrLf
Response.Write "</td></tr></table></td></tr><tr> "& vbCrLf
Response.Write "<td align=center bgcolor=000000> <span id=txt2 name=txt2 style=""font-size:9pt"">0</span><span style=""font-size:9pt"">%</span></td></tr>"& vbCrLf
Response.Write "</table>"& vbCrLf
Response.Flush
Dim Rsc, Rss, SoftNum, SortNum, totalPut, body, i, Rs1, AllSortID
Set Rs = server.CreateObject("adodb.recordset")
Set Rsc = server.CreateObject("adodb.recordset")
Set Rss = server.CreateObject("adodb.recordset")

Rs.Open "select * from NC_SoftSort where depth=0 order by sortid asc", conn, 1, 1
If Rs.bof And Rs.EOF Then
	Response.Write ""
Else
	totalPut = Rs.recordcount
	i = 1
	Do While Not Rs.EOF
		Rss.Open "select Count(softid) as SoftNum from NC_softinfo where isLock=0 and rootid="&Rs("rootid")&"", conn, 1, 1
		SoftNum = Rss("SoftNum")
		Rss.Close
		conn.Execute("update NC_SoftSort set SoftNum="&SoftNum&",isUpdate=1 where depth=0 and sortid=" & Rs("sortid"))
		Rsc.Open "select * from NC_SoftSort where depth<>0 order by sortid asc", conn, 1, 1
		If Rsc.bof And Rsc.EOF Then
			Response.Write ""
		Else
			Do While Not Rsc.EOF

				Set Rs1 = Conn.Execute("select * from NC_SoftSort where strParent like '%"& Rsc("sortid") &"%'")
				If Rs1.EOF And Rs1.bof Then
					AllSortID = Rsc("sortid")
				Else
					AllSortID = Rsc("sortid")
					Do While Not Rs1.EOF
						AllSortID = AllSortID & "," & Rs1("sortid")
						Rs1.movenext
					Loop
				End If
				Rs1.Close
				 Set Rs1 = Nothing
				Rss.Open "select Count(softid) as SoftNum from NC_softinfo where isLock=0 and sortid in ("&AllSortID&")", conn, 1, 1
				SortNum = Rss("SoftNum")
				Rss.Close
				conn.Execute("update NC_SoftSort set SoftNum="&SortNum&",isUpdate=1 where depth<>0 and sortid=" & Rsc("sortid"))
				Rsc.movenext
			Loop
		End If
		Rsc.Close
		Response.Write "<script>img2.width=" & Fix((i / totalPut) * 400) & ";" & vbCrLf
		Response.Write "txt2.innerHTML=""更新完数据，" & FormatNumber(i / totalPut * 100, 4, -1) & """;" & vbCrLf
		Response.Write "img2.title=""(" & i & ")"";</script>" & vbCrLf
		Response.Flush
		body = "<table cellpadding=0 cellspacing=0 border=0 width=95% align=center><tr><td colspan=2 class=forumrow>更新软件数据成功，["&Rs(1)&"] 共有 "&Rs(9)&" 个软件。</td></tr></table>"
		Response.Write body
		Response.Flush
		Rs.movenext
		i = i + 1
	Loop
End If
Rs.Close
Set Rs = Nothing
Set Rss = Nothing
Set Rsc = Nothing
Response.Write"<script>img2.width=400;txt2.innerHTML=""100"";</script>"
Response.Write"<meta HTTP-EQUIV=REFRESH CONTENT='2; URL=admin_softupdate.asp?action=yes'>"

DownsysClass.admin_footer
NothingObject
%>
