<!--#include file=../conn.asp-->
<!--#include file="inc/const.asp" -->
<!--#include file="../Dv_Plus/Avatar/Plus_Avatar_Const.asp" -->
<%
Head()
If Not Dvbbs.Master Or InStr("," & Session("Flag") & ",", ",38,") = 0 Then
	ErrMsg = ErrMsg & "<BR><li>本页面为管理员专用，请<a href=../admin_login.asp target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
	Call Dvbbs_Error()
Else
	Select Case Request("action")
	Case "TypeInfo"
		Call TypeInfo()
	Case "TypeAdd"
		Call TypeAdd()
	Case "TypeEdit"
		Call TypeEdit()
	Case "TypeDel"
		Call TypeDel()
	Case "TypeOrdersUp"
		Call TypeOrdersUp()
	Case "TypeOrdersDown"
		Call TypeOrdersDown()
	Case "SubTypeInfo"
		Call SubTypeInfo()
	Case "SubTypeAdd"
		Call SubTypeAdd()
	Case "SubTypeEdit"
		Call SubTypeEdit()
	Case "SaveEdit"
		Call SaveEdit()
	Case "SubTypeDel"
		Call SubTypeDel()
	Case "SubTypeOrdersUp"
		Call SubTypeOrdersUp()
	Case "SubTypeOrdersDown"
		Call SubTypeOrdersDown()
	Case "ThdTypeInfo"
		Call ThdTypeInfo()
	Case "ThdTypeAdd"
		Call ThdTypeAdd()
	Case "ThdTypeEdit"
		Call ThdTypeEdit()
	Case "SaveEdit"
		Call SaveEdit()
	Case "ThdTypeDel"
		Call ThdTypeDel()
	Case "ThdTypeOrdersUp"
		Call ThdTypeOrdersUp()
	Case "ThdTypeOrdersDown"
		Call ThdTypeOrdersDown()
	Case Else
		Call TypeInfo()
	End Select
	Footer()
End If

