<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href=inc/css.css rel=STYLESHEET type=text/css>
<body topmargin="5" leftmargin="5" rightmargin="5" bottommargin="5">
<%
if Request.Cookies("WrzcNethtml")("admin_class")<>0 and Request.Cookies("WrzcNethtml")("admin_class")<>2 then
response.write "你没有这个权限!"
response.end
end if
%>

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

if tosub=sub_number then
response.write "<p style=""margin:5"">合并到的订单号和现有订单号重复！"
response.end
end if


if tosub="" then
response.write "<p style=""margin:5"">请输入合并到的订单号！"
response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_sub where sub_number='"&sub_number&"'"
rs.open sql,conn,1,1
if rs.eof then
response.write "<p style=""margin:5"">错误信息，请刷新页面后重试！"
response.end
end if
rs.close
set rs=nothing

set rs2=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_sub where sub_number='"&tosub&"'"
rs2.open sql,conn,1,1
if rs2.eof then
response.write "<p style=""margin:5"">您输入的订单号不存在！"
response.end
end if
rs2.close
set rs2=nothing


set rsp=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_basket where sub_number='"&sub_number&"' 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 basket_check=1"
rss.open sql,conn,1,3
do while not rss.eof
if rsp("hw_id")=rss("hw_id") 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&"'"
rs.open sql,conn,1,3
rs.delete
rs.update
rs.close
set rs=nothing


response.write "<p style=""margin:5"">合并成功，<a href='javascript:history.back(1)'>返回</a>!"
response.end
else
%><div align="center">
<table border="0" cellpadding="0" cellspacing="0" class="st">
<form method="POST" action="ad_hebing.asp?action=add">
<tr><td align="right" class="sa"></td><td class="sa">订单合并</td></tr>
<tr><td align="right" class="s0">本订单号：</td>
<td class="s0"><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="s1">合并到订单：</td><td class="s1">
	<input name="tosub" type="text" class=input size="16">
	<font color="#FF0000">*请输入订单号</font></td></tr>
<tr><td class="s0"></td><td class="s0"><input name=B12 type=image src="../img/regbutton.gif"></td></tr>
<tr><td class="s1"></td><td class="s1"><font color="#FF0000">
			请注意：合并之后订单收货信息将以合并到的订单号为准!</font></td></tr></form></table>
</div>
<%end if%><!--#include file="ad_bottom.asp"-->