<!--#include file=connection.asp-->
<!-- #include file="../inc/const.asp" -->
<!-- #include file="../inc/DvADChar.asp" -->
<!-- #include file="../z_home_const.asp" -->
<!--#Include File="JaClog.Asp"-->
<%
dim action,sqlstr
action=request.querystring("action")
dim boardid
dim menu,body
menu=request.querystring("menu")
dvbbs.stats="家园商品管理页面"

'Dvbbs.head()
'dvbbs.nav()
%>
<html>
<head>
<title>管理页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<BODY  bgcolor="#D6DFF7">
<%
	dim admin_flag
	admin_flag=",2,"

	call main()


sub main()
dim rs1,rs2,curType1,curType2,curseqno1,curseqno2%>
<table cellpadding="2" cellspacing="1" border="0" width="95%" class="tableBorder" align=center>
<tr>
<th align=left colspan=6 height=23>虚拟家园管理</th>
</tr>
<tr>
<td width=20% class=forumrow>注意事项</td>
<td width=80% class=forumrow colspan=5>①限购者保留将使物品对所有用户不可见；<br>
  ②点物品名进行相应的资料操作；<br>
  ③导入的新物品如果当前已经存在系统将自动跳过；<br>
  ④批量修改的条件请尽量简单；<br>
  ⑤<font color="#FF0000">请仔细阅读相关操作的说明</font><br>
	<form action="?" method=post><input type=hidden name=action value=recalc><input type=Submit value="刷新热销物品" name="Submit"></form></td>
</tr>
<form action="?action=homeSearch" method=post>
<tr>
<td width=20% class=forumrow>快速搜索</td>
<td width=80% class=forumrow colspan=5>
<select size=1 name="homeSearch" onchange="javascript:submit()">
<option value="0">请选择查询条件</option>
<option value="8" <%if request("homeSearch")=8 then%>selected<%end if%>>列出所有物品</option>
<option value="1" <%if request("homeSearch")=1 then%>selected<%end if%>>列出所有保留物品</option>
<option value="2" <%if request("homeSearch")=2 then%>selected<%end if%>>列出所有专供管理员的物品</option>
<option value="3" <%if request("homeSearch")=3 then%>selected<%end if%>>列出所有专供超级版主的物品</option>
<option value="4" <%if request("homeSearch")=4 then%>selected<%end if%>>列出所有专供版主的物品</option>
<option value="5" <%if request("homeSearch")=5 then%>selected<%end if%>>列出所有专供VIP会员的物品</option>
<option value="6" <%if request("homeSearch")=6 then%>selected<%end if%>>列出所有今天上架的物品</option>
<option value="7" <%if request("homeSearch")=7 then%>selected<%end if%>>列出所有库存为零的物品</option>
</select>
</td>
</tr>
</form>
<%if request("action")="" or request("homeSearch")="0" then%>
<form action="?action=homeSearch" method=post>
<tr>
<th align=left colspan=6 height=23>高级查询</th>
</tr>
<tr>
<td width=20% class=forumrow>注意事项</td>
<td width=80% class=forumrow colspan=5>在记录很多的情况下搜索条件越多查询越慢，请尽量减少查询条件；最多显示记录数也不宜选择过大</td>
</tr>
<tr>
<td width=20% class=forumrow>最多显示记录数</td>
<td width=80% class=forumrow colspan=5><input size=45 name="searchMax" type=textbox value=100></td>
</tr>
<tr>
<td width=20% class=forumrow>物品编号</td>
<td width=80% class=forumrow colspan=5><input size=45 name="homeid" type=textbox></td>
</tr>
<tr>
<td width=20% class=forumrow>物品名称</td>
<td width=80% class=forumrow colspan=5><input size=45 name="homename" type=textbox>&nbsp;<input type=checkbox name="homenamechk" value="yes" checked>物品名称完整匹配</td>
</tr>
<tr>
<td width=20% class=forumrow>物品类别</td>
<td width=80% class=forumrow colspan=5>
<select size=1 name="hometype">
<option value=0>任意</option>
<%
set rs1=server.createobject("ADODB.recordset")
set rs2=server.createobject("ADODB.recordset")
rs1.open "select * from home_type order by seqno",conn,1,1
do while not rs1.eof
	curseqno1=rs1("seqno")
	curtype1=rs1("typename")
	rs2.open "select * from home_subtype where typeseq="&curseqno1&" order by seqno",conn,1,1
	rs1.movenext
	if not rs1.eof then
		response.write "<option value=00"&curseqno1&">┣"&curtype1&"</option>"
	else
		response.write "<option value=00"&curseqno1&">┗"&curtype1&"</option>"
	end if
	do while not rs2.eof
		curseqno2=rs2("seqno")
		curtype2=rs2("subtypename")
		rs2.movenext
		if not rs2.eof then
			if not rs1.eof then
				response.write "<option value="&curseqno2&"0"&curseqno1&">┃&nbsp;&nbsp;├"&curtype2&"</option>"
			else
				response.write "<option value="&curseqno2&"0"&curseqno1&">　&nbsp;&nbsp;├"&curtype2&"</option>"
			end if
		else
			if not rs1.eof then
				response.write "<option value="&curseqno2&"0"&curseqno1&">┃&nbsp;&nbsp;└"&curtype2&"</option>"
			else
				response.write "<option value="&curseqno2&"0"&curseqno1&">　&nbsp;&nbsp;└"&curtype2&"</option>"
			end if
		end if
	loop
	rs2.close
