<!-- #include virtual = "/include/myopen.asp" -->
<%
	set RS = Server.CreateObject("ADODB.RecordSet")
	set RS1 = Server.CreateObject("ADODB.RecordSet")
	set RS2 = Server.CreateObject("ADODB.RecordSet")
	AA = MONTH(DATE)
	IF AA <10 THEN
	M = "0" & AA
	ELSE
	M = AA
	END IF
	BB = DAY(DATE)
	IF BB <10 THEN
	D = "0" & BB
	ELSE
	D = BB
	END IF
%>
<%
IF Request.Cookies ("USER_NAME") = "" OR Request.Cookies ("USER_PASS") ="" THEN

	descr_url=Request.ServerVariables("SCRIPT_NAME")
	'订购的登陆
	
	'没有登陆
	Response.Redirect ("/member/login.asp?source_url=" & descr_url & "")
	
END IF
IF REQUEST("ORDER_SEND") <> "" THEN
	IF Request.Cookies ("dl_user") <> "" THEN
	DL_USER = Request.Cookies ("dl_user")
	ELSE
	DL_USER = "CZX"
	END IF

	'正式填写定单
	'填加定单数据库
IF REQUEST("PAY_MODE") = "招商银行一卡通" THEN
	
	SQL = "SELECT * FROM ORDER_NAME where order_no = '" & REQUEST("ORDER_NO") & "'"
	RS.Open SQL,CONN,adOpenKeyset ,adLockReadOnly
		IF RS.RecordCount >0 THEN
		ELSE
			SQL = "SELECT SUM(CARD_TOTAL) AS TOTAL FROM ORDER_TEMP WHERE USER_NAME = '" & Request.ServerVariables("REMOTE_ADDR") & "'"
			RS1.Open SQL,CONN,adOpenKeyset ,adLockReadOnly
				IF RS1.RecordCount >0 THEN
					TOTAL = RS1("TOTAL")
					'可以付款
					'取本用户的联系方法
					SQL = "SELECT * FROM MEMBER WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
					RS2.Open SQL,CONN,adOpenStatic ,adLockReadOnly
						IF RS2.RecordCount >0 THEN
							TURE_NAME = RS2("TRUE_NAME")
							POST_CODE = RS2("POST_CODE")
							ADDRESS = RS2("ADDRESS")
							YMEMAIL = RS2("EMAIL")
						END IF
					RS2.Close 
				ELSE
					'连接够物车
					Response.Redirect ("order_card.asp")
				END IF
			RS1.Close 
	
		SQL = "INSERT INTO ORDER_NAME VALUES('" & DL_USER & "','" & Request.Cookies ("USER_NAME") & "','" & TURE_NAME & "','" & REQUEST("ORDER_NO") & "',"
		SQL = SQL & TOTAL & ",'" & Request("PAY_MODE") & "','" & REQUEST("SEND_MODE") & "',#"
		SQL = SQL & REQUEST("SEND_DATE") & "#,'" & REQUEST("SEND_ADDR") & "','" & REQUEST("SEND_POST") & "','"
		SQL = SQL & REQUEST("SEND_DESC") & "',#" & DATE & "#,'未到')"
		CONN.Execute (SQL)

	'填加定单明晰数据库
		SQL1 = "SELECT * FROM ORDER_TEMP WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
		RS1.Open SQL1,CONN,adOpenStatic ,adLockReadOnly
			DO WHILE NOT RS1.EOF 
				SQL = "INSERT INTO ORDER_DESC VALUES('" & REQUEST("ORDER_NO") & "','" & RS1("CARD_NO") & "','"
				SQL = SQL & RS1("CARD_UNIT") & "'," & RS1("CARD_NUMBER") & "," & RS1("CARD_PRICE_A") & "," & RS1("CARD_TOTAL") & ")"		
				CONN.Execute (SQL)
			RS1.MoveNext 
			LOOP
			RS1.Close 
		'删除临时数据库
		SQL = "DELETE * FROM ORDER_TEMP WHERE USER_NAME = '" & Request.ServerVariables("REMOTE_ADDR") & "'"
		CONN.Execute (SQL)	
		
		Set myMail = Server.CreateObject("CDONTS.NewMail")
		myMail.From = "sales@mensun.com"
		myMail.To = YMEMAIL
		myMail.Subject = "您的定单：" & REQUEST("ORDER_NO") & "已经成功订购"
		
					Abody="订单号码： " & REQUEST("ORDER_NO") & chr(13)
					Abody=Abody & "会员编号：" & Request.Cookies ("USER_NAME") & chr(13)
					Abody=Abody & "会员名称：" & TURE_NAME & chr(13)
					Abody=Abody & "总计价格：" & TOTAL & "元" & CHR(13)
					Abody=Abody & "订购日期：" & DATE & CHR(13)
					Abody=Abody & "付款方式：" & REQUEST("PAY_MODE") & CHR(13)
					Abody=Abody & "请查收您的商品，具体商品详细清单请到网站查询！查询地址为：http://www.mensun.com/member/login.asp" & CHR(13)
					Abody=Abody & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13)
					Abody=Abody & "美慎成人用品购物中心 " & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13)
		myMail.Body = Abody
		myMail.Send
		
		%>
<link rel="stylesheet" href="../news%5B1%5D.css">

<form action="https://www.sh.cmbchina.com/netpayment/BaseHttp.dll?PrePay1" method=post id=form1 name=form1>
<input type="hidden" name="CoNo" value="000335"><input type="hidden" name="BillNo"
value="<%=REQUEST("ORDER_NO")%>"><input type="hidden" name="Amount" value="<%=TOTAL%>">
<input  type="hidden" name="Date" value="<%=year(date) & M & D%>">
<input  type="hidden" name="MerchantUrl" value="http://www.mensun.com">
  <div align="center"><center>
  <table
  border="1" width="45%" bordercolor="#008080">
    <tr>
      <td width="39%" align="center">　</td>
      <td width="61%" align="center">　 　</td>
    </tr>
    <tr>
      <td width="39%" align="center"><font color="#FF0000"><strong>订单号</strong></font></td>
      <td width="61%" align="center"><%=REQUEST("ORDER_NO")%></td>
    </tr>
    <tr>
      <td width="39%" align="center"><font color="#FF0000"><strong>金&nbsp; 额</strong></font></td>
      <td width="61%" align="center"><%=TOTAL%>
</td>
    </tr>
    <tr>
      <td width="39%" align="center"><font color="#FF0000"><strong>日&nbsp; 期</strong></font></td>
      <td width="61%" align="center"><%=year(date) & month(date) & day(date)%>　</td>
    </tr>
  </table>
  </center></div><div align="center"><center>
      <p><br>
      <hr>
        <font color="#000000"> </font>
    </center></div><div align="center"><center><p><input type="submit" value="立即转帐"  id=submit1 name=submit1></p>
  </center></div>
</form>

<p align="center">&nbsp; </p>


		<%
		END IF	'小于0
		Response.End 