Sub TypeInfo()
	Dim Rs, i, n, TypeCount, SubTypeCount, ItemCount, TotalItemCount, TotalSubTypeCount, TempStr, TempRs
	
	TotalSubTypeCount = 0
	TotalItemCount = 0
	TypeCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Type")(0)
	Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_Type Order By Orders")%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
		<tr height=25>
			<th colspan="6" id="TableTitleLink"><font color="<%=Dvbbs.MainSetting(1)%>">查看一级分类</font>
		</tr>
		<tr height=25 align=center>
			<td class=forumrow><b>一级<br>分类ID</b></td>
			<td class=forumrowhighlight><b>一级分类名称<br>(点击查看二级分类)</b></td>
			<td class=forumrow><b>下级分<br>类个数</b></td>
			<td class=forumrowhighlight><b>商品<br>个数</b></td>
			<td class=forumrow><b>显示</b></td>
			<td class=forumrowhighlight><b>操作</b></td>
		</tr>
		<%If Rs.Eof Then%>
			<tr height=25> 
				<td colspan="6" class=forumrow align=center><b>没有任何一级分类！</b></td>
			</tr>
		<%Else
			n = 1
			Do While Not Rs.Eof
				SubTypeCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where TypeID=" & Rs("ID"))(0)
				TotalSubTypeCount = TotalSubTypeCount + SubTypeCount
				Set TempRs = Dvbbs.Plus_Execute("Select MyType From Dv_Plus_Avatar_SubType Where TypeID=" & Rs("ID") & " And MyType<>0")
				TempStr = ""
				Do While Not TempRs.EOF
					If TempStr <> "" Then TempStr = TempStr & " Or "
					TempStr = TempStr & "Type=" & TempRs(0)
					TempRs.MoveNext
				Loop
				TempRs.Close
				If TempStr = "" Then
					ItemCount = 0
				Else
					ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where " & TempStr)(0)
				End If
				TotalItemCount = TotalItemCount + ItemCount%>
				<tr align=center height=25> 
					<td class=forumrow><font color=<%=Dvbbs.MainSetting(1)%>><%=Rs("ID")%></font></td>
					<td class=forumrowhighlight><a href="Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=<%=Rs("ID")%>"><%=Rs("TypeName")%></a></td>
					<td class=forumrow><%=SubTypeCount%></td>
					<td class=forumrowhighlight><%=ItemCount%></td>
					<td class=forumrow><%
						If Rs("Visible") <> 0 Then
							Response.Write "<b>√</b>"
						Else
							Response.Write "<b>×</b>"
						End If
					%></td>
					<td class=forumrowhighlight><a href="Plus_Avatar_Type.asp?action=SubTypeAdd&typeid=<%=Rs("ID")%>">增加</a><font color="<%=Dvbbs.MainSetting(1)%>">|</font><a href="Plus_Avatar_Type.asp?action=TypeEdit&typeid=<%=Rs("ID")%>">编辑</a><font color="<%=Dvbbs.MainSetting(1)%>">|</font><a href="Plus_Avatar_Type.asp?action=TypeDel&typeid=<%=Rs("ID")%>">删除</a><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=TypeOrdersUp&typeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向上</option>
						<%For i = 1 To n - 1
							Response.Write "<option value=""" & i & """>" & i & "</option>"
						Next%>
						</select><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=TypeOrdersDown&typeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向下</option>
						<%For i = n + 1 To TypeCount
							Response.Write "<option value=""" & (i - n) & """>" & (i - n) & "</option>"
						Next%>
						</select>
					</td>
				</tr>
				<%Rs.MoveNext
				n = n + 1
			Loop
		End If%>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>照相背景</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class=99")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>照相身后</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class=98")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>照相身前</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class=97")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>照相前景</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class=96")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>系统商品</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class=0")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr align=center height=25>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>作废商品</font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<%ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Class>0 And Class<90 And Type=0")(0)
			TotalItemCount = TotalItemCount + ItemCount%>
			<td class=forumrowhighlight><font color=gray><%=ItemCount%></font></td>
			<td class=forumrow><font color=gray>-</font></td>
			<td class=forumrowhighlight><font color=gray>保留商品禁止操作</font></td>
		</tr>
		<tr height=25 align=center>
			<td class=forumrowhighlight>&nbsp;</td>
			<td class=forumrowhighlight><b>合计</b></td>
			<td class=forumrowhighlight><b><%=TotalSubTypeCount%></b></td>
			<td class=forumrowhighlight><b><%=TotalItemCount%></b></td>
			<td colspan=2 class=forumrowhighlight align=right>[<a href="Plus_Avatar_Type.asp?action=TypeAdd"><b>增加新的一级分类</b></a>]&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
	</table>
	<p align="center"><font color="<%=Dvbbs.MainSetting(1)%>">注意：删除一个一级分类，里边的全部二级分类和三级分类也会一起删除，包含有商品的一级分类不能删除！</font></p>
	<%Rs.Close
End Sub

Sub TypeAdd
	Dim TypeName, isVisible
	Dim Orders
	
	If Request("add")<>"" Then
		TypeName = Dvbbs.CheckStr(Trim(Request("TypeName")))
		If TypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>一级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Type Where TypeName='" & TypeName & "'").Eof Then
			ErrMsg = ErrMsg & "<BR><li>一级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		Set Rs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_Type Order By Orders")
		Orders = 1
		Do While Not Rs.Eof
			If Rs(0) > Orders Then
				Exit Do
			End If
			Orders = Orders + 1
			Rs.MoveNext
		Loop
		Rs.Close
		Dvbbs.Plus_Execute("Insert Into Dv_Plus_Avatar_Type (TypeName,Orders,Visible) Values ('" & TypeName & "'," & Orders & "," & isVisible & ")")
		Dv_Suc("新增一级分类成功！<a href=Plus_Avatar_Type.asp>返回一级分类管理</a>")
	Else%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<col width="50%"><col width="50%">
			<form action="Plus_Avatar_Type.asp?action=TypeAdd&add=1" method="post">
			<tr height=25>
				<th colspan="2" id="TableTitleLink"><a href="Plus_Avatar_Type.asp?action=TypeInfo">一级分类管理</a> | <font color="<%=Dvbbs.MainSetting(1)%>">增加新的一级分类</font></th>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>一级分类名称&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input name="typename" type="text" size=40 maxlength=50></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1" checked> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"> 否</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 添 加 "></td>
			</tr>
		</table>
		</form>
	<%End If
End Sub

Sub TypeEdit()
	Dim TypeID, TypeName, isVisible, Rs
	
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Or TypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	If Not IsNull(Request("edit")) And Request("edit")<>"" Then
		TypeName = Dvbbs.CheckStr(Trim(Request("typename")))
		If TypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>一级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Type Where TypeName='" & TypeName & "' And ID<>" & TypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>一级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Type Set TypeName='" & TypeName &"',Visible=" & isVisible & " Where ID=" & TypeID)
		Call MakeAvatarXML()
		Dv_Suc("修改一级分类成功！<a href=Plus_Avatar_Type.asp>返回一级分类管理</a>")
	Else%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<col width="50%"><col width="50%">
			<form action="Plus_Avatar_Type.asp?action=TypeEdit&edit=1" method=post>
			<input type=hidden name=typeid value="<%=TypeID%>">
			<tr height=25> 
				<th colspan="2" id="TableTitleLink"><a href="Plus_Avatar_Type.asp?action=TypeInfo">一级分类管理</a> | <font color="<%=Dvbbs.MainSetting(1)%>">修改一级分类</font></th>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>一级分类ID&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<%=Rs("ID")%></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>一级分类名称&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input name="typename" type="text" size=40 maxlength=50 value="<%=Rs("TypeName")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1"<%If Rs("Visible") <> 0 Then%> checked<%End If%>> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"<%If Rs("Visible") = 0 Then%> checked<%End If%>> 否</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 修 改 "></td>
			</tr>
			</form>
		</table>
	<%End If
	Rs.Close
End Sub

Sub TypeDel()
	Dim TypeID, HasSecondType
	
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Or TypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Type Where ID=" & TypeID).Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	HasSecondType = (Not Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID).Eof)
	If Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Type In (Select MyType From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & ")")(0) > 0 Then
		ErrMsg = ErrMsg & "<BR><li>包含有商品的一级分类不能删除！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	If HasSecondType Then Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID)
	Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If HasSecondType Then Call MakeAvatarXML()
	Dv_Suc("已经成功地删除了一级分类！<a href=Plus_Avatar_Type.asp>返回一级分类管理</a>")
End Sub

Sub TypeOrdersUp()
	Dim OldOrders, NewOrders, MoveStep
	Dim TypeID, OtherTypeID, Rs, i
	
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_Type Where Orders<" & OldOrders & " Order By Orders Desc", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_Type Where Orders<" & OldOrders & " Order By Orders Desc", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Type Set Orders=" & NewOrders & " Where ID=" & TypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Type Set Orders=" & OldOrders & " Where ID=" & OtherTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=TypeInfo';</script>"
End Sub

Sub TypeOrdersDown()
	Dim OldOrders, NewOrders, MoveStep
	Dim TypeID, OtherTypeID, Rs, i
	
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_Type Where Orders>" & OldOrders & " Order By Orders", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_Type Where Orders>" & OldOrders & " Order By Orders", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Type Set Orders=" & NewOrders & " Where ID=" & TypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Type Set Orders=" & OldOrders & " Where ID=" & OtherTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=TypeInfo';</script>"
End Sub

Sub SubTypeInfo()
	Dim TypeID, TypeName, IsReserved, HasThdType
	Dim Rs, i, n, SubTypeCount, ItemCount, ThdTypeCount, TotalItemCount, TotalThdTypeCount, TempStr, TempRs
	
	TotalThdTypeCount = 0
	TotalItemCount = 0
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 TypeName From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	TypeName = Rs(0)
	Rs.Close
	SubTypeCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=0")(0)
	Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=0 Order By Orders")%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
		<tr height=25>
			<th colspan="9" id="TableTitleLink"><a href="Plus_Avatar_Type.asp?action=TypeInfo">一级分类管理</a> | <font color="<%=Dvbbs.MainSetting(1)%>">查看【<%=TypeName%>】的二级分类</font>
		</tr>
		<tr height=25 align=center>
			<td class=forumrowhighlight rowspan=2><b>ID</b></td>
			<td class=forumrow rowspan=2><b>名称</b></td>
			<td class=forumrowhighlight><b>三级分<br>类个数</b></td>
			<td class=forumrowhighlight><b>显示</b></td>
			<td class=forumrowhighlight><b>默认<br>标价</b></td>
			<td class=forumrowhighlight><b>默认<br>有效期</b></td>
			<td class=forumrowhighlight><b>默认<br>限购属性</b></td>
			<td class=forumrow rowspan=2><b>图示<br>方式</b></td>
			<td class=forumrowhighlight rowspan=2><b>操作</b></td>
		</tr>
		<tr height=25 align=center>
			<td class=forumrow><b>商品<br>个数</b></td>
			<td class=forumrow><b>类别<br>代码</b></td>
			<td class=forumrow><b>默认<br>VIP价</b></td>
			<td class=forumrow><b>默认<br>库存</b></td>
			<td class=forumrow><b>默认<br>限购等级</b></td>
		</tr>
		<%If Rs.Eof Then%>
			<tr height=25> 
				<td colspan="9" class=forumrow align=center><b>没有任何二级分类！</b></td>
			</tr>
		<%Else
			n = 1
			Do While Not Rs.Eof
				If (Rs("MyType") = 0 Or (Rs("MyType") Mod 100) > 50 Or (Rs("MyType") \ 100) > 50) And Rs("MyType")<>999 Then
					IsReserved = True
				Else
					IsReserved = False
				End If
				If (Rs("MyType") \ 100) > 50 Then
					HasThdType = True
				Else
					HasThdType = False
				End If
				If HasThdType Then
					ThdTypeCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where ParentSubType=" & Rs("ID"))(0)
				Else
					ThdTypeCount = 0
				End If
				TotalThdTypeCount = TotalThdTypeCount + ThdTypeCount
				If IsReserved And Not HasThdType Then
					ItemCount = 0
				Else
					Set TempRs = Dvbbs.Plus_Execute("Select MyType From Dv_Plus_Avatar_SubType Where ParentSubType=" & Rs("ID") & " Or ID=" & Rs("ID"))
					TempStr = ""
					Do While Not TempRs.EOF
						If TempStr <> "" Then TempStr = TempStr & " Or "
						TempStr = TempStr & "Type=" & TempRs(0)
						TempRs.MoveNext
					Loop
					TempRs.Close
					If TempStr = "" Then
						ItemCount = 0
					Else
						ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where " & TempStr)(0)
					End If
				End If
				TotalItemCount = TotalItemCount + ItemCount
				%>
				<tr align=center height=25> 
					<td class=forumrowhighlight rowspan=2><font color=<%=Dvbbs.MainSetting(1)%>><%=Rs("ID")%></font></td>
					<td class=forumrow rowspan=2><%
						If HasThdType Then
							Response.Write "<a href=""Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & Rs("ID") & """><font color=""blue""><u>" & Rs("SubTypeName") & "</u></font></a>"
						Else
							Response.Write "<font color=""gray"" style=""cursor:pointer"" title=""没有三级分类"">" & Rs("SubTypeName") & "</font>"
						End If
					%></td>
					<td class=forumrowhighlight><%
						If HasThdType Then
							Response.Write ThdTypeCount
						Else
							Response.Write "<font color=gray>-</font>"
						End If
					%></td>
					<td class=forumrowhighlight><%
						If Rs("Visible") <> 0 Then
							Response.Write "<b>√</b>"
						Else
							Response.Write "<b>×</b>"
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPrice1") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>免费</b></font>"
						Else
							Response.Write Rs("DefPrice1")
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPeriod") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>永远有效</b></font>"
						Else
							Response.Write Rs("DefPeriod")
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefVip") <> 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>VIP</b></font>"
						Else
							Response.Write "不限"
						End If
					%></td>
					<td class=forumrow rowspan=2><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("isBig") = 0 Then
							Response.Write "<b>小图</b>"
						ElseIf Rs("isBig") = 3 Then
							Response.Write "<b>中图</b>"
						ElseIf Rs("isBig") = 1 Then
							Response.Write "<b>大图</b>"
						Else
							Response.Write "<b>超大</b>"
						End If
					%></td>
					<td class=forumrowhighlight rowspan=2><%
						If (Rs("MyType") Mod 100) > 50 Then
							Response.Write "<font color=""gray"" style=""cursor:pointer"" title=""系统保留的二级分类不能增加三级分类"">增加</font><font color=""" & Dvbbs.MainSetting(1) & """>|</font><font color=""gray"" style=""cursor:pointer"" title=""系统保留的二级分类不能修改"">编辑</font><font color=""" & Dvbbs.MainSetting(1) & """>|</font><font color=""gray"" style=""cursor:pointer"" title=""系统保留的二级分类不能删除"">删除</font>"
						Else
							If HasThdType Then
								Response.Write "<a href=""Plus_Avatar_Type.asp?action=ThdTypeAdd&subtypeid=" & Rs("ID")& """>增加</a>"
							Else
								Response.Write "<font color=""gray"" style=""cursor:pointer"" title=""不是二级菜单的二级分类不能增加三级分类"">增加</font>"
							End If
							Response.Write "<font color=""" & Dvbbs.MainSetting(1) & """>|</font><a href=""Plus_Avatar_Type.asp?action=SubTypeEdit&subtypeid=" & Rs("ID") & """>编辑</a><font color=""" & Dvbbs.MainSetting(1) & """>|</font><a href=""Plus_Avatar_Type.asp?action=SubTypeDel&subtypeid=" & Rs("ID") & """>删除</a>"
						End If
						%><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=SubTypeOrdersUp&subtypeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向上</option>
						<%For i = 1 To n - 1
							Response.Write "<option value=""" & i & """>" & i & "</option>"
						Next%>
						</select><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=SubTypeOrdersDown&subtypeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向下</option>
						<%For i = n + 1 To SubTypeCount
							Response.Write "<option value=""" & (i - n) & """>" & (i - n) & "</option>"
						Next%>
						</select>
					</td>
				</tr>
				<tr align=center height=25> 
					<td class=forumrow><%
						If IsReserved And Not HasThdType Then
							Response.Write "<font color=gray>-</font>"
						Else
							Response.Write ItemCount
						End If
					%></td>
					<td class=forumrow><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						Else
							Response.Write "<font color=blue><b>" & Rs("MyType") & "</b></font>"
						End If%>
					</td>
					<td class=forumrow><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPrice2") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>免费</b></font>"
						Else
							Response.Write Rs("DefPrice2")
						End If
					%></td>
					<td class=forumrow><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefQuantity") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>断货</b></font>"
						Else
							Response.Write Rs("DefQuantity")
						End If
					%></td>
					<td class=forumrow><%
						If IsReserved Or HasThdType Then
							Response.Write "<font color=gray>-</font>"
						Else
							Select Case Rs("DefFlag")
							Case 0
								Response.Write "<font color=gray>保留商品</font>"
							Case 1
								Response.Write "所有会员"
							Case 2
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">版主以上"
							Case 3
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">超级版主</font>"
							Case 4
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">管理员</font>"
							End Select
						End If
					%></td>
				</tr>
				<%Rs.MoveNext
				n = n + 1
			Loop
		End If%>
		<tr height=25 align=center> 
			<td class=forumrowhighlight rowspan="2">&nbsp;</td>
			<td class=forumrowhighlight rowspan="2"><b>合计</b></td>
			<td class=forumrowhighlight><b><%=TotalThdTypeCount%></b></td>
			<td colspan=7 class=forumrowhighlight align=right rowspan="2">[<a href="Plus_Avatar_Type.asp?action=SubTypeAdd&typeid=<%=TypeID%>"><b>为【<%=TypeName%>】增加新的二级分类</b></a>]&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr height=25 align=center> 
			<td class=forumrowhighlight><b><%=TotalItemCount%></b></td>
		</tr>
	</table>
	<p align="center"><font color="<%=Dvbbs.MainSetting(1)%>">注意：删除一个二级分类，里边的全部三级分类也会一起删除，包含有商品的二级分类不能删除！</font></p>
	<%Rs.Close
End Sub

Sub SubTypeAdd()
	Dim TypeID, TypeName, SubTypeName, isVisible, isSubMenu, MyType, DefPrice1, DefPrice2, DefPeriod, DefQuantity, DefVIP, DefFlag, IsBig, QQType
	Dim Orders, TempValue
	
	TypeID = Request("typeid")
	If TypeID = "" Or Not IsInteger(TypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	TypeID = CLng(TypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 TypeName From Dv_Plus_Avatar_Type Where ID=" & TypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	TypeName = Rs(0)
	Rs.Close
	If Request("add")<>"" Then
		SubTypeName = Dvbbs.CheckStr(Trim(Request("SubTypeName")))
		If SubTypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>二级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where SubTypeName='" & SubTypeName & "' And TypeID=" & TypeID & " And ParentSubType=0").Eof Then
			ErrMsg = ErrMsg & "<BR><li>二级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		isSubMenu = Request("isSubMenu")
		If isSubMenu = "" Then
			isSubMenu = False
		ElseIf Not isInteger(isSubMenu) Then
			isSubMenu = False
		ElseIf isSubMenu <> "0" Then
			isSubMenu = True
		Else
			isSubMenu = False
		End If
		If isSubMenu Then
			TempValue = 99
			Do While Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & TempValue & Right("00" & (TypeID - 1), 2)).Eof And TempValue > 50
				TempValue = TempValue - 1
			Loop
			If TempValue <= 50 Then
				ErrMsg = ErrMsg & "<BR><li>指定的一级分类已经不能添加二级菜单了！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			MyType = TempValue & Right("00" & (TypeID - 1), 2)
			QQType = 0
			DefPrice1 = 0
			DefPrice2 = 0
			DefPeriod = 0
			DefQuantity = 0
			DefVip = 0
			DefFlag = 0
			IsBig = 0
		Else
			MyType = Request("MyType")
			If MyType = "" Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not IsInteger(MyType) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			MyType = CLng(MyType)
			If MyType <= 100 Or MyType > 5000 Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码必须大于100小于5000！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If (MyType \ 100) > 50 Or (MyType Mod 100) > 50 Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码不能是系统保留的类别代码！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & MyType).Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码已经存在！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			QQType = Request("QQType")
			If QQType = "" Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not IsInteger(QQType) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			QQType = CLng(QQType)
			If QQType > 0 Then
				If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where QQType=" & QQType).Eof Then
					ErrMsg = ErrMsg & "<BR><li>指定的腾讯类别代码已经存在！"
					Call Dvbbs_Error()
					Exit Sub
				End If
			End If
			DefPrice1 = Request("DefPrice1")
			If DefPrice1 = "" Or Not IsInteger(DefPrice1) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPrice1 = CLng(DefPrice1)
			DefPrice2 = Request("DefPrice2")
			If DefPrice2 = "" Or Not IsInteger(DefPrice2) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPrice2 = CLng(DefPrice2)
			DefPeriod = Request("DefPeriod")
			If DefPeriod = "" Or Not IsInteger(DefPeriod) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPeriod = CLng(DefPeriod)
			DefQuantity = Request("DefQuantity")
			If DefQuantity = "" Or Not IsInteger(DefQuantity) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefQuantity = CLng(DefQuantity)
			DefVip = Request("DefVip")
			If DefVip = "" Then
				DefVip = 0
			ElseIf Not isInteger(DefVip) Then
				DefVip = 0
			ElseIf DefVip <> "0" Then
				DefVip = 1
			Else
				DefVip = 0
			End If
			DefFlag = Request("DefFlag")
			If DefFlag = "" Then
				DefFlag = 1
			ElseIf Not isInteger(DefFlag) Then
				DefFlag = 1
			Else
				DefFlag = CLng(DefFlag)
				If DefFlag > 4 Then
					DefFlag = 1
				End If
			End If
			IsBig = Request("IsBig")
			If IsBig = "" Then
				IsBig = 0
			ElseIf Not isInteger(IsBig) Then
				IsBig = 0
			Else
				IsBig = CLng(IsBig)
				If IsBig > 3 Then
					IsBig = 0
				End If
			End If
		End If
		Set Rs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=0 Order By Orders")
		Orders = 1
		Do While Not Rs.Eof
			If Rs(0) > Orders Then
				Exit Do
			End If
			Orders = Orders + 1
			Rs.MoveNext
		Loop
		Rs.Close
		Dvbbs.Plus_Execute("Insert Into Dv_Plus_Avatar_SubType (TypeID,SubTypeName,ParentSubType,Orders,Visible,MyType,QQType,DefPrice1,DefPrice2,DefPeriod,DefQuantity,DefVip,DefFlag,isBig) Values (" & TypeID & ",'" & SubTypeName & "',0," & Orders & "," & isVisible & "," & MyType & "," & QQType & "," & DefPrice1 & "," & DefPrice2 & "," & DefPeriod & "," & DefQuantity & "," & DefVip & "," & DefFlag & "," & isBig & ")")
		Call MakeAvatarXML()
		Dv_Suc("新增二级分类成功！<a href=Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=" & TypeID & ">返回二级分类管理</a>")
	Else%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<form action="?action=SubTypeAdd&add=1" method=post>
			<input type="hidden" name="typeid" value="<%=TypeID%>">
			<tr height=25> 
				<th colspan="2" id="TableTitleLink"><a href="?action=SubTypeInfo&typeid=<%=TypeID%>"><b>【<%=TypeName%>】的二级分类管理</b></a> | <font color="<%=Dvbbs.MainSetting(1)%>">增加【<%=TypeName%>】的二级分类</font></th>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>二级分类名称&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<input type="text" name="subtypename" size=40 maxlength=50></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1" checked> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否作为二级菜单&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isSubMenu" id="isSubMenu1" value="1" onclick="ToggleSubMenu(true)"> 是&nbsp;&nbsp;<input type="radio" name="isSubMenu" id="isSubMenu2" value="0" checked onclick="ToggleSubMenu(false)"> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>商品类别代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="MyType" id="MyType" size=40 maxlength=4></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>QQShow页面代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="QQType" id="QQType" size=40 maxlength=4 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认标准价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice1" id="DefPrice1" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认VIP价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice2" id="DefPrice2" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认有效期限&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPeriod" id="DefPeriod" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认当前库存&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefQuantity" id="DefQuantity" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购属性&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefVip" id="DefVip1" value="1"> VIP&nbsp;&nbsp;<input type="radio" name="DefVip" id="DefVip2" value="0" checked> 不限</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购等级&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefFlag" id="DefFlag0" value="0"> 保留商品&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag1" value="1" checked> 所有会员&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag2" value="2"> 版主以上&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag3" value="3"> 超级版主&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag4" value="4"> 管理员</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>图示方式&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isBig" id="isBig0" value="0" checked> 小图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig3" value="3"> 中图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig1" value="1"> 大图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig2" value="2"> 超大</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 添 加 "></td>
			</tr>
			</form>
		</table>
		<script language="javascript">
		function ToggleSubMenu(pFlag) {
			if(pFlag) {
				document.getElementById("MyType").disabled = true;
				document.getElementById("MyType").value = "";
				document.getElementById("QQType").disabled = true;
				document.getElementById("QQType").value = "";
				document.getElementById("DefPrice1").disabled = true;
				document.getElementById("DefPrice1").value = "";
				document.getElementById("DefPrice2").disabled = true;
				document.getElementById("DefPrice2").value = "";
				document.getElementById("DefPeriod").disabled = true;
				document.getElementById("DefPeriod").value = "";
				document.getElementById("DefQuantity").disabled = true;
				document.getElementById("DefQuantity").value = "";
				document.getElementById("DefVip1").disabled = true;
				document.getElementById("DefVip1").checked = false;
				document.getElementById("DefVip2").disabled = true;
				document.getElementById("DefVip2").checked = false;
				document.getElementById("DefFlag0").disabled = true;
				document.getElementById("DefFlag0").checked = false;
				document.getElementById("DefFlag1").disabled = true;
				document.getElementById("DefFlag1").checked = false;
				document.getElementById("DefFlag2").disabled = true;
				document.getElementById("DefFlag2").checked = false;
				document.getElementById("DefFlag3").disabled = true;
				document.getElementById("DefFlag3").checked = false;
				document.getElementById("DefFlag4").disabled = true;
				document.getElementById("DefFlag4").checked = false;
				document.getElementById("isBig0").disabled = true;
				document.getElementById("isBig0").checked = false;
				document.getElementById("isBig1").disabled = true;
				document.getElementById("isBig1").checked = false;
				document.getElementById("isBig2").disabled = true;
				document.getElementById("isBig2").checked = false;
				document.getElementById("isBig3").disabled = true;
				document.getElementById("isBig3").checked = false;
			} else {
				document.getElementById("MyType").disabled = false;
				document.getElementById("QQType").disabled = false;
				document.getElementById("QQType").value = "0";
				document.getElementById("DefPrice1").disabled = false;
				document.getElementById("DefPrice1").value = "0";
				document.getElementById("DefPrice2").disabled = false;
				document.getElementById("DefPrice2").value = "0";
				document.getElementById("DefPeriod").disabled = false;
				document.getElementById("DefPeriod").value = "0";
				document.getElementById("DefQuantity").disabled = false;
				document.getElementById("DefQuantity").value = "0";
				document.getElementById("DefVip1").disabled = false;
				document.getElementById("DefVip1").checked = false;
				document.getElementById("DefVip2").disabled = false;
				document.getElementById("DefVip2").checked = true;
				document.getElementById("DefFlag0").disabled = false;
				document.getElementById("DefFlag0").checked = false;
				document.getElementById("DefFlag1").disabled = false;
				document.getElementById("DefFlag1").checked = true;
				document.getElementById("DefFlag2").disabled = false;
				document.getElementById("DefFlag2").checked = false;
				document.getElementById("DefFlag3").disabled = false;
				document.getElementById("DefFlag3").checked = false;
				document.getElementById("DefFlag4").disabled = false;
				document.getElementById("DefFlag4").checked = false;
				document.getElementById("isBig0").disabled = false;
				document.getElementById("isBig0").checked = false;
				document.getElementById("isBig1").disabled = false;
				document.getElementById("isBig1").checked = false;
				document.getElementById("isBig2").disabled = false;
				document.getElementById("isBig2").checked = false;
				document.getElementById("isBig3").disabled = false;
				document.getElementById("isBig3").checked = false;
			}
		}
		</script>
		<script language="javascript" for="window" event="onload">
		if(document.getElementById("isSubMenu1").checked) ToggleSubMenu(true);
		</script>
	<%End If
End Sub

Sub SubTypeEdit()
	Dim TypeID, TypeName, SubTypeID, SubTypeName, isVisible, isSubMenu, MyType, DefPrice1, DefPrice2, DefPeriod, DefQuantity, DefVIP, DefFlag, IsBig, QQType
	Dim Orders, TempValue, Rs, TempRs, OldTypeID, OldMyType, Pos, SubMenuID
	
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Or SubTypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	If (Rs("MyType") Mod 100) > 50  Then
		ErrMsg = ErrMsg & "<BR><li>系统保留的二级分类不能修改！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldTypeID = Rs("TypeID")
	OldMyType = Rs("MyType")
	Set TempRs = Dvbbs.Plus_Execute("Select Top 1 TypeName From Dv_Plus_Avatar_Type Where ID=" & OldTypeID)
	If TempRs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		TempRs.Close
		Rs.Close
		Exit Sub
	End If
	TypeName = TempRs(0)
	TempRs.Close
	If Not IsNull(Request("edit")) And Request("edit")<>"" Then
		TypeID = Trim(Request("ParentID"))
		Pos = InStr(TypeID, ",")
		If Pos > 0 Then
			SubMenuID = Trim(Mid(TypeID, Pos + 1))
			TypeID = Trim(Left(TypeID, Pos - 1))
		Else
			SubMenuID = "0"
		End If
		If TypeID = "" Or Not IsInteger(TypeID) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		TypeID = CLng(TypeID)
		If SubMenuID = "" Or Not IsInteger(SubMenuID) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		SubMenuID = CLng(SubMenuID)
		If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Type Where ID=" & TypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		If SubMenuID > 0 Then
			If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where ID=" & SubMenuID & " And ParentSubType=0 And MyType>5000").Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
				Call Dvbbs_Error()
				Rs.Close
				Exit Sub
			End If
		End If
		SubTypeName = Dvbbs.CheckStr(Trim(Request("SubTypeName")))
		If SubTypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>二级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where SubTypeName='" & SubTypeName & "' And TypeID=" & TypeID & " And ID<>" & SubTypeID & " And ParentSubType=0").Eof Then
			ErrMsg = ErrMsg & "<BR><li>二级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		isSubMenu = Request("isSubMenu")
		If isSubMenu = "" Then
			isSubMenu = False
		ElseIf Not isInteger(isSubMenu) Then
			isSubMenu = False
		ElseIf isSubMenu <> "0" Then
			isSubMenu = True
		Else
			isSubMenu = False
		End If
		If SubMenuID > 0 And isSubMenu Then
			ErrMsg = ErrMsg & "<BR><li>子菜单不能作为三级分类！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If isSubMenu Then
			If OldMyType <= 5000 Then
				If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Items Where Type=" & OldMyType).Eof Then
					ErrMsg = ErrMsg & "<BR><li>拥有商品的二级分类不能修改为二级菜单！"
					Call Dvbbs_Error()
					Rs.Close
					Exit Sub
				End If
			End If
			MyType = Rs("MyType")
			If (MyType \ 100) <= 50 Then			
				TempValue = 99
				Do While Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & TempValue & Right("00" & (TypeID - 1), 2)).Eof And TempValue > 50
					TempValue = TempValue - 1
				Loop
				If TempValue <= 50 Then
					ErrMsg = ErrMsg & "<BR><li>指定的一级分类已经不能添加二级菜单了！"
					Call Dvbbs_Error()
					Exit Sub
				End If
				MyType = TempValue & Right("00" & (TypeID - 1), 2)
			End If
			QQType = 0
			DefPrice1 = 0
			DefPrice2 = 0
			DefPeriod = 0
			DefQuantity = 0
			DefVip = 0
			DefFlag = 0
			IsBig = 0
		Else
			If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID).Eof Then
				ErrMsg = ErrMsg & "<BR><li>拥有三级分类的二级菜单不能修改为二级分类！"
				Call Dvbbs_Error()
				Rs.Close
				Exit Sub
			End If
			MyType = Request("MyType")
			If MyType = "" Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not IsInteger(MyType) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			MyType = CLng(MyType)
			If MyType <= 100 Or MyType > 5000 Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码必须大于100小于5000！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If (MyType \ 100) > 50 Or (MyType Mod 100) > 50 Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码不能是系统保留的类别代码！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & MyType & " And ID<>" & SubTypeID).Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的类别代码已经存在！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			QQType = Request("QQType")
			If QQType = "" Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			If Not IsInteger(QQType) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			QQType = CLng(QQType)
			If QQType > 0 Then
				If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where QQType=" & QQType & " And ID<>" & SubTypeID).Eof Then
					ErrMsg = ErrMsg & "<BR><li>指定的腾讯类别代码已经存在！"
					Call Dvbbs_Error()
					Exit Sub
				End If
			End If
			DefPrice1 = Request("DefPrice1")
			If DefPrice1 = "" Or Not IsInteger(DefPrice1) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPrice1 = CLng(DefPrice1)
			DefPrice2 = Request("DefPrice2")
			If DefPrice2 = "" Or Not IsInteger(DefPrice2) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPrice2 = CLng(DefPrice2)
			DefPeriod = Request("DefPeriod")
			If DefPeriod = "" Or Not IsInteger(DefPeriod) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefPeriod = CLng(DefPeriod)
			DefQuantity = Request("DefQuantity")
			If DefQuantity = "" Or Not IsInteger(DefQuantity) Then
				ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
			DefQuantity = CLng(DefQuantity)
			DefVip = Request("DefVip")
			If DefVip = "" Then
				DefVip = 0
			ElseIf Not isInteger(DefVip) Then
				DefVip = 0
			ElseIf DefVip <> "0" Then
				DefVip = 1
			Else
				DefVip = 0
			End If
			DefFlag = Request("DefFlag")
			If DefFlag = "" Then
				DefFlag = 1
			ElseIf Not isInteger(DefFlag) Then
				DefFlag = 1
			Else
				DefFlag = CLng(DefFlag)
				If DefFlag > 4 Then
					DefFlag = 1
				End If
			End If
			IsBig = Request("IsBig")
			If IsBig = "" Then
				IsBig = 0
			ElseIf Not isInteger(IsBig) Then
				IsBig = 0
			Else
				IsBig = CLng(IsBig)
				If IsBig > 3 Then
					IsBig = 0
				End If
			End If
		End If
		If TypeID <> OldTypeID Or SubMenuID > 0 Then
			If SubMenuID > 0 Then
				Set TempRs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=" & SubMenuID & " Order By Orders")
			Else
				Set TempRs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=0 Order By Orders")
			End If
			Orders = 1
			Do While Not TempRs.Eof
				If TempRs(0) > Orders Then
					Exit Do
				End If
				Orders = Orders + 1
				TempRs.MoveNext
			Loop
			TempRs.Close
			If MyType <> OldMyType And OldMyType <> 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set Type=" & MyType & " Where Type=" & OldMyType)
			End If
			If SubMenuID > 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set TypeID=" & TypeID & ",ParentSubType=" & SubMenuID & ",Orders=" & Orders & ",SubTypeName='" & SubTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & SubTypeID)
			Else
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set TypeID=" & TypeID & ",Orders=" & Orders & ",SubTypeName='" & SubTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & SubTypeID)
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set TypeID=" & TypeID & " Where ParentSubType=" & SubTypeID)
			End If
		Else
			If MyType <> OldMyType And OldMyType <> 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set Type=" & MyType & " Where Type=" & OldMyType)
			End If
			Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set SubTypeName='" & SubTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & SubTypeID)
		End If
		Call MakeAvatarXML()
		Dv_Suc("修改二级分类成功！<a href=Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=" & OldTypeID & ">返回二级分类管理</a>")
	Else
		If (Rs("MyType") \ 100) > 50 Then
			isSubMenu = True
		Else
			isSubMenu = False
		End If%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<form action="?action=SubTypeEdit&edit=1" method=post>
			<input type="hidden" name="subtypeid" value="<%=SubTypeID%>">
			<tr height=25> 
				<th colspan="2" id="TableTitleLink"><a href="?action=SubTypeInfo&typeid=<%=Rs("TypeID")%>"><b>【<%=TypeName%>】的二级分类管理</b></a> | <font color="<%=Dvbbs.MainSetting(1)%>">修改【<%=TypeName%>】的二级分类</font></th>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>二级分类名称&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<input type="text" name="subtypename" size=40 maxlength=50 value="<%=Rs("SubTypeName")%>"></td>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>所属分类&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<%
					Response.Write "<select name='ParentID' id='ParentID' onchange='if(this.options[this.selectedIndex].value!="""") ToggleParent(this.options[this.selectedIndex].value);'>" & vbCrLf
					Call ShowTypeSelect(Rs("ID"), Rs("TypeID"))
					Response.Write "</select>" & vbCrLf
				%></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1"<%If Rs("Visible") = 1 Then%> checked<%End If%>> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"<%If Rs("Visible") = 0 Then%> checked<%End If%>> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否作为菜单&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isSubMenu" id="isSubMenu1" value="1" onclick="ToggleSubMenu(true,'<%=Rs("MyType")%>','<%=Rs("QQType")%>','<%=Rs("DefPrice1")%>','<%=Rs("DefPrice2")%>','<%=Rs("DefPeriod")%>','<%=Rs("DefQuantity")%>','<%=Rs("DefVip")%>','<%=Rs("DefFlag")%>','<%=Rs("isBig")%>')"<%If isSubMenu Then%> checked<%End If%>> 是&nbsp;&nbsp;<input type="radio" name="isSubMenu" id="isSubMenu2" value="0" onclick="ToggleSubMenu(false,'<%=Rs("MyType")%>','<%=Rs("QQType")%>','<%=Rs("DefPrice1")%>','<%=Rs("DefPrice2")%>','<%=Rs("DefPeriod")%>','<%=Rs("DefQuantity")%>','<%=Rs("DefVip")%>','<%=Rs("DefFlag")%>','<%=Rs("isBig")%>')"<%If Not isSubMenu Then%> checked<%End If%>> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>商品类别代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="MyType" id="MyType" size=40 maxlength=4<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("MyType")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>QQShow页面代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="QQType" id="QQType" size=40 maxlength=4<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("QQType")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认标准价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice1" id="DefPrice1" size=40 maxlength=6<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("DefPrice1")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认VIP价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice2" id="DefPrice2" size=40 maxlength=6<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("DefPrice2")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认有效期限&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPeriod" id="DefPeriod" size=40 maxlength=6<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("DefPeriod")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认当前库存&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefQuantity" id="DefQuantity" size=40 maxlength=6<%If isSubMenu Then%> disabled value=""<%Else%> value="<%=Rs("DefQuantity")%>"<%End If%>></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购属性&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefVip" id="DefVip1" value="1"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefVip")=1 Then%> checked<%End If%>> VIP&nbsp;&nbsp;<input type="radio" name="DefVip" id="DefVip2" value="0"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefVip")=0 Then%> checked<%End If%>> 不限</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购等级&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefFlag" id="DefFlag0" value="0"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefFlag")=0 Then%> checked<%End If%>> 保留商品&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag1" value="1"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefFlag")=1 Then%> checked<%End If%>> 所有会员&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag2" value="2"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefFlag")=2 Then%> checked<%End If%>> 版主以上&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag3" value="3"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefFlag")=3 Then%> checked<%End If%>> 超级版主&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag4" value="4"<%If isSubMenu Then%> disabled<%ElseIf Rs("DefFlag")=4 Then%> checked<%End If%>> 管理员</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>图示方式&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isBig" id="isBig0" value="0"<%If Rs("isBig")=0 Then%> checked<%End If%><%If isSubMenu Then%> disabled<%End If%>> 小图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig3" value="3"<%If Rs("isBig")=3 Then%> checked<%End If%><%If isSubMenu Then%> disabled<%End If%>> 中图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig1" value="1"<%If Rs("isBig")=1 Then%> checked<%End If%><%If isSubMenu Then%> disabled<%End If%>> 大图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig2" value="2"<%If Rs("isBig")=2 Then%> checked<%End If%><%If isSubMenu Then%> disabled<%End If%>> 超大</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 修 改 "></td>
			</tr>
			</form>
		</table>
		<script language="javascript">
		function ToggleParent(ParentID) {
			if(ParentID.indexOf(",") >= 0) {
				if(document.getElementById("isSubMenu1").checked) {
					document.getElementById("isSubMenu2").checked = true;
					ToggleSubMenu(false,'<%=Rs("MyType")%>','<%=Rs("QQType")%>','<%=Rs("DefPrice1")%>','<%=Rs("DefPrice2")%>','<%=Rs("DefPeriod")%>','<%=Rs("DefQuantity")%>','<%=Rs("DefVip")%>','<%=Rs("DefFlag")%>','<%=Rs("isBig")%>');
				}
				document.getElementById("isSubMenu1").disabled = true;
			} else
				document.getElementById("isSubMenu1").disabled = false;
		}
		function ToggleSubMenu(pFlag,MyType,QQType,DefPrice1,DefPrice2,DefPeriod,DefQuantity,DefVip,DefFlag,isBig) {
			if(pFlag) {
				document.getElementById("MyType").disabled = true;
				document.getElementById("MyType").value = "";
				document.getElementById("QQType").disabled = true;
				document.getElementById("QQType").value = "";
				document.getElementById("DefPrice1").disabled = true;
				document.getElementById("DefPrice1").value = "";
				document.getElementById("DefPrice2").disabled = true;
				document.getElementById("DefPrice2").value = "";
				document.getElementById("DefPeriod").disabled = true;
				document.getElementById("DefPeriod").value = "";
				document.getElementById("DefQuantity").disabled = true;
				document.getElementById("DefQuantity").value = "";
				document.getElementById("DefVip1").disabled = true;
				document.getElementById("DefVip1").checked = false;
				document.getElementById("DefVip2").disabled = true;
				document.getElementById("DefVip2").checked = false;
				document.getElementById("DefFlag0").disabled = true;
				document.getElementById("DefFlag0").checked = false;
				document.getElementById("DefFlag1").disabled = true;
				document.getElementById("DefFlag1").checked = false;
				document.getElementById("DefFlag2").disabled = true;
				document.getElementById("DefFlag2").checked = false;
				document.getElementById("DefFlag3").disabled = true;
				document.getElementById("DefFlag3").checked = false;
				document.getElementById("DefFlag4").disabled = true;
				document.getElementById("DefFlag4").checked = false;
				document.getElementById("isBig0").disabled = true;
				document.getElementById("isBig0").checked = false;
				document.getElementById("isBig1").disabled = true;
				document.getElementById("isBig1").checked = false;
				document.getElementById("isBig2").disabled = true;
				document.getElementById("isBig2").checked = false;
				document.getElementById("isBig3").disabled = true;
				document.getElementById("isBig3").checked = false;
			} else {
				document.getElementById("MyType").disabled = false;
				document.getElementById("MyType").value = MyType;
				document.getElementById("QQType").disabled = false;
				document.getElementById("QQType").value = QQType;
				document.getElementById("DefPrice1").disabled = false;
				document.getElementById("DefPrice1").value = DefPrice1;
				document.getElementById("DefPrice2").disabled = false;
				document.getElementById("DefPrice2").value = DefPrice2;
				document.getElementById("DefPeriod").disabled = false;
				document.getElementById("DefPeriod").value = DefPeriod;
				document.getElementById("DefQuantity").disabled = false;
				document.getElementById("DefQuantity").value = DefQuantity;
				document.getElementById("DefVip1").disabled = false;
				document.getElementById("DefVip1").checked = (DefVip != '0');
				document.getElementById("DefVip2").disabled = false;
				document.getElementById("DefVip2").checked = (DefVip == '0');
				document.getElementById("DefFlag0").disabled = false;
				document.getElementById("DefFlag0").checked = (DefFlag == '0');
				document.getElementById("DefFlag1").disabled = false;
				document.getElementById("DefFlag1").checked = (DefFlag == '1');
				document.getElementById("DefFlag2").disabled = false;
				document.getElementById("DefFlag2").checked = (DefFlag == '2');
				document.getElementById("DefFlag3").disabled = false;
				document.getElementById("DefFlag3").checked = (DefFlag == '3');
				document.getElementById("DefFlag4").disabled = false;
				document.getElementById("DefFlag4").checked = (DefFlag == '4');
				document.getElementById("isBig0").disabled = false;
				document.getElementById("isBig0").checked = false;
				document.getElementById("isBig1").disabled = false;
				document.getElementById("isBig1").checked = false;
				document.getElementById("isBig2").disabled = false;
				document.getElementById("isBig2").checked = false;
				document.getElementById("isBig3").disabled = false;
				document.getElementById("isBig3").checked = false;
			}
		}
		</script>
		<script language="javascript" for="window" event="onload">
		if(document.getElementById("isSubMenu1").checked)
			ToggleSubMenu(true,'<%=Rs("MyType")%>','<%=Rs("QQType")%>','<%=Rs("DefPrice1")%>','<%=Rs("DefPrice2")%>','<%=Rs("DefPeriod")%>','<%=Rs("DefQuantity")%>','<%=Rs("DefVip")%>','<%=Rs("DefFlag")%>','<%=Rs("isBig")%>');
		else
			ToggleSubMenu(false,'<%=Rs("MyType")%>','<%=Rs("QQType")%>','<%=Rs("DefPrice1")%>','<%=Rs("DefPrice2")%>','<%=Rs("DefPeriod")%>','<%=Rs("DefQuantity")%>','<%=Rs("DefVip")%>','<%=Rs("DefFlag")%>','<%=Rs("isBig")%>');
		if(document.getElementById("ParentID").options[document.getElementById("ParentID").selectedIndex].value!="")
			ToggleParent(document.getElementById("ParentID").options[document.getElementById("ParentID").selectedIndex].value);
		</script>
	<%End If
	Rs.Close