loop
rs1.close
set rs2=nothing
set rs1=nothing%>
</select>
</td>
</tr>
<tr>
<td width=20% class=forumrow>限购者</td>
<td width=80% class=forumrow colspan=5>
<select size=1 name="homeflag">
<option value=9>任意</option>
<option value=0>保留物品</option>
<option value=1>所有会员</option>
<option value=2>版主以上</option>
<option value=3>超级版主</option>
<option value=4>管理员</option>
</select>
</td>
</tr>
<tr>
<td width=20% class=forumrow>是否VIP专购</td>
<td width=80% class=forumrow colspan=5><input type=radio name="homevip" value="2" checked>&nbsp;任意&nbsp;&nbsp;<input type=radio name="homevip" value="0">&nbsp;否&nbsp;&nbsp;<input type=radio name="homevip" value="1">&nbsp;是</td>
</tr>
<tr>
<th align=left colspan=6 height=23>特殊查询&nbsp;（注意： <多于> 或 <少于> 已默认包含 <等于>；条件留空则不使用此条件 ）</th>
</tr>
<tr>
<td width=20% class=forumrow>标价</td>
<td width=80% class=forumrow colspan=5><input type=radio value=more name="homeprice1" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value=less name="homeprice1">&nbsp;少于&nbsp;&nbsp;<input size=5 name="homeprice1T" type=textbox> 元</td>
</tr>
<tr>
<td width=20% class=forumrow>VIP价</td>
<td width=80% class=forumrow colspan=5><input type=radio value=more name="homeprice2" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value=less name="homeprice2">&nbsp;少于&nbsp;&nbsp;<input size=5 name="homeprice2T" type=textbox> 元</td>
</tr>
<tr>
<td width=20% class=forumrow>有效期</td>
<td width=80% class=forumrow colspan=5><input type=radio value=more name="homeperiod" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value=less name="homeperiod">&nbsp;少于&nbsp;&nbsp;<input size=5 name="homeperiodT" type=textbox> 天</td>
</tr>
<tr>
<td width=20% class=forumrow>库存</td>
<td width=80% class=forumrow colspan=5><input type=radio value=more name="homequantity" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value=less name="homequantity">&nbsp;少于&nbsp;&nbsp;<input size=5 name="homequantityT" type=textbox> 个</td>
</tr>
<tr>
<td width=20% class=forumrow>销量</td>
<td width=80% class=forumrow colspan=5><input type=radio value=more name="hometotalsales" checked>&nbsp;多于&nbsp;&nbsp;<input type=radio value=less name="hometotalsales">&nbsp;少于&nbsp;&nbsp;<input size=5 name="hometotalsalesT" type=textbox> 个</td>
</tr>
<tr>
<td width=100% class=forumrow align=center colspan=6><input name="submit" type=submit value="   搜  索   "></td>
</tr>
<input type=hidden value="9" name="homeSearch">
</form>
<%elseif request("action")="recalc" then
	set rs=server.createobject("ADODB.Recordset")
	sql="select itemid,count(itemid) from home_myitems group by itemid"
	rs.open sql,conn,1,1
	do while not rs.eof
		conn.execute("update home_items set totalsales="&rs(1)&" where id="&rs(0))
		rs.movenext
	loop
	set rs=nothing
	response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
elseif request("action")="homeSearch" then%>
<tr>
<th colspan=6 align=left height=23>搜索结果</th>
</tr>
<%dim currentpage,page_count,Pcount
dim totalrec,endpage
currentPage=request("page")
if currentpage="" or not isInteger(currentpage) then
	currentpage=1
else
	currentpage=clng(currentpage)
	if err then
		currentpage=1
		err.clear
	end if
