| 论文首页哲学论文经济论文法学论文教育论文文学论文历史论文理学论文工学论文医学论文管理论文艺术论文 | 
(转载自中国科教评价网www.nseac.com )
                                                                          
 在例程3-11得到产品对象后,然后调用类似one(DIELDNAME)方法便可以得到产品名称等属性然后结合HTML控制便可以得到图3-10所示的效果。
 主页面主要包含头、尾文件。经过处理得到产品ID,如果没有就跳转到系统首页。
 Commentone.asp页面主要显示用户针对该产品的所有评论,例程3-12为Commentone.asp页面实现的参考代码。
    (科教范文网http://fw.nseac.com) 
                     例程3-12  Commentone.asp页面实现的参考代码
                                                                              
 <%
   dim dbc,rs,query
   shopopendatabase dbc
     query =  "select TOP 10 * from comment where  productid = " & productid & " order by lasttime desc"
     set rs = dbc.execute(query)
     dim content,ptime,pren,preply
     dim n
     n=0
     Do WHILE not rs.EOF and n<10
  content= rs("comment")
  ptime = rs("lasttime")
  pren = rs("nickname")
  preply = rs("reply")
  n=n+1
 %>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="text6">
  <tr>
  <td style="padding-left:20px;padding-right:5px">
    <%=content%>
          </td>
          <td width="60"> <%=ptime%> </td>
          <td  width="45"> <%=pren%> </td>
  </tr>
 <%
  if (preply<>"") then   
(转载自http://zw.NSEaC.com科教作文网)
我的购物车页面主要暂存用户选择的预购买的产品,图3-21为购物车页面。
. 
                         图3-21  购物车页面 (转载自科教范文网http://fw.nseac.com) 
Cart.asp购物车页面代码如例程3-13所示。
                        例程3-13  cart.asp购物车页面代码
                                                                             
<%
dim myaction
dim cartstr,cartnumstr
DimMyProductArray(20), MyNumArray(20),totalnum,MyProductArrayTmp,MyNumArrayTmp
cartstr = getCartFromCookie()
cartnumstr=getCartNumFromCookie()
 
if (cartstr=NULL or cartstr ="") then
cartstr =""
end if
if (cartnumstr=NULL or cartnumstr ="") then
cartnumstr =""
end if
MyProductArrayTmp = Split(cartstr, ",",-1,1) 
MyNumArrayTmp = Split(cartnumstr, ",",-1,1) 
'response.write "cartstr=" & cartstr &"<br>"
'response.write "cartnumstr=" & cartnumstr &"<br>"
'response.write "UBound(MyProductArrayTmp)=" &UBound(MyProductArrayTmp) &"<br>"
'response.write "LBound(MyProductArrayTmp)=" &LBound(MyProductArrayTmp) &"<br>"
'response.write "UBound(MyNumArrayTmp=" &UBound(MyNumArrayTmp) &"<br>"
'response.write "LBound(MyNumArrayTmp)=" &LBound(MyNumArrayTmp) &"<br>"
If(UBound(MyProductArrayTmp)<>UBound(MyNumArrayTmp)or LBound(MyProductArrayTmp)<>LBound(MyNumArrayTmp)) then
cartstr =""
cartnumstr =""
setCartToCookie cartstr,cartnumstr,0,0
 MyProductArrayTmp = Split(cartstr, ",",-1,1) 
 MyNumArrayTmp = Split(cartnumstr, ",",-1,1)  (科教作文网http://zw.ΝsΕac.cOM编辑) 
end if
dim n
For n =LBound(MyProductArrayTmp) to  UBound(MyProductArrayTmp)
MyProductArray(n)=MyProductArrayTmp(n)
MyNumArray(n)=MyNumArrayTmp(n)
Next
totalnum=getCartTotalNumFromCookie()
if (totalnum=NULL or totalnum="") then
totalnum=0
end if
myaction=request("myaction")
dim productidif (myaction="add") then
productid=request("productid")
if (IsValid(productid)) then
if (cartstr=NULL or cartstr ="") then
 cartstr=productid
 cartnumstr=1
MyProductArray(0)=productid
 MyNumArray(0)=1
 totalnum=1
else
Dim i,IsExist
 IsExist="false"
For i = 0 to CInt(totalnum)-1
if (MyProductArray(i) =productid) then
 IsExist="true"
 exit for
 end if 
if (IsExist="true") then
MyNumArray(i)=MyNumArray(i)+1    
 cartnumstr=""
For i = 0 to CInt(totalnum)-1
 if (cartnumstr="") then
cartnumstr=CStr(MyNumArray(0))
 else
cartnumstr=CStr(cartnumstr)+","+CStr(MyNumArray(i))
 end if 
 Next
else
cartstr=CStr(cartstr)+","+CStr(productid)
cartnumstr=cartnumstr+",1"
MyProductArray(totalnum)=productid
MyNumArray(totalnum)=1
totalnum=totalnum+1
end if 
end if
setCartToCookie cartstr,cartnumstr,totalnum,0
response.redirect("cart.asp")
response.end
else
 response.write "增加的产品id不合法!<br>" 
end if 
else 
 if(myaction="del") then
productid=request("productid")
if (IsValid(productid)) then
 cartstr=""
cartnumstr=""
For i = 0 to CInt(totalnum)-1
 if (productid<>MyProductArray(i)) then
 if (cartnumstr="") then
cartstr=CStr(MyProductArray(i))
cartnumstr=CStr(MyNumArray(i)) (科教作文网http://zw.ΝsΕAc.com发布) 
end
cartstr=cartstr+","+CStr(MyProductArray(i))
cartnumstr=CStr(cartnumstr)+","+CStr(MyNumArray(i))
 end if 
end if
 Next
end if
else 
 if(myaction="update") then 
 cartstr="update"
else
end if
end if
end ifsetCartToCookie cartstr,cartnumstr,totalnum,0
ShowCart("yes")
%>
   
3.5.4结帐处理
    
 当用户把产品放进购物车中,单击“结帐”按钮时,需要显示结帐页面,结帐页面如图3-22所示。
 结帐页面对应的文件是check.asp.从图3-22可以看出,在结帐页面需要先显示用户决定购买的产品信息,然后提供表单让用户输入姓名,选择送货的时间等。
 
 
                             图3-22 网站结帐页面
 例程3-14为结帐页面表单的参考代码
 
                           例程3-14  结帐页面表单的参考代码
                                                                          
<%
dim cartstr
cartstr = getCartFromCookie()
if (cartstr=NULL or cartstr ="") then
response.redirect "Cart.asp"
response.end
end if
dim payName,payPhone,payEmail,payAddress
if (session("userautoid")<=0) then (科教范文网 fw.nseac.com编辑发布) 
payName=""
payPhone=""
payEmail=""
payAddress=""
else
dim dbc,query,rs
shopopendatabase dbc
query =  "select * from myUser where autoid = " & session("userautoid")
set rs = dbc.execute(query)
Ifrs.EOF ThepayName=rs("realname")payPhone=rs("phone")payEmail=rs("userid")payAddress=rs("Address")end if
   closerecordset rs 
   shopclosedatabase dbc
end if
%>
<html>
<head>
<title>绿植鲜花玩具礼品店</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/lvzhi.css" type="text/css">
<STYLE type=text/css>TD {
    FONT-SIZE: 12px; FONT-FAMILY: "宋体"
}
</STYLE>
<script language="java script">
    function setReceiverFormVisible(vGet)
        {if(vGet=='1'){document.all.receiverinfo_form.style.display='none';}else{document.all.receiverinfo_form.style.display='block'}
function checkinput(){var payName=document.mymainform.MypayName.value;
 if (payName=="")
{alert("付款人名称不能为空!");
document.mymainform.MypayName.focus();
eturn false;}
var payPhone=document.mymainform.payPhone.value;
 if (payPhone=="")
{alert("付款人电话不能为空!");
document.mymainform.payPhone.focus();
eturn false;}
f(document.mymainform.myrec2.checked==true)
{var recName=document.mymainform.recName.value;
 if (recName==""){alert("收货人名称不能为空!");
document.mymainform.recName.focus();
eturn false;}
var recPhone=document.mymainform.recPhone.value;
 f (recPhone==""){alert("收货人电话不能为空!");
document.mymainform.recPhone.focus();
return false;}}
return true;}
</script>