endif
'只显示部分图书介绍,
'注意这里一定要用Convert函数对介绍内容进行HTML编码和加入换行符
strIntro=Convert(rsObj("introduce"))
iflenB(strIntro)>300then
strIntro=leftB(strIntro,300)
endif
%>
colspan=2>推荐图书
>
"height=<%=conBigImageHeight%>border=0>
"title="点击查看具体信息"><%=rsObj("Name")%>
[图书介绍]
<%=strIntro%>
市场价:<%=rsObj("marketPrice")%>元商城价:<%=rsObj("memberPrice")%>元
立即节省:<%=rsObj("marketPrice")-rsObj("memberPrice")%>元
">
放入购物车
<%
rsObj.Close()
setrsObj=Nothing
endsub
%>
程序5.1.1.6出版商搜索过成的实现
<%
'=================================================
'过程名:ShowProductTypeList
'作用:用下拉列表框显示出版商
'参数:nTypeId:出版商编号
'=================================================
subShowProductTypeList(nTypeId)
%>
全部出版商
<%callProductTypeToSelect(nTypeId)%>
<%
endsub
'=================================================
'过程名:ProductTypeToSelect
'作用:将出版商添加到下拉列表框中(无修饰)
'参数:nTypeId:出版商编号
'=================================================
subProductTypeToSelect(nTypeId)
dimstrSQL,rsObj
dimtempi
dimnID,szName
ifNotIsNumeric(nTypeId)then
nTypeId=0
endif
strSQL="SELECT*FROMProductTypeWHERESuperID=0"
setrsObj=conn.execute(strSQL)
if(rsObj.eoforerr)then
Response.Write"ERr!"
exitsub
else
dowhilenotrsObj.eof
nID=rsObj("id")
szName=rsObj("name")
Response.Write""
Response.WriteszName&""
rsObj.MoveNext
loop
endif
endsub
%>
<%
'=================================================
'过程名:ShowSearchForm
'作用:显示查找表单
'参数:
'myKeyword:在搜索产品文本框中显示的内容
'nTypeId:出版商编号
'=================================================
subShowSearchForm(myKeyword,nTypeId)
%>
订单号
"style="font-size:9pt;border:1pxsolid#7D85A2;background-color:rgb(210,232,255)"ID="Text2">
<%callShowProductTypeList(nTypeId)%>
<%
endsub
%>
程序清单5.1.1.7展示最新图书的实现代码
<%
'=================================================
'过程名:ShowNewProductPreview
'作用:预览最新图书
'参数:
' ShowType,ProductType,KeyWord,CurPage
'分别表示:显示类型:Top/All,类型ID,过滤关键字,当前页
'=================================================
SubShowNewProductPreview(ShowType,ProductType,KeyWord,CurPage)
%>
>新书快递
">
<%callShowNewProductPreviewList(ShowType,ProductType,KeyWord,CurPage)%>
">
<%
endsub
'=================================================
'过程名:ShowNewProductPreviewList
'作用:预览最新图书数据(无修饰)
'参数:
' ShowType,ProductType,KeyWord,CurPage
'分别表示:显示类型:Top/All,类型ID,过滤关键字,当前页
'=================================================
SubShowNewProductPreviewList(ShowType,ProductType,KeyWord,CurPage)
dimpage,PageCount,TotalCount
dimthisUrl
dimstrSrc,strTemp
dimstrSQL,rsObj
dimnum_row '每行显示的产品个数
dimrows '显示的产品行数
dimnMaxPerPage
dimnImageHeight
constconBaseImageHeight=90
dimi,j,k
dimszProductName
num_row=2 '每行放置的产品数
rows=6 '放置的产品行数
nMaxPerPage=num_row*rows
nImageHeight=conBaseImageHeight-15*(num_row-1)
Session("oldUrl")=thisUrl&"&page="&CurPage
ifShowType="Top"then
strSQL="SELECTtop10*FROMproductWHERERecommend>-1ORDERbyiddesc"
nMaxPerPage=10
elseifShowType="All"then
thisUrl="product.asp?ProductType="&ProductType&"&Keyword="&KeyWord
strSQL="SELECT*FROMproductWHEREid>1"
ifnot(KeyWord=""orIsEmpty(KeyWord))then
strSQL=strSQL&"ANDnamelike'%"&KeyWord&"%'"
endif
ifProductType>0then
strSQL=strSQL&"ANDProductType="&ProductType
endif
strSQL=strSQL&"ORDERbyiddesc"
endif
setrsObj=conn.execute(strSQL)
rsObj.pagesize=nMaxPerPage
if(CurPage=""orIsEmpty(CurPage))thenCurPage=1
ifnot(rsObj.eoforerr)thenrsObj.move(CurPage-1)*nMaxPerPage
page=CurPage
PageCount=rsObj.pageCount
TotalCount=rsObj.recordCount
Response.Write""
j=1
dowhilenot(rsObj.eoforerr)
if(jmodnum_row)=1then
strTemp=""
strTemp=strTemp&""
Response.WritestrTemp
endif
Response.Write""
ifrsObj("smallImg")="nothing"then
strSrc="images/noSmallImg.gif"
else
strSrc="smallimg/"&rsObj("smallImg")
endif
ifnot(KeyWord=""orIsEmpty(KeyWord))then
szProductName=Replace(rsObj("name"),KeyWord,""&KeyWord&"")
else
szProductName=rsObj("name")
endif
%>
"title="点击查看具体信息">
"border=0height="<%=nImageHeight%>">
"title="点击查看具体信息"><%=szProductName%>
市场价:<%=rsObj("marketPrice")%>元
商城价:<%=rsObj("memberPrice")%>元
">放入购物车
<%
ifnum_row=1then
Response.Write""
Response.Write"【顶部】"
Response.Write""
endif
%>
<%
Response.Write""
'根据一行是否结否来输出换行符以及插入一行分隔线
if(jmodnum_row)=0then
Response.Write""
%>
">
<%
else'如果没有结束,插一个竖的分隔线
Response.Write""
Response.Write""
endif
j=j+1
ifj>nMaxPerPagethenexitdo
rsObj.MoveNext
loop
'处理最后的空行
k=(j-1)modnum_row
ifnot(k=0)then
Response.Write""
Response.Write""
endif
Response.Write""
endsub
'=================================================
'过程名:ShowProduct
'作用:显示图书详细信息
'参数:无
'=================================================
subShowProduct(ProductId)
dimstrSQL,rsObj
ifIsEmpty(ProductId)thenProductId=0
strSQL="SELECT*FROMproductWHEREid="&ProductId
setrsObj=conn.execute(strSQL)
ifnot(rsObj.eoforerr)then
%>
">
"width=<%=conBigImagewWidth%>border="0"alt="点击放大查看">
<%=rsObj("name")%>(图片仅供参考)
市场价:<%=rsObj("marketPrice")%>元
书城价:<%=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
上一篇:ASP+ACCESS深水蓝文学网站(论文和程序)
下一篇:试析影响公路路面平整度的因素及应采取的施工措施