<!--#include file="../admin/conn.asp" -->
<%
Name=session("user_id")
RecName=request.form("RecName")
RecPhone=request.form("RecPhone")
CompPhone=request.form("CompPhone")
Gettime=request.form("Gettime")
RecAddress=request.form("RecAddress")
Notes=request.form("Notes")
Recmail=request.form("Recmail")
RecTime=request.form("RecTime")
Zipcode=request.form("ZipCode")
Discount=request.form("Discount")
	'该商品的返回页面
Pei=request.form("pei")
Fei=request.form("fei")
'thiskou=FormatNumber(request.form("userkou"),2)
if session("user_id")="" then
response.redirect "../error.asp?error=006"
response.end
end if
ProductList = Session("ProductList")
if productlist="" then
response.redirect "../error.asp?error=007"
response.end
else
sql="select * from shop where ProdId in ("&productlist&") order by ProdId"
Set rs = conn.Execute( sql )
end if
if session("sum")="" then response.redirect "../error.asp?error=007"
Total=session("sum")
yy=right(year(date),2)
mm=right("00"&month(date),2)
dd=right("00"&day(date),2)
riqi=yy & mm & dd
xiaoshi=right("00"&hour(time),2)
fenzhong=right("00"&minute(time),2)
miao=right("00"&second(time),2)
BillNo=xiaoshi & fenzhong & miao
inBillNo=yy & mm & dd & xiaoshi & fenzhong & miao		'根据服务器时间生成订单号
Set rsadd=server.createobject("adodb.recordset")		'保存订单信息
rsadd.Open "select * from orderlist" ,conn,3,3
Set rsdetail=server.createobject("adodb.recordset")
rsdetail.Open "select * from OrderDetail" ,conn,3,3
conn.Begintrans
rsadd.AddNew 
rsadd("UserId")=Name
rsadd("OrderNum")=inBillNo
rsadd("RecName")=RecName
rsadd("OrderSum")=Total
rsadd("RecPhone")=RecPhone
rsadd("RecAddress")=RecAddress
rsadd("pei")=pei     '配送方式
rsadd("fei")=fei     '配送费用
'rsadd("thiskou")=thiskou
if compphone<>"" then rsadd("CompPhone")=CompPhone
if gettime<>"" then rsadd("gettime")=Gettime
if ZipCode<>"" then rsadd("ZipCode")=ZipCode
if RecTime<>"" then rsadd("RecTime")=RecTime
if Recmail<>"" then rsadd("Recmail")=Recmail
if Discount="" then Discount=0 
rsadd("Discount")=Discount
rsadd("PayType")=PayType
if Notes<>"" then rsadd("Notes")=Notes
if error>0 then
response.write " 操作订单列表生成错误！！"
return
end if
rsadd.Update
Sum = 0
While Not rs.EOF
Quatity = CInt( Request( "Q_" & rs("ProdId")) )
If Quatity <= 0 Then 
Quatity = CInt( Session(rs("ProdId")) )
If Quatity <= 0 Then Quatity = 1
End If
Session(rs("shop_Name")) = Quatity
Sum = Sum + csng(rs("shop_jg")) * Quatity
Sum = FormatNumber(Sum,2) 
rsdetail.AddNew 
if Name<>"" then rsdetail("UserId")=Name	'下单会员
rsdetail("OrderNum")=inBillNo			'订单号码
rsdetail("ProdId")=rs("ProdId")			'产品编码
rsdetail("ProdUnit")=Quatity			'购买数量
rsdetail("BuyPrice")=rs("shop_jg")		'购买单价
rsdetail("pei")=pei				'配送方式
rsdetail("fei")=fei				'配送费用
IF ERROR>0 THEN
response.write "操作订单详细信息表生成错误！！"
RETURN
END if
rsdetail.Update
rs.MoveNext
Wend
conn.CommitTrans
rsdetail.close
set rsdetail=nothing
rsadd.close
set rsadd=nothing
Session("ProductList") = ""
%>

<HTML>
<HEAD>
<TITLE>订单提交成功</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../shop.css" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</HEAD>
<body>

<table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width=100%>
	<tr><td align="center" valign="middle" height=60><br><br><font color="#FF3333">恭喜，订单提交成功！您的订单号码是：
		<b><%=inBillNo%></b>&nbsp;&nbsp;&nbsp;&nbsp;本次交易金额为：<b><%=total%></b>元</font></td></tr>
	<tr>
	  <td align="center" valign="middle"  height=60>
		只有付款成功后，才能完成本次交易。<a href="../hlep.asp#hlep2" target="_blank" class="style1" >查看付款方式</a>。
	</td>
	</tr>
</table>

</body>
</HTML>
<%
set conn=nothing
%> 