end if
Set rs= Server.CreateObject("ADODB.Recordset")
select case cint(request("homeSearch"))
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=" datediff(d,dateandtime,getdate())=0"
case 7
	sqlstr=" quantity=0"
case 8
	sqlstr="flag=1"
case 9
	sqlstr=""
	if request("homeid")<>"" and isInteger(request("homeid")) then
		sqlstr=" id="&request("homeid")
	end if
	if request("homename")<>"" then
		if request("homenamechk")="yes" then
			if sqlstr="" then
				sqlstr=" name='"&request("homename")&"'"
			else
				sqlstr=sqlstr & " and name='"&request("homename")&"'"
			end if
		else
			if sqlstr="" then
				sqlstr=" name like '%"&request("homename")&"%'"
			else
				sqlstr=sqlstr & " and name like '%"&request("homename")&"%'"
			end if
		end if
	end if
	if cint(request("hometype"))>0 then
		if request("hometype")\100="0" then
			if sqlstr="" then
				sqlstr=" type % 100="&(request("hometype") mod 100)&""
			else
				sqlstr=sqlstr & " and type % 100="&(request("hometype")mod 100)&""
			end if
		else
			if sqlstr="" then
				sqlstr=" type="&request("hometype")&""
			else
				sqlstr=sqlstr & " and type="&request("hometype")&""
			end if
		end if
	end if
	if request("homeflag")<>"9" then
		if sqlstr="" then
			sqlstr=" flag="&request("homeflag")
		else
			sqlstr=sqlstr & " and flag="&request("homeflag")
		end if
	end if
	if request("homevip")="0" or request("homevip")="1" then
		if sqlstr="" then
			if request("homevip")="0" then
				sqlstr="vip=0"
			else
				sqlstr=" vip=1"
			end if
		else
			if request("homevip")="0" then
				sqlstr=sqlstr & " and vip=0"
			else
				sqlstr=sqlstr & " and vip=1"
			end if
		end if
	end if
	dim Tsqlstr
	if request("homeprice1T")<>"" then
		if request("homeprice1")="more" then
			Tsqlstr=" price1 >= "&request("homeprice1T")&""
		else
			Tsqlstr=" price1 <= "&request("homeprice1T")&""
		end if 	
		if sqlstr="" then 
			sqlstr=Tsqlstr
		else
			sqlstr=sqlstr & "and" & Tsqlstr
		end if 
	end if
	if request("homeprice2T")<>"" then
		if request("homeprice2")="more" then
			Tsqlstr=" price2 >= "&request("homeprice2T")&""
		else
			Tsqlstr=" price2 <= "&request("homeprice2T")&""
		end if 	
		if sqlstr="" then 
			sqlstr=Tsqlstr
		else
			sqlstr=sqlstr & " and " & Tsqlstr
		end if 
	end if
	if request("homeperiodT")<>"" then
		if request("homeperiod")="more" then
			Tsqlstr=" period >= "&request("homeperiodT")&""
		else
			Tsqlstr=" period <= "&request("homeperiodT")&""
		end if 	
		if sqlstr="" then 
			sqlstr=Tsqlstr
		else
			sqlstr=sqlstr & " and " & Tsqlstr
		end if 
	end if
	if request("homequantityT")<>"" then
		if request("homequantity")="more" then
			Tsqlstr=" quantity >= "&request("homequantityT")&""
		else
			Tsqlstr=" quantity <= "&request("homequantityT")&""
		end if 	
		if sqlstr="" then 
			sqlstr=Tsqlstr
		else
			sqlstr=sqlstr & " and " & Tsqlstr
		end if 
	end if
	if request("hometotalsalesT")<>"" then
		if request("hometotalsales")="more" then
			Tsqlstr=" totalsales >= "&request("hometotalsalesT")&""
		else
			Tsqlstr=" totalsales <= "&request("hometotalsalesT")&""
		end if 	
		if sqlstr="" then 
			sqlstr=Tsqlstr
		else
			sqlstr=sqlstr & " and " & Tsqlstr
		end if 
	end if
	if sqlstr="" then
		response.write "<tr><td colspan=6 class=forumrow>请指定搜索参数！</td></tr>"
		response.end
	end if
case else
	response.write "<tr><td colspan=6 class=forumrow>错误的参数。</td></tr>"
	response.end
end select
sql="select id,name,type,flag,vip,totalsales from home_items where "&sqlstr&" and type<>0 order by dateandtime desc"

rs.open sql,conn,1,1
if rs.eof or rs.bof then
	response.write "<tr><td colspan=6 class=forumrow>没有找到相关记录。</td></tr>"
