<!--#include file="Inc/EnSysProduct.asp" -->
<!--#include file="inc/Skin_css.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 Productlj_Id in ("&productlist&") order by Productlj_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 "Operate the inquire list result mistake!!"
    return
end if
rsadd("Flag")="No"
rsadd.Update


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

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

 IF ERROR>0 THEN
	response.write "Operate the inquire detailed form has mistake!"
	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") =""
%>
<!-- #include file="EnHead.asp" -->
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="5" valign="top" bgcolor="#FFFFFF"></td>
  </tr>
  <tr> 
    <td height="72" valign="top" bgcolor="#FFFFFF"><table width="843" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="tdbg_left"  width="190" height="179" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;User 
                  login</td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td> 
                        <% call ShowUserLogin() %>
                      </td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;&nbsp;&nbsp;Prouduct 
                  list</td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td> 
                        <% call ShowSmallClass_Tree() %>
                      </td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;&nbsp;Prouduct 
                  search</td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td> 
                        <% call ShowSearch(1) %>
                      </td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table></td>
          <td width="6"></td>
          <td  valign="top"><table Class=border width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td height="206" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td class="title_right" height="32">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;Online 
                        Inquire </td>
                    </tr>
					
                    
                  </table>
                  <table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width="90%" bgcolor="B0266D">
                    <tr bgcolor="eeeeee"> 
                      <td height="56" align="center"  bgcolor="eeeeee">Thank you, 
                        the inquire send out success, please keeps remember your 
                        order number, convenient to check.</td>
                    </tr>
                    <tr bgcolor="#FFFFFF"> 
                      <td width="100%" align="center" valign="middle"><br>
                        Thank your inquire our products!<b><br>
                        </b><font color="B0266D">Your inquire number is:</font><b><font color="B0266D"><b><%=inBillNo%></b><br>
                        <br>
                        </font> <br>
                        </b></td>
                    </tr>
                  </table> </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<!-- #include file="Inc/EnFoot.asp" -->
</BODY></HTML>
