<!--#include file=conn.asp-->
<!--#include file="inc/const.asp" -->
<!-- #include file="inc/const_admin.asp" -->
<!--#include file="z_Home_const.asp" -->
<%
Dvbbs.head()
dim CurItemList,ItemName,rsHome,CurScenID,CurItemSplit
dim CurType,CurDate,SucFlag,ItemCount,ItemSplit,j,CartBagFull
dim CurScenName,CurDefaultFlag,CurOpenFlag,BuyCount,BuyItems,BuyItemSplit,CartBagCount,NewBuyItems
dim ItemArray(),TmpStr,StrLength,CurChar

founderr=false
If Dvbbs.Userid=0 Or Dvbbs.Userid="" Then 

Dvbbs.AddErrCode(6):Dvbbs.Showerr()
	founderr=true
end if

CurScenID=CheckStr(request("ScenNo"))
if isnull(curscenid) then
	errmsg=errmsg+"<br>"+"<li>没有指定设计方案编号！"
	founderr=true
elseif not isnumeric(curscenid) then
	errmsg=errmsg+"<br>"+"<li>错误的设计方案编号！"
	founderr=true
end if
CurScenID=CLng(CurScenID)

CurType=CheckStr(request("Type"))
if isnull(curtype) then
	errmsg=errmsg+"<br>"+"<li>没有指定保存方式！"
	founderr=true
elseif not isnumeric(curtype) then
	errmsg=errmsg+"<br>"+"<li>错误的保存方式！"
	founderr=true
end if
CurType=CInt(CurType)
if ((CurType=0 or CurType=7) And CurScenID<>0) Or (CurType>0 And CurType<7 And CurScenID=0) then
errmsg=errmsg+"<br>"+"<li>提交的数据有错误！"
founderr=true
end if
if CurType=0 Or CurType=1 Or CurType=7 then
CurItemList=CheckStr(request("itemlist"))
	if isnull(CurItemList) then
		errmsg=errmsg+"<br>"+"<li>错误的方案数据！"
		founderr=true
	else
		ItemSplit=split(CurItemList,"|")
		ItemCount=UBound(ItemSplit)
		if ItemCount<2 then
			errmsg=errmsg+"<br>"+"<li>不能保存没有设计完成的方案！"
			founderr=true
		else
			for i=0 to ItemCount-1
				CurItemSplit=Split(ItemSplit(i),"_")
				if ubound(CurItemSplit)<>4 then
					errmsg=errmsg+"<br>"+"<li>错误的方案数据！"
					founderr=true
					exit for
				else
					SucFlag=True
					for j=0 to 4
						if isnull(CurItemSplit(j)) then
							errmsg=errmsg+"<br>"+"<li>错误的方案数据！"
							founderr=true
							SucFlag=False
							exit for
						elseif not isnumeric(CurItemSplit(j)) then
							errmsg=errmsg+"<br>"+"<li>错误的方案数据！"
							founderr=true
							SucFlag=False
							exit for
						end if
					next
				end if
				if not SucFlag then exit for
			next
			if SucFlag then redim preserve ItemSplit(ItemCount-1)
		end if
	end if
elseif CurType=3 then










	CurOpenFlag=CheckStr(request("Open"))
	if isnull(curOpenFlag) then
		errmsg=errmsg+"<br>"+"<li>没有指定开放状态！"
		founderr=true
	elseif not isnumeric(curOpenFlag) then
		errmsg=errmsg+"<br>"+"<li>错误的开放状态！"
		founderr=true
	end if
	CurOpenFlag=CInt(CurOpenFlag)
end if
set rsHome=server.createobject("ADODB.Recordset")
if CurType>0 and CurType<7 then
sql="select Name,isOpen,isDefault from Home_Scen Where ID="&CurScenID&" and UserName='"&dvbbs.Membername&"'"
rsHome.open sql,home_conn,1,1
if rshome.eof then
  errmsg=errmsg+"<br>"+"<li>该方案不存在！"
		founderr=true
	else
		CurScenName=rshome(0)
		if CurType=4 then
			if rshome(1) then
				CurOpenFlag=1
			else
				CurOpenFlag=0
			end if
		elseif CurType=3 then
			if rshome(2) then
				CurDefaultFlag=1
			else
				CurDefaultFlag=0
			end if
		end if
	end if
	rshome.close
end if
if founderr then
	call save_head()
	call save_Msg()
else
	if CurType=0 then
		if request("action")="save" then
			CurScenName=CheckStr(request("ScenName"))
			if isnull(curscenName) then
				errmsg=errmsg+"<br>"+"<li>方案名称不可为空！"
				founderr=true
			elseif trim(CurScenName)="" then
				errmsg=errmsg+"<br>"+"<li>方案名称不可为空！"
				founderr=true
			end if
			TmpStr=""
			StrLength=0
			for i=1 to len(CurScenName)
				CurChar=mid(CurScenName,i,1)
				if ASC(CurChar)>=0 and ASC(CurChar)<256 then
					if StrLength<50 then
						TmpStr=TmpStr&CurChar
						StrLength=StrLength+1
					else
						exit for
					end if
				else
					if StrLength<49 then
						TmpStr=TmpStr&CurChar
						StrLength=StrLength+2
					else
						exit for
					end if
				end if
			next
			CurScenName=TmpStr
			CurOpenFlag=CheckStr(request("OpenFlag"))
			if isnull(curOpenflag) then
				CurOpenFlag=0
			elseif not isnumeric(curOpenFlag) then
				CurOpenFlag=0
			else
				CurOpenFlag=CInt(CurOpenFlag)
			end if
			CurDefaultFlag=CheckStr(request("DefaultFlag"))
			if isnull(curDefaultflag) then
				CurDefaultFlag=0
			elseif not isnumeric(curDefaultFlag) then
				CurDefaultFlag=0
			else
				CurDefaultFlag=CInt(CurDefaultFlag)
			end if
			if founderr then
				call save_head()
				call save_Msg()
			else
				ItemCount=0
				SucFlag=True
				for i=0 to ubound(ItemSplit)
					CurItemSplit=Split(ItemSplit(i),"_")
					if CInt(CurItemSplit(0))<>0 then
						for j=0 to ItemCount-1
							if CInt(CurItemSplit(0))=ItemArray(0,j) then
								ItemArray(1,j)=ItemArray(1,j)+1
								exit for
							end if
						next
						if j>ItemCount-1 then
							redim preserve ItemArray(2,ItemCount)
							ItemArray(0,ItemCount)=CInt(CurItemSplit(0))
							ItemArray(1,ItemCount)=1
							ItemArray(2,ItemCount)=0
							ItemCount=ItemCount+1
						end if
					end if
				next
				for i=0 to ItemCount-1
					sql="select count(*) from home_myitems where itemid="&ItemArray(0,i)&" and username='"&dvbbs.membername&"' and Type<>0"
					rshome.Open sql,home_conn,1,1
					if not rshome.eof then
						ItemArray(2,i)=rshome(0)
					end if
					rshome.close
					if ItemArray(1,i)>ItemArray(2,i) and SucFlag then 
						SucFlag=False
					end if
				next
				if not SucFlag then
					errmsg="<li>如下物品尚未购买不能保存家园方案："
					founderr=true
					BuyCount=0
					BuyItems=request.cookies("myHomeBuy_"&dvbbs.Userid)
					CartBagFull=False
					for i=0 to ItemCount-1
						if ItemArray(1,i)>ItemArray(2,i) then
							sql="select Name from Home_Items where id="&ItemArray(0,i)
							rshome.open sql,home_conn,1,1
							if not rshome.eof then
								BuyCount=BuyCount+1
								errmsg=errmsg&"<br>&nbsp;&nbsp;&nbsp;"&BuyCount&"、"&rshome(0)&" ("&(ItemArray(1,i)-ItemArray(2,i))&" 个)"
								BuyItemSplit=Split(BuyItems,"|")
								if BuyItems="" then
									CartBagCount=0
								else
									CartBagCount=Ubound(BuyItemSplit)+1
								end if
								NewBuyItems=""
								SucFlag=True
								for j=0 to CartBagCount-1
									CurItemSplit=Split(BuyItemSplit(j),"$")
									if UBound(CurItemSplit)=1 then
										if CInt(CurItemSplit(0))=ItemArray(0,i) then
											SucFlag=False
											if CInt(CurItemSplit(1))<ItemArray(1,i)-ItemArray(2,i) then
												if CInt(CurItemSplit(1))>=10 then
													CartBagFull=True
												else
													if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
													if ItemArray(1,i)-ItemArray(2,i)>10 then
														CartBagFull=True
														NewBuyItems=NewBuyItems&ItemArray(0,i)&"$10"
													else
														NewBuyItems=NewBuyItems&ItemArray(0,i)&"$"&(ItemArray(1,i)-ItemArray(2,i))
													end if
												end if
											else
												if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
												NewBuyItems=NewBuyItems&BuyItemSplit(j)
											end if
										else
											if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
											NewBuyItems=NewBuyItems&BuyItemSplit(j)
										end if
									else
										if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
										NewBuyItems=NewBuyItems&BuyItemSplit(j)
									end if
								next
								if SucFlag then
									if CartBagCount>CartLength then
										CartBagFull=True
									else
										if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
										if ItemArray(1,i)-ItemArray(2,i)>10 then
											CartBagFull=True
											NewBuyItems=NewBuyItems&ItemArray(0,i)&"$10"
										else
											NewBuyItems=NewBuyItems&ItemArray(0,i)&"$"&(ItemArray(1,i)-ItemArray(2,i))
										end if
									end if
								end if
								BuyItems=NewBuyItems
							end if
							rshome.close
						end if
					next
					response.cookies("myHomeBuy_"&dvbbs.Userid)=BuyItems
					response.cookies(dvbbs.Userid&"_savehome")="Action=save&Type="&CurType&"&ScenNo="&CurScenID&"&ItemList="&CurItemList&"&ScenName="&CurScenName&"&OpenFlag="&CurOpenFlag&"&DefaultFlag="&CurDefaultFlag
					errmsg=errmsg&"<li>系统已将这些物品自动放入您的购物车。"
					if CartBagFull then
						errmsg=errmsg&"<li>由于购物车已满，部分物品没能放入购物车，请结算后再次购买！"
					end if
					call save_head()
					call save_Msg()
				else
					if CurDefaultFlag=1 then
						home_conn.execute("update Home_Scen Set isDefault=0 where username='"&dvbbs.membername&"'")
					end if
					home_conn.execute("insert into Home_Scen (Name,UserName,isOpen,isDefault) values ('"&CurScenName&"','"&dvbbs.membername&"',"&CurOpenFlag&","&CurDefaultFlag&")")
					CurScenID=home_conn.execute("select top 1 ID from Home_Scen order by DateAndTime DESC")(0)
					for i=0 to ubound(ItemSplit)
						if ItemSplit(i)<>"" then
							CurItemSplit=Split(ItemSplit(i),"_")
							home_conn.execute("insert into Home_ScenDetail (ScenID,ItemID,Unicode,isFlip,PosX,PosY) Values ("&CurScenID&","&CurItemSplit(0)&","&CurItemSplit(1)&","&CurItemSplit(2)&","&CurItemSplit(3)&","&CurItemSplit(4)&")")
						end if
					next
					errmsg="<li>家园方案【"&CurScenName&"】已被成功地保存！"
					call save_head()
					call save_Msg()
					response.write "<script>"&vbcrlf
					response.write "if(typeof(window.opener) == ""object"") "
					response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
					response.write "</script>"
				end if
			end if
		else
			response.cookies(dvbbs.Userid&"_savehome")=""
			call save_head()%>
			<form action="?type=<%=CurType%>&ScenNo=<%=CurScenID%>" method=post name=save>
			<input type=hidden name="action" value="save">
			<table cellpadding=3 cellspacing=1 align=center class=tableBorder1 width=97%>
				<tr valign=middle> 
					<th colspan=2>保存虚拟家园设计方案</th>
				</tr>
				<tr valign=middle> 
					<td class=tablebody1 align=right><b>当前家园方案名称&nbsp;</b></td>
					<td class=tablebody1 align=left>&nbsp;<input type=text name="ScenName" size=50 MaxLength=50 value=""></td>
				</tr>
				<tr valign=middle>
					<td class=tablebody1 align=right><b>允许别人查看当前方案&nbsp;</b></td>
					<td class=tablebody1 align=left>&nbsp;<input type=radio name="OpenFlag" value="1" checked>&nbsp;是&nbsp;&nbsp;<input type=radio name="OpenFlag" value="0">&nbsp;否</td>
	      </tr>
				<tr valign=middle> 
					<td class=tablebody1 align=right><b>优先显示该方案&nbsp;</b></td>
					<td class=tablebody1 align=left>&nbsp;<input type=radio name="DefaultFlag" value="1" checked>&nbsp;是&nbsp;&nbsp;<input type=radio name="DefaultFlag" value="0">&nbsp;否</td>
				</tr>
				<tr valign=middle> 
					<td class=tablebody2 colspan=2 align=center><input type="hidden" name="ItemList" value="<%=CurItemList%>"><input type=Submit value="确定" name=Submit>&nbsp;<input type="button" name="close" value="关闭" onclick="window.close()"></td>
				</tr>
			</table>
			</form>
		<%end if
	elseif CurType=1 then
		ItemCount=0
		SucFlag=True
		for i=0 to ubound(ItemSplit)
			CurItemSplit=Split(ItemSplit(i),"_")
			if CInt(CurItemSplit(0))<>0 then
				for j=0 to ItemCount-1
					if CInt(CurItemSplit(0))=ItemArray(0,j) then
						ItemArray(1,j)=ItemArray(1,j)+1
						exit for
					end if
				next
				if j>ItemCount-1 then
					redim preserve ItemArray(2,ItemCount)
					ItemArray(0,ItemCount)=CInt(CurItemSplit(0))
					ItemArray(1,ItemCount)=1
					ItemArray(2,ItemCount)=0
					ItemCount=ItemCount+1
				end if
			end if
		next
		for i=0 to ItemCount-1
			sql="select count(*) from home_myitems where itemid="&ItemArray(0,i)&" and username='"&dvbbs.membername&"' and Type<>0"
			rshome.Open sql,home_conn,1,1
			if not rshome.eof then
				ItemArray(2,i)=rshome(0)
			end if
			rshome.close
			if ItemArray(1,i)>ItemArray(2,i) and SucFlag then 
				SucFlag=False
			end if
		next
		if not SucFlag then
			errmsg="<li>如下物品尚未购买不能保存家园方案："
			founderr=true
			BuyCount=0
			BuyItems=request.cookies("myHomeBuy_"&dvbbs.Userid)
			CartBagFull=False
			for i=0 to ItemCount-1
				if ItemArray(1,i)>ItemArray(2,i) then
					sql="select Name from Home_Items where id="&ItemArray(0,i)
					rshome.open sql,home_conn,1,1
					if not rshome.eof then
						BuyCount=BuyCount+1
						errmsg=errmsg&"<br>&nbsp;&nbsp;&nbsp;"&BuyCount&"、"&rshome(0)&" ("&(ItemArray(1,i)-ItemArray(2,i))&" 个)"
						BuyItemSplit=Split(BuyItems,"|")
						if BuyItems="" then
							CartBagCount=0
						else
							CartBagCount=Ubound(BuyItemSplit)+1
						end if
						NewBuyItems=""
						SucFlag=True
						for j=0 to CartBagCount-1
							CurItemSplit=Split(BuyItemSplit(j),"$")
							if UBound(CurItemSplit)=1 then
								if CInt(CurItemSplit(0))=ItemArray(0,i) then
									SucFlag=False
									if CInt(CurItemSplit(1))<ItemArray(1,i)-ItemArray(2,i) then
										if CInt(CurItemSplit(1))>=10 then
											CartBagFull=True
										else
											if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
											if ItemArray(1,i)-ItemArray(2,i)>10 then
												CartBagFull=True
												NewBuyItems=NewBuyItems&ItemArray(0,i)&"$10"
											else
												NewBuyItems=NewBuyItems&ItemArray(0,i)&"$"&(ItemArray(1,i)-ItemArray(2,i))
											end if
										end if
									else
										if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
										NewBuyItems=NewBuyItems&BuyItemSplit(j)
									end if
								else
									if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
									NewBuyItems=NewBuyItems&BuyItemSplit(j)
								end if
							else
								if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
								NewBuyItems=NewBuyItems&BuyItemSplit(j)
							end if
						next
						if SucFlag then
							if CartBagCount>CartLength then
								CartBagFull=True
							else
								if NewBuyItems<>"" then NewBuyItems=NewBuyItems&"|"
								if ItemArray(1,i)-ItemArray(2,i)>10 then
									CartBagFull=True
									NewBuyItems=NewBuyItems&ItemArray(0,i)&"$10"
								else
									NewBuyItems=NewBuyItems&ItemArray(0,i)&"$"&(ItemArray(1,i)-ItemArray(2,i))
								end if
							end if
						end if
						BuyItems=NewBuyItems
					end if
					rshome.close
				end if
			next
			response.cookies("myHomeBuy_"&dvbbs.Userid)=BuyItems
			response.cookies(dvbbs.Userid&"_savehome")="Type="&CurType&"&ScenNo="&CurScenID&"&ItemList="&CurItemList
			errmsg=errmsg&"<li>系统已将这些物品自动放入您的购物车。"
			if CartBagFull then
				errmsg=errmsg&"<li>由于购物车已满，部分物品没能放入购物车，请结算后再次购买！"
			end if
			call save_head()
			call save_Msg()
		else
		
		
		
		sql="select * from Home_ScenDetail Where ScenID="&CurScenID&" Order By ID"
   rsHome.open sql,home_conn,1,1
   j=0
   do while not rshome.eof
    if j<=ubound(ItemSplit) then
     if ItemSplit(j)<>"" then
      CurItemSplit=Split(ItemSplit(j),"_")
      home_conn.execute("update Home_ScenDetail set ItemID="&CurItemSplit(0)&",Unicode="&CurItemSplit(1)&",isFlip="&CurItemSplit(2)&",PosX="&CurItemSplit(3)&",PosY="&CurItemSplit(4)&" where id="&rshome("ID"))
     else
      home_conn.execute("delete from Home_scenDetail where id="&rshome("ID"))
     end if
    else
     home_conn.execute("delete from Home_scenDetail where id="&rshome("ID"))
    end if
    j=j+1
    rshome.movenext
   loop
   for i=j to ubound(ItemSplit)
    if ItemSplit(i)<>"" then
     CurItemSplit=Split(ItemSplit(i),"_")
     home_conn.execute("insert into Home_ScenDetail (ScenID,ItemID,Unicode,isFlip,PosX,PosY) Values ("&CurScenID&","&CurItemSplit(0)&","&CurItemSplit(1)&","&CurItemSplit(2)&","&CurItemSplit(3)&","&CurItemSplit(4)&")")
    end if
   next


		
		
		
		
		'	home_conn.execute("delete from Home_ScenDetail Where ScenID="&CurScenID)
		'	for i=0 to ubound(ItemSplit)
		'		if ItemSplit(i)<>"" then
		'			CurItemSplit=Split(ItemSplit(i),"_")
		'			home_conn.execute("insert into Home_ScenDetail (ScenID,ItemID,Unicode,isFlip,PosX,PosY) Values ("&CurScenID&","&CurItemSplit(0)&","&CurItemSplit(1)&","&CurItemSplit(2)&","&CurItemSplit(3)&","&CurItemSplit(4)&")")
		'		end if
		'	next
			home_conn.execute("update Home_Scen set DateAndTime=Now()")

			errmsg="<li>家园方案【"&CurScenName&"】已被成功地保存！"
			home_conn.execute("update Home_Scen set DateAndTime=Now()")
			call save_head()
			call save_Msg()
			response.write "<script>"&vbcrlf
			response.write "if(typeof(window.opener) == ""object"") "
			response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
			response.write "</script>"
		end if
	elseif CurType=2 then
		if request("action")="save" then
			CurScenName=CheckStr(request("ScenName"))
			if isnull(curscenName) then
				errmsg=errmsg+"<br>"+"<li>方案名称不可为空！"
				founderr=true
			elseif trim(CurScenName)="" then
				errmsg=errmsg+"<br>"+"<li>方案名称不可为空！"
				founderr=true
			end if
			TmpStr=""
			StrLength=0
			for i=1 to len(CurScenName)
				CurChar=mid(CurScenName,i,1)
				if ASC(CurChar)>=0 and ASC(CurChar)<256 then
					if StrLength<50 then
						TmpStr=TmpStr&CurChar
						StrLength=StrLength+1
					else
						exit for
					end if
				else
					if StrLength<49 then
						TmpStr=TmpStr&CurChar
						StrLength=StrLength+2
					else
						exit for
					end if
				end if
			next
			CurScenName=TmpStr
			if founderr then
				call save_head()
				call save_Msg()
			else
				home_conn.execute("update Home_Scen Set Name='"&CurScenName&"' where ID="&CurScenID)
				errmsg="<li>家园方案【"&CurScenName&"】已被成功地改名！"
				call save_head()
				call save_Msg()
				response.write "<script>"&vbcrlf
				response.write "if(typeof(window.opener) == ""object"") "
				response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
				response.write "</script>"
			end if
		else
			call save_head()%>
			<form action="?type=<%=CurType%>&ScenNo=<%=CurScenID%>" method=post name=save>
			<input type=hidden name="action" value="save">
			<table cellpadding=3 cellspacing=1 align=center class=tableBorder1 width=97%>
				<tr valign=middle> 
					<th colspan=2>重命名虚拟家园设计方案</th>
				</tr>
				<tr valign=middle> 
					<td class=tablebody1 align=right><b>当前家园方案名称&nbsp;</b></td>
					<td class=tablebody1 align=left>&nbsp;<%=CurScenName%></td>
				</tr>
				<tr valign=middle>
					<td class=tablebody1 align=right><b>新的家园方案名称&nbsp;</b></td>
					<td class=tablebody1 align=left>&nbsp;<input type=text name="ScenName" size=50 MaxLength=50 value=""></td>
	      </tr>
				<tr valign=middle> 
					<td class=tablebody2 colspan=2 align=center><input type="hidden" name="ItemList" value="<%=CurItemList%>"><input type=Submit value="确定" name=Submit>&nbsp;<input type="button" name="close" value="关闭" onclick="window.close()"></td>
				</tr>
			</table>
			</form>
		<%end if
	elseif CurType=3 then
	
	
	if CurOpenFlag=1 then
   sql="select a.itemid,a.needcnt,b.hascnt from (select itemid,count(itemid) as needcnt from home_scendetail inner join home_scen on home_scendetail.scenid=home_scen.id where home_scen.id="&CurScenID&" and home_scendetail.itemid<>0 group by itemid) a inner join (select itemid,count(itemid) as hascnt from home_myitems where username='"&dvbbs.membername&"' and type>0 and Type<5 group by itemid) b on a.itemid=b.itemid where a.needcnt>b.hascnt"
   rshome.open sql,home_conn,1,1
   if not rshome.eof then
    errmsg="<li>由于家园方案中如下物品过期，该方案不能允许其他人查看："
    founderr=true
    BuyCount=0
    do while not rshome.eof
     BuyCount=BuyCount+1
     errmsg=errmsg&"<br>&nbsp;&nbsp;&nbsp;"&BuyCount&"、"&home_conn.execute("select name from Home_Items where id="&rshome(0))(0)&" ("&(rshome(1)-rshome(2))&" 个)"
     rshome.movenext
    loop
   else
    home_conn.execute("update Home_Scen set isOpen=1 Where ID="&CurScenID)
    errmsg="<li>家园方案【"&CurScenName&"】已允许其他人查看！"
   end if
  else
   home_conn.execute("update Home_Scen set isOpen=0,isDefault=0 Where ID="&CurScenID)
   errmsg="<li>家园方案【"&CurScenName&"】已禁止其他人查看！"
  end if
  call save_head()
  call save_Msg()
  if not Founderr then
   response.write "<script>"&vbcrlf
   response.write "if(typeof(window.opener) == ""object"") "
   response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
   response.write "</script>"
  end if
		
	
		
		
	elseif CurType=4 then
		if CurOpenFlag=0 then
			errmsg="<li>没有公开的方案不能设置为优先显示，家园方案【"&CurScenName&"】无法设置为优先显示！"
			founderr=true
			call save_head()
			call save_Msg()
		else
			home_conn.execute("update Home_Scen Set isDefault=0 where username='"&dvbbs.membername&"'")
			home_conn.execute("update Home_Scen Set isDefault=1 where ID="&CurScenID)
			errmsg="<li>家园方案【"&CurScenName&"】已被设置为优先显示！"
			call save_head()
			call save_Msg()
			response.write "<script>"&vbcrlf
			response.write "if(typeof(window.opener) == ""object"") "
			response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
			response.write "</script>"
		end if
	elseif CurType=5 then
		home_conn.execute("delete from Home_Scen Where ID="&CurScenID)
		home_conn.execute("delete from Home_ScenDetail Where ScenID="&CurScenID)
		errmsg="<li>家园方案【"&CurScenName&"】已被成功地删除！"
		call save_head()
		call save_Msg()
		response.write "<script>"&vbcrlf
		response.write "if(typeof(window.opener) == ""object"") "
		response.write "window.opener.document.URL='z_home.asp';"&vbcrlf
		response.write "</script>"
	elseif CurType=6 then
  errmsg="<li>家园方案【"&CurScenName&"】已被成功地绘制好图纸！"
  call SaveScen(CurScenID,True,True,True)
  call save_head()
  call save_Msg()
  response.write "<script>"&vbcrlf
  response.write "if(typeof(window.opener) == ""object"") "
  response.write "window.opener.document.URL='z_home.asp?scenno="&CurScenID&"';"&vbcrlf
  response.write "</script>"
