<!--#include file="conn.asp"--><%seo_title="Orders-"&sitename%>
<!--#include file="IncAsp/WrzcNethtml_top.asp"-->
<div align="center">
<table cellpadding="0" cellspacing="0" class="all_t1">
<tr><td class="all_l_td" valign="top">
<!--#include file="IncAsp/WrzcNethtml_log.asp"--><div class="d5"></div>
</td>
<td valign="top" class="all_c_td">

<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="sort">&nbsp;<IMG src="Skin/<%=WrzcNethtml_skin%>/home.gif" border=0 align="absmiddle">  <a href="index.html">Home</a> >>&nbsp;Orders</td></tr>
</table>

<%

if Request.Cookies("WrzcNethtml")("user_name")="" and Request.Cookies("WrzcNethtml")("guest")="" then
response.redirect "login.asp?comurl=orders.asp"
response.end
else
if Request.Cookies("WrzcNethtml")("user_name")<>"" then
user_name=Request.Cookies("WrzcNethtml")("user_name")
chklogin(user_name)
elseif Request.Cookies("WrzcNethtml")("guest")<>"" then
user_name=Request.Cookies("WrzcNethtml")("guest")
end if
end if



if request("action")="add" then
sub_id=request("sub_id")
chkid(sub_id)
tosub=DelStr(request("tosub"))
sub_number=request("sub_number")

if tosub=sub_number then
Response.Write "<script language=javascript>alert('Error!'); window.location.href='"&Request.ServerVariables("Http_Referer")&"';</script>"
response.end
end if

if tosub="" then
Response.Write "<script language=javascript>alert('Please Enter Order Number'); window.location.href='"&Request.ServerVariables("Http_Referer")&"';</script>"
response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_sub where sub_number='"&sub_number&"' and sub_name='"&user_name&"' and sub_zt<=1"
rs.open sql,conn,1,1
if rs.eof then
Response.Write "<script language=javascript>alert('Error!'); window.location.href='"&Request.ServerVariables("Http_Referer")&"';</script>"
response.end
else
	quan_id=rs("quan_id")
	quan_cash=rs("quan_cash")
	quan_man=rs("quan_man")
	quan_no=rs("quan_no")
	quan_pass=rs("quan_pass")
end if
rs.close
set rs=nothing

set rs2=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_sub where sub_number='"&tosub&"' and sub_name='"&user_name&"'"
rs2.open sql,conn,1,1
if rs2.eof then
Response.Write "<script language=javascript>alert('Order Not existed'); window.location.href='"&Request.ServerVariables("Http_Referer")&"';</script>"
response.end
elseif rs2("sub_zt")>1 then
Response.Write "<script language=javascript>alert('Error!'); window.location.href='"&Request.ServerVariables("Http_Referer")&"';</script>"
response.end
else
	quan_idt=rs2("quan_id")
	quan_casht=rs2("quan_cash")
	quan_mant=rs2("quan_man")
	quan_not=rs2("quan_no")
	quan_passt=rs2("quan_pass")
end if
rs2.close
set rs2=nothing


set rsp=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_basket where sub_number='"&sub_number&"' and user_name='"&user_name&"' and basket_check=1"
rsp.open sql,conn,1,3
do while not rsp.eof
icc=0

set rss=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_basket where sub_number='"&tosub&"' and user_name='"&user_name&"' and basket_check=1"
rss.open sql,conn,1,3
do while not rss.eof
if rsp("hw_id")=rss("hw_id") and rsp("tao_id")=rss("tao_id") and rsp("kxa")=rss("kxa") and rsp("kxb")=rss("kxb") and icc=0 then


	icc=1
	rss("basket_count")=rss("basket_count")+rsp("basket_count")
end if
rss.movenext
loop
rss.close
set rss=nothing




if icc=0 then
rsp("sub_number")=tosub
else
rsp.delete
end if

rsp.update
rsp.movenext
loop
rsp.close
set rsp=nothing

set rs=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_sub where sub_number='"&sub_number&"' and sub_name='"&user_name&"'"
rs.open sql,conn,1,3
rs.delete
rs.update
rs.close
set rs=nothing

if quan_cash>quan_casht then
	set rs=server.createobject("adodb.recordset")
	sql="select * from WrzcNethtml_sub where sub_number='"&tosub&"' and sub_name='"&user_name&"'"
	rs.open sql,conn,1,3
		rs("quan_id")=quan_id
		rs("quan_cash")=quan_cash
		rs("quan_man")=quan_man
		rs("quan_no")=quan_no
		rs("quan_pass")=quan_pass
	rs.update
	rs.close
	set rs=nothing
end if




Response.Write "<script language=javascript>alert('Success!'); window.location.href='orders.asp';</script>"
response.end
else

chkid(request("sub_id"))
%><table border="0" cellpadding="2" cellspacing="0" width="99%">
	<form method="POST" action="hebing.asp?action=add">
		<tr>
			<td align="right" class="cartshow1"></td>
			<td class="cartshow1"></td>
		</tr>
		<tr>
			<td align="right" class="cartshow0">Order Number:</td>
			<td class="cartshow0">
			<input name="sub_number" type="hidden" value="<%=request("sub_number")%>">
			<input name="sub_id" type="hidden" value="<%=request("sub_id")%>">
<%=request("sub_number")%></td>
		</tr>
		<tr>
			<td align="right" class="cartshow1">Add to Order:</td>
			<td class="cartshow1">
			<input name="tosub" type="text" class=input size="16">
			<font color="#FF0000">*Please Enter Order Number</font></td>
		</tr>
		<tr>
			<td class="cartshow0"></td>
			<td class="cartshow0">
			<input name=B12 type=image src="img/regbutton.gif"></td>
		</tr>
	</form>
</table>
<%end if%></td></tr></table></div><!--#include file="IncAsp/WrzcNethtml_copy.asp"-->