<!--#include file=conn.asp-->
<!--#include file="inc/const.asp" -->
<!-- #include file="inc/const_admin.asp" -->
<!--#include file="z_home_const.asp" -->
<%
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,"
If Not Dvbbs.master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=admin_index.asp target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		dvbbs_error()
	Else 

 
	if menu="" then
 		call main()
	elseif menu=1 then
	 	call defaultvalue()
	elseif menu=2 then
 		call feeman()
	elseif menu=3 then
 		call fixnew()
	elseif menu=4 then
 		call importitems()
	elseif menu=5 then
 		call delperiod()
	end if 	
end if%>

<%sub main() 
dim sql1,rs1,sql2,rs2 
sql1="select * from home_config" 
set rs1=Home_Conn.execute(sql1) %>
<br>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
	<form action=?menu=5 method=post>
	<tr>
		<th valign=middle colspan=2 height=23 align=left>清除过期的物品</th>
	</tr>
	<tr>
		<td valign=middle width=40% class=forumrow>清除过期多少天物品(填写数字)</td><td class=forumrow><input type=text name="DelPeriod" value=60 size=30>&nbsp;<input type=submit name="submit" value="提 交"></td>
	</tr>
	</form>
</table>
<br>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr><th align=center colspan=4 height=1 align="left"><b>家园物品默认值管理</b></th></tr> 
<form name="form" method="post" action="?menu=1"> 
<tr> 
	<td align=right width="25%" height="25" class=forumrow>默认的标价：</td> 
	<td align=left width="25%" height="25" class=forumrow><INPUT type=text name=price1 size="20" value="<%=rs1("price1")%>"></td> 
	<td align=right width="25%" height="25" class=forumrow>默认的VIP价：</td> 
	<td align=left width="25%" height="25" class=forumrow><INPUT type=text name=price2 size="20" value="<%=rs1("price2")%>"></td> 
</tr> 
<tr> 
	<td align=right width="25%" height="25" class=forumrow>默认的有效期：</td> 
	<td align=left width="25%" height="25" class=forumrow><INPUT type=text name=period size="20" value="<%=rs1("period")%>"></td> 
	<td align=right width="25%" height="25" class=forumrow>默认的库存：</td> 
	<td align=left width="25%" height="25" class=forumrow><INPUT type=text name=quantity size="20" value="<%=rs1("quantity")%>"></td> 
</tr> 
<tr> 
	<td align=right width="25%" height="25" class=forumrow>默认的限购者：</td> 
	<td align=left width="25%" height="25" class=forumrow><select size=1 name="flag"><option value=0<%if rs1("flag")=0 then%> selected<%end if%>>保留商品</option><option value=1<%if rs1("flag")=1 then%> selected<%end if%>>所有会员</option><option value=2<%if rs1("flag")=2 then%> selected<%end if%>>版主以上</option><option value=3<%if rs1("flag")=3 then%> selected<%end if%>>超级版主</option><option value=4<%if rs1("flag")=4 then%> selected<%end if%>>管理员</option></select></td> 
	<td align=right width="25%" height="25" class=forumrow>默认是否VIP专购：</td> 
	<td align=left width="25%" height="25" class=forumrow><input type=radio name="vip" value="0"<%if not rs1("vip") then%> checked<%end if%>>&nbsp;否&nbsp;&nbsp;<input type=radio name="vip" value="1"<%if rs1("vip") then%> checked<%end if%>>&nbsp;是</td> 
</tr> 
<tr> 
	<td align=center colspan=4 height="27" class=forumrow><INPUT type=submit value=修改 name=submit></td> 
