ASP+ACCESS基于B2C电子商务网站设计

摘  要

运用ASP技术结合了Access数据库原理,基于B/S模式我们开发了一个网上购物系统。在我们的系统中,顾客可以很方便的注册成为会员,对商品进行浏览检索,查看商品的详细资料,然后根据各人的喜好购买心仪的商品。系统会自动为顾客生成订单,按照顾客所填写的信息提交订单并发货。系统管理员则可以对现有的商品进行添加和编辑,审查已注册的用户并对提交的订单进行处理。

关键词:B/S模式;ASP;电子商务;Access

2.6 平台功能模块的设计

在平台功能的分析基础上,得到本平台的功能模块图如下:网上购物系统平台主要包括四大功能模块,用户管理、网站布局、管理员管理、搜索等功能模块。其中用户管理模块,主要包括用户注册、用户修改、用户删除等功能;管理员管理主要包括会员管理、商品管理、参数设置等

下面是“浙西分校电子商务网”的流程图:

  1. 系统前台功能模块图

图2.1

  • 2. 后台功能模块图

图2.2

2.7 使用工具

本设计利用现在比较广泛的ASP + access数据库的架构实现的。是B/S结构。以Internet和Intranet作为平台Server/Browser结构的应用程序,由于具有操作系统独立性,维护的简单性,用户界面一致性等特点,正越来越受到广大程序员和用户的欢迎。

其次使用的是Windows 2000自带的Internet服务管理器,IIS(Internet Information Server)作为当今流行的Web服务器之一,提供了强大的Internet和Intranet服务功能,使用它可以轻松的发布站点,在课题制作过程中可以随时进行调试,浏览自己的页面。

另外建数据库是用的Access。由于本课题较小使用的数据量不大,所以采用它,但它的安全性不好。而AQL Server的安全性较好,但它适合于有大量数据存储的应用软件。

ASP的全称是:Active Server Pages,是在服务器端脚本编译环境,使用它可以创建和运行动态、交互的Web服务器应用程序。ASP对服务器端要求安装独立的ASP软件,对客户端没有特别的要求,只要有一个浏览器就行。 HTML文件中, 用任意一个文本编辑器就 可以编写一个完整的ASP页面。所谓ASP,就是在HTML文件中引入了两个扩展的成对的HTML标记<%和%>,同时文件的扩展名改为 .asp。 在IIS接到用户对.asp文件的请求时,首先执行括在<%和%> 标记间的VBScript语句,然后将执行的结果和其他的HTML语句一起返回客户端,这样客户看到的仍然是标准的HTML语句,不会看到开发者的编程逻辑,这与客户端的JavaScript是完全不同的,JavaScript没有办法阻止用户看到源码。ASP可以与HTML页、脚本命令和ActiveX组件组合创建交互的Web页和基于Web的功能强大的应用程序。ASP应用程序很容易开发和修改。

以下罗列了 Active Server Pages 所独具的一些特点:
   1. 使用 VBScript ,JScript 等简单易用的脚本语言,结合 HTML 代码,即可快速地完成网站的应用程序的编写。
   2. 无须编译,容易编写,调试方便可在服务器端直接执行。
   3. 使用普通的文本编辑器,如 Windows 的记事本,或在FRONTPAGE等流行软件中都可进行编辑设计。
   4. 与浏览器无关 (Browser Independence)。用户端只要使用可执行HTML 码的浏览器,即可浏览ASP网页的内容。ASP所使用的脚本语言 (VBScript、 Jscript) 均在 WEB 服务器端执行,用户端的浏览器不要求能够执行这些脚本语言。
   5. ASP 能与任何ActiveX scripting 语言相容。除了可使用 VBScript 或 JScript 语言来设计外,还通过 plug-in 的方式,使用由第三方所提供的其他脚本语言,如:REXX 、Perl 、Tcl 等。脚本引擎是处理脚本程序的 COM(Component Object Model) 物件。
   6.Active Server Pages 的源程序,不会被传到客户浏览器,因而可以避免所写的源程序被他人直接剽窃,提高了程序的安全性。
   7. 可使用服务器端的脚本来控制产生客户端的脚本。
   8.ActiveX Server Components(ActiveX 服务器元件 ) 具有无限可扩充性。可以使用 Visual Basic 、 Java 、 Visual C++ 、 COBOL 等编程语言来编写你所需要的 ActiveX Server Component 。

4.1 前台的功能和实现

前台卖家经过身份验证如果是已经注册的用户可直接登陆到首页,如果是

注册的用户系统提示注册。

买家通过主页面进入商品区,选择进入一个商品区,然后查看商品,选择商品。并且有搜索商品,查看推荐商品的功能。

图4.1

4.2 后台的功能和实现

后台管理员可以对商品的类别进行添加,对商品进行添加维护,可以查看前台注册的用户的具体信息,通过管理数据库对留言进行维护。

                                     图4.2

4.3本人所做的是店铺商品模块的设计

4.3.1店铺商品增加

图4.3 管理员登录界面

1.程序清单(goods_add

<SCRIPT language=JavaScript>

function CheckInput() {

    if (input.goodsname.value=='') {

        alert("商品名称不能为空!");

        input.goodsname.focus();

        return false;}

if (input.goodscont ert("商品描述不能为空!");

        input.goodscontent.focus();

        return false;}

    if(input.goodsprice.value==''){

        alert("商品价格不能为空!");

        input.goodsprice.focus();

        return false; }

    if(input.goodsamount.value==''){

        alert("商品数量不能为空!");

        input.goodsamount.focus();

        return false; }

    if(input.goodslong.value==''){

        alert("有效期不能为空!");

        input.goodslong.focus();

        return false; }

        return true;  }

</SCRIPT>

<TABLE width=760 border=0 align=center cellSpacing=0 cellPadding=0 >

  <TBODY>

    <TR>

      <td width=176 valign=top>

      <TD align="center" vAlign=top>

        <TABLE cellSpacing=0 cellPadding=0 width="570" border=0 class=page>

          <TBODY>

            <TR>

              <TD bgColor=#E4F4E1 height=21> <TABLE width="100%" border=0>

                  <TBODY>

                    <TR>

                      <TD align=middle width=25>

                       <img border="0" src="images/news.gif" width="15" height="15"></TD>

                      <TD>发布商品</TD>

                    </TR>

                  </TBODY>

                </TABLE></TD>

            </TR>

            <TR>

              <TD align="center"> <form action="goods_save.asp" method="post" name="input" id="input" οnsubmit=return(CheckInput())>

                  <table width="98%" border="0" align="center">

                    <tr>

                      <td> </td>

                      <td> </td>

                    </tr>

                    <tr>

                      <td>商品名称</td>

                      <td><input name="goodsname" type="text" id="goodsname" size="20" maxlength="20">

                        <font color="#FF0000">*</font> 不超过20个字符 注意:注册后不能修改</td>

                    </tr>

                    <tr>

                      <td>商品描述:</td>

                      <td><textarea name="goodscontent" cols="45" rows="6" id="goodscontent"></textarea>

                        <font color="#FF0000">*</font> 不超过255个字符</td>

                    </tr>

                    <tr>

                      <td>商品价格:</td>

                      <td><input name="goodsprice" type="text" id="goodsprice" size="15" maxlength="15">

                        元 <font color="#FF0000">*</font></td>

                    </tr>

                    <tr>

                      <td>商品数量:</td>

                      <td><input name="goodsamount" type="text" id="goodsamount" size="10" maxlength="10">

                        个 <font color="#FF0000">*</font></td>

                    </tr>

                    <tr>

                      <td>有效期:</td>

                      <td><select name="goodslong" id="goodslong">

                          <option selected>有效期</option>

                          <option value="7">1个礼拜</option>

                          <option value="15">2个礼拜</option>

                          <option value="30">1个月</option>

                          <option value="90">3个月</option>

                          <option value="180">半年</option>

                          <option value="0">长期有效</option>

                        </select> <font color="#FF0000">*</font> </td>

                    </tr>

                    <tr>

                      <td>商品图片:</td>

                      <td><input name="goodspic" type="text" id="goodspic" size="40" maxlength="40">

                      </td>

                    </tr>

                    <tr>

                      <td>上传图片:</td>

                      <td height="40">

<iframe border="0" frameBorder="0" frameSpacing="0" height="21" marginHeight="0" marginWidth="0" noResize scrolling="no" width="100%" vspale="0" src="upfile.asp"></iframe></td>

                    </tr>

                    <tr align="center">

                      <td colspan="2"> <input type="submit" name="Submit" value="提交">

                        <input type="reset" name="Submit2" value="重置"> <%

Randomize '初始代随机数种子

num1=rnd() '产生随机数num1

num1=int(26*num1)+65 '修改num1的范围以使其是A-Z范围的Ascii码,以防表单名出错

session("antry")="test"&chr(num1) '产生随机字符串

%> <input name="temp" type="hidden" id="temp" value="<%=session("antry")%>">

                      </td>

                    </tr>

                  </table>

                </form></TD>

            </TR>

          </TBODY>

        </TABLE>

      </TD>

    </TR>

  </TBODY>

4.3.2图片上传按钮

图4.4

  1. 程序清单(goods_edit.asp

<!--#include FILE="conn.asp"-->

<!--#include FILE="upload.inc"--><%

if session("user_id")="" then

response.write "<script language='javascript'>" & VbCRlf

response.write "alert('非法操作!');" & VbCrlf

response.write "history.go(-1);" & vbCrlf

response.write "</script>" & VbCRLF

else

if request("action")="upload" then

if session("goods_id")<>"" then

set rs = server.CreateObject ("Adodb.recordset")

sql = "select * from goods_info where goods_id="&session("goods_id")

rs.open sql,conn,1,3

if rs("goods_pic")<>"" then

tempfpath=rs("goods_pic")

FiLePaTh = Server.MapPath(tempfpath)

Set fso = CreateObject("Scripting.FileSystemObject")

fso.DeleteFile(FiLePaTh)

Set fso = nothing

rs.close

set rs = nothing

end if

session("goods_id")=""

end if

user_id="user_id_"&session("user_id")&"_"

nowtime=now()

sj=cstr(year(nowtime))+"-"+right("0"+cstr(month(nowtime)),2)+"-"+right("0"+cstr(day(nowtime)),2)

dim upload,file,formName,formPath,iCount

set upload=new upload_F

function MakedownName()

dim fname

fname = now()

fname = replace(fname,"-","")

fname = replace(fname," ","")

fname = replace(fname,":","")

fname = replace(fname,"PM","")

fname = replace(fname,"AM","")

fname = replace(fname,"上午","")

fname = replace(fname,"下午","")

fname = int(fname) + int((10-1+1)*Rnd + 1)

MakedownName=fname

end function

formPath="uploadfiles/"

iCount=0

for each formName in upload.file ''列出所有上传了的文件

set file=upload.file(formName) ''生成一个文件对象

if file.FileSize<100 then

      response.write "上传发生错误,请先选择你要上传的文件! [ <a href=# οnclick=history.go(-1)>重新上传</a> ]"

       response.end

 end if

       if file.FileSize>51200 then

      response.write "上传发生错误,文件大小超过了50K![ <a href=# οnclick=history.go(-1)>重新上传</a> ]"

       response.end

 end if

fileExt=lcase(right(file.filename,4))

if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".bmp" then

      response.write "上传发生错误,文件格式不正确![ <a href=# οnclick=history.go(-1)>重新上传</a> ]"

       response.end

 end if

if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据

newname=user_id&MakedownName()&"."&mid(file.FileName,InStrRev(file.FileName, ".")+1)

file.SaveAs Server.mappath(formPath&newname) ''保存文件

iCount=iCount+1

else

response.write "未找到文件 &nbsp;&nbsp;<A HREF=javascript:history.back(1)>返回</A>"

end if

next

Response.Write("<SCRIPT>parent.input.goodspic.value+='uploadfiles/"&newname&"'</SCRIPT>")

else

%>

<style type="text/css"><!-- input { border: 1px solid;} -->

</style>

<form action="upfile.asp?action=upload" method="POST" enctype="multipart/form-data" name=myform>

  <div align="left">

  <table border="0" cellspacing="0" style="border-collapse: collapse" width="100%" bordercolorlight="#FFEEB3" cellpadding="0" bordercolordark="#FFEEB3">

    <tr><td><input type="file" name="cimg" size="15" value="浏览">

        &nbsp; <input type="submit" value="上传" name="B1" isshowprocessbar="True">

        (gif或jpg格式,200K以下)</td> </tr>

   </table>

</div>

</form>

  <%

end if

end if%>

4.3.3店铺商品信息

                                 图4.5

3.程序清单goods_info.asp

          <TBODY> <TR>

        <TD bgColor=#E4F4E1 height=21> <TABLE width="100%" border=0>

                  <TBODY> <TR> <TD align=middle width=25>

                                        <img border="0" src="images/news.gif" width="15" height="15"></TD>

                      <TD><%=Conn.ExeCute("select goods_name from goods_info where goods_id="&Request("goods_id")&"")(0)%></TD>

                      <TD align="right"> 该商品已被浏览 <font color="#FF0000"><%=rs("goods_hits")%></font> 次</TD>

                    </TR>

                  </TBODY>

                </TABLE></TD>

            </TR><TR> <TD align="center">找不到该商品!</TD>

                   </TR>

          </TBODY>

        </TABLE>

 <%else

conn.execute("update goods_info set goods_hits=goods_hits+1 where goods_id="&request("goods_id")&"")

%>

        <TABLE cellSpacing=0 cellPadding=0 width="450" border=0 class=page>

    <TBODY><TR> <TD bgColor=#E4F4E1 height=21> <TABLE width="100%" border=0>

                  <TBODY><TR><TD align=middle width=25>                                                                <img border="0" src="images/news.gif" width="15" height="15"></TD>

                      <TD><%=Conn.ExeCute("select goods_name from goods_info where goods_id="&Request("goods_id")&"")(0)%></TD>

                      <TD align="right"> 该商品已被浏览 <font color="#FF0000"><%=rs("goods_hits")%></font> 次</TD>  </TR>

                   </TBODY>

                </TABLE></TD>

            </TR>

            <TR>  <TD align="center"> <table width="92%" border="0" cellpadding="4">

                          <tr><td><a href=<%=rs("goods_pic")%> target=_blank><IMG src="<%=rs("goods_pic")%>" width="80" height="100"

                  border=0 style="border: 1px solid #008000"></a></td>

                    <td><table width="100%" border="0">

                        <tr>

                          <td><font color="#009933">价格:</font><%=rs("goods_price")%>元</td>

                          <td><font color="#009933">数量:</font><%=rs("goods_amount")%>个</td>

                          <td><font color="#009933">有效期:</font><%=rs("goods_long")%>天</td>

                        </tr>

                        <tr>

                          <td colspan="3"><font color="#009933">上架时间:</font><%=rs("goods_date")%></td>

                        </tr>

                        <tr>

                          <td colspan="3"><font color="#009933">店铺名称:</font><%=Conn.ExeCute("select shop_name from user_info where user_id="&rs("user_id")&"")(0)%></td>

                        </tr>

                        <tr>

                          <td colspan="3"><font color="#009933">店铺掌柜:</font><%=Conn.ExeCute("select user_realname from user_info where user_id="&rs("user_id")&"")(0)%></td>

                        </tr>

                        <tr>

                          <td colspan="3"><font color="#009933">店铺地址:</font><%=Conn.ExeCute("select shop_address from user_info where user_id="&rs("user_id")&"")(0)%></td>

                        </tr>

                        <tr>

                          <td colspan="3"><font color="#009933">联系电话:</font><%=Conn.ExeCute("select shop_phone from user_info where user_id="&rs("user_id")&"")(0)%></td>

                        </tr>

<tr>

                          <td colspan="3"><font color="#009933">联系OICQ:</font><a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=Conn.ExeCute("select user_qq from user_info where user_id="&rs("user_id")&"")(0)%>&Site=大学校园网络店铺&Menu=yes><%=Conn.ExeCute("select user_qq from user_info where user_id="&rs("user_id")&"")(0)%></a></td>

                        </tr>

                      </table></td>

                  </tr>

                  <tr>

                    <td colspan="2"><img src="images/goods.gif" width="16" height="15">

                      <font color="#009933">商品描述:</font><%=left(rs("goods_content"),100)%></td>

                  </tr>

                  <tr align="right">

                    <td colspan="2">[<a href="shop_info.asp?user_id=<%=rs("user_id")%>"><font color="#FF0000">浏览该店铺的其它商品</font></a>]</td>

                  </tr>

                </table>

                <%end if%></TD>

            </TR>

          </TBODY>

        </TABLE>

        </TD>

    </TR>

  </TBODY>

4.3.4店铺商品列表

                             图4.6

4.程序清单goods_list.asp

<SCRIPT language=JavaScript>

function CheckInput(){

       if(input.username.value==''){

              alert("用户帐号不能为空!");

              input.username.focus();

              return false;}

       if( input.password.value =="") {

                alert("密码不能为空!")

              input.password.focus();

        return false;}

              return true;}

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

<!--

function GoPage() {window.location.href="?page_no="+ page.value;}-->

</SCRIPT>

<%dim strsql,rs

set rs=server.CreateObject("adodb.recordset")

strsql="select * from goods_info order by goods_id desc"

rs.open strsql,conn,1,1%>

        <TABLE cellSpacing="1" width="570" cellpadding="0" border=0 bgcolor="#E4F4E1">

          <TBODY><TR>  <TD bgColor=#E4F4E1 align="left" height=21>

                            &nbsp;<img border="0" src="images/news.gif" width="15" height="15">

                            商品列表</TD>  </TR>

            <TR>

              <TD > <table width="100%" border="0" cellpadding="2" cellSpacing=1>

<%

         IF not rs.eof and not rs.bof then

         dim page_size

         dim page_no

         dim page_total

         page_size=20

         if request.QueryString("page_no")="" then

         page_no=1

         else

         page_no=cint(request.QueryString("page_no"))

         end if

         rs.pagesize=page_size

         page_total=rs.pagecount

         rs.absolutepage=page_no

         dim I,J

         I=0

         J=page_size

         do while not rs.eof and J>0

         J=J-1

         I=I+1%>

      <tr><td height=18 bgcolor="#FFFFFF" >&nbsp; ·<a href="goods_info.asp?goods_id=<%=rs("goods_id")%>" target="_blank"><%=rs("goods_name")%></a></td>

                    <td align="right" bgcolor="#FFFFFF" ><font color="#999999">(<%=rs("goods_date")%>)</font></td>

                 </tr><%

             Rs.MoveNext

              Loop     

         End IF   %>

</table>

<table  width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="page">

              <tr><td bgcolor="#E4F4E1"><div align="center">[本页是<%=int(page_no)%>/<%=int(page_total)%>] [<a href="?page_no=1">第一页</a>]

              <%if int(page_no)>1 then%>

              [<a href="?page_no=<%=cstr(int(page_no-1))%>">前一页</a>]

              <%elseif int(page_no)<=1 then%>

              [<a href="?page_no=1">前一页</a>]

              <%end if%>

              <%if int(page_no)<int(page_total) then%>

              [<a href="?page_no=<%=cstr(int(page_no+1))%>">后一页</a>]

              <%elseif int(page_no)>=int(page_total) then%>

              [<a href="?page_no=<%=cstr(int(page_total))%>">后一页</a>]

              <%end if%>

              [<a href="?page_no=<%=page_total%>">最后一页</a>] 转到

              <input name="page" type="text" value="<%=page_no%>" size="5">页

                     <input type="button" class=input name="Submit" value="转到" οnclick="GoPage()"></div></td>

              </tr>

</table></TD></TR>

    </TBODY>

      

  • 29
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值