End sub

Sub SubTypeDel
	Dim SubTypeID, HasThdType, TypeID, Rs
	
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Or SubTypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 TypeID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	TypeID = Rs(0)
	Rs.Close
	HasThdType = (Not Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID).Eof)
	If Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Type In (Select MyType From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID & " Or ID=" & SubTypeID & ")")(0) > 0 Then
		ErrMsg = ErrMsg & "<BR><li>包含有商品的二级分类不能删除！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	If HasThdType Then Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID)
	Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	Call MakeAvatarXML()
	Dv_Suc("已经成功地删除了二级分类！<a href=Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=" & TypeID & ">返回二级分类管理</a>")
End Sub

Sub SubTypeOrdersUp()
	Dim OldOrders, NewOrders, MoveStep, TypeID
	Dim SubTypeID, OtherSubTypeID, Rs, i
	
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders,TypeID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	TypeID = Rs(1)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders<" & OldOrders & " And TypeID=" & TypeID & " And ParentSubType=0 Order By Orders Desc", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders<" & OldOrders & " And TypeID=" & TypeID & " And ParentSubType=0 Order By Orders Desc", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherSubTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & NewOrders & " Where ID=" & SubTypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & OldOrders & " Where ID=" & OtherSubTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=" & TypeID & "';</script>"
End Sub