</tr> 
</form> 
</table> 
<br> 
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr><th align=center colspan=4 height=1 align="left"><b>家园物品的手续费管理</b></th></tr> 
<form name="form" method="post" action="?menu=2"> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>赠送商品的手续费(标准价格的百分比)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=send size="20" value="<%=rs1("send")%>"> %</td> 
</tr> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>出售商品的手续费(成交价格的百分比)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=sale size="20" value="<%=rs1("sale")%>"> %</td> 
</tr> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>出售商品的最低价(标准价格的百分比)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=salemin size="20" value="<%=rs1("salemin")%>"> %</td> 
</tr> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>低价商品的标准(低于此价格的商品记为低价商品)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=pricemin size="20" value="<%=rs1("pricemin")%>"> 元</td> 
</tr> 
<tr> 
	<td align=center colspan=2 height="27" class=forumrow><INPUT type=submit value=修改 name=submit></td> 
</tr> 
</form> 
</table> 
<br> 
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr><th align=center colspan=4 height=1 align="left"><b>家园物品的翻新管理</b></th></tr> 
<form name="form" method="post" action="?menu=3"> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>增加一天有效期的费用(享受价格/有效期的百分比)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=new1 size="20" value="<%=rs1("new1")%>"> %</td> 
</tr> 
<tr> 
	<td align=right width="50%" height="25" class=forumrow>增加至永远有效的费用(享受价格的倍数)：</td> 
	<td align=left width="50%" height="25" class=forumrow><INPUT type=text name=new0 size="20" value="<%=rs1("new0")%>"> 倍</td> 
</tr> 
<tr> 
	<td align=center colspan=2 height="27" class=forumrow><INPUT type=submit value=修改 name=submit></td> 
</tr> 
</form> 
</table> 
<br> 
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder"> 
<tr><th align=center height=1 colspan="2" align="left">家园物品管理</p</th></tr>
<tr> 
<td width="35%" class=forumrow><b>添加家园物品</b><br>（请输入您想导入的商品数据库文件名）</td>
<form name="form1" method="post" action="?menu=4"> 
<td width="65%" class=forumrow height="45">例如NewHome<%=right("00"&month(now()),2)&right("00"&day(now()),2)&".mdb"%><br><INPUT type=text name=newhomefile size="40">&nbsp; <INPUT type=submit value=确认 name=submit></td> 
</form> 
</tr> 
<tr> 
<td width="35%" class=forumrow><b>家园物品管理</b></td>
<form name="form1" method="get" action="z_admin_home_items.asp">
<td width="65%" class=forumrow height="40"><INPUT type=submit value='进 行 管 理' name=submit></td> 
</form>
</tr> 
<tr> 
<td width="35%" class=forumrow><b>家园物品分类管理</b></td>
<form name="form1" method="get" action="z_admin_home_type.asp">
<td width="65%" class=forumrow height="40"><INPUT type=submit value='进 行 管 理' name=submit></td> 
</form>
</tr> 
</table> 
<br> 
<%end sub

sub defaultvalue() 
	dim price1,price2,period,quantity,flag,vip,rs,sql
	if not isInteger(request.form("price1")) or not isInteger(request.form("price2")) or not isInteger(request.form("period")) or not isInteger(request.form("quantity")) or not isInteger(request.form("flag")) or not isInteger(request.form("vip")) then
		response.write "输入的数据必须为整数！"
		response.end 
	else 
		if request.form("price1")="" then 
			price1=100
		else 
			price1=int(request.form("price1")) 
		end if 
		if request.form("price2")="" then 
			price2=50 
		else 
			price2=int(request.form("price2")) 
		end if 
		if request.form("period")="" then 
			period=30 
		else 
			period=int(request.form("period")) 
		end if 
		if request.form("quantity")="" then 
			quantity=15 
		else 
			quantity=int(request.form("quantity")) 
		end if 
		if request.form("flag")="" then 
			flag=1 
		else 
			flag=int(request.form("flag")) 
		end if 
		if request.form("vip")="" then 
			vip=0
		else 
			vip=int(request.form("vip")) 
		end if 
	end if 
	set rs= server.createobject ("adodb.recordset") 
	sql = "select * from home_config" 
	rs.Open sql,Home_Conn,1,3 
	if not(rs.eof and rs.bof) then 
		rs("price1") = price1 
		rs("price2") = price2 
		rs("period") = period
		rs("quantity") = quantity 
		rs("flag") = flag 
		if vip=0 then
			rs("vip")=false
		else
			rs("vip")=true
		end if
		rs.Update 
	end if 
	rs.close 
	set rs=nothing 
	response.write "修改成功!" 
end sub 

sub feeman() 
	dim send,sale,salemin,pricemin,rs,sql
	if not isInteger(request.form("send")) or not isInteger(request.form("sale")) or not isInteger(request.form("salemin")) or not isInteger(request.form("pricemin")) then
		response.write "输入的数据必须为整数！"
		response.end 
	else 
		if request.form("send")="" then 
			send=5
		else 
			send=int(request.form("send")) 
		end if 
		if request.form("sale")="" then 
			sale=5
		else 
			sale=int(request.form("sale")) 
		end if 
		if request.form("salemin")="" then 
			salemin=30 
		else 
			salemin=int(request.form("salemin")) 
		end if 
		if request.form("pricemin")="" then 
			pricemin=5 
		else 
			pricemin=int(request.form("pricemin")) 
		end if 
	end if 
	set rs= server.createobject ("adodb.recordset") 
	sql = "select * from home_config" 
	rs.Open sql,Home_Conn,1,3 
	if not(rs.eof and rs.bof) then 
		rs("send") = send
		rs("sale") = sale
		rs("salemin") = salemin
		rs("pricemin") = pricemin
		rs.Update 
	end if 
	rs.close 
	set rs=nothing 
	response.write "修改成功!" 
end sub 

sub fixnew() 
	dim new1,new0,rs,sql
	if not isInteger(request.form("new1")) or not isInteger(request.form("new0")) then
		response.write "输入的数据必须为整数！"
		response.end 
	else 
		if request.form("new1")="" then 
			new1=50
		else 
			new1=int(request.form("new1")) 
		end if 
		if request.form("new0")="" then 
			new0=5
		else 
			new0=int(request.form("new0")) 
		end if 
	end if 
	set rs= server.createobject ("adodb.recordset") 
	sql = "select * from home_config" 
	rs.Open sql,Home_Conn,1,3 
	if not(rs.eof and rs.bof) then 
		rs("new1") = new1
		rs("new0") = new0
		rs.Update 
	end if 
	rs.close 
	set rs=nothing 
	response.write "修改成功!" 
end sub 

sub delperiod()
	dim dtime
	dtime=request("DelPeriod")
	if not isInteger(dtime) then
		response.write "输入的天数需要为整数。"
	else
		Home_Conn.execute("delete from home_myitems where datediff('d',fixdate,now())-period>"&dtime&" and period>0")
		response.write "删除成功。"
	end if
end sub 

sub importitems()
	dim homename,TCONN,icount,pcount
	homename=Checkstr(trim(request("newhomefile")))
	if homename="" then
		response.write "请填写导入的数据库名"
		exit sub
	end if
	Set tconn = Server.CreateObject("ADODB.Connection")
	tconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(homename)
	dim trs,nrs
	set trs=tconn.execute(" select * from home_items ")
	sql="select * from home_config" 
	set rs=Home_Conn.execute(sql)
	icount=0
	pcount=0
	do while not trs.eof
		if Home_Conn.execute("select top 1 id from home_items where id="&trs("id")).eof then
			Home_Conn.execute("insert into home_items (id,name,type,Parm1,Parm3,price1,price2,period,quantity,flag,vip) values ("&trs("id")&",'"&trs("name")&"',"&trs("type")&",'"&trs("Parm1")&"',"&trs("Parm3")&","&rs("price1")&","&rs("price2")&","&rs("period")&","&rs("quantity")&","&rs("flag")&","&rs("vip")&")")
			icount=icount+1
		else
			pcount=pcount+1
		end if
		trs.movenext
	loop
	trs.close
	set trs=nothing
	rs.close
	response.write "数据导入成功(导入"&icount&"个新商品，跳过"&pcount&"个已有商品)！"
end sub%>