<!--#include file=../conn.asp-->
<!--#include file="inc/const.asp" -->
<!--#include file="../Dv_Plus/Avatar/Plus_Avatar_Const.asp" -->
<%
Head()
Server.ScriptTimeout=9999999
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
	Call AvatarHead()
	If Request("action") = "" Or Request("AvatarSearch") = "0" Then
		Call Main()
	ElseIf Request("action") = "ReCalc" Then
		Call ReCalc()
	ElseIf Request("action") = "AvatarSearch" Then
		Call Query()
	ElseIf Request("action") = "MultiUpdate" Then
		Call MultiUpdate()
	ElseIf Request("action") = "ItemInfo" Then
		Call ItemInfo()
	ElseIf Request("action") = "SingleUpdate" Then
		Call SingleUpdate()
	End If
	Footer()
End If

Sub AvatarHead()%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
		<col width="200"><col widht="*">
		<tr height=25>
			<th colspan=2>形象商品管理</th>
		</tr>
		<form action="Plus_Avatar_Items.asp" method=post>
		<input type=hidden name="action" value="ReCalc">
		<tr height=25>
			<td class=forumrowhighlight>注意事项</td>
			<td class=forumrow>①限购者保留将使商品对所有用户不可见；<br>②点商品名进行相应的资料操作；<br>③批量修改的条件请尽量简单；<br>④<font color="#FF0000">请仔细阅读相关操作的说明</font><br><input type=Submit value="刷新热销商品" Name="Submit"></td>
		</tr>
		</form>
		<form action="Plus_Avatar_Items.asp" method=post>
		<input type=hidden name="action" value="AvatarSearch">
		<tr height=25>
			<td class=forumrowhighlight>快速搜索</td>
			<td class=forumrow><select size=1 Name="AvatarSearch" onchange="javascript:submit()">
				<option value="0">请选择查询条件</option>
				<option value="8" <%if Request("AvatarSearch")=8 then%>selected<%end if%>>列出所有商品</option>
				<option value="1" <%if Request("AvatarSearch")=1 then%>selected<%end if%>>列出所有保留商品</option>
				<option value="2" <%if Request("AvatarSearch")=2 then%>selected<%end if%>>列出所有专供管理员的商品</option>
				<option value="3" <%if Request("AvatarSearch")=3 then%>selected<%end if%>>列出所有专供超级版主的商品</option>
				<option value="4" <%if Request("AvatarSearch")=4 then%>selected<%end if%>>列出所有专供版主的商品</option>
				<option value="5" <%if Request("AvatarSearch")=5 then%>selected<%end if%>>列出所有专供Vip会员的商品</option>
				<option value="6" <%if Request("AvatarSearch")=6 then%>selected<%end if%>>列出所有今天上架的商品</option>
				<option value="7" <%if Request("AvatarSearch")=7 then%>selected<%end if%>>列出所有库存为零的商品</option>
			</select></td>
		</tr>
		</form>
	</table>
	<script language="JavaScript">
	function CheckAll(form)	{
		for (var i=0;i<form.elements.length;i++)		{
			var e = form.elements[i];
			if (e.name == 'ItemID') e.checked = form.chkall.checked;
		 }
		}
	
	function CheckPageAll(form)	{
		for (var i=0;i<form.elements.length;i++)		{
			var e = form.elements[i];
			if (e.name == 'chkall' || e.name == 'ItemID') {
				e.checked = form.chkpageall.checked;
				e.disabled = form.chkpageall.checked;
			}
		 }
		}
	function DisableAllOperation() {
		document.getElementById("selAvatarType").disabled = true;
		document.getElementById("selAvatarType").selectedIndex = 0;
		document.getElementById("selAvatarSex").disabled = true;
		document.getElementById("selAvatarSex").selectedIndex = 0;
		document.getElementById("selAvatarFlag").disabled = true;
		document.getElementById("selAvatarFlag").selectedIndex = 0;
		document.getElementById("selAvatarVip").disabled = true;
		document.getElementById("selAvatarVip").selectedIndex = 0;
		document.getElementById("selAvatarPrice1").disabled = true;
		document.getElementById("selAvatarPrice1").selectedIndex = 0;
		document.getElementById("selAvatarPrice1T").disabled = true;
		document.getElementById("selAvatarPrice1T").value = '';
		document.getElementById("selAvatarPrice2").disabled = true;
		document.getElementById("selAvatarPrice2").selectedIndex = 0;
		document.getElementById("selAvatarPrice2T").disabled = true;
		document.getElementById("selAvatarPrice2T").value = '';
		document.getElementById("selAvatarPeriod").disabled = true;
		document.getElementById("selAvatarPeriod").selectedIndex = 0;
		document.getElementById("selAvatarPeriodT").disabled = true;
		document.getElementById("selAvatarPeriodT").value = '';
		document.getElementById("selAvatarQuantity").disabled = true;
		document.getElementById("selAvatarQuantity").selectedIndex = 0;
		document.getElementById("selAvatarQuantityT").disabled = true;
		document.getElementById("selAvatarQuantityT").value = '';
	}
	function CheckOperation() {
		DisableAllOperation();
		switch (event.srcElement.value) {
			case '1' :
				document.getElementById("selAvatarType").disabled = false;
				break;
			case '2' :
				document.getElementById("selAvatarSex").disabled = false;
				break;
			case '3' :
				document.getElementById("selAvatarFlag").disabled = false;
				break;
			case '4' :
				document.getElementById("selAvatarVip").disabled = false;
				break;
			case '5' :
				document.getElementById("selAvatarPrice1").disabled = false;
				document.getElementById("selAvatarPrice1T").disabled = false;
				break;
			case '6' :
				document.getElementById("selAvatarPrice2").disabled = false;
				document.getElementById("selAvatarPrice2T").disabled = false;
				break;
			case '7' :
				document.getElementById("selAvatarPeriod").disabled = false;
				document.getElementById("selAvatarPeriodT").disabled = false;
				break;
			case '8' :
				document.getElementById("selAvatarQuantity").disabled = false;
				document.getElementById("selAvatarQuantityT").disabled = false;
				break;
		}
	}
	</script>
