| 
                        本管理程序的主要功能有:
 1、图书列表展示功能;2、图书放置购物车、移去购物车和清空购物车功能;3、购书结帐功能;4、新会员注册功能。 
Iindex.asp 首页。框架结构。上框架连接Top.htm页面,下框架连接Booklist页面。 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>网上图书管理系统--图书列表</title> 
</head> 
<frameset rows="80,*" cols="*" frameborder="NO" border="0" framespacing="0"> 
<frame src="top.htm" name="topFrame" scrolling="NO" noresize > 
<frame src="booklist.asp" name="mainFrame"> 
</frameset> 
<noframes> 
<body> 
</body> 
</noframes> 
</html> 
Conn.asp 数据库连接文件。在所有与数据库连接的页面中只要包括该文件,即可以连接和打开数据库。 
'创建连接对象 
<% set Conn=server.CreateObject("ADODB.Connection") 
'连接字符串 
strSQL="Driver={Microsoft Access Driver (*.mdb)};DBQ=" &_ 
server.MapPath("bookshop.mdb") 
conn.open(strSQL) 
%> 
Top.htm 图书列表 Top 页。仅仅是一个图片标题页。 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>网上图书管理系统</title> 
<link href="style.css" rel="stylesheet"> 
</head> 
<body topmargin="0"> 
<table width="770" height="124" border="0" cellpadding="-2" cellspacing="-2"> 
<tr> 
<td background="images/bg_booklist.gif"> </td> 
</tr> 
</table> 
</body> 
</html> 
Booklist 以表格的形式分页显示出所有的图书。 
本页面以表格的形式分页显示出所有记录。实现过程如下: 
1、使用一个包含文件,创建一个数据库连接对象; 
2、创建一个记录集对象; 
3、创建一个表格,第一行用来显示字段名; 
4、判断记录指针是不是到了记录的头部或尾部之外,若是显示提示信息,若不是,则开始进行提取当前页的每一条记录和进行分页; 
5、通过Do While 循环语句,将当前页的每一条记录读取出来; 
6、通过For 循环将除当前页码之外的每一个页码做一个超连接; 
7、关闭记录集对象并释放其所占用的所有资源; 
8、关闭连接对象并释放其所占用的所有资源。 
<%@LANGUAGE="VBSCRIPT"%> 
<!--使用一个包含文件,创建一个数据库连接对象--> 
<!--#include file="Connections/conn.asp" --> 
<% 
'创建一个记录集对象。 
set rs_booklist=Server.CreateObject("ADODB.RecordSet") 
sql="SELECT BookID, BookName, bnumber FROM DB_bookinfo ORDER BY bnumber DESC,bookname" 
rs_booklist.open sql,conn,1,3 
%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>图书列表</title> 
<link href="style.css" rel="stylesheet"> 
<style type="text/css"> 
<!-- 
body,td,th { 
font-size: 11pt; 
color: #009999; 
line-height: 1.5; 
} 
body { 
background-image: url(images/bg1.jpg); 
} 
--> 
</style> 
</head> 
<body leftmargin="0" topmargin="0"> 
<div align="center"> 
<!--创建一个表格,第一行用来显示字段名。--> 
<table width="644" border="1" bordercolor="#cccc99" background="images/bg.jpg"> 
<tr> 
<td height="20"><div align="center"><strong>书号</strong></div></td> 
<td height="20"><div align="center"><strong>书名</strong></div></td> 
<td height="20"><div align="center"><strong>数量</strong></div></td> 
<td height="20"> </td> 
</tr> 
<!--*******分页开始******************--> 
<% 
'判断记录指针是不是到了记录的头部或尾部之外,若是显示提示信息,若不是,则开始进行提取当前页的每一条记录和进行分页。 
If rs_booklist.Bof AND rs_booklist.Eof Then 
Response.Write "没有数据" 
Else 
'分页显示 
Dim page_size '此变量用来存放每一页的记录数。 
Dim page_nonce '此变量用来存放当前页的页码。 
Dim page_total '此变量用来存放总页数。 
page_size=7 '将第一页记录数设置为7条。 
rs_booklist.PageSize=page_size '将page_size变量中的值赋给rs_booklist记录集对象的页面大小(PageSize)属性。 
page_total=rs_booklist.PageCount '将rs_booklist记录集对象的页面个数(PageCount)属性赋给变量page_total。 
'下面5句,是判断网页是不是刚打开,若是,则将1赋给变量page_nonce(即当前页为第一页), 
'若不是,则将由Request对象的Querystring集合从HTTP查询字符串中获取来的变量值(当前页码)赋给变量page_nonce。 
If Request.QueryString("page_nonce")<>"" Then 
page_nonce=Cint(Request.QueryString ("page_nonce")) 
Else 
page_nonce=1 
End If 
'将当前页码赋给记录集对象的表示当前记录页号的属性(AbsolutePage)。 
rs_booklist.AbsolutePage=page_nonce 
Dim I 
I=page_size 
'通过Do While 循环语句,将当前页的每一条记录读取出来。 
Do While Not rs_booklist.Eof And I>0 
I=I-1 
Response.Write "<tr align='center'>" 
Response.Write "<td height='10'>" & rs_booklist("BookID") & "</td>" 
Response.Write "<td height='10'>" & rs_booklist("BookName") & "</td>" 
Response.Write "<td height='10'>" & rs_booklist("bnumber") & " </td>" 
%> 
<td width="25" height='10'><div align="center"><a href="buycar_add.asp?bookID=<%= rs_booklist("bookID") %>" target="txtFrame"><img src="images/add.gif" alt="添加至购物车" width="18" height="18" border="0" align="middle"></a></div></td> 
<% 
'将记录指针移动到下一条记录。 
rs_booklist.MoveNext 
Loop 
Response.Write "</table>" 
'开始做分页连接。 
Response.Write "<p align='center'>分页: " 
'通过For 循环将除当前页码号之外的每一个页码号做一个超连接, 
For j=1 To page_total 
If j=page_nonce Then 
Response.Write j & " " 
Else 
Response.Write "<a href='booklist.asp?page_nonce=" & j & "'>" & j & "</a> " 
End If 
Next 
End If 
rs_booklist.Close 
Set rs_booklist=nothing 
Conn.Close 
Set Conn=nothing 
%> 
</table> 
</dir> 
</body> 
</html>                        
 (编辑:源码门户网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |