shopa_formatorder.asp

来自「ASP+SQL Server动态网站开发从基础到实践教程」· ASP 代码 · 共 252 行

ASP
252
字号
<%option explicit%>
<!-- #include file="shop$db.asp" -->
<%
'*******************************************************************
Dim Orders
Dim Items
Dim strSQL
Dim lngOrderid
Dim lngOcustomerid
Dim datOdate
Dim curOrderamount
Dim strOfirstname
Dim strOlastname
Dim strOemail
Dim strOaddress
Dim strOcity
Dim strOpostcode
Dim strOstate
Dim strOcountry
Dim strOphone
Dim strOfax
Dim strOcompany
Dim strOcardtype
Dim strOcardno
Dim strOcardname
Dim strOcardexpires
Dim strOcardaddress
Dim booOprocessed
Dim strOcomment
Dim curOtax
Dim datOpromisedshipdate
Dim datOshippeddate
Dim lngOshipmethod
Dim curOshipcost
Dim strOshipname
Dim strOshipcompany
Dim strOshipemail
Dim strOshipmethodtype
Dim strOshipaddress
Dim strOshiptown
Dim strOshipzip
Dim strOshipstate
Dim strOshipcountry
Dim lngOpaymethod
Dim strOther1
Dim strOther2
Dim Dbc
dim oid
dim rc
AdminPageHeader              ' Normal page header
ShopOpenDatabase dbc            ' Open the database 
oid=request.querystring("OID")
OpenOrder                   ' pen orders and items
FormatDetails
FormatCustomer
AdminPageTrailer             ' Normal Shop page trailer
ShopCloseDatabase   dbc        ' Close the database 
'
Sub OpenOrder
dim sql
strsql = "select * from orders where orderid=" & oid
Set Orders = Server.CreateObject("ADODB.Recordset")
Orders.open strSQL, dbc, adopenkeyset, adlockoptimistic
if (Orders.BOF and Orders.EOF) then
	WriteInfo  "There are no orders that match your search criteria."
        rc=4
        exit sub
else
      GetOrderData
      strSQL = "select * FROM oitems where orderid = " & Orders("orderid")
      Set Items = dbc.Execute(strSQL)
      if Items.EOF then
             writeInfo "Order items missing"
      else
       items.movefirst
      end if 
end if
end sub
Sub GetOrderData
lngOrderid = ORDERS("Orderid")
		lngOcustomerid = ORDERS("Ocustomerid")
		datOdate = ORDERS("Odate")
		curOrderamount = ORDERS("Orderamount")
		strOfirstname = ORDERS("Ofirstname")
		strOlastname = ORDERS("Olastname")
		strOemail = ORDERS("Oemail")
		strOaddress = ORDERS("Oaddress")
		strOcity = ORDERS("Ocity")
		strOpostcode = ORDERS("Opostcode")
		strOstate = ORDERS("Ostate")
		strOcountry = ORDERS("Ocountry")
		strOphone = ORDERS("Ophone")
		strOfax = ORDERS("Ofax")
		strOcompany = ORDERS("Ocompany")
		strOcardtype = ORDERS("Ocardtype")
		strOcardno = ORDERS("Ocardno")
		strOcardname = ORDERS("Ocardname")
		strOcardexpires = ORDERS("Ocardexpires")
		strOcardaddress = ORDERS("Ocardaddress")
		booOprocessed = ORDERS("Oprocessed")
		strOcomment = ORDERS("Ocomment")
		curOtax = ORDERS("Otax")
		datOpromisedshipdate = ORDERS("Opromisedshipdate")
		datOshippeddate = ORDERS("Oshippeddate")
		lngOshipmethod = ORDERS("Oshipmethod")
		curOshipcost = ORDERS("Oshipcost")
		strOshipname = ORDERS("Oshipname")
		strOshipcompany = ORDERS("Oshipcompany")
		strOshipemail = ORDERS("Oshipemail")
		strOshipmethodtype = ORDERS("Oshipmethodtype")
		strOshipaddress = ORDERS("Oshipaddress")
		strOshiptown = ORDERS("Oshiptown")
		strOshipzip = ORDERS("Oshipzip")
		strOshipstate = ORDERS("Oshipstate")
		strOshipcountry = ORDERS("Oshipcountry")
		lngOpaymethod = ORDERS("Opaymethod")
		strOther1 = ORDERS("Other1")
		strOther2 = ORDERS("Other2")
end sub

' Format details

Sub FormatDetails
dim totalprice
dim quantity
dim unitprice
dim mylink
Dim total
Dim isubtotal
dim mycolor
mycolor="#FFFFFF"
if boooprocessed<>0 then
   WriteInfo "该订单已经被处理"