END IF



	SQL = "SELECT * FROM ORDER_NAME where order_no = '" & REQUEST("ORDER_NO") & "'"
	RS.Open SQL,CONN,adOpenKeyset ,adLockReadOnly
		IF RS.RecordCount >0 THEN
		ELSE
			SQL = "SELECT SUM(CARD_TOTAL) AS TOTAL FROM ORDER_TEMP WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
			RS1.Open SQL,CONN,adOpenKeyset ,adLockReadOnly
				IF RS1.RecordCount >0 THEN
					TOTAL = RS1("TOTAL")
					'可以付款
					'取本用户的联系方法
					SQL = "SELECT * FROM MEMBER WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
					RS2.Open SQL,CONN,adOpenStatic ,adLockReadOnly
						IF RS2.RecordCount >0 THEN
							TURE_NAME = RS2("TRUE_NAME")
							POST_CODE = RS2("POST_CODE")
							ADDRESS = RS2("ADDRESS")
							YMEMAIL = RS2("EMAIL")
						END IF
					RS2.Close 
				ELSE
					'连接够物车
					Response.Redirect ("order_card.asp")
				END IF
			RS1.Close 
	
		SQL = "INSERT INTO ORDER_NAME VALUES('" & DL_USER & "','" & Request.Cookies ("USER_NAME") & "','" & TURE_NAME & "','" & REQUEST("ORDER_NO") & "',"
		SQL = SQL & TOTAL & ",'" & Request("PAY_MODE") & "','" & REQUEST("SEND_MODE") & "',#"
		SQL = SQL & REQUEST("SEND_DATE") & "#,'" & REQUEST("SEND_ADDR") & "','" & REQUEST("SEND_POST") & "','"
		SQL = SQL & REQUEST("SEND_DESC") & "',#" & DATE & "#,'未到')"
		CONN.Execute (SQL)

	'填加定单明晰数据库
		SQL1 = "SELECT * FROM ORDER_TEMP WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
		RS1.Open SQL1,CONN,adOpenStatic ,adLockReadOnly
			DO WHILE NOT RS1.EOF 
				SQL = "INSERT INTO ORDER_DESC VALUES('" & REQUEST("ORDER_NO") & "','" & RS1("CARD_NO") & "','"
				SQL = SQL & RS1("CARD_UNIT") & "'," & RS1("CARD_NUMBER") & "," & RS1("CARD_PRICE_A") & "," & RS1("CARD_TOTAL") & ")"		
				CONN.Execute (SQL)
			RS1.MoveNext 
			LOOP
			RS1.Close 
		'删除临时数据库
		SQL = "DELETE * FROM ORDER_TEMP WHERE USER_NAME = '" & Request.Cookies ("USER_NAME") & "'"
		CONN.Execute (SQL)	
		
		
		Set myMail = Server.CreateObject("CDONTS.NewMail")
		myMail.From = "sales@mensun.com"
		myMail.To = YMEMAIL
		myMail.Subject = "您的定单：" & REQUEST("ORDER_NO") & "已经成功订购"
					Abody="订单号码： " & REQUEST("ORDER_NO") & chr(13)
					Abody=Abody & "会员编号：" & USER_NAME & chr(13)
					Abody=Abody & "会员名称：" & TURE_NAME & chr(13)
					Abody=Abody & "总计价格：" & TOTAL & "元" & CHR(13)
					Abody=Abody & "订购日期：" & DATE & CHR(13)
					Abody=Abody & "付款状态：" & PAY_MODE & CHR(13)
					Abody=Abody & "请查收您的商品，具体商品详细清单请到网站查询！查询地址为：http://www.mensun.com/member/login.asp" & CHR(13)
					Abody=Abody & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13)
					Abody=Abody & "美慎成人用品购物中心 " & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13) & CHR(13)
		myMail.Body = ABody
		myMail.Send
	
		
		%>
		<html>
<head>
<title>收银台</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF">
<table width="636" border="0" cellspacing="1" cellpadding="0" bgcolor="#FF0000" align="center">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="20" >
        <tr> 
          <td> 
            <div align="center">订 单 提 交 成 功 ！</div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td> 
      <div align="center"> 
        <p>&nbsp;</p>
        <p><font color="#000000">您的订单已经发送，订单编号为：<font color="#FF0000"><%=REQUEST("ORDER_NO")%></font> 
          ,请记下此订单号，以便日后查询。</font></p>
        <p><font color="#000000">如果您选择的是“货到付款”且留了电话，我们将在24小时之内与您联系。</font></p>
        <p><font color="#000000">如果是邮购，请按照以下的汇款资料将货款打出，我们在在收到货款后立即为您发货。</font></p>
        <p><font color="#000000">您也可以进入服务中心查询您的订单及状况。谢谢！</font></p>
        <table width="60%" border="0" cellspacing="1" cellpadding="0" bgcolor="#FF8C8C">
          <tr bgcolor="#FF9999"> 
            <td height="25" width="50%"> 
              <div align="center">邮局汇款资料</div>
            </td>
            <td height="25"> 
              <div align="center">银行汇款资料</div>
            </td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td> <br>
              收款地址：上海市斜土路780号4号楼1F 
              <p>邮政编码：200023 </p>
              <p>收款人：上海美慎科技发展有限公司<br>
              </p>
              </td>
            <td> <br>
              开户行：中国银行漕河泾支行天分处 
              <p>帐号：044227-05160910004 </p>
              <p>户名：上海美慎科技发展有限公司 <br>
              </p>
              </td>
          </tr>
        </table>
        
      </div>
    </td>
  </tr>
</table>
<table width="775" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="299" class="word"> 
      <div align="center"> 
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      </div>
    </td>
  </tr>
</table>
<br>
</body>
</html>

		<%
		END IF	'小于0
		
END IF	'付款
%>
