<!--#include file="Inc/SysProduct.asp" -->
<%
UserName=session("UserName")			'登陆用户id
Receiver=request.form("Receiver")			'必填字段
Sex=request.form("Sex")			'
Phone=request.form("Phone")		'必填字段
Add=request.form("Add")	'必填字段
Notes=request.form("Notes")			
Email=request.form("Email")			
Subject=request.form("Subject")
CompanyName=request.form("CompanyName")			
Fax=request.form("Fax")		
if UserName="" then 
    UserName="游客" 
end if
if Add="" then
	Add=null
end if
if Fax="" then
	Fax=null
end if


'判断购物车是否为空
ProductList = Session("ProductList")
if productlist="" then
 response.redirect "error.asp?error=007"
 response.end
else
  sql_product="select * from Product where Product_Id in ("&productlist&") order by Product_Id"
  Set rs_order = conn.Execute(sql_product)
end if

BranchID="0022"
CoNo="000040"

'交易日期，格式：YYYYMMDD
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,1,3
Set rsdetail=server.createobject("adodb.recordset")
rsdetail.Open "select * from OrderDetail" ,conn,1,3

'事务定义开始
'conn.Begintrans

'操作之一开始写入订单列表信息
rsadd.AddNew 
rsadd("UserName")=UserName
rsadd("OrderNum")=inBillNo
rsadd("Receiver")=Receiver
rsadd("Sex")=Sex
rsadd("Phone")=Phone
rsadd("Add")=Add
rsadd("RecTime")=now()
if Subject<>"" then rsadd("Subject")=Subject
if Email<>"" then rsadd("Email")=Email
if CompanyName<>"" then rsadd("CompanyName")=CompanyName
if Fax<>"" then rsadd("Fax")=Fax
if Notes<>"" then rsadd("Notes")=Notes
if error>0 then
	response.write " 操作订单列表生成错误！！"
    return
end if
rsadd("Flag")="No"
rsadd.Update


While Not rs_order.EOF '把购买的产品资料读出来，写入定单详细资料表中

 rsdetail.AddNew 
 rsdetail("UserName")=UserName		'下单用户号
 rsdetail("OrderNum")=inBillNo		'订单号码
 rsdetail("Product_Id")=rs_order("Product_Id")		'产品编码
 rsdetail("OrderTime")=date()

 IF ERROR>0 THEN
	response.write "操作订单详细信息表生成错误！！"
	RETURN
 END if
 rsdetail.Update
 rs_order.MoveNext
Wend
'事务操作结束
'conn.CommitTrans

rsdetail.close
set rsdetail=nothing
rsadd.close
set rsadd=nothing
rs_order.close
set rs_order=nothing
Session("ProductList") =""
%>
<style type="text/css">
<!--
.style1 {color: #6F6F6F}
-->
</style>
<style type="text/css">
<!--
.style2 {color: #CC0000}
-->
</style>
<!-- #include file="Head.asp" -->
      <TABLE class=about_body cellSpacing=0 cellPadding=0 width=968 align=center 
border=0>
        <TBODY>
          <TR>
            <TD vAlign=top width=739><TABLE cellSpacing=0 cellPadding=0 width=739 border=0>
                <TBODY>
                  <TR>
                    <TD class=nav_title width=739><TABLE height=50 cellSpacing=0 cellPadding=0 width="100%" 
              border=0>
                        <TBODY>
                          <TR>
                            <TD width="7%">&nbsp;</TD>
                            <TD vAlign=center width="11%">产品订购</TD>
                            <TD width="82%"><SPAN>Products Order </SPAN></TD>
                          </TR>
                        </TBODY>
                    </TABLE></TD>
                  </TR>
                  <TR>
                    <TD class=about_ifnobg vAlign=top><TABLE style="MARGIN-LEFT: 6px" cellSpacing=0 cellPadding=0 
            width=729 border=0>
                        <TBODY>
                          <TR>
                            <TD style="PADDING-TOP: 21px"><table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width="97%" bgcolor="#eaeaea">
                              <tr bgcolor="eeeeee">
                                <td height="56" align="center"  bgcolor="eeeeee"><span class="style11">谢谢您，询价提交成功，请您记住您的询价号码，以便查询。</span></td>
                              </tr>
                              <tr bgcolor="#FFFFFF">
                                <td height="75" align="center" valign="middle">感谢您咨询我们的产品!<b><br>
                                    <br>
                                </b><span class="style2">您的询价号码是:</span><b><font color="B0266D"><b><%=inBillNo%></b></font></b></td>
                              </tr>
                              <tr bgcolor="#FFFFFF">
                                <td width="100%" height="69" align="center" valign="middle">
                                  <a href="UserOrder.asp"><font color="#FF0000"><b>我的询价号码有什么用？</b></font></a></td>
                              </tr>
                            </table></TD>
                          </TR>
                        </TBODY>
                    </TABLE></TD>
                  </TR>
                </TBODY>
              </TABLE>
                <table width="90%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="15"></td>
                  </tr>
              </table></TD>
            <TD vAlign=top><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                <TBODY>
                  <TR>
                    <TD><TABLE height=68 cellSpacing=0 cellPadding=0 width=229 border=0>
                        <TBODY>
                          <TR>
                            <TD vAlign=top background=imgbyw/about_title-24.jpg><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                                <TBODY>
                                  <TR>
                                    <TD width="17%" height=31>&nbsp;</TD>
                                    <TD class=STYLE2 width="83%"><DIV 
                        style="MARGIN-TOP: 3px; FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #ffffff">产品系列 </DIV></TD>
                                  </TR>
                                </TBODY>
                            </TABLE></TD>
                          </TR>
                        </TBODY>
                    </TABLE></TD>
                  </TR>
                  <TR>
                    <TD height=126 align="right" 
          vAlign=top background=imgbyw/about_title-26.jpg 
          style="BACKGROUND-IMAGE: url(images/hao/about_title-26.jpg); BACKGROUND-REPEAT: no-repeat"><% call ShowSmallClass_Tree() %></TD>
                  </TR>
                  <TR>
                    <TD></TD>
                  </TR>
                </TBODY>
              </TABLE>
                <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                  <TBODY>
                    <TR>
                      <TD><IMG height=254 alt="" src="imgbyw/about_service.jpg" 
            width=229></TD>
                    </TR>
                  </TBODY>
              </TABLE></TD>
          </TR>
        </TBODY>
      </TABLE>
      <!--#include file="Foot.asp" -->
</BODY></HTML>