end if 
Response.write "<b>订单编号: " & lngOrderid & "</b> on " & adFormatdate(datODate) & "<br>"
%>
<table   <table border="2" cellpadding="0" cellspacing="1" width="80%">
  <tr>
    <td bgcolor="#99CCCC" colspan="8"><font face="Arial, Arial, Helvetica">
	<font color="#FFFFFF" face="Arial"><strong>订单详细清单:</strong></font></td>
  </tr>
  <tr>
    <td bgcolor="#CFDFFC"><font face="Arial, Arial, Helvetica">商品名称</font></td>
    <td bgcolor="#CFDFFC"><font face="Arial, Arial, Helvetica">数量</font></td>
    <td bgcolor="#CFDFFC"><font face="Arial, Arial, Helvetica">单价</font></td>
    <td bgcolor="#CFDFFC"><font face="Arial, Arial, Helvetica">总价</font></td>
  </tr>

<%
	Do While Not Items.EOF
'link to catalog item in database
mylink=" <a href=shopa_editrecord.asp?database=" & Session("db") & "&table=products&idfield=catalogid&which=" & items("catalogid") & ">" & Items("ItemName") & "</a>"        
quantity=Items("numitems")
unitprice=Items("UnitPrice")
totalprice=quantity*unitprice
%>
<td width="60%" bgcolor="<%=mycolor%>"><font face="Arial, Arial, Helvetica"><% = mylink%></font></TD>
<td width="10%" bgcolor="<%=mycolor%>"><font face="Arial, Arial, Helvetica"><% = quantity%></font></TD>
<td width="10%" align="right" bgcolor="<%=mycolor%>"><font face="Arial, Arial, Helvetica"><% = formatcurrency(unitprice,2)%></font></TD>
<td width="10%" align="right" bgcolor="<%=mycolor%>"><font face="Arial, Arial, Helvetica"><% = formatcurrency(totalprice,2)%></font></TD>
<TR>
<% 
        isubtotal=isubtotal+totalprice
	Items.MoveNext
	Loop 
    AddOthers isubtotal, total, curoshipcost,curotax,"Format"
end sub

Sub FormatCustomer
%>
<TABLE border=1 cellPadding=1 cellSpacing=1 width=80% bordercolordark="#333399" bordercolorlight="#666699">
<%
  DoHeader "客户信息"
  Dofield "名", stroFirstName
  DoField "姓", stroLastName 
  DoField  "地址" ,stroAddress
  DoField  "市县", stroCity
  DoField  "省份" , stroState
  DoField  "邮编",stroPostCode 
  DoField  "国家",strocountry
  DoField   "Email",stroemail
  DoField  "电话",strophone
  DoField  "传真",strofax
  DoField  "公司",strocompany
  DoHeader  "支付信息"
  DoField   "卡类型",strocardtype
  DoField   "卡名称",strocardname
  Dofield   "卡号",strocardno
  DoField   "卡有效期",strocardexpires
  DoField   "卡地址",strocardaddress
  Doheader  "送货信息"
  DoField   "送货方式",stroshipmethodtype
  DoField   "送货价格", curoshipcost
  DoField   "收货人",stroshipname
  Dofield   "送货地址",stroshipaddress
  DoField   "收货城市",stroshiptown
  DoField    "省份",stroshipstate 
  Dofield   "邮编",stroshipzip
  Dofield   "公司",stroshipcompany
  DoField    "国家",stroshipcountry
%>
</TABLE>
<font face="Trebuchet MS, Arial, Helvetica"><font face="Arial, Arial, Helvetica">
<%
If Orders("ocomment") <> "" then
%>
     <h3>订单说明:</h3>
     <%=Orders("ocomment")%><br>     
<%end if%>
<%
End Sub
Sub WriteInfo (msg)
%>
<p align="center"><font face="Arial" color="#FF0000"><b><%=msg%></b></font></p>
<%
end sub
Sub DoHeader (mytext)
%>
  <TR>
 <TD align="left" colspan=2 bgColor=darkblue><font face="Trebuchet MS, Arial, Helvetica"><font face="Arial, Arial, Helvetica"><FONT color=white face="" style="BACKGROUND-COLOR: #00008b">
        <STRONG><%=mytext%></STRONG></FONT> </font></font></TD>
 </TR>
<%
end sub
Sub DoField (fieldname,fieldvalue)
%>
 <TR>
 <TD align="left"><font face="Trebuchet MS, Arial, Helvetica" size="2"><%=fieldname%></font></TD>
 <TD align="left"><font face="Trebuchet MS, Arial, Helvetica" size="2"><b><%=fieldvalue%></b></font></TD></TR>
<%
end sub
Function AdFormatDate(indate)
dim monthname
Dim outdate
Dim m
Dim d
dim yyyy
 monthname=array("Jan","Feb","Mar","Apr", _
            "May","Jun","Jul","Aug", _
            "Sep","Oct","Nov","Dec")

m=DatePart("m",indate)
m=M-1
outdate = monthname(m) & " "
d=Datepart("d", indate)
outdate = outdate & d
yyyy=Datepart("yyyy",indate)
outdate = outdate & " " & yyyy
AdFormatdate=outdate
end function

%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?