<%End Sub

Sub Main()%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
		<form action="Plus_Avatar_Items.asp" method=post>
		<input type=hidden name="action" value="AvatarSearch">
		<tr height=25>
			<th colspan=3>高级查询</th>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>注意事项</td>
			<td class=forumrow colspan=2>在记录很多的情况下搜索条件越多查询越慢，请尽量减少查询条件。</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>商品编号</td>
			<td class=forumrow colspan=2><input size=45 Name="AvatarID" type=textbox maxlength=6></td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>商品名称</td>
			<td class=forumrow colspan=2><input size=45 Name="AvatarName" type=textbox maxlength=20>&nbsp;<input type=checkbox Name="AvataNameChk" value="yes" checked>商品名称完整匹配</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>商品类别</td>
			<td class=forumrow colspan=2><select size=1 Name="AvatarType"><option value=0>任意</option><%Call AvatarTypeSelect()%></select></td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>适用性别</td>
			<td class=forumrow colspan=2><select size=1 Name="AvatarSex"><option value=9>任意</option><%Call AvatarSexOption()%></select></td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>限购属性</td>
			<td class=forumrow colspan=2><select size=1 Name="AvatarVip"><option value=9>任意</option><%Call AvatarVipOption()%></select></td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>限购等级</td>
			<td class=forumrow colspan=2><select size=1 Name="AvatarFlag"><option value=9>任意</option><%Call AvatarFlagOption()%></select></td>
		</tr>
		<tr height=25>
			<th colspan=3>特殊查询&nbsp;(注意： <多于> 或 <少于> 已默认包含 <等于>；条件留空则不使用此条件 )</th>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>标准价格</td>
			<td class=forumrow colspan=2><input type=radio value="more" Name="AvatarPrice1" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value="less" Name="AvatarPrice1">&nbsp;少于&nbsp;&nbsp;<input size=5 Name="AvatarPrice1T" type=textbox maxlength=6> 元</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>Vip价格</td>
			<td class=forumrow colspan=2><input type=radio value="more" Name="AvatarPrice2" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value="less" Name="AvatarPrice2">&nbsp;少于&nbsp;&nbsp;<input size=5 Name="AvatarPrice2T" type=textbox maxlength=6> 元</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>有效期限</td>
			<td class=forumrow colspan=2><input type=radio value="more" Name="AvatarPeriod" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value="less" Name="AvatarPeriod">&nbsp;少于&nbsp;&nbsp;<input size=5 Name="AvatarPeriodT" type=textbox maxlength=6> 天</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>当前库存</td>
			<td class=forumrow colspan=2><input type=radio value="more" Name="AvatarQuantity" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value="less" Name="AvatarQuantity">&nbsp;少于&nbsp;&nbsp;<input size=5 Name="AvatarQuantityT" type=textbox maxlength=6> 个</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>销量</td>
			<td class=forumrow colspan=2><input type=radio value="more" Name="AvatarTotalSales" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value="less" Name="AvatarTotalSales">&nbsp;少于&nbsp;&nbsp;<input size=5 Name="AvatarTotalSalesT" type=textbox maxlength=6> 个</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight align=center colspan=3><input Name="submit" type=submit value=" 搜	索 "></td>
		</tr>
		<input type=hidden value="9" Name="AvatarSearch">
		</form>
	</table>
<%End Sub

Sub ReCalc()
	Dim Rs
	
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set TotalSales=0")
	Set Rs = Dvbbs.Plus_Execute("Select ItemID,Count(ItemID) From Dv_Plus_Avatar_MyItems Group By ItemID")
	Do While Not Rs.Eof
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Items Set TotalSales=" & Rs(1) & " Where ID=" & Rs(0))
		Rs.movenext
	Loop
	Rs.Close
	Dv_Suc("已经成功地重新计算了热销商品。<a href=Plus_Avatar_Items.asp>返回形象商品管理</a>")
End Sub

Sub Query()
	Dim SQLStr, SQL, Rs, TempRs1, TempRs2, TempRs3
	Dim CurrentPage, Page_Count, PCount, i
	Dim TotalRec, EndPage
	
	CurrentPage = Request("page")
	If CurrentPage = "" Or Not IsInteger(CurrentPage) Then
		CurrentPage = 1
	Else
		CurrentPage = CLng(CurrentPage)
	End If
	Select Case Request("AvatarSearch")
	Case 1
		SQLStr = " Flag=0"
	Case 2
		SQLStr = " Flag=4"
	Case 3
		SQLStr = " Flag=3"
	Case 4
		SQLStr = " Flag=2"
	Case 5
		SQLStr = " Vip=1"
	Case 6
		SQLStr = " " & SqlDateDiffString("DateAndTime", SqlNowString) & "=0"
	Case 7
		SQLStr = " Quantity=0"
	Case 8
		SQLStr = " 2>1"
	Case 9
		If Request("AvatarID") <> "" Then
			If Not isInteger(Request("AvatarID")) Then
				ErrMsg = ErrMsg & "<BR><li>商品编号必须是整数！"
				Call Dvbbs_Error()
				Exit Sub
			End If
		End If
		SQLStr = GetSQLStr()
		If SQLStr = "" Then
			ErrMsg = ErrMsg & "<BR><li>请指定搜索条件！"
			Call Dvbbs_Error()
			Exit Sub
		End If
	Case Else
		ErrMsg = ErrMsg & "<BR><li>指定了错误的参数。"
		Call Dvbbs_Error()
		Exit Sub
	End Select
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "Select ID,Name,Sex,Type,Period,Flag,Vip,Quantity,TotalSales From Dv_Plus_Avatar_Items Where " & SQLStr & " And Type<>0 Order By ID Desc"
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open SQL, Plus_Conn, 1, 1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open SQL, Conn, 1, 1
	End If
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>没有找到相关记录。"
		Call Dvbbs_Error()
		Exit Sub
	Else
%>
		<br>
		<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder">
			<tr height=25>
				<th colspan=10>搜索结果</th>
			</tr>
			<FORM METHOD=POST ACTION="Plus_Avatar_Items.asp">
			<input type=hidden name="action" value="MultiUpdate">
			<tr height=25>
				<th>商品编号</th>
				<th>商品名称</th>
				<th>商品类别</th>
				<th>适用性别</th>
				<th>有效期限</th>
				<th>限购等级</th>
				<th>限购属性</th>
				<th>库存</th>
				<th>销量</th>
				<th>操作</th>
			</tr>
			<%Rs.PageSize = CLng(Dvbbs.Forum_Setting(11))
			Rs.AbsolutePage = CurrentPage
			Page_Count = 0
			TotalRec = Rs.RecordCount
			Do While Not Rs.Eof And Page_Count < CLng(Dvbbs.Forum_Setting(11))%>
				<tr height=25>
					<td class=forumrow align=center><%=Rs(0)%></td>
					<td class=forumrowhighlight><a href="Plus_Avatar_Items.asp?action=ItemInfo&ItemID=<%=Rs(0)%>"><%=Rs(1)%></a></td>
					<td class=forumrow align=center><%
						Set TempRs1 = Dvbbs.Plus_Execute("Select Top 1 SubTypeName,TypeID,ParentSubType From Dv_Plus_Avatar_SubType Where MyType=" & Rs(3))
						If TempRs1.Eof Then
							Response.Write "未知"
						Else
							Set TempRs2 = Dvbbs.Plus_Execute("Select Top 1 TypeName From Dv_Plus_Avatar_Type Where ID=" & TempRs1(1))
							If TempRs2.Eof Then
								Response.Write "未知"
							Else
								If TempRs1(2) <> 0 Then
									Set TempRs3 = Dvbbs.Plus_Execute("Select Top 1 SubTypeName From Dv_Plus_Avatar_SubType Where ID=" & TempRs1(2))
									If TempRs3.Eof Then
										Response.Write "未知"
									Else
										Response.Write TempRs2(0) & "→" & TempRs3(0) & "→" & TempRs1(0)
									End If
									TempRs3.Close
								Else
									Response.Write TempRs2(0) & "→" & TempRs1(0)
								End If
							End If
							TempRs2.Close
						End If
						TempRs1.close
					%></td>
					<td class=forumrowhighlight align=center><%
						Select Case Rs(2)
						Case 0
							Response.Write "女"
						Case 1
							Response.Write "男"
						Case Else
							Response.Write "不限"
						End Select
					%></td>
					<td class=forumrow align=center><%
						If Rs(4) = 0 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">永远有效</font>"
						Else
							Response.Write Rs(4)
						End If
					%></td>
					<td class=forumrow align=center><%
						Select Case Rs(5)
						Case 0
							Response.Write "<font color=gray>保留商品</font>"
						Case 1
							Response.Write "所有会员"
						Case 2
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">版主以上</font>"
						Case 3
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">超级版主</font>"
						Case 4
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">管理员</font>"
						End select
					%></td>
					<td class=forumrowhighlight align=center><%
						If Rs(6) = 1 Then
							Response.Write "<font color=" & Dvbbs.MainSetting(1) & "><b>VIP</b></font>"
						Else
							Response.Write "不限"
						End If
					%></td>
					<td class=forumrow align=center><%=Rs(7)%></td>
					<td class=forumrowhighlight align=center><%=Rs(8)%></td>
					<td class=forumrow align=center><input type="checkbox" Name="ItemID" value="<%=Rs(0)%>"></td>
				</tr>
				<%Page_Count = Page_Count + 1
				Rs.MoveNext
			Loop
			PCount = Rs.PageCount
			Rs.Close
			Set Rs = Nothing%>
			<tr height=25>
				<td colspan=10 class=forumrowhighlight align=center>分页：<%
					Dim SearchStr
					SearchStr = "?action=" & Request("action") & "&AvatarSearch=" & Request("AvatarSearch") & "&AvatarID=" & Request("AvatarID") & "&AvatarName=" & Request("AvatarName") & "&AvataNameChk=" & Request("AvataNameChk") & "&AvatarType=" & Request("AvatarType") & "&AvatarSex=" & Request("AvatarSex") & "&AvatarFlag=" & Request("AvatarFlag") & "&AvatarVip=" & Request("AvatarVip") & "&AvatarPrice1=" & Request("AvatarPrice1") & "&AvatarPrice1T=" & Request("AvatarPrice1T") & "&AvatarPrice2=" & Request("AvatarPrice2") & "&AvatarPrice2T=" & Request("AvatarPrice2T") & "&AvatarPeriod=" & Request("AvatarPeriod") & "&AvatarPeriodT=" & Request("AvatarPeriodT") & "&AvatarQuantity=" & Request("AvatarQuantity") & "&AvatarQuantityT=" & Request("AvatarQuantityT") & "&AvatarTotalSales=" & Request("AvatarTotalSales") & "&AvatarTotalSalesT=" & Request("AvatarTotalSalesT")
					If CurrentPage > 4 Then
						Response.Write "<a href=""" & SearchStr & "&page=1"">[1]</a> ..."
					End If
					If PCount > CurrentPage + 3 Then
						EndPage = CurrentPage + 3
					Else
						EndPage = PCount
					End If
					For i = CurrentPage - 3 To EndPage
						If Not i < 1 Then
							If i = CLng(CurrentPage) Then
								Response.Write " <font color=red>[" & i & "]</font>"
							Else
								Response.Write " <a href=""" & SearchStr & "&page=" & i & """>[" & i & "]</a>"
							End If
						End If
					Next
					If CurrentPage + 3 < Pcount Then
						Response.Write "... <a href=""" & SearchStr & "&page=" & Pcount & """>[" & Pcount & "]</a>"
					End If
				%></td>
			</tr>
			<tr height=25>
				<th colspan=10>请选择您需要进行的操作</td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改类别&nbsp;<input type="radio" Name="Avataraction" id="Avataraction1" value=1 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarType"><%Call AvatarTypeSelect()%></select></td>
				<td colspan=3 class=forumrowhighlight align=center rowspan=8><input type=checkbox value="on" Name="chkall" onclick="CheckAll(this.form)">&nbsp;当前页全部<br><input type=checkbox value="on" Name="chkpageall" onclick="CheckPageAll(this.form)">&nbsp;所有页全部</td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改性别&nbsp;<input type="radio" Name="Avataraction" id="Avataraction2" value=2 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarSex"><%Call AvatarSexOption()%></select></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改限购等级&nbsp;<input type="radio" Name="Avataraction" id="Avataraction3" value=3 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarFlag"><%Call AvatarFlagOption()%></select></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改限购属性&nbsp;<input type="radio" Name="Avataraction" id="Avataraction4" value=4 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarVip"><%Call AvatarVipOption()%></select></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改标准价格&nbsp;<input type="radio" Name="Avataraction" id="Avataraction5" value=5 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarPrice1"><option value=0>修改为(元)</option><option value=1>增加(%)</option><option value=2>减少(%)</option><option value=3>增加(元)</option><option value=4>减少(元)</option></select>&nbsp;<input type=textboxbox Name="selAvatarPrice1T" size=15 maxlength=6></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改Vip价格&nbsp;<input type="radio" Name="Avataraction" id="Avataraction6" value=6 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarPrice2"><option value=0>修改为(元)</option><option value=1>增加(%)</option><option value=2>减少(%)</option><option value=3>增加(元)</option><option value=4>减少(元)</option></select>&nbsp;<input type=textboxbox Name="selAvatarPrice2T" size=15 maxlength=6></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改有效期限&nbsp;<input type="radio" Name="Avataraction" id="Avataraction7" value=7 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarPeriod"><option value=0>修改为(天)</option><option value=1>增加(%)</option><option value=2>减少(%)</option><option value=3>增加(天)</option><option value=4>减少(天)</option></select>&nbsp;<input type=textboxbox Name="selAvatarPeriodT" size=15 maxlength=6></td>
			</tr>
			<tr height=25>
				<td colspan=3 class=forumrowhighlight align=right>修改当前库存&nbsp;<input type="radio" Name="Avataraction" id="Avataraction8" value=8 onclick="CheckOperation()">&nbsp;</td>
				<td colspan=4 class=forumrow align=left>&nbsp;<select size=1 Name="selAvatarQuantity"><option value=0>修改为(个)</option><option value=1>增加(%)</option><option value=2>减少(%)</option><option value=3>增加(个)</option><option value=4>减少(个)</option></select>&nbsp;<input type=textboxbox Name="selAvatarQuantityT" size=15 maxlength=6></td>
			</tr>
			<tr height=25>
				<td colspan=10 class=forumrowhighlight align=center><input type=submit Name=submit value="执行选定的操作"	onclick="{if(confirm('确定执行选择的操作吗?')){return true;}return false;}"></td>
			</tr>
			<input type=hidden Name="AvatarID" value="<%=Request("AvatarID")%>">
			<input type=hidden Name="AvatarName" value="<%=Request("AvatarName")%>">
			<input type=hidden Name="AvataNameChk" value="<%=Request("AvatarNameChk")%>">
			<input type=hidden Name="AvatarType" value="<%=Request("AvatarType")%>">
			<input type=hidden Name="AvatarSex" value="<%=Request("AvatarSex")%>">
			<input type=hidden Name="AvatarFlag" value="<%=Request("AvatarFlag")%>">
			<input type=hidden Name="AvatarVip" value="<%=Request("AvatarVip")%>">
			<input type=hidden Name="AvatarPrice1" value="<%=Request("AvatarPrice1")%>">
			<input type=hidden Name="AvatarPrice1T" value="<%=Request("AvatarPrice1T")%>">
			<input type=hidden Name="AvatarPrice2" value="<%=Request("AvatarPrice2")%>">
			<input type=hidden Name="AvatarPrice2T" value="<%=Request("AvatarPrice2T")%>">
			<input type=hidden Name="AvatarPeriod" value="<%=Request("AvatarPeriod")%>">
			<input type=hidden Name="AvatarPeriodT" value="<%=Request("AvatarPeriodT")%>">
			<input type=hidden Name="AvatarQuantity" value="<%=Request("AvatarQuantity")%>">
			<input type=hidden Name="AvatarQuantityT" value="<%=Request("AvatarQuantityT")%>">
			<input type=hidden Name="AvatarTotalSales" value="<%=Request("AvatarTotalSales")%>">
			<input type=hidden Name="AvatarTotalSalesT" value="<%=Request("AvatarTotalSalesT")%>">
			</FORM>
		</table>
		<script language="javascript" for="window" event="onload">
			DisableAllOperation();
			for(var i=0;i<8;i++)
				document.getElementById("Avataraction" + (i + 1)).checked=false;
		</script>
	<%End If
End Sub

Sub ItemInfo()
	Dim Rs

	If Request("ItemID") = "" Or Not IsInteger(Request("ItemID")) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的商品编码。"
		Call Dvbbs_Error()
		Exit Sub
	End If
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_Items Where ID=" & CLng(Request("ItemID")))
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的商品不存在。"
		Call Dvbbs_Error()
		Rs.Close
		Exit Sub
	End If
%>
	<br>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"	align=center class="tableBorder" style="width:<%=CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SampleWidth").text) + 310%>;table-layout:fixed;word-break:break-all">
		<col width="<%=CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SampleWidth").text) + 40%>"><col width="*">
		<form action="Plus_Avatar_Items.asp" method=post>
		<input type=hidden name="action" value="SingleUpdate">
		<input type=hidden name="ItemID" value="<%=Rs("ID")%>">
		<tr height=25>
			<th colspan=2 align=left>修改商品资料</th>
		</tr>
		<tr height=25>
			<td rowspan="5" class=forumrowhighlight align=center><img src="<%
				If AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("LocalPic").text = "1" Then
					Response.Write "../"
				End If
				Response.Write AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PicPath").text & GetPicURL(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("LocalPic").text, 0, Rs("ID"))
			%>" width="<%=AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SampleWidth").text%>" height="<%=AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SampleHeight").text%>" border="1"></td>
			<td class=forumrowhighlight>&nbsp;<input type=textboxbox Name=itemName size=16 value="<%=Rs("Name")%>" maxlength=20>(<select Name=itemsex><%
				If Rs("sex") = 1 Then
					Response.Write "<option value=1 selected>男</option>"
				Else
					Response.Write "<option value=1>男</option>"
				End If
				If Rs("sex") = 0 Then
					Response.Write "<option value=0 selected>女</option>"
				Else
					Response.Write "<option value=0>女</option>"
				End If
				If Rs("sex") = 2 Then
					Response.Write "<option value=2 selected>不限</option>"
				Else
					Response.Write "<option value=2>不限</option>"
				End If
			%></select>)&nbsp;</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>&nbsp;&nbsp;标准价格：<input type=textbox Name=itemPrice1 size=15 value="<%=Rs("Price1")%>" maxlength=6> 元</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>&nbsp;&nbsp;VIP 价格：<input type=textbox Name=itemPrice2 size=15 value="<%=Rs("Price2")%>" maxlength=6> 元</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>&nbsp;&nbsp;有效期限：<input type=textbox Name=itemPeriod size=15 value="<%=Rs("Period")%>" maxlength=6> 天</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight>&nbsp;&nbsp;当前库存：<input type=textbox Name=itemQuantity size=15 value="<%=Rs("Quantity")%>" maxlength=6> 个</td>
		</tr>
		<tr height=25>
			<td class=forumrowhighlight align=center>限购属性：<select name=itemVip><%
				If Rs("Vip") = 0 Then
					Response.Write "<option value=0 checked>不限</option>"
				Else
					Response.Write "<option value=0> 不限</option>"
				End If
				If Rs("Vip") <> 0 Then
					Response.Write "<option value=1 checked>VIP</option>"
				Else
					Response.Write "<option value=1>VIP</option>"
				End If
			%></select></td>
			<td class=forumrowhighlight>&nbsp;&nbsp;限购等级：<select Name=itemFlag><%
				If Rs("Flag") = 0 Then
					Response.Write "<option value=0 selected>保留商品</option>"
				Else
					Response.Write "<option value=0>保留商品</option>"
				End If
				If Rs("Flag") = 1 Then
					Response.Write "<option value=1 selected>所有会员</option>"
				Else
					Response.Write "<option value=1>所有会员</option>"
				End If
				If Rs("Flag") = 2 Then
					Response.Write "<option value=2 selected>版主以上</option>"
				Else
					Response.Write "<option value=2>版主以上</option>"
				End if
				If Rs("Flag") = 3 Then
					Response.Write "<option value=3 selected>超级版主</option>"
				Else
					Response.Write "<option value=3>超级版主</option>"
				End If
				If Rs("Flag") = 4 Then
					Response.Write "<option value=4 selected>管理员</option>"
				Else
					Response.Write "<option value=4>管理员</option>"
				End If
			%></select></td>
		</tr>
		<tr height=25>
			<td colspan=2 class=forumrowhighlight align=center><input type=Submit value=" 更 新 " Name="Submit"></td>
		</tr>
		</form>
	</table>	
<%
	Rs.close
End Sub

Sub SingleUpdate()
	Dim Rs, SQL
	
	If Request("itemid") = "" Or Not IsInteger(Request("itemid")) Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的商品编码。"
		Call Dvbbs_Error()
		Exit Sub
	End If
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "Select Top 1  * From Dv_Plus_Avatar_Items Where ID=" & CLng(Request("itemid"))
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs.Open SQL, Plus_Conn, 1, 3
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs.Open SQL, Conn, 1, 3
	End If
	If Rs.Eof Then
		ErrMsg = ErrMsg & "<BR><li>指定的商品不存在。"
	End If
	If Trim(Request.form("itemName")) = "" Then
		ErrMsg = ErrMsg & "<BR><li>商品名称不可为空。"
	End If
	If Request.form("itemSex") <> "0" And Request.form("itemSex") <> "1" And Request.form("itemSex") <> "2" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的商品适用性别。"
	End If
	If Request.form("itemPrice1") = "" Or Not IsInteger(Request.form("itemPrice1")) Then
		ErrMsg = ErrMsg & "<BR><li>标准价格必须是整数。"
	End If
	If Request.form("itemPrice2") = "" Or Not IsInteger(Request.form("itemPrice2")) Then
		ErrMsg = ErrMsg & "<BR><li>VIP价格必须是整数。"
	End If
	If Request.form("itemPeriod") = "" Or Not IsInteger(Request.form("itemPeriod")) Then
		ErrMsg = ErrMsg & "<BR><li>有效期限必须是整数。"
	End If
	If Request.form("itemQuantity") = "" Or Not IsInteger(Request.form("itemQuantity")) Then
		ErrMsg = ErrMsg & "<BR><li>当前库存必须是整数。"
	End If
	If Request.form("itemVip") <> "0" And Request.form("itemVip") <> "1" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的限购属性。"
	End If
	If Request.form("itemFlag") <> "0" And Request.form("itemFlag") <> "1" And Request.form("itemFlag") <> "2" And Request.form("itemFlag") <> "3" And Request.form("itemFlag") <> "4" Then
		ErrMsg = ErrMsg & "<BR><li>指定了错误的限购等级。"
	End If
	If ErrMsg <> "" Then
		Call Dvbbs_Error()
		Rs.Close
		Set Rs = Notihng
		Exit Sub
	End If
	Rs("Name") = Trim(Request.form("itemName"))
	Rs("sex") = Request.form("itemsex")
	Rs("Price1") = Request.form("itemPrice1")
	Rs("Price2") = Request.form("itemPrice2")
	Rs("Period") = Request.form("itemPeriod")
	Rs("Quantity") = Request.form("itemQuantity")
	Rs("Vip") = Request.form("itemVip")
	Rs("Flag") = Request.form("itemFlag")
	Rs.Update
	Rs.Close
	Set Rs = Nothing
	Call MakeAvatarXML()
	Dv_Suc("形象商品更新成功！<a href=Plus_Avatar_Items.asp>返回形象商品管理</a>")
End Sub

Sub MultiUpdate()
	Dim UpdateStr, SQLStr
	
	If Request("AvatarID") <> "" Then
		If Not isInteger(Request("AvatarID")) Then
			ErrMsg = ErrMsg & "<BR><li>商品编号必须是整数！"
			Call Dvbbs_Error()
			Exit Sub
		End If
	End If
	SQLStr = GetSQLStr()
	If (Request("ItemID") = "" And Request("chkpageall") <> "on") Or (SQLStr = "" And Request("chkpageall") = "on") Then
		ErrMsg = ErrMsg & "<BR><li>请选择相关商品。"
		Call Dvbbs_Error()
		Exit Sub
	End If
	If Request("chkpageall") <> "on" Then
		SQLStr = SQLStr & " And ID In (" & Dvbbs.CheckStr(Request("ItemID")) & ")"
	End If
	Select Case Request("Avataraction")
	Case 1
		If CInt(Request("selAvatarType")) < 100 Or (CInt(Request("selAvatarType")) \ 100) > 50 Or (CInt(Request("selAvatarType")) Mod 100) > 50 Then
			ErrMsg = ErrMsg & "<BR><li>不能将商品归入这个类别。"
			Call Dvbbs_Error()
			Exit Sub
		End If
		UpdateStr = "Type=" & CInt(Request("selAvatarType"))
	Case 2
		UpdateStr = "Sex=" & CInt(Request("selAvatarSex"))
	Case 3
		UpdateStr = "Flag=" & CInt(Request("selAvatarFlag"))
	Case 4
		UpdateStr = "Vip=" & CInt(Request("selAvatarVip"))
	Case 5
		If Request("selAvatarPrice1T") = "" Or Not IsInteger(Request("selAvatarPrice1T")) Then
			ErrMsg = ErrMsg & "<BR><li>标准价格指定错误。"
			Call Dvbbs_Error()
			Exit Sub
		Else
			Select Case Request("selAvatarPrice1")
			Case 0
				UpdateStr = "Price1=" & CLng(Request("selAvatarPrice1T"))
			Case 1
				UpdateStr = "Price1=Price1*(100+" & CLng(Request("selAvatarPrice1T")) & ")/100"
			Case 2
				UpdateStr = "Price1=Price1*(100-" & CLng(Request("selAvatarPrice1T")) & ")/100"
			Case 3
				UpdateStr = "Price1=Price1+" & CLng(Request("selAvatarPrice1T"))
			Case 4
				If IsSqlDataBase = 1 Then
					UpdateStr = "Price1=Case When Price1>=" & CLng(Request("selAvatarPrice1T")) & " Then Price1-" & CLng(Request("selAvatarPrice1T")) & " Else 0 End"
				Else
					UpdateStr = "Price1=Iif(Price1>=" & CLng(Request("selAvatarPrice1T")) & ",Price1-" & CLng(Request("selAvatarPrice1T")) & ",0)"
				End If
			End Select
		End If
	Case 6
		If Request("selAvatarPrice2T") = "" Or Not IsInteger(Request("selAvatarPrice2T")) Then
			ErrMsg = ErrMsg & "<BR><li>VIP价格指定错误。"
			Call Dvbbs_Error()
			Exit Sub
		Else
			Select Case Request("selAvatarPrice2")
			Case 0
				UpdateStr = "Price2=" & CLng(Request("selAvatarPrice2T"))
			Case 1
				UpdateStr = "Price2=Price2*(100+" & CLng(Request("selAvatarPrice2T")) & ")/100"
			Case 2
				UpdateStr = "Price2=Price2*(100-" & CLng(Request("selAvatarPrice2T")) & ")/100"
			Case 3
				UpdateStr = "Price2=Price2+" & CLng(Request("selAvatarPrice2T"))
			Case 4
				If IsSqlDataBase = 1 Then
					UpdateStr = "Price2=Case When Price2>=" & CLng(Request("selAvatarPrice2T")) & " Then Price2-" & CLng(Request("selAvatarPrice2T")) & " Else 0 End"
				Else
					UpdateStr = "Price2=Iif(Price2>=" & CLng(Request("selAvatarPrice2T")) & ",Price2-" & CLng(Request("selAvatarPrice2T")) & ",0)"
				End If
			End Select
		End If
	Case 7
		If Request("selAvatarPeriodT") = "" Or Not IsInteger(Request("selAvatarPeriodT")) Then
			ErrMsg = ErrMsg & "<BR><li>有效期限指定错误。"
			Call Dvbbs_Error()
			Exit Sub
		Else
			Select Case Request("selAvatarPeriod")
			Case 0
				UpdateStr = "Period=" & CLng(Request("selAvatarPeriodT"))
			Case 1
				UpdateStr = "Period=Period*(100+" & CLng(Request("selAvatarPeriodT")) & ")/100"
			Case 2
				UpdateStr = "Period=Period*(100-" & CLng(Request("selAvatarPeriodT")) & ")/100"
			Case 3
				UpdateStr = "Period=Period+" & CLng(Request("selAvatarPeriodT"))
			Case 4
				If IsSqlDataBase = 1 Then
					UpdateStr = "Period=Case When Period>=" & CLng(Request("selAvatarPeriodT")) & " Then Period-" & CLng(Request("selAvatarPeriodT")) & " Else 0 End"
				Else
					UpdateStr = "Period=Iif(Period>=" & CLng(Request("selAvatarPeriodT")) & ",Period-" & CLng(Request("selAvatarPeriodT")) & ",0)"
				End If
			End Select
		End If
	Case 8
		If Request("selAvatarQuantityT") = "" Or Not IsInteger(Request("selAvatarQuantityT")) Then
			ErrMsg = ErrMsg & "<BR><li>当前库存指定错误。"
			Call Dvbbs_Error()
			Exit Sub
		Else
			Select Case Request("selAvatarQuantity")
			Case 0
				UpdateStr = "Quantity=" & CLng(Request("selAvatarQuantityT"))
			Case 1
				UpdateStr = "Quantity=Quantity*(100+" & CLng(Request("selAvatarQuantityT")) & ")/100"
			Case 2
				UpdateStr = "Quantity=Quantity*(100-" & CLng(Request("selAvatarQuantityT")) & ")/100"
			Case 3
				UpdateStr = "Quantity=Quantity+" & CLng(Request("selAvatarQuantityT"))
			Case 4
				If IsSqlDataBase = 1 Then
					UpdateStr = "Quantity=Case When Quantity>=" & CLng(Request("selAvatarQuantityT")) & " Then Quantity-" & CLng(Request("selAvatarQuantityT")) & " Else 0 End"
				Else
					UpdateStr = "Quantity=Iif(Quantity>=" & CLng(Request("selAvatarQuantityT")) & ",Quantity-" & CLng(Request("selAvatarQuantityT")) & ",0)"
				End If
			End Select
		End If
	Case Else
		ErrMsg = ErrMsg & "<BR><li>没有指定操作参数。"
		Call Dvbbs_Error()
		Exit Sub
	End Select
	SQLStr = "Update Dv_Plus_Avatar_Items Set " & UpdateStr & " Where " & SQLStr & " And Type<>0"
	Dvbbs.Plus_Execute(SQLStr)
	Call MakeAvatarXML()
	Dv_Suc("已经成功地更新了商品信息。<a href=Plus_Avatar_Items.asp>返回形象商品管理</a>")
End Sub

Sub AvatarTypeSelect()
	Dim SubTypeIDSplit, SubTypeNameSplit, i, j, k, SubNode, TypeCount, NodeList, ThdTypeIDSplit, ThdTypeNameSplit

	Set NodeList = AvatarXMLDOM.documentElement.selectNodes("/Plus_Avatar/AvatarTypeList/AvatarType[@TypeName != '' and @TypeID != '0' and @TypeID != '94' and @TypeID != '95' and @TypeID != '96' and @TypeID != '97' and @TypeID != '98' and @TypeID != '99']")
	TypeCount = NodeList.Length
	For i = 0 To TypeCount - 1
		Set SubNode = NodeList.item(i)
		If i < TypeCount - 1 Then
			Response.Write "<option value='" & SubNode.attributes.getNamedItem("TypeID").text & "'>┣" & SubNode.attributes.getNamedItem("TypeName").text & "</option>"
		Else
			Response.Write "<option value='" & SubNode.attributes.getNamedItem("TypeID").text & "'>┗" & SubNode.attributes.getNamedItem("TypeName").text & "</option>"
		End If
		SubTypeIDSplit = Split(SubNode.attributes.getNamedItem("SubTypeIDList").text, "$$")
		SubTypeNameSplit = Split(SubNode.attributes.getNamedItem("SubTypeNameList").text, "$$")
		For j = 0 To UBound(SubTypeIDSplit)
			If SubTypeIDSplit(j) <> "" And SubTypeIDSplit(j) <> "0" Then
				If InStr(SubTypeIDSplit(j), "||") > 0 Then
					ThdTypeIDSplit = Split(SubTypeIDSplit(j), "||")
					ThdTypeNameSplit = Split(SubTypeNameSplit(j), "||")
					If j < UBound(SubTypeIDSplit) Then
						If i < TypeCount - 1 Then
							Response.Write "<option value='" & ThdTypeIDSplit(0) & "'>┃&nbsp;&nbsp;├" & ThdTypeNameSplit(0) & "</option>"
						Else
							Response.Write "<option value='" & ThdTypeIDSplit(0) & "'>　&nbsp;&nbsp;├" & ThdTypeNameSplit(0) & "</option>"
						End If
					Else
						If i < TypeCount - 1 Then
							Response.Write "<option value='" & ThdTypeIDSplit(0) & "'>┃&nbsp;&nbsp;　" & ThdTypeNameSplit(0) & "</option>"
						Else
							Response.Write "<option value='" & ThdTypeIDSplit(0) & "'>　&nbsp;&nbsp;　" & ThdTypeNameSplit(0) & "</option>"
						End If
					End If
					For k = 0 To UBound(ThdTypeIDSplit)
						If ThdTypeIDSplit(k) <> "" And ThdTypeIDSplit(k) <> "0" Then
							If (CLng(ThdTypeIDSplit(k)) \ 100) <= 50 Then
								If k < UBound(ThdTypeIDSplit) Then
									If j < UBound(SubTypeIDSplit) Then
										If i < TypeCount - 1 Then
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>┃&nbsp;&nbsp;│&nbsp;&nbsp;├" & ThdTypeNameSplit(k) & "</option>"
										Else
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>　&nbsp;&nbsp;│&nbsp;&nbsp;├" & ThdTypeNameSplit(k) & "</option>"
										End If
									Else
										If i < TypeCount - 1 Then
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>┃&nbsp;&nbsp;　&nbsp;&nbsp;├" & ThdTypeNameSplit(k) & "</option>"
										Else
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>　&nbsp;&nbsp;　&nbsp;&nbsp;├" & ThdTypeNameSplit(k) & "</option>"
										End If
									End If
								Else
									If j < UBound(SubTypeIDSplit) Then
										If i < TypeCount - 1 Then
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>┃&nbsp;&nbsp;│&nbsp;&nbsp;└" & ThdTypeNameSplit(k) & "</option>"
										Else
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>　&nbsp;&nbsp;│&nbsp;&nbsp;└" & ThdTypeNameSplit(k) & "</option>"
										End If
									Else
										If i < TypeCount - 1 Then
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>┃&nbsp;&nbsp;　&nbsp;&nbsp;└" & ThdTypeNameSplit(k) & "</option>"
										Else
											Response.Write "<option value='" & ThdTypeIDSplit(k) & "'>　&nbsp;&nbsp;　&nbsp;&nbsp;└" & ThdTypeNameSplit(k) & "</option>"
										End If
									End If
								End If
							End If
						End If
					Next
				ElseIf (CLng(SubTypeIDSplit(j)) Mod 100) <= 50 Then
					If j < UBound(SubTypeIDSplit) Then
						If i < TypeCount - 1 Then
							Response.Write "<option value='" & SubTypeIDSplit(j) & "'>┃&nbsp;&nbsp;├" & SubTypeNameSplit(j) & "</option>"
						Else
							Response.Write "<option value='" & SubTypeIDSplit(j) & "'>　&nbsp;&nbsp;├" & SubTypeNameSplit(j) & "</option>"
						End If
					Else
						If i < TypeCount - 1 Then
							Response.Write "<option value='" & SubTypeIDSplit(j) & "'>┃&nbsp;&nbsp;└" & SubTypeNameSplit(j) & "</option>"
						Else
							Response.Write "<option value='" & SubTypeIDSplit(j) & "'>　&nbsp;&nbsp;└" & SubTypeNameSplit(j) & "</option>"
						End If
					End If
				End If
			End If
		Next
	Next
	Response.Write "</select>"
End Sub

Sub AvatarSexOption()
	Response.Write "<option value=0>女</option>"
	Response.Write "<option value=1>男</option>"
	Response.Write "<option value=2>不限</option>"
End Sub

Sub AvatarFlagOption()
	Response.Write "<option value=0>保留商品</option>"
	Response.Write "<option value=1>所有会员</option>"
	Response.Write "<option value=2>版主以上</option>"
	Response.Write "<option value=3>超级版主</option>"
	Response.Write "<option value=4>管理员</option>"
End Sub

Sub AvatarVipOption()
	Response.Write "<option value=0>不限</option>"
	Response.Write "<option value=1>VIP</option>"
End Sub

Function GetSQLStr()
	Dim SQLStr
	
	SQLStr = " 2>1"
	If Request("AvatarID") <> "" Then
		SQLStr = SQLStr & " And id=" & CLng(Request("AvatarID"))
	End If
	If Request("AvatarName") <> "" Then
		If Request("AvataNameChk") = "yes" Then
			SQLStr = SQLStr & " And Name='" & Dvbbs.CheckStr(Request("AvatarName")) & "'"
		Else
			SQLStr = SQLStr & " And Name Like '%" & Dvbbs.CheckStr(Request("AvatarName")) & "%'"
		End If
	End If
	If Request("AvatarType") <> "0" And Request("AvatarType") <> "" Then
		If CInt(Request("AvatarType")) < 100 Then
			SQLStr = SQLStr & " And Type In (Select s.MyType From Dv_Plus_Avatar_SubType s Where s.TypeID=" & CInt(Request("AvatarType")) & ")"
		Else
			If (CInt(Request("AvatarType")) \ 100) <= 50 Then
				SQLStr = SQLStr & " And Type=" & CInt(Request("AvatarType")) & ""
			Else
				SQLStr = SQLStr & " And Type In (Select s1.MyType From Dv_Plus_Avatar_SubType s1 Where s1.ParentSubType In (Select s2.ID From Dv_Plus_Avatar_SubType s2 Where s2.MyType=" & CInt(Request("AvatarType")) & "))"
			End If
		End If
	End If
	If Request("AvatarSex") <> "9" And Request("AvatarSex") <> "" Then
		SQLStr = SQLStr & " And Sex=" & CInt(Request("AvatarSex"))
	End If
	If Request("AvatarFlag") <> "9" And Request("AvatarFlag") <> "" Then
		SQLStr = SQLStr & " And Flag=" & CInt(Request("AvatarFlag"))
	End If
	If Request("AvatarVip") = "0" Or Request("AvatarVip") = "1" Then
		If Request("AvatarVip") = "0" Then
			SQLStr = SQLStr & " And Vip=0"
		Else
			SQLStr = SQLStr & " And Vip<>0"
		End If
	End If
	If Request("AvatarPrice1T") <> "" Then
		If Request("AvatarPrice1") = "more" Then
			SQLStr = SQLStr & " And Price1 >= " & CLng(Request("AvatarPrice1T"))
		Else
			SQLStr = SQLStr & " And Price1 <= " & CLng(Request("AvatarPrice1T"))
		End If
	End If
	If Request("AvatarPrice2T") <> "" Then
		If Request("AvatarPrice2") = "more" Then
			SQLStr = SQLStr & " And Price2 >= " & CLng(Request("AvatarPrice2T"))
		Else
			SQLStr = SQLStr & " And Price2 <= " & CLng(Request("AvatarPrice2T"))
		End If
	End If
	If Request("AvatarPeriodT") <> "" Then
		If Request("AvatarPeriod") = "more" Then
			SQLStr = SQLStr & " And Period >= " & CInt(Request("AvatarPeriodT"))
		Else
			SQLStr = SQLStr & " And Period <= " & CInt(Request("AvatarPeriodT"))
		End If
	End If
	If Request("AvatarQuantityT") <> "" Then
		If Request("AvatarQuantity") = "more" Then
			SQLStr = SQLStr & " And Quantity >= " & CLng(Request("AvatarQuantityT"))
		Else
			SQLStr = SQLStr & " And Quantity <= " & CLng(Request("AvatarQuantityT"))
		End If
	End If
	If Request("AvatarTotalSalesT") <> "" Then
		If Request("AvatarTotalSales") = "more" Then
			SQLStr = SQLStr & " And TotalSales >= " & CLng(Request("AvatarTotalSalesT"))
		Else
			SQLStr = SQLStr & " And TotalSales <= " & CLng(Request("AvatarTotalSalesT"))
		End If
	End If
	GetSQLStr = SQLStr
End Function
%>											