Sub SubTypeOrdersDown()
	Dim OldOrders, NewOrders, MoveStep, TypeID
	Dim SubTypeID, OtherSubTypeID, Rs, i
	
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders,TypeID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	TypeID = Rs(1)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders>" & OldOrders & " And TypeID=" & TypeID & " And ParentSubType=0 Order By Orders", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders>" & OldOrders & " And TypeID=" & TypeID & " And ParentSubType=0 Order By Orders", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherSubTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & NewOrders & " Where ID=" & SubTypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & OldOrders & " Where ID=" & OtherSubTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=" & TypeID & "';</script>"
End Sub

Sub ThdTypeInfo()
	Dim SubTypeID, SubTypeName, IsReserved, TotalItemCount
	Dim Rs, i, n, ThdTypeCount, ItemCount, TypeID
	
	TotalItemCount = 0
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Or SubTypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 SubTypeName,MyType,TypeID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	If (Rs(1) \ 100) <= 50 Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不是二级菜单！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	SubTypeName = Rs(0)
	TypeID = Rs(2)
	Rs.Close
	ThdTypeCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID)(0)
	Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_SubType Where ParentsubType=" & SubTypeID & " Order By Orders")%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
		<tr height=25>
			<th colspan="9" id="TableTitleLink"><a href="Plus_Avatar_Type.asp?action=SubTypeInfo&typeid=<%=TypeID%>">二级分类管理</a> | <font color="<%=Dvbbs.MainSetting(1)%>">查看【<%=SubTypeName%>】的三级分类</font>
		</tr>
		<tr height=25 align=center>
			<td class=forumrowhighlight rowspan=2><b>ID</b></td>
			<td class=forumrow rowspan=2><b>名称</b></td>
			<td class=forumrowhighlight rowspan=2><b>商品<br>个数</b></td>
			<td class=forumrowhighlight><b>显示</b></td>
			<td class=forumrowhighlight><b>默认<br>标价</b></td>
			<td class=forumrowhighlight><b>默认<br>有效期</b></td>
			<td class=forumrowhighlight><b>默认<br>限购属性</b></td>
			<td class=forumrow rowspan=2><b>大图<br>商品</b></td>
			<td class=forumrowhighlight rowspan=2><b>操作</b></td>
		</tr>
		<tr height=25 align=center>
			<td class=forumrow><b>类别<br>代码</b></td>
			<td class=forumrow><b>默认<br>VIP价</b></td>
			<td class=forumrow><b>默认<br>库存</b></td>
			<td class=forumrow><b>默认<br>限购等级</b></td>
		</tr>
		<%If Rs.Eof Then%>
			<tr height=25> 
				<td colspan="9" class=forumrowhighlight align=center>没有任何三级分类！</td>
			</tr>
		<%Else
			n = 1
			Do While Not Rs.Eof
				If (Rs("MyType") = 0 Or (Rs("MyType") Mod 100) > 50 Or (Rs("MyType") \ 100) > 50) And Rs("MyType")<>999 Then
					IsReserved = True
				Else
					IsReserved = False
				End If
				If IsReserved Then
					ItemCount = 0
				Else
					ItemCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Type=" & Rs("MyType"))(0)
				End If
				TotalItemCount = TotalItemCount + ItemCount
				%>
				<tr align=center height=25> 
					<td class=forumrowhighlight rowspan=2><font color=<%=Dvbbs.MainSetting(1)%>><%=Rs("ID")%></font></td>
					<td class=forumrow rowspan=2><%=Rs("SubTypeName")%></td>
					<td class=forumrowhighlight rowspan=2><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						Else
							Response.Write ItemCount
						End If
					%></td>
					<td class=forumrowhighlight><%
						If Rs("Visible") <> 0 Then
							Response.Write "<b>√</b>"
						Else
							Response.Write "<b>×</b>"
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPrice1") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>免费</b></font>"
						Else
							Response.Write Rs("DefPrice1")
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPeriod") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>永远有效</b></font>"
						Else
							Response.Write Rs("DefPeriod")
						End If
					%></td>
					<td class=forumrowhighlight><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefVip") <> 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>VIP</b></font>"
						Else
							Response.Write "不限"
						End If
					%></td>
					<td class=forumrow rowspan=2><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("isBig") = 0 Then
							Response.Write "<b>小图</b>"
						ElseIf Rs("isBig") = 3 Then
							Response.Write "<b>中图</b>"
						ElseIf Rs("isBig") = 1 Then
							Response.Write "<b>大图</b>"
						Else
							Response.Write "<b>超大</b>"
						End If
					%></td>
					<td class=forumrowhighlight rowspan=2><%
						If (Rs("MyType") Mod 100) > 50 Then
							Response.Write "<font color=""gray"" style=""cursor:pointer"" title=""系统保留的三级分类不能修改"">编辑</font><font color=""" & Dvbbs.MainSetting(1) & """>|</font><font color=""gray"" style=""cursor:pointer"" title=""系统保留的三级分类不能删除"">删除</font>"
						Else
							Response.Write "<a href=""Plus_Avatar_Type.asp?action=ThdTypeEdit&thdtypeid=" & Rs("ID") & """>编辑</a><font color=""" & Dvbbs.MainSetting(1) & """>|</font><a href=""Plus_Avatar_Type.asp?action=ThdTypeDel&thdtypeid=" & Rs("ID") & """>删除</a>"
						End If
						%><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=ThdTypeOrdersUp&thdtypeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向上</option>
						<%For i = 1 To n - 1
							Response.Write "<option value=""" & i & """>" & i & "</option>"
						Next%>
						</select><font color="<%=Dvbbs.MainSetting(1)%>">|</font><select onchange="if(this.options[this.selectedIndex].value!='') document.location='Plus_Avatar_Type.asp?action=ThdTypeOrdersDown&thdtypeid=<%=Rs("ID")%>&movestep=' + this.options[this.selectedIndex].value;">
						<option value="">向下</option>
						<%For i = n + 1 To ThdTypeCount
							Response.Write "<option value=""" & (i - n) & """>" & (i - n) & "</option>"
						Next%>
						</select>
					</td>
				</tr>
				<tr align=center height=25> 
					<td class=forumrow><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						Else
							Response.Write "<font color=blue><b>" & Rs("MyType") & "</b></font>"
						End If%>
					</td>
					<td class=forumrow><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefPrice2") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>免费</b></font>"
						Else
							Response.Write Rs("DefPrice2")
						End If
					%></td>
					<td class=forumrow><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						ElseIf Rs("DefQuantity") = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>断货</b></font>"
						Else
							Response.Write Rs("DefQuantity")
						End If
					%></td>
					<td class=forumrow><%
						If IsReserved Then
							Response.Write "<font color=gray>-</font>"
						Else
							Select Case Rs("DefFlag")
							Case 0
								Response.Write "<font color=gray>保留商品</font>"
							Case 1
								Response.Write "所有会员"
							Case 2
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">版主以上"
							Case 3
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">超级版主</font>"
							Case 4
								Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">管理员</font>"
							End Select
						End If
					%></td>
				</tr>
				<%Rs.MoveNext
				n = n + 1
			Loop
		End If%>
		<tr height=25 align=center>
			<td class=forumrowhighlight>&nbsp;</td>
			<td class=forumrowhighlight><b>合计</b></td>
			<td class=forumrowhighlight><b><%=TotalItemCount%></b></td>
			<td colspan=6 class=forumrowhighlight align=right>[<a href="Plus_Avatar_Type.asp?action=ThdTypeAdd&subtypeid=<%=SubTypeID%>"><b>为【<%=SubTypeName%>】增加新的三级分类</b></a>]&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		</tr>
	</table>
	<p align="center"><font color="<%=Dvbbs.MainSetting(1)%>">注意：包含有商品的三级分类不能删除！</font></p>
	<%Rs.Close
End Sub

Sub ThdTypeAdd()
	Dim TypeID, SubTypeID, SubTypeName, ThdTypeName, isVisible, MyType, DefPrice1, DefPrice2, DefPeriod, DefQuantity, DefVIP, DefFlag, IsBig, QQType
	Dim Orders
	
	SubTypeID = Request("subtypeid")
	If SubTypeID = "" Or Not IsInteger(SubTypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	SubTypeID = CLng(SubTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 SubTypeName,TypeID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	SubTypeName = Rs(0)
	TypeID = Rs(1)
	Rs.Close
	If Request("add")<>"" Then
		ThdTypeName = Dvbbs.CheckStr(Trim(Request("ThdTypeName")))
		If ThdTypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>三级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where SubTypeName='" & ThdTypeName & "' And ParentSubType=" & SubTypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>三级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		MyType = Request("MyType")
		If MyType = "" Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not IsInteger(MyType) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		MyType = CLng(MyType)
		If MyType <= 100 Or MyType > 5000 Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码必须大于100小于5000！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If (MyType \ 100) > 50 Or (MyType Mod 100) > 50 Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码不能是系统保留的类别代码！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & MyType).Eof Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码已经存在！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		QQType = Request("QQType")
		If QQType = "" Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not IsInteger(QQType) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		QQType = CLng(QQType)
		If QQType > 0 Then
			If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where QQType=" & QQType).Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的腾讯类别代码已经存在！"
				Call Dvbbs_Error()
				Exit Sub
			End If
		End If
		DefPrice1 = Request("DefPrice1")
		If DefPrice1 = "" Or Not IsInteger(DefPrice1) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPrice1 = CLng(DefPrice1)
		DefPrice2 = Request("DefPrice2")
		If DefPrice2 = "" Or Not IsInteger(DefPrice2) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPrice2 = CLng(DefPrice2)
		DefPeriod = Request("DefPeriod")
		If DefPeriod = "" Or Not IsInteger(DefPeriod) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPeriod = CLng(DefPeriod)
		DefQuantity = Request("DefQuantity")
		If DefQuantity = "" Or Not IsInteger(DefQuantity) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefQuantity = CLng(DefQuantity)
		DefVip = Request("DefVip")
		If DefVip = "" Then
			DefVip = 0
		ElseIf Not isInteger(DefVip) Then
			DefVip = 0
		ElseIf DefVip <> "0" Then
			DefVip = 1
		Else
			DefVip = 0
		End If
		DefFlag = Request("DefFlag")
		If DefFlag = "" Then
			DefFlag = 1
		ElseIf Not isInteger(DefFlag) Then
			DefFlag = 1
		Else
			DefFlag = CLng(DefFlag)
			If DefFlag > 4 Then
				DefFlag = 1
			End If
		End If
		IsBig = Request("IsBig")
		If IsBig = "" Then
			IsBig = 0
		ElseIf Not isInteger(IsBig) Then
			IsBig = 0
		Else
			IsBig = CLng(IsBig)
			If IsBig > 3 Then
				IsBig = 0
			End If
		End If
		Set Rs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where ParentSubType=" & SubTypeID & " Order By Orders")
		Orders = 1
		Do While Not Rs.Eof
			If Rs(0) > Orders Then
				Exit Do
			End If
			Orders = Orders + 1
			Rs.MoveNext
		Loop
		Rs.Close
		Dvbbs.Plus_Execute("Insert Into Dv_Plus_Avatar_SubType (TypeID,SubTypeName,ParentSubType,Orders,Visible,MyType,QQType,DefPrice1,DefPrice2,DefPeriod,DefQuantity,DefVip,DefFlag,isBig) Values (" & TypeID & ",'" & ThdTypeName & "'," & SubTypeID & "," & Orders & "," & isVisible & "," & MyType & "," & QQType & "," & DefPrice1 & "," & DefPrice2 & "," & DefPeriod & "," & DefQuantity & "," & DefVip & "," & DefFlag & "," & isBig & ")")
		Call MakeAvatarXML()
		Dv_Suc("新增三级分类成功！<a href=Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & SubTypeID & ">返回三级分类管理</a>")
	Else%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<form action="?action=ThdTypeAdd&add=1" method=post>
			<input type="hidden" name="subtypeid" value="<%=SubTypeID%>">	
			<tr height=25> 
				<th colspan="2" id="TableTitleLink"><a href="?action=ThdTypeInfo&subtypeid=<%=SubTypeID%>"><b>【<%=SubTypeName%>】的三级分类管理</b></a> | <font color="<%=Dvbbs.MainSetting(1)%>">增加【<%=SubTypeName%>】的三级分类</font></th>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>三级分类名称&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<input type="text" name="thdtypename" size=40 maxlength=50></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1" checked> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>商品类别代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="MyType" id="MyType" size=40 maxlength=4></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>QQShow页面代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="QQType" id="QQType" size=40 maxlength=4 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认标准价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice1" id="DefPrice1" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认VIP价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice2" id="DefPrice2" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认有效期限&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPeriod" id="DefPeriod" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认当前库存&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefQuantity" id="DefQuantity" size=40 maxlength=6 value="0"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购属性&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefVip" id="DefVip1" value="1"> VIP&nbsp;&nbsp;<input type="radio" name="DefVip" id="DefVip2" value="0" checked> 不限</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购等级&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefFlag" id="DefFlag0" value="0"> 保留商品&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag1" value="1" checked> 所有会员&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag2" value="2"> 版主以上&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag3" value="3"> 超级版主&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag4" value="4"> 管理员</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>图示方式&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isBig" id="isBig0" value="0" checked> 小图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig3" value="3"> 中图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig1" value="1"> 大图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig2" value="2"> 超大</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 添 加 "></td>
			</tr>
			</form>
		</table>
	<%End If
End Sub

Sub ThdTypeEdit()
	Dim TypeID, SubTypeID, SubTypeName, ThdTypeID, ThdTypeName, isVisible, MyType, DefPrice1, DefPrice2, DefPeriod, DefQuantity, DefVIP, DefFlag, IsBig, QQType
	Dim Orders, Rs, TempRs, OldSubTypeID, OldMyType, Pos, OldTypeID
	
	ThdTypeID = Request("thdtypeid")
	If ThdTypeID = "" Or Not IsInteger(ThdTypeID) Or ThdTypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	ThdTypeID = CLng(ThdTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_SubType Where ID=" & ThdTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的三级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	If (Rs("MyType") Mod 100) > 50  Then
		ErrMsg = ErrMsg & "<BR><li>系统保留的三级分类不能修改！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldTypeID = Rs("TypeID")
	OldSubTypeID = Rs("ParentSubType")
	OldMyType = Rs("MyType")
	Set TempRs = Dvbbs.Plus_Execute("Select Top 1 SubTypeName From Dv_Plus_Avatar_SubType Where ID=" & OldSubTypeID)
	If TempRs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		TempRs.Close
		Rs.Close
		Exit Sub
	End If
	SubTypeName = TempRs(0)
	TempRs.Close
	If Not IsNull(Request("edit")) And Request("edit")<>"" Then
		SubTypeID = Trim(Request("ParentID"))
		Pos = InStr(SubTypeID, ",")
		If Pos > 0 Then
			TypeID = Trim(Left(SubTypeID, Pos - 1))
			SubTypeID = Trim(Mid(SubTypeID, Pos + 1))
		Else
			TypeID = SubTypeID
			SubTypeID = "0"
		End If
		If TypeID = "" Or Not IsInteger(TypeID) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		TypeID = CLng(TypeID)
		If SubTypeID = "" Or Not IsInteger(SubTypeID) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		SubTypeID = CLng(SubTypeID)
		If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Type Where ID=" & TypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>指定的一级分类不存在！"
			Call Dvbbs_Error()
			Rs.Close
			Exit Sub
		End If
		If SubTypeID > 0 Then
			If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where ID=" & SubTypeID).Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的二级分类不存在！"
				Call Dvbbs_Error()
				Rs.Close
				Exit Sub
			End If
		End If
		ThdTypeName = Dvbbs.CheckStr(Trim(Request("ThdTypeName")))
		If ThdTypeName = "" Then
			ErrMsg = ErrMsg & "<BR><li>三级分类名称不能为空！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where SubTypeName='" & ThdTypeName & "' And ParentSubType=" & SubTypeID & " And ID<>" & ThdTypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>三级分类名称不能重复！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		isVisible = Request("isVisible")
		If isVisible = "" Then
			isVisible = 0
		ElseIf Not isInteger(isVisible) Then
			isVisible = 0
		ElseIf isVisible <> "0" Then
			isVisible = 1
		Else
			isVisible = 0
		End If
		MyType = Request("MyType")
		If MyType = "" Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not IsInteger(MyType) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		MyType = CLng(MyType)
		If MyType <= 100 Or MyType > 5000 Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码必须大于100小于5000！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If (MyType \ 100) > 50 Or (MyType Mod 100) > 50 Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码不能是系统保留的类别代码！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where MyType=" & MyType & " And ID<>" & ThdTypeID).Eof Then
			ErrMsg = ErrMsg & "<BR><li>指定的类别代码已经存在！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		QQType = Request("QQType")
		If QQType = "" Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		If Not IsInteger(QQType) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		QQType = CLng(QQType)
		If QQType > 0 Then
			If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_SubType Where QQType=" & QQType & " And ID<>" & ThdTypeID).Eof Then
				ErrMsg = ErrMsg & "<BR><li>指定的腾讯类别代码已经存在！"
				Call Dvbbs_Error()
				Exit Sub
			End If
		End If
		DefPrice1 = Request("DefPrice1")
		If DefPrice1 = "" Or Not IsInteger(DefPrice1) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPrice1 = CLng(DefPrice1)
		DefPrice2 = Request("DefPrice2")
		If DefPrice2 = "" Or Not IsInteger(DefPrice2) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPrice2 = CLng(DefPrice2)
		DefPeriod = Request("DefPeriod")
		If DefPeriod = "" Or Not IsInteger(DefPeriod) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefPeriod = CLng(DefPeriod)
		DefQuantity = Request("DefQuantity")
		If DefQuantity = "" Or Not IsInteger(DefQuantity) Then
			ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
		DefQuantity = CLng(DefQuantity)
		DefVip = Request("DefVip")
		If DefVip = "" Then
			DefVip = 0
		ElseIf Not isInteger(DefVip) Then
			DefVip = 0
		ElseIf DefVip <> "0" Then
			DefVip = 1
		Else
			DefVip = 0
		End If
		DefFlag = Request("DefFlag")
		If DefFlag = "" Then
			DefFlag = 1
		ElseIf Not isInteger(DefFlag) Then
			DefFlag = 1
		Else
			DefFlag = CLng(DefFlag)
			If DefFlag > 4 Then
				DefFlag = 1
			End If
		End If
		IsBig = Request("IsBig")
		If IsBig = "" Then
			IsBig = 0
		ElseIf Not isInteger(IsBig) Then
			IsBig = 0
		Else
			IsBig = CLng(IsBig)
			If IsBig > 4 Then
				IsBig = 0
			End If
		End If
		If TypeID <> OldTypeID Or SubTypeID <> OldSubTypeID Or SubTypeID = 0 Then
			If SubTypeID > 0 Then
				Set TempRs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=" & SubTypeID & " Order By Orders")
			Else
				Set TempRs = Dvbbs.Plus_Execute("Select Orders From Dv_Plus_Avatar_SubType Where TypeID=" & TypeID & " And ParentSubType=0 Order By Orders")
			End If
			Orders = 1
			Do While Not TempRs.Eof
				If TempRs(0) > Orders Then
					Exit Do
				End If
				Orders = Orders + 1
				TempRs.MoveNext
			Loop
			TempRs.Close
			If MyType <> OldMyType And OldMyType <> 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set Type=" & MyType & " Where Type=" & OldMyType)
			End If
			If SubTypeID > 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set TypeID=" & TypeID & ",ParentSubType=" & SubTypeID & ",Orders=" & Orders & ",SubTypeName='" & ThdTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & ThdTypeID)
			Else
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set TypeID=" & TypeID & ",ParentSubType=0,Orders=" & Orders & ",SubTypeName='" & ThdTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & ThdTypeID)
			End If
		Else
			If MyType <> OldMyType And OldMyType <> 0 Then
				Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set Type=" & MyType & " Where Type=" & OldMyType)
			End If
			Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set SubTypeName='" & ThdTypeName & "',Visible=" & isVisible & ",MyType=" & MyType & ",QQType=" & QQType & ",DefPrice1=" & DefPrice1 & ",DefPrice2=" & DefPrice2 & ",DefPeriod=" & DefPeriod & ",DefQuantity=" & DefQuantity & ",DefVip=" & DefVip & ",DefFlag=" & DefFlag & ",isBig=" & isBig & " Where ID=" & ThdTypeID)
		End If
		Call MakeAvatarXML()
		Dv_Suc("修改三级分类成功！<a href=Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & OldSubTypeID & ">返回三级分类管理</a>")
	Else%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<form action="?action=ThdTypeEdit&edit=1" method=post>
			<input type="hidden" name="thdtypeid" value="<%=ThdTypeID%>">
			<tr height=25> 
				<th colspan="2" id="TableTitleLink"><a href="?action=ThdTypeInfo&subtypeid=<%=Rs("ParentSubType")%>"><b>【<%=SubTypeName%>】的三级分类管理</b></a> | <font color="<%=Dvbbs.MainSetting(1)%>">修改【<%=SubTypeName%>】的三级分类</font></th>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>三级分类名称&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<input type="text" name="thdtypename" size=40 maxlength=50 value="<%=Rs("SubTypeName")%>"></td>
			</tr>
			<tr height=25> 
				<td width="40%" class=forumrowhighlight align=right>所属分类&nbsp;</td>
				<td width="60%" class=forumrow align=left>&nbsp;<%
					Response.Write "<select name='ParentID'>" & vbCrLf
					Call ShowTypeSelect(Rs("ID"), Rs("TypeID") & "," & Rs("ParentSubType"))
					Response.Write "</select>" & vbCrLf
				%></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>是否显示&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isVisible" value="1"<%If Rs("Visible") = 1 Then%> checked<%End If%>> 是&nbsp;&nbsp;<input type="radio" name="isVisible" value="0"<%If Rs("Visible") = 0 Then%> checked<%End If%>> 否</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>商品类别代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="MyType" id="MyType" size=40 maxlength=4 value="<%=Rs("MyType")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>QQShow页面代码&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="QQType" id="QQType" size=40 maxlength=4 value="<%=Rs("QQType")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认标准价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice1" id="DefPrice1" size=40 maxlength=6 value="<%=Rs("DefPrice1")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认VIP价格&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPrice2" id="DefPrice2" size=40 maxlength=6 value="<%=Rs("DefPrice2")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认有效期限&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefPeriod" id="DefPeriod" size=40 maxlength=6 value="<%=Rs("DefPeriod")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认当前库存&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="text" name="DefQuantity" id="DefQuantity" size=40 maxlength=6 value="<%=Rs("DefQuantity")%>"></td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购属性&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefVip" id="DefVip1" value="1"<%If Rs("DefVip")=1 Then%> checked<%End If%>> VIP&nbsp;&nbsp;<input type="radio" name="DefVip" id="DefVip2" value="0"<%If Rs("DefVip")=0 Then%> checked<%End If%>> 不限</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>默认限购等级&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="DefFlag" id="DefFlag0" value="0"<%If Rs("DefFlag")=0 Then%> checked<%End If%>> 保留商品&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag1" value="1"<%If Rs("DefFlag")=1 Then%> checked<%End If%>> 所有会员&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag2" value="2"<%If Rs("DefFlag")=2 Then%> checked<%End If%>> 版主以上&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag3" value="3"<%If Rs("DefFlag")=3 Then%> checked<%End If%>> 超级版主&nbsp;&nbsp;<input type="radio" name="DefFlag" id="DefFlag4" value="4"<%If Rs("DefFlag")=4 Then%> checked<%End If%>> 管理员</td>
			</tr>
			<tr height=25> 
				<td class=forumrowhighlight align=right>图示方式&nbsp;</td>
				<td class=forumrow align=left>&nbsp;<input type="radio" name="isBig" id="isBig0" value="0"<%If Rs("isBig")=0 Then%> checked<%End If%>> 小图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig3" value="3"<%If Rs("isBig")=3 Then%> checked<%End If%>> 中图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig1" value="1"<%If Rs("isBig")=1 Then%> checked<%End If%>> 大图&nbsp;&nbsp;<input type="radio" name="isBig" id="isBig2" value="2"<%If Rs("isBig")=2 Then%> checked<%End If%>> 超大</td>
			</tr>
			<tr height=25> 
				<td colspan="2" class=forumrowhighlight align=center><input type="submit" name="Submit" value=" 修 改 "></td>
			</tr>
			</form>
		</table>
	<%End If
	Rs.Close
End sub

Sub ThdTypeDel
	Dim ThdTypeID, MyType, Rs, SubTypeID
	
	ThdTypeID = Request("thdtypeid")
	If ThdTypeID = "" Or Not IsInteger(ThdTypeID) Or ThdTypeID = "0" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	ThdTypeID = CLng(ThdTypeID)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 ParentSubType,MyType From Dv_Plus_Avatar_SubType Where ID=" & ThdTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的三级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	SubTypeID = Rs(0)
	If Not SubTypeID > 0 Then
		ErrMsg = ErrMsg & "<BR><li>指定的不是三级分类！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	MyType = Rs(1)
	Rs.Close
	If Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_Items Where Type=" & MyType)(0) > 0 Then
		ErrMsg = ErrMsg & "<BR><li>包含有商品的三级分类不能删除！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_SubType Where ID=" & ThdTypeID)
	Call MakeAvatarXML()
	Dv_Suc("已经成功地删除了三级分类！<a href=Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & SubTypeID & ">返回三级分类管理</a>")
End Sub

Sub ThdTypeOrdersUp()
	Dim OldOrders, NewOrders, MoveStep, SubTypeID
	Dim ThdTypeID, OtherThdTypeID, Rs, i
	
	ThdTypeID = Request("thdtypeid")
	If ThdTypeID = "" Or Not IsInteger(ThdTypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	ThdTypeID = CLng(ThdTypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders,ParentSubType From Dv_Plus_Avatar_SubType Where ID=" & ThdTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的三级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	SubTypeID = Rs(1)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders<" & OldOrders & " And ParentSubType=" & SubTypeID & " Order By Orders Desc", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders<" & OldOrders & " And ParentSubType=" & SubTypeID & " Order By Orders Desc", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherThdTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & NewOrders & " Where ID=" & ThdTypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & OldOrders & " Where ID=" & OtherThdTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & SubTypeID & "';</script>"
End Sub

Sub ThdTypeOrdersDown()
	Dim OldOrders, NewOrders, MoveStep, SubTypeID
	Dim ThdTypeID, OtherThdTypeID, Rs, i
	
	ThdTypeID = Request("thdtypeid")
	If ThdTypeID = "" Or Not IsInteger(ThdTypeID) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	ThdTypeID = CLng(ThdTypeID)
	MoveStep = Request("MoveStep")
	If MoveStep = "" Or Not IsInteger(MoveStep) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数！"
		Call Dvbbs_Error()
		Exit Sub
	End If
	MoveStep = CInt(MoveStep)
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 Orders,ParentSubType From Dv_Plus_Avatar_SubType Where ID=" & ThdTypeID)
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的三级分类不存在！"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
	OldOrders = Rs(0)
	SubTypeID = Rs(1)
	Rs.Close
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders>" & OldOrders & " And ParentSubType=" & SubTypeID & " Order By Orders", Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open "Select ID,Orders From Dv_Plus_Avatar_SubType Where Orders>" & OldOrders & " And ParentSubType=" & SubTypeID & " Order By Orders", Conn, 1, 1
	End If
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	End If
	i = 1
	Do While Not Rs.Eof And i <= MoveStep
		OtherThdTypeID = Rs(0)
		NewOrders = Rs(1)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & NewOrders & " Where ID=" & ThdTypeID)
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_SubType Set Orders=" & OldOrders & " Where ID=" & OtherThdTypeID)
		OldOrders = NewOrders
		Rs.MoveNext
		i = i + 1
	Loop
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Response.Write "<script language=""javascript"">document.location='Plus_Avatar_Type.asp?action=ThdTypeInfo&subtypeid=" & SubTypeID & "';</script>"
End Sub

Sub ShowTypeSelect(ThisID, ParentID)
	Dim Rs1, Rs2
	
	Set Rs1 = Dvbbs.Plus_Execute("Select ID,TypeName From Dv_Plus_Avatar_Type")
	Do While Not Rs1.Eof
		Response.Write "<option value='" & Rs1(0) & "'"
		If Rs1(0) = ParentID Then Response.Write " selected"
		Response.Write ">+----" & Rs1(1) & "</option>" & vbCrLf
		Set Rs2 = Dvbbs.Plus_Execute("Select ID,TypeID,MyType,SubTypeName From Dv_Plus_Avatar_SubType Where ParentSubType=0 And TypeID=" & Rs1(0) & " And ID<>" & ThisID)
		Do While Not Rs2.EOF
			If (Rs2(2) \ 100) > 50 Then
				Response.Write "<option value='" & Rs2(1) & "," & Rs2(0) & "'"
				If Rs2(1) & "," & Rs2(0) = ParentID Then Response.Write " selected"
				Response.Write ">+&nbsp;&nbsp;&nbsp;&nbsp;+----" & Rs2(3) & "</option>" & vbCrLf
			End If
			Rs2.MoveNext
		Loop
		Rs2.Close
		Rs1.MoveNext
	Loop
	Rs1.Close
End Sub
%>
