?? xt_order_add.asp
字號(hào):
<%@ LANGUAGE=vbscript %>
<!--#INCLUDE FILE="include/shop.asp" -->
<!--#INCLUDE FILE="include/util.asp" -->
<% REM ##########################################################################%>
<% REM #%>
<% REM CONFIRMED.ASP #%>
<% REM 訂單確認(rèn) #%>
<% REM #%>
<% REM Copyright (c) 1996-98 Microsoft Corporation. All rights reserved. #%>
<% REM #%>
<% REM ##########################################################################%>
<%
cardnum=request("cardnum")
password=request("password")
dim errorList
cmdTemp.CommandText = "SELECT * FROM CARRIAGE"
Set recordSet = Server.CreateObject("ADODB.Recordset")
recordSet.Open cmdTemp, , adOpenKeyset, adLockOptimistic
while not(recordset.EOF)
if recordset("id")="1" then cost1=recordset("cost")
if recordset("id")="2" then cost2=recordset("cost")
if recordset("id")="3" then cost3=recordset("cost")
if recordset("id")="4" then cost4=recordset("cost")
recordset.MoveNext
wend
recordset.Close
cmdTemp.CommandText = "SELECT * FROM basket WHERE session_id = '" & session.SessionID & "' order by product_id"
Set recordSet = Server.CreateObject("ADODB.Recordset")
recordSet.Open cmdTemp, , adOpenKeyset, adLockOptimistic
if recordset.RecordCount =0 then
errorList=errorList & "您的購物籃是空的。<br>"
end if
if (Isnull(ShopperID) or isempty(ShopperID)) then
errorList=errorList & "用戶未登錄或操作超時(shí)。<br>"
end if
bill_to_name = checklength(Request("bill_to_name"), 25)
if IsNull(bill_to_name) then
errorList=errorList & "付款人必須在1到25個(gè)漢字。<br>"
end if
bill_to_street = checklength(Request("bill_to_street"), 120)
if IsNull(bill_to_street) then
errorList=errorList & "付款人地址必須在1到120個(gè)漢字。<br>"
end if
bill_to_state = checklength(Request("bill_to_state"),15)
if IsNull(bill_to_state) then
errorList=errorList & "付款人位置付款人地址必須在1到15個(gè)漢字。<br>"
end if
bill_to_method = checklength(Request("bill_to_method"),4)
if IsNull(bill_to_method) then
errorList=errorList & "付款方式必須在1到4個(gè)漢字。<br>"
end if
select case bill_to_method
case "國際匯兌"
bill_to_method="1"
case "西聯(lián)匯款"
bill_to_method="2"
case "貨到付款"
bill_to_method="3"
case "儲(chǔ)蓄卡付"
bill_to_method="4"
end select
bill_to_city = checklength(Request("bill_to_city"), 25)
if IsNull(bill_to_city) then
errorList=errorList & "付款人城市必須在1到25個(gè)漢字。<br>"
end if
bill_to_zip = checklength(Request("bill_to_zip"), 15)
if IsNull(bill_to_zip) then
errorList=errorList & "付款人郵編位置必須在1到15個(gè)數(shù)字。<br>"
end if
bill_to_phone = checklength(Request("bill_to_phone"), 20)
if IsNull(bill_to_phone) then
errorList=errorList & "付款人電話必須是1到20個(gè)字符。<br>"
end if
ship_to_name = checklength(Request("ship_to_name"), 25)
if IsNull(ship_to_name) then
errorList=errorList & "收貨人必須在1到25個(gè)漢字。<br>"
end if
ship_to_street = checklength(Request("ship_to_street"), 120)
if IsNull(ship_to_street) then
errorList=errorList & "收貨人地址必須在1到120個(gè)漢字。<br>"
end if
ship_to_state = checklength(Request("ship_to_state"),15)
if IsNull(ship_to_state) then
errorList=errorList & "收貨人位置付款人地址必須在1到15個(gè)漢字。<br>"
end if
ship_to_city = checklength(Request("ship_to_city"), 25)
if IsNull(ship_to_city) then
errorList=errorList & "收貨人城市必須在1到25個(gè)漢字。<br>"
end if
ship_to_zip = checklength(Request("ship_to_zip"), 15)
if IsNull(ship_to_zip) then
errorList=errorList & "收貨人郵編位置必須在1到15個(gè)數(shù)字。<br>"
end if
ship_to_phone = checklength(Request("ship_to_phone"), 20)
if IsNull(ship_to_phone) then
errorList=errorList & "收貨人電話必須是1到20個(gè)字符。<br>"
end if
description = checklength(Request("note"), 100)
ship_to_email = checklength(Request("ship_to_email"), 50)
bill_to_email = checklength(Request("bill_to_email"), 50)
'計(jì)算運(yùn)費(fèi)
if trim(bill_to_state)="其它" then
pay_currency="美金"
else
pay_currency="人民幣"
end if
if trim(ship_to_state)="北京" and pay_currency="人民幣" then
ship_fee=cost1
elseif trim(ship_to_state)<>"北京" and pay_currency="人民幣" then
ship_fee=cost2
elseif trim(ship_to_state)="北京" and pay_currency="美金" then
ship_fee=cost3
else
ship_fee=cost4
end if
%>
<%if errorList="" then
cmdTemp.CommandText = " select seq_orderid.nextval as orderid from dual"
Set rstTemp = Server.CreateObject("ADODB.Recordset")
rstTemp.Open cmdTemp, , adOpenStatic, adLockReadOnly
orderid=rstTemp("orderid")
rstTemp.Close
Set rstOrder = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT * FROM basket WHERE session_id = '" & session.SessionID & "' order by product_id"
rstOrder.Open cmdTemp, , adOpenKeyset, adLockReadOnly
total_price=0
For i = 1 to rstOrder.RecordCount
If rstOrder.EOF then exit for
quantity=rstOrder("quantity").value
if pay_currency="美金" then
adjusted_price=rstOrder("list_price").value
else
adjusted_price=rstOrder("rmb_price").value
end if
subtotal_price=formatnumber(quantity)*formatnumber(adjusted_price,2)
total_price=total_price+subtotal_price
rstOrder.MoveNext
next
rstOrder.Close
total_price=total_price+formatnumber(ship_fee)
if bill_to_method="4" then
tradesum=cstr(clng(total_price*100))
set check=server.CreateObject ("eprojm.epro")
password=check.epropassword (cardnum,password)
checkstr=check.eprocmp(cardnum)
set connbj=server.CreateObject ("adodb.connection")
connbj.Open "DSN=Web ORA;UID=zj;PWD=zj;"
'檢驗(yàn)用戶
set rs=server.CreateObject ("adodb.recordset")
rs.Open "select * from tbaccount where cardnum='" + cardnum + "'",connbj,1,3
if rs.RecordCount <>1 then
errorList="您所輸入的賬號(hào)不存在,請您查實(shí)后再輸!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'Response.Write checkstr
'Response.Write "<br>"
'Response.Write rs("checkstr")
'Response.End
if rs("checkstr")<>checkstr then
errorList="您所輸入的賬號(hào)有誤,請您查實(shí)后再輸!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'檢驗(yàn)口令
if password<>rs("password") then
errorList="您所輸入的密碼有誤,請您查實(shí)后再輸!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'檢驗(yàn)死戶
if rs("state")<>0 then
errorList="您的賬戶先被凍結(jié),請您與郵儲(chǔ)部門聯(lián)系!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'檢驗(yàn)待扣額
'Response.Write check.eprorecremains(rs("cardnum"),rs("remains"))
'Response.End
remains=clng(check.eprorecremains(rs("cardnum"),rs("remains")))
'Response.Write check.eprorecremains(rs("cardnum"),rs("remains"))
'Response.End
total=clng(rs("recoup"))+remains
if (clng(rs("recoup"))<0) or (remain<0) or (total<>20000) then
errorList="您的賬戶有問題,請您去郵儲(chǔ)部門查實(shí)!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'檢驗(yàn)余額是否足夠
remains=remains-clng(tradesum)
if remains<0 then
errorList="您的余額不足!"
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
%><!--#INCLUDE FILE="include/error.asp" --><%
Response.End
else
'交易開始
connbj.BeginTrans
recoup=clng(rs("recoup"))+clng(tradesum)
relen=len(cstr(recoup))
for i=0 to 9-relen-1
recoup="0"+cstr(recoup)
next
'Response.Write remains
'Response.End
remains=check.eproremains(cardnum,remains)
sql1="update tbaccount set recoup='" + recoup + "',remains='" + remains + "' where cardnum='" + cardnum + "'"
connbj.Execute (sql1)
sql2="insert into tblog (tradenum,cardnum,tradesum) values (trade_id.nextval,'" + cardnum + "','" + tradesum + "')"
connbj.Execute (sql2)
rstOrder.Open "order_item",conn, adOpenKeyset, adLockOptimistic
for i=1 to recordset.RecordCount
rstOrder.AddNew
rstOrder("order_id")=orderid
rstOrder("Product_id")=recordset("Product_id")
rstOrder("name")=recordset("name")
rstOrder("Quantity")=recordset("Quantity")
if pay_currency="美金" then
rstOrder("Adjusted_price")=recordset("List_price")
else
rstOrder("Adjusted_price")=recordset("Rmb_price")
end if
rstOrder.Update
recordset.MoveNext
next
rstOrder.Close
rstOrder.Open "shop_order",, adOpenKeyset, adLockOptimistic
rstOrder.AddNew
rstOrder("order_id")=orderid
rstOrder("shoppername")=ShopperID
rstOrder("currency")=pay_currency
rstOrder("ship_fee")=ship_fee
rstOrder("total")=total_price
rstOrder("status")="未交易"
rstOrder("date_entered")=now
rstOrder("date_changed")=now
rstOrder("sname")=ship_to_name
rstOrder("sstreet")=ship_to_street
rstOrder("scity")=ship_to_city
rstOrder("sprovince")=ship_to_state
rstOrder("scountry")="中國"
rstOrder("sphone")=ship_to_phone
rstOrder("semail")=ship_to_email
rstOrder("szip")=ship_to_zip
rstOrder("bname")=bill_to_name
rstOrder("bstreet")=bill_to_street
rstOrder("bcity")=bill_to_city
rstOrder("bprovince")=bill_to_state
rstOrder("paymode")=bill_to_method
rstOrder("bcountry")="中國"
rstOrder("bphone")=bill_to_phone
rstOrder("bemail")=bill_to_email
rstOrder("bzip")=bill_to_zip
rstOrder("description")=description
rstOrder.Update
rstOrder.Close
recordset.Close
conn.Execute "Delete FROM basket WHERE session_id = '" & session.SessionID & "'"
' Response.Write session.SessionID
' Response.End
'事務(wù)處理試驗(yàn)
sql33="delete from ggg"
' connbj.Execute (sql33)
connbj.CommitTrans
end if
end if
end if
end if
end if
end if
set check=nothing
rs.Close
set rs=nothing
connbj.Close
set connbj=nothing
'Response.Write "交易結(jié)束"
else
cmdTemp.CommandText = " select seq_orderid.nextval as orderid from dual"
Set rstTemp = Server.CreateObject("ADODB.Recordset")
rstTemp.Open cmdTemp, , adOpenStatic, adLockReadOnly
orderid=rstTemp("orderid")
rstTemp.Close
Set rstOrder = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT * FROM basket WHERE session_id = '" & session.SessionID & "' order by product_id"
rstOrder.Open cmdTemp, , adOpenKeyset, adLockReadOnly
total_price=0
For i = 1 to rstOrder.RecordCount
If rstOrder.EOF then exit for
quantity=rstOrder("quantity").value
if pay_currency="美金" then
adjusted_price=rstOrder("list_price").value
else
adjusted_price=rstOrder("rmb_price").value
end if
subtotal_price=formatnumber(quantity)*formatnumber(adjusted_price,2)
total_price=total_price+subtotal_price
rstOrder.MoveNext
next
rstOrder.Close
total_price=total_price+formatnumber(ship_fee)
rstOrder.Open "order_item",conn, adOpenKeyset, adLockOptimistic
for i=1 to recordset.RecordCount
rstOrder.AddNew
rstOrder("order_id")=orderid
rstOrder("Product_id")=recordset("Product_id")
rstOrder("name")=recordset("name")
rstOrder("Quantity")=recordset("Quantity")
if pay_currency="美金" then
rstOrder("Adjusted_price")=recordset("List_price")
else
rstOrder("Adjusted_price")=recordset("Rmb_price")
end if
rstOrder.Update
recordset.MoveNext
next
rstOrder.Close
rstOrder.Open "shop_order",, adOpenKeyset, adLockOptimistic
rstOrder.AddNew
rstOrder("order_id")=orderid
rstOrder("shoppername")=ShopperID
rstOrder("currency")=pay_currency
rstOrder("ship_fee")=ship_fee
rstOrder("total")=total_price
rstOrder("status")="未交易"
rstOrder("date_entered")=now
rstOrder("date_changed")=now
rstOrder("sname")=ship_to_name
rstOrder("sstreet")=ship_to_street
rstOrder("scity")=ship_to_city
rstOrder("sprovince")=ship_to_state
rstOrder("scountry")="中國"
rstOrder("sphone")=ship_to_phone
rstOrder("semail")=ship_to_email
rstOrder("szip")=ship_to_zip
rstOrder("bname")=bill_to_name
rstOrder("bstreet")=bill_to_street
rstOrder("bcity")=bill_to_city
rstOrder("bprovince")=bill_to_state
rstOrder("paymode")=bill_to_method
rstOrder("bcountry")="中國"
rstOrder("bphone")=bill_to_phone
rstOrder("bemail")=bill_to_email
rstOrder("bzip")=bill_to_zip
rstOrder("description")=description
rstOrder.Update
rstOrder.Close
recordset.Close
conn.Execute "Delete FROM basket WHERE session_id = '" & session.SessionID & "'"
end if
%>
<html>
<head>
<title>確認(rèn)</title>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK REL=stylesheet HREF="ecom.css" TYPE="text/css">
</head>
<body topmargin="0">
<!--#INCLUDE FILE = "include/toolbar.asp" -->
<br>
<table border="0" width="425" align="center">
<tr>
<td align="center" height=25 bgColor=<%=tdcolor4%>>
多謝光臨,您的訂單號(hào)是<%=orderid%>。
</td>
</tr>
</table>
<!--#INCLUDE FILE = "include/footer.asp" -->
</body>
</html>
<%else%>
<!--#INCLUDE FILE="include/error.asp" -->
<%end if%>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -