城价:<%=rsObj("memberPrice")%>元
立即节省:<%=rsObj("marketPrice")-rsObj("memberPrice")%>
元
">放入购物车
图书介绍:
<%=convert(rsObj("introduce"))%>
其他说明:
<%=convert(rsObj("Remark"))%>
返回`
<%
'修改点击率+1
dimnID
nID=RealString(Request.QueryString("id"))
strSQL="UpdateproductsethitNum=hitNum+1WHEREid="&nID
conn.execute(strSQL)
endif
setrsObj=nothing
endsub
%>
5.1.2图书信息流览模块
程序清单5.1.2.1图书预览列表和查询功能实现代码
<%ShowHeadAndMenu()%>
<%
dimKeyword
dimProductType
dimpage
Keyword=RealString(Request.Form("Keyword"))
'因为Producttype的来源可能是QueryString,也可能是Form
ProductType=RealString(Request("ProductType"))
page=RealString(Request.QueryString("page"))
ifProductType=""thenProductType=0
%>
cellPadding=0width="100%"bgColor=#666666
borderColorLight=#aaaaaaborder=1ID="Table18">
style="border-collapse:collapse"bordercolor="#111111"ID="Table19">
<%callShowSearchForm(Keyword,ProductType)%>
<%
ifKeyword<>""then
Response.Write"搜索关键词"&Keyword&"的结果为......"
endif
%>
cellPadding=0width="100%"bgColor=#666666
borderColorLight=#aaaaaaborder=1ID="Table2">
<%
callShowNewProductPreview("All",ProductType,Keyword,page)%>
程序清单5.1.2.2图书详细信息实现代码
<%ShowHeadAndMenu()%>
cellPadding=0width="100%"bgColor=#666666
borderColorLight=#aaaaaaborder=1ID="Table2">
<%
callShowProduct(RealString(Request.QueryString("id")))
%>
5.1.3购物车管理模块
程序清单5.1.3.1读取参数操作购物车实现代码
<%ShowHeadAndMenu()%>
cellPadding=0width="100%"bgColor=#666666
borderColorLight=#aaaaaaborder=1ID="Table2">
<%
dimreqProductID,reqClear,reqModify
dimproducts,tempQuantity
dimi,j
dimHead
'读取参数
reqProductID=Request.QueryString("productID")
'此句可以排除reqProductID为空和是非数字的情况
ifNotIsNumeric(reqProductID)then
reqProductID="0"
ResPonse.Write"您所选够的商品不存在,请重试......"
Response.End
endif
reqClear=Request.QueryString("clear")
reqModify=Request.Form("Modify")
'如果reqProductID有效,刚将它加入到购物车
ifreqProductID<>"0"then
PutToCartreqProductID,"1"
endif
Head="以下是您所选购的物品清单"
'如果是清空购物车命令,刚清空购物车
IfreqClear="yes"Then
Session("productList")=""
Session("quantityList")=""
EndIf
'如果单击了"确认修改",则按照当前设置重新装载购物车
IfreqModify="Yes"Then
Session("productList")=""
Session("quantityList")=""
'此处Form中的productID为每个商品对应的复选框
'注意这里明确使用Request.QueryString和Request.Form的作用
'如果从表单提交的以个以上的同名参数,则值之间以英文逗号分隔
products=Split(Request.Form("productID"),",")
ForI=0ToUBound(products)
j=UBound(products)-i
tempQuantity=Request.Form("quantity"&products(j))
iftempQuantity=""thentempQuantity=1
PutToCartproducts(j),tempQuantity
Next
EndIf
'Response.WriteSession("productList")
'Response.Write""
'Response.WriteSession("quantityList")
'Response.Write""
'显示购物车
callShowCart()
%>
程序清单5.1.3.2购物车基本函数实现代码
<%
'=================================================
'过程名:PutToCart
'作用:显示购物车图书数据(无修饰)
'参数:
' productID:放入购物车的图书编号
' quantity,:放入图书数量
'=================================================
SubPutToCart(productID,quantity)
dimproductList,quantityList
'放到本地变量中,以期提高效率
productList=Session("productList")
quantityList=Session("quantityList")
IfLen(productList)=0Then
Session("productList")=productID
Session("quantityList")=quantity
ElseIfInStr(productList&",",productID&",")<=0Then
Session("productList")=productID&","&productList
Session("quantityList")=quantity&","&quantityList
EndIf
EndSub
'=================================================
'过程名:ShowCartTable
'作用:显示购物车图书数据(无修饰)
'参数:无
'=================================================
subShowCart()
dimcanPay
%>
>购物清单
<%=Head%>
<%
canPay=ShowCartTable()
%>
ID="Submit1">
';"style="font-size:9pt"ID="Button1">
ID="Button2">
ID="Button3">
注意:注意:改变图书数量和减少图书种类需按"确认更改"按钮/font>
<%
endsub
'=================================================
'过程名:ShowCartTable
'作用:显示购物车图书数据(无修饰)
'参数:无
'=================================================
functionShowCartTable()
dimSum,canPay
dimquantityArray,productArray,quantity,i
dimstrSQL,rsObj
%>
购买
图书编号
图书名称
图书价格
图书数量
总价
<%
Sum=0
IfLen(Session("productList"))<>0Then
quantityArray=Split(Session("quantityList"),",")
productArray=Split(Session("productList"),",")
fori=0toUBound(productArray)
strSQL="SELECT*FROMproductWHEREid="&productArray(i)
setrsObj=conn.execute(strSQL)
ifNotrsObj.EOForerrthen
quantity=quantityArray(i)
Ifquantity<=0Thenquantity=1
Sum=Sum+rsObj("memberPrice")*quantity
%>
"CheckedID="Checkbox1">
<%=rsObj("id")%>
<%=rsObj("name")%>
<%=rsObj("memberPrice")%>
"Value="<%=quantity%>"Size="4"Up="checknum(quantity<%=rsObj("id")%>)"ID="Text1">
<%=rsObj("memberPrice")*quantity%>元
<%
endif
setrsObj=nothing
next
canPay=""
else
canPay="disabled"
endif
%>
总价格:<%=Sum%>元人民币
<%
'返回价格总数,以标识购物车内是否有图书
ShowCartTable=canPay
endfunction
%>
functioncl
上一篇:ASP+ACCESS深水蓝文学网站(论文和程序)
下一篇:思想品德教学中学生创新能力的培养