elseif CurType=7 then
  errmsg="<li>家园方案数据提取："
  errmsg=errmsg&"<br>&nbsp;&nbsp;&nbsp;&nbsp;"&CurItemList
  call save_head()
  call save_Msg()
end if
	
	
	
end if
Dvbbs.footer()
set rsHome=nothing

sub save_head()%>
	<html><head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	<title>保存虚拟家园设计方案</title>
	
	</head>
	<body><br>
<%end sub

sub save_Msg()%>
	<br>
	<table cellpadding=3 cellspacing=1 align=center class=tableBorder1 width=97%>
		<tr align=center>
			<th width="100%">保存虚拟家园设计方案信息</th>
		</tr>
		<tr>
			<td width="100%" class=tablebody1><b>操作结果：</b><br><%
				if founderr then
					response.write "<font color=red>"
					response.write errmsg
					response.write "</font>"
				else
					response.write errmsg
				end if
			%></td>
		</tr>
		<tr align=center>
			<td width="100%" class=tablebody2><a href="javascript:window.close()">[关闭窗口]</a><%if (request("action")="save" or CurType=1) and founderr then%><%if request.cookies(dvbbs.Userid&"_savehome")<>"" then%>&nbsp;&nbsp;<a href="z_home_cartbag.asp">[查看购物车]</a><%else%>&nbsp;&nbsp;<a href="javascript:history.go(-1)">[返回上页]</a><%end if%><%end if%></td>
		</tr>
	</table>
<%end sub%>