else%>
<FORM METHOD=POST ACTION="?action=tohome">
<tr align=center>
<td class=forumHeaderBackgroundAlternate><B>物品编号</B></td>
<td class=forumHeaderBackgroundAlternate><B>物品名称</B></td>
<td class=forumHeaderBackgroundAlternate><B>物品类别</B></td>
<td class=forumHeaderBackgroundAlternate><B>限购者</B></td>
<td class=forumHeaderBackgroundAlternate><B>是否VIP专购</B></td>
<td class=forumHeaderBackgroundAlternate><B>操作</B></td>
</tr>
<%rs.PageSize = 20
rs.AbsolutePage=currentpage
page_count=0
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = 20)%>
	<tr>
	<td class=forumrow width=2% align=center><%=rs("id")%></td>
	<td class=forumrow><a href="?action=modify&homeid=<%=rs("id")%>"><%=rs("name")%></a>&nbsp;(<%=rs("totalsales")%>)</td>
	<td class=forumrow width=20% align=center><%
		set rs2=Server.CreateObject("ADODB.Recordset")
		rs2.open "select top 1 typename from home_type where seqno="&(rs("type") mod 100),conn,1,1
		if not rs2.eof and not rs2.bof then
			response.write rs2("typename")
		else
			response.write "未知"
		end if
		rs2.close
		response.write "→"
		rs2.open "select top 1 subtypename from home_subtype where seqno="&(rs("type")\100)&" and typeseq="&(rs("type") mod 100),conn,1,1
		if not rs2.eof and not rs2.bof then
			response.write rs2("subtypename")
		else
			response.write "未知"
		end if
		rs2.close
		set rs2=nothing
	%></td>
	<td class=forumrow width=10% align=center><%
		select case rs("flag")
		case 0
			response.write "保留物品"
		case 1 
			response.write "所有会员"
		case 2
			response.write "版主以上"
		case 3
			response.write "超级版主"
		case 4
			response.write "管理员"
		end select
	%></td>
	<td class=forumrow width=10% align=center><%
		if rs("vip") then
			response.write "是"
		else
			response.write "否"
		end if
	%></td>
	<td class=forumrow align=center width=5%><input type="checkbox" name="homeid" value="<%=rs("id")%>"></td>
	</tr>
	<%page_count = page_count + 1
	rs.movenext
wend
Pcount=rs.PageCount
%>
<tr><td colspan=6 class=forumrow align=center>分页：
<%call DispPageNum(currentpage,PCount,"""?page=","&homeSearch="&request("homeSearch")&"&homeid="&request("homeid")&"&homename="&request("homename")&"&hometype="&request("hometype")&"&homeflag="&request("homeflag")&"&homevip="&request("homevip")&"&action="&request("action")&"&homeprice1="&request("homeprice1")&"&homeprice1T="&request("homeprice1T")&"&homeprice2="&request("homeprice2")&"&homeprice2T="&request("homeprice2T")&"&homeperiod="&request("homeperiod")&"&homeperiodT="&request("homeperiodT")&"&homequantity="&request("cisualquantity")&"&homequantityT="&request("homequantityT")&"&hometotalsales="&request("hometotalsales")&"&hometotalsalesT="&request("hometotalsalesT")&"&searchmax="&request("searchmax")&"""")%>
</td></tr>
<tr>
<td colspan=4 class=forumrow align=center><B>请选择您需要进行的操作</B></td>
<td colspan=2 class=forumrow 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>
<td colspan=2 class=forumrow align=right>修改类别&nbsp;<input type="radio" name="homeaction" value=1 checked>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhometype"><%
set rs1=server.createobject("ADODB.recordset")
set rs2=server.createobject("ADODB.recordset")
rs1.open "select * from home_type order by seqno",conn,1,1
do while not rs1.eof
	curseqno1=rs1("seqno")
	curtype1=rs1("typename")
	rs2.open "select * from home_subtype where typeseq="&curseqno1&" order by seqno",conn,1,1
	rs1.movenext
	if not rs1.eof then
		response.write "<option value=00"&curseqno1&">┣"&curtype1&"</option>"
	else
		response.write "<option value=00"&curseqno1&">┗"&curtype1&"</option>"
	end if
	do while not rs2.eof
		curseqno2=rs2("seqno")
		curtype2=rs2("subtypename")
		rs2.movenext
		if not rs2.eof then
			if not rs1.eof then
				response.write "<option value="&curseqno2&"0"&curseqno1&">┃&nbsp;&nbsp;├"&curtype2&"</option>"
			else
				response.write "<option value="&curseqno2&"0"&curseqno1&">　&nbsp;&nbsp;├"&curtype2&"</option>"
			end if
		else
			if not rs1.eof then
				response.write "<option value="&curseqno2&"0"&curseqno1&">┃&nbsp;&nbsp;└"&curtype2&"</option>"
			else
				response.write "<option value="&curseqno2&"0"&curseqno1&">　&nbsp;&nbsp;└"&curtype2&"</option>"
			end if
		end if
	loop
	rs2.close
loop
rs1.close
set rs2=nothing
set rs1=nothing
%></select></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改限购者&nbsp;<input type="radio" name="homeaction" value=3>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomeflag">
<option value=0>保留物品</option>
<option value=1>所有会员</option>
<option value=2>版主以上</option>
<option value=3>超级版主</option>
<option value=4>管理员</option>
</select></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改VIP专购&nbsp;<input type="radio" name="homeaction" value=4>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomevip">
<option value=0>否</option>
<option value=1>是</option>
</select></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改标价&nbsp;<input type="radio" name="homeaction" value=5>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomeprice1">
<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="selhomeprice1T" size=15></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改VIP价&nbsp;<input type="radio" name="homeaction" value=6>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomeprice2">
<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="selhomeprice2T" size=15></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改有效期&nbsp;<input type="radio" name="homeaction" value=7>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomeperiod">
<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="selhomeperiodT" size=15></td>
</tr>
<tr>
<td colspan=2 class=forumrow align=right>修改库存&nbsp;<input type="radio" name="homeaction" value=8>&nbsp;</td>
<td colspan=2 class=forumrow align=left>&nbsp;<select size=1 name="selhomequantity">
<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="selhomequantityT" size=15></td>
</tr>
<tr><td colspan=6 class=forumrow align=center><input type=hidden name=sqlstr value="<%=sqlstr%>">
<input type=submit name=submit value="执行选定的操作"  onclick="{if(confirm('确定执行选择的操作吗?')){return true;}return false;}">
</td></tr>
</FORM>
<%end if
rs.close
set rs=nothing	
elseif request("action")="tohome" then
	response.write "<tr><th colspan=6 height=23 align=left>执行结果</th></tr>"
	if request("homeaction")="" then
		response.write "<tr><td colspan=6 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	if (request("homeid")="" and request("chkpageall")<>"on") or (request("sqlstr")="" and request("chkpageall")="on") then
		response.write "<tr><td colspan=6 class=forumrow>请选择相关物品。</td></tr>"
		founderr=true
	end if
	if not founderr then
		if request("homeaction")=1 then
			if request("chkpageall")="on" then
				conn.execute("update home_items set type="&replace(request("selhometype"),"'","")&" where "&request("sqlstr")&" and type<>0")
			else
				conn.execute("update home_items set type="&replace(request("selhometype"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
			end if
			response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
		elseif request("homeaction")=3 then
			if request("chkpageall")="on" then
				conn.execute("update home_items set flag="&replace(request("selhomeflag"),"'","")&" where "&request("sqlstr")&" and type<>0")
			else
				conn.execute("update home_items set flag="&replace(request("selhomeflag"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
			end if
			response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
		elseif request("homeaction")=4 then
			if request("selhomevip")="1" then
				if request("chkpageall")="on" then
					conn.execute("update home_items set vip=true where "&request("sqlstr")&" and type<>0")
				else
					conn.execute("update home_items set vip=true where id in ("&replace(request("homeid"),"'","")&")")
				end if
			else
				if request("chkpageall")="on" then
					conn.execute("update home_items set vip=false where "&request("sqlstr")&" and type<>0")
				else
					conn.execute("update home_items set vip=false where id in ("&replace(request("homeid"),"'","")&")")
				end if
			end if
			response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
		elseif request("homeaction")=5 then
			if request("selhomeprice1T")="" or not isnumeric(request("selhomeprice1T")) then
				response.write "<tr><td colspan=6 class=forumrow>错误的标价。</td></tr>"
			else
				if request("chkpageall")="on" then
					select case request("selhomeprice1")
					case 0
						conn.execute("update home_items set price1="&replace(request("selhomeprice1T"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 1
						conn.execute("update home_items set price1=price1*(1+"&replace(request("selhomeprice1T"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
					case 2
						if csng(request("selhomeprice1T"))<=100 then
							conn.execute("update home_items set price1=price1*(1-"&replace(request("selhomeprice1T"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
						else
							conn.execute("update home_items set price1=0 where "&request("sqlstr")&" and type<>0")
						end if
					case 3
						conn.execute("update home_items set price1=price1+"&replace(request("selhomeprice1T"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 4
						conn.execute("update home_items set price1=price1-"&replace(request("selhomeprice1T"),"'","")&" where "&request("sqlstr")&" and type<>0")
						conn.execute("update home_items set price1=0 where "&request("sqlstr")&" and type<>0 and price1<0")
					end select
				else
					select case request("selhomeprice1")
					case 0
						conn.execute("update home_items set price1="&replace(request("selhomeprice1T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 1
						conn.execute("update home_items set price1=price1*(1+"&replace(request("selhomeprice1T"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
					case 2
						if csng(request("selhomeprice1T"))<=100 then
							conn.execute("update home_items set price1=price1*(1-"&replace(request("selhomeprice1T"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
						else
							conn.execute("update home_items set price1=0 where id in ("&replace(request("homeid"),"'","")&")")
						end if
					case 3
						conn.execute("update home_items set price1=price1+"&replace(request("selhomeprice1T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 4
						conn.execute("update home_items set price1=price1-"&replace(request("selhomeprice1T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
						conn.execute("update home_items set price1=0 where id in ("&replace(request("homeid"),"'","")&") and price1<0")
					end select
				end if
				response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
			end if
		elseif request("homeaction")=6 then
			if request("selhomeprice2T")="" or not isnumeric(request("selhomeprice2T")) then
				response.write "<tr><td colspan=6 class=forumrow>错误的VIP价。</td></tr>"
			else
				if request("chkpageall")="on" then
					select case request("selhomeprice2")
					case 0
						conn.execute("update home_items set price2="&replace(request("selhomeprice2T"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 1
						conn.execute("update home_items set price2=price2*(1+"&replace(request("selhomeprice2T"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
					case 2
						if csng(request("selhomeprice2T"))<=100 then
							conn.execute("update home_items set price2=price2*(1-"&replace(request("selhomeprice2T"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
						else
							conn.execute("update home_items set price2=0 where "&request("sqlstr")&" and type<>0")
						end if
					case 3
						conn.execute("update home_items set price2=price2+"&replace(request("selhomeprice2T"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 4
						conn.execute("update home_items set price2=price2-"&replace(request("selhomeprice2T"),"'","")&" where "&request("sqlstr")&" and type<>0")
						conn.execute("update home_items set price2=0 where "&request("sqlstr")&" and type<>0 and price2<0")
					end select
				else
					select case request("selhomeprice2")
					case 0
						conn.execute("update home_items set price2="&replace(request("selhomeprice2T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 1
						conn.execute("update home_items set price2=price2*(1+"&replace(request("selhomeprice2T"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
					case 2
						if csng(request("selhomeprice2T"))<=100 then
							conn.execute("update home_items set price2=price2*(1-"&replace(request("selhomeprice2T"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
						else
							conn.execute("update home_items set price2=0 where id in ("&replace(request("homeid"),"'","")&")")
						end if
					case 3
						conn.execute("update home_items set price2=price2+"&replace(request("selhomeprice2T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 4
						conn.execute("update home_items set price2=price2-"&replace(request("selhomeprice2T"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
						conn.execute("update home_items set price2=0 where id in ("&replace(request("homeid"),"'","")&") and price2<0")
					end select
				end if
				response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
			end if
		elseif request("homeaction")=7 then
			if request("selhomeperiodT")="" or not isnumeric(request("selhomeperiodT")) then
				response.write "<tr><td colspan=6 class=forumrow>错误的有效期。</td></tr>"
			else
				if request("chkpageall")="on" then
					select case request("selhomeperiod")
					case 0
						conn.execute("update home_items set period="&replace(request("selhomeperiodT"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 1
						conn.execute("update home_items set period=period*(1+"&replace(request("selhomeperiodT"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
					case 2
						if csng(request("selhomeperiodT"))<=100 then
							conn.execute("update home_items set period=period*(1-"&replace(request("selhomeperiodT"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
						else
							conn.execute("update home_items set period=0 where "&request("sqlstr")&" and type<>0")
						end if
					case 3
						conn.execute("update home_items set period=period+"&replace(request("selhomeperiodT"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 4
						conn.execute("update home_items set period=period-"&replace(request("selhomeperiodT"),"'","")&" where "&request("sqlstr")&" and type<>0")
						conn.execute("update home_items set period=0 where "&request("sqlstr")&" and type<>0 and period<0")
					end select
				else
					select case request("selhomeperiod")
					case 0
						conn.execute("update home_items set period="&replace(request("selhomeperiodT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 1
						conn.execute("update home_items set period=period*(1+"&replace(request("selhomeperiodT"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
					case 2
						if csng(request("selhomeperiodT"))<=100 then
							conn.execute("update home_items set period=period*(1-"&replace(request("selhomeperiodT"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
						else
							conn.execute("update home_items set period=0 where id in ("&replace(request("homeid"),"'","")&")")
						end if
					case 3
						conn.execute("update home_items set period=period+"&replace(request("selhomeperiodT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 4
						conn.execute("update home_items set period=period-"&replace(request("selhomeperiodT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
						conn.execute("update home_items set period=0 where id in ("&replace(request("homeid"),"'","")&") and period<0")
					end select
				end if
				response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
			end if
		elseif request("homeaction")=8 then
			if request("selhomequantityT")="" or not isnumeric(request("selhomequantityT")) then
				response.write "<tr><td colspan=6 class=forumrow>错误的库存。</td></tr>"
			else
				if request("chkpageall")="on" then
					select case request("selhomequantity")
					case 0
						conn.execute("update home_items set quantity="&replace(request("selhomequantityT"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 1
						conn.execute("update home_items set quantity=quantity*(1+"&replace(request("selhomequantityT"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
					case 2
						if csng(request("selhomequantityT"))<=100 then
							conn.execute("update home_items set quantity=quantity*(1-"&replace(request("selhomequantityT"),"'","")&"/100) where "&request("sqlstr")&" and type<>0")
						else
							conn.execute("update home_items set quantity=0 where "&request("sqlstr")&" and type<>0")
						end if
					case 3
						conn.execute("update home_items set quantity=quantity+"&replace(request("selhomequantityT"),"'","")&" where "&request("sqlstr")&" and type<>0")
					case 4
						conn.execute("update home_items set quantity=quantity-"&replace(request("selhomequantityT"),"'","")&" where "&request("sqlstr")&" and type<>0")
						conn.execute("update home_items set quantity=0 where "&request("sqlstr")&" and type<>0 and quantity<0")
					end select
				else
					select case request("selhomequantity")
					case 0
						conn.execute("update home_items set quantity="&replace(request("selhomequantityT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 1
						conn.execute("update home_items set quantity=quantity*(1+"&replace(request("selhomequantityT"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
					case 2
						if csng(request("selhomequantityT"))<=100 then
							conn.execute("update home_items set quantity=quantity*(1-"&replace(request("selhomequantityT"),"'","")&"/100) where id in ("&replace(request("homeid"),"'","")&")")
						else
							conn.execute("update home_items set quantity=0 where id in ("&replace(request("homeid"),"'","")&")")
						end if
					case 3
						conn.execute("update home_items set quantity=quantity+"&replace(request("selhomequantityT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
					case 4
						conn.execute("update home_items set quantity=quantity-"&replace(request("selhomequantityT"),"'","")&" where id in ("&replace(request("homeid"),"'","")&")")
						conn.execute("update home_items set quantity=0 where id in ("&replace(request("homeid"),"'","")&") and quantity<0")
					end select
				end if
				response.write "<tr><td colspan=6 class=forumrow>操作成功。</td></tr>"
			end if
		else
			response.write "<tr><td colspan=6 class=forumrow>错误的参数。</td></tr>"
		end if
	end if
elseif request("action")="modify" then
	dim homename
	response.write "<tr><th colspan=6 height=23 align=left>物品资料操作</th></tr>"
	if not isnumeric(request("homeid")) then
		response.write "<tr><td colspan=6 class=forumrow>错误的物品参数。</td></tr>"
		founderr=true
	end if
	if not founderr then
		Set rs= Server.CreateObject("ADODB.Recordset")
		sql="select * from home_items where id="&request("homeid")
		rs.open sql,conn,1,1
		if rs.eof and rs.bof then
			response.write "<tr><td colspan=6 class=forumrow>没有找到相关物品。</td></tr>"
			founderr=true
		else%>
			<tr valign=middle>
				<td class=forumrow colspan=6>
					<div align="center">
      			
        <table width="400" border="0" cellspacing="1" cellpadding="0" class="tableborder">
          <form action="?action=savehomeinfo&itemid=<%=rs("id")%>" method=post>
            <tr valign=middle height=25> 
              <td rowspan="5" height="84" width="100" class=forumrow align=center><img src="<%
					  dim tmppth
			          	if localpic=1 then
							tmppth="../"&picpath
			          		response.write tmppth&"0/"&right("0000"&rs("id"),4)&".GIF"
			          	else
			          		response.write PicPath&right("00000000"&rs("id"),8)&"/00/00/"
			          	end if
	          		%>" width="84" height="84" border="0"></td>
              <td class=forumrow>&nbsp;&nbsp;名　称： <input type=textboxbox name=itemname size=16 value=<%=rs("name")%>> 
                &nbsp;</td>
            </tr>
            <tr valign=middle height=25> 
              <td class=forumrow>&nbsp;&nbsp;标　价：<input type=textbox name=itemprice1 size=15 value=<%=rs("price1")%> 元</td>
            </tr>
            <tr valign=middle height=25> 
              <td class=forumrow>&nbsp;&nbsp;VIP 价：<input type=textbox name=itemprice2 size=15 value=<%=rs("price2")%> 元</td>
            </tr>
            <tr valign=middle height=25> 
              <td class=forumrow>&nbsp;&nbsp;有效期：<input type=textbox name=itemperiod size=15 value=<%=rs("period")%> 天</td>
            </tr>
            <tr valign=middle height=25> 
              <td class=forumrow>&nbsp;&nbsp;库　存：<input type=textbox name=itemquantity size=15 value=<%=rs("quantity")%> 个</td>
            </tr>
            <tr valign=middle height=25> 
              <td class=forumrow align=center> 
                <%
		          		if rs("vip") then
		          			response.write "<input type=checkbox name=itemvip value=yes checked> VIP物品"
		          		else
		          			response.write "<input type=checkbox name=itemvip value=yes> VIP物品"
		          		end if
	          		%>
              </td>
              <td class=forumrow>&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 valign=middle height=25> 
              <td class=forumrow align=center>&nbsp;</td>
            <%if localpic=1 then%>  <td class=forumrow align=left>&nbsp;&nbsp;删 除:
                <input name="del" type="radio" value="0"></td><%end if%>
            </tr>
            <tr valign=middle height=25> 
              <td colspan=2 class=forumrow align=center><input type=Submit value="更　新" name="Submit"> 
              </td>
            </tr>
          </form>
        </table>  
					</div>
				</td>
			</tr>
		<%end if
		rs.close
		set rs=nothing
	end if
elseif request("action")="savehomeinfo" then
dim sql
	response.write "<tr><th colspan=6 height=23 align=left>更新物品资料</th></tr>"
	if not isnumeric(request("itemid")) then
		response.write "<tr><td colspan=6 class=forumrow>错误的物品参数。</td></tr>"
		founderr=true
	end if

	if isempty(request("del"))or request("del")<>0 then
	if not founderr then
		Set rs= Server.CreateObject("ADODB.Recordset")
		sql="select * from home_items where id="&request("itemid")
		rs.open sql,conn,1,3
		if rs.eof and rs.bof then
			response.write "<tr><td colspan=6 class=forumrow>没有找到相关物品。</td></tr>"
			founderr=true
		else
			rs("name")=request.form("itemname")
			rs("price1")=request.form("itemprice1")
			rs("price2")=request.form("itemprice2")
			rs("period")=request.form("itemperiod")
			rs("quantity")=request.form("itemquantity")
			if request.form("itemvip")="yes" then
				rs("vip")=true
			else
				rs("vip")=false
			end if
			rs("flag")=request.form("itemflag")
			rs.update
		end if
		rs.close
		set rs=nothing
	end if
	if founderr then
		response.write "<tr><td colspan=6 class=forumrow>更新失败。</td></tr>"
	else
		response.write "<tr><td colspan=6 class=forumrow>更新物品数据成功。</td></tr>"
	end if
else
	dim filenme11
	filenme11=right("0000"&request("itemid"),4)
	set rs=Server.CreateObject("ADODB.Recordset")
	sql="delete from home_items where id="&request("itemid")
	rs.open sql,conn
'	rs.close
'	set rs=nothing
	Dim objFSO    '声明一个名称为 objFSO 的变量以存放对象实例
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
   If objFSO.FileExists(Server.MapPath("../"&picpath&"0/"&filenme11&".gif")) and objFSO.FileExists(Server.MapPath("../"&picpath&"1/"&filenme11&".gif"))Then
     objFSO.DeleteFile Server.MapPath("../"&picpath&"0/"&filenme11&".gif"),True
	 objFSO.DeleteFile Server.MapPath("../"&picpath&"1/"&filenme11&".gif"),True
     Response.Write "<tr><td colspan=6 class=forumrow>已经成功地对文件"&filenme11&".gif"&"进行了删除</td></tr>"
   Else
     Response.Write "<tr><td colspan=6 class=forumrow>"&Server.MapPath("../"&picpath&"0/"&filenme11&".gif")&"不存在，无法进行删除</td></tr>"
   End If
  Set objFSO = Nothing      
end if
end if
%>
</table>
<%end sub%>                      
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name == 'homeid') 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.substring(0,3) == 'chk' || e.name == 'homeid') && e.name != 'chkpageall') e.disabled = form.chkpageall.checked; 
   }
  }
//-->
</script>
</html>









