ASP.NET网络商店设计与实现

发布于:2024-05-06 ⋅ 阅读:(34) ⋅ 点赞:(0)

  要

本文首先系统地研究了开发电子商务网站的背景和意义,分析了当今B2C电子商务交易的网站特点和共性,从而得出设计本网站的思路和方法。接着介绍了实现系统开发的ASP.NETIIS5.0环境,数据库用ACCESS实现。同时简要介绍了以上工具的功能和方法。

在介绍以上基础知识的基础上,论文主要分析了系统设计的两个关键步骤:概要设计和详细设计。概要设计分成后台数据库管理操作设计和客户端操作设计,同时介绍了数据库的建立和维护。详细设计主要阐述了用户管理、商品管理、交易结算过程、模糊查寻等后台管理功能的实现,并给出了系统的设计代码。

最后,对每个功能模块和整个系统进行了测试,测试结果表明:系统基本具备了网上交易的功能以及快速的响应速度。

关键词:电子商务;后台管理;ASP.NET;ACESS

2.1  ASP.NET简介

Asp.net 是一种建立在通用语言上的程序构架,能被用于一台Web服务器来建立强大的Web应用程序。Asp.net提供许多比现在的Web开发模式强大的优势。

(1)执行效率的大幅提高

(2)强大性和适应性

(3)简单性和易学性

(4)高效可管理性

(5)多处理器环境的可靠性

(6)自定义性,和可扩展性

(7)安全性

2.2  Microsoft Access 简介

Access与许多优秀的关系数据库一样,可以让你很容易地连接相关的信息而且还对其他的数据库系统有所补充。它能操作其它来源的资料,包括许多流行的PC数据库程序(如dBASE,Paradox,Microsoft FoxPro)和服务器、小型机及大型机上的许多SQL数据库。Access还完全支持Microsoft的OLE技术。

Access还提供windows操作系统的高级应用程序开发系统。Access与其它数据库开发系统之间相当显著的区别就是:您不用写一行代码,就可以在很短的时间里开发出一个功能强大而且相当专业的数据库应用程序,并且这一愉快的过程是完全可视的!如果您能给它加上简短的VBA代码,那么您的程序决不比专业程序员潜心开发的程序差。

Access将所有有名字的东西都成为对象(object),最重要的对象有表,查询,窗体,报表,宏和模块。

5.1  登陆模块的设计

因为维护系统的安全性,管理员登陆必需由正确的帐号和密码,否则就不能登陆,并将提示出错原因。相应的文件为:ad_login.aspx

实现的设计效果如图5.1:

图5.1  管理登录设计效果图

实现该功能的相应代码为:

<%@ Page language="c#" Codebehind="ad_login.aspx.cs" AutoEventWireup="false" Inherits="eshop.ad_login" %>

<html>

<head>

<title>管理员登陆</title>

<meta http-equiv="content-type" content="text/html;charset=gbk"/>

<link rel="stylesheet" href="img/admin.css" type="text/css"/>

</head>

<body>

&nbsp;

<form id="form1" runat="server">

<div class="mframe">

<table width="300" align="center" cellspacing="0" cellpadding="0">

<tr>

<td class="tl"></td>

<td class="tm" >

       <span class="tt">&nbsp; 管理员登陆</span>

</td>

<td class="tr"></td>

</tr>

</table>

<table width="300" align="center" cellspacing="0" cellpadding="0">

<tr>

<td class="ml"></td>

<td class="mm">

       <table cellpadding="3" width="100%" align="center" >

       <tr>

       <td rowspan="4" width="100">

              <img src="img/admin_key.gif"/>

       </td>

       <td align="center">

              <asp:Label width="100%" id=Label1 runat="server"/>

              用户名:

              <asp:TextBox Columns="10" MaxLength="50" id="Username" Class="inputbg" runat="server"/>

                 <asp:RequiredFieldValidator id="RequiredFieldValidator"

                     ControlToValidate="UserName"

                     ErrorMessage="*"

                     Display="Dynamic"

                     runat="server"/>

              <asp:RegularExpressionValidator

                     runat="server"

                     ControlToValidate="Username"

                     ValidationExpression="[^']+"

                     ErrorMessage="*"

                     Display="Dynamic" />

       </td></tr>

       <tr><td align="center">

              密 码:

              <asp:TextBox id="Password" Columns="10" textmode="Password"

 MaxLength="50" CssClass="inputbg" runat="server"/>

              <asp:RequiredFieldValidator id="RequiredFieldValidator1"

                     ControlToValidate="Password"

                     ErrorMessage="*"

                     Display="Dynamic"

                     runat="server"/>

              <asp:RegularExpressionValidator

                     runat="server"

                     ControlToValidate="Password"

                     ValidationExpression="[^' ]+"

                     ErrorMessage="*"

                     Display="Dynamic" />

       </td></tr>

       <tr><td align="center">

              验证码:

              <asp:TextBox id="VerifyCode" Columns=10 MaxLenth=10

CssClass="inputbg" Style="ime-mode:disabled" runat="server"/>

              <asp:RequiredFieldValidator

                     ControlToValidate="VerifyCode"

                     ErrorMessage="*"

                     Display="Dynamic"

                     runat="server"/>

       </td></tr>

       <tr><td align="left">验证码为:<img align="absmiddle" src="gif.aspx" />

       </td><td width="20"></td></tr>

       <tr>

       <td width="107"> </td><td align="center" >

       <asp:Button id="myButton2"

              Text="提交"

              CommandName="command"

              CommandArgument="commandArgument"

              runat="server"/>

              &nbsp;&nbsp;&nbsp;

                     <asp:Button id="myButton1"

              Text="重置"

              CommandName="command"

              CommandArgument="commandArgument"

              runat="server"/>

       </td>

       </tr>

       </table>

</td>

5.2  商品和订单管理模块设计

5.2.1  商品分类管理模块

商品分类管理模块分为大类和小类,大类可以实现类别的添加和删除并且可以对类别名称加以修改。小类即子类同样可以实现添加和删除功能,且可以改名。文件为ad_addsort.aspx。

该功能的实现的设计效果如图5.2:

图5.2  商品分类设计效果图

相应的代码描述为:

      <form method="POST" action="ad_addsort1.aspx">

<input type="hidden" name="options" value>

  <table border="0" cellpadding="0" cellspacing="0" width="95%" align="center">

    <tr>

      <td><div align="center"><center><p>类别:

<select name="subject" size="1"style="font-size: 9pt">

 <asp:Repeater id="Repeater1" runat="server">

 <ItemTemplate>

   <option value=<%# DataBinder.Eval(Container.DataItem,"sort_id")%>>

<%# DataBinder.Eval(Container.DataItem,"sort_name")%></option>   

 </ItemTemplate>

 </asp:Repeater>

      </select>

      <input type="submit" value="删除" name="B2" οnclick="form.options.value='del'" ></td>

    </tr>

    <tr align="center">

      <td><br>

      </td>

    </tr>

    <tr align="center">

      <td><p>新名字:<input type="text" name="reTitle" size="20" class=smallinput>

      <input type="submit" value= οnclick="改名" name="B1" "form.options.value='rename'">

      </td>

    </tr>

    <tr align="center">

      <td><br>

      </td>

    </tr>

    <tr align="center">

      <td><p>新类别:<input type="text" name="newTitle" size="20" class=smallinput>

      <input type="submit" value="新增" name="B3" οnclick="form.options.value='new'"></td>

    </tr>

  </table>

</form>

    </td>

  </tr>

</table>

<table width="758" border="0" cellspacing="0" cellpadding="0" height="75">

  <tr>

    <td>

<form method="POST" action="ad_addsort2.aspx">

<input type="hidden" name="options" value>

  <table border="0" cellpadding="0" cellspacing="0" width="95%" align="center">

    <tr>

      <td align="center"><hr><b>子专题管理</b></td>

    </tr>

    <tr align="center">

      <td><br>

      </td>

    </tr>

    <tr>

      <td><div align="center"><center><p>子专题:

<select name="subject" size="1" style="font-size: 9pt">

<asp:Repeater id="Repeater2" runat="server">

 <ItemTemplate>

   <option value=<%# DataBinder.Eval(Container.DataItem,"Nsort_id")%>><%# DataBinder.Eval(Container.DataItem,"Nsort_name")%></option>   

 </ItemTemplate>

 </asp:Repeater>

      </select>

      <input type="submit" value="删除" name="B2" οnclick="form.options.value='del'"></td>

    </tr>

    <tr align="center">

      <td><br>

      </td>

    </tr>

    <tr align="center">

      <td><p>专题修改:<input type="text" name="reTitle" size="20"  class=smallinput>

在 <select name="sort_id" size="1"style="font-size: 9pt">

 <asp:Repeater id="Repeater3" runat="server">

 <ItemTemplate>

   <option value=<%# DataBinder.Eval(Container.DataItem,"sort_id")%>><%# DataBinder.Eval(Container.DataItem,"sort_name")%></option>   

 </ItemTemplate>

 </asp:Repeater>

      </select> 中

      <input type="submit" value="改名" name="B1" οnclick="form.options.value='rename'"><br>(请选择上方相应子类别,然后输入新名字和选择类别)

      </td>

    </tr>

    <tr align="center">

      <td><br>

      </td>

    </tr>

    <tr align="center">

      <td><p>新专题:<input type="text" name="newTitle" size="20"  class=smallinput>

      在 <select name="psubject" size="1"style="font-size: 9pt">

<asp:Repeater id="Repeater4" runat="server">

 <ItemTemplate>

   <option value=<%# DataBinder.Eval(Container.DataItem,"sort_id")%>><%# DataBinder.Eval(Container.DataItem,"sort_name")%></option>   

 </ItemTemplate>

 </asp:Repeater>      </select> 中

      <input type="submit" value="新增" name="B3" οnclick="form.options.value='new'"></td>

   

5.2.2  商品定单管理模块

商品订单管理模块存储了用户在下订单后所留下的记录,具体表现在:订单序号、订单号、订货人、地址、日期等信息。过期或无作用的订单信息可以删除,也可以查看详细资料。当订单太多时可以通过翻页来查看。文件为ad_subp.aspx。

实现的设计效果如图5.3:

图5.3  订单管理页面效果图

相应代码设计如下所示:

                     <asp:datagrid id="dgCustomPage"

                            runat="server" Width="600px" AutoGenerateColumns="False"

 CellPadding="4" BackColor="White"  DataKeyField="sub_id"

                            BorderWidth="1px" BorderStyle="None" BorderColor="#ffffff"

Height="20px" AllowPaging="True"

                            AllowCustomPaging="false" PageSize="15">

                            <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"

BackColor="#009999"></SelectedItemStyle>

                            <ItemStyle ForeColor="#000000"  BackColor="#F7F9FD"

 Height="23"></ItemStyle>

                            <HeaderStyle Font-Bold="True" ForeColor="#000000"

 HorizontalAlign="center" Height="25" BackColor="#EDF1F8"></HeaderStyle>

              <FooterStyle ForeColor="#003399"

BackColor="#99CCCC"></FooterStyle>

                            <Columns>

              <asp:TemplateColumn HeaderText="订单序号">

                     <ItemTemplate>

                     <asp:Label id=lblColumn runat="server"

Text='<%# DataBinder.Eval(Container, "DataItem.sub_id") %>'>

                                                                             </asp:Label>

                                                                      </ItemTemplate>

                                                                      </asp:TemplateColumn>

                                   <asp:HyperLinkColumn

                                          HeaderText="订单号"

                                          DataNavigateUrlField="sub_id"

                                          DataTextField="sub_number"

                                          DataNavigateUrlFormatString="ad_subm.aspx?sub_id={0}"

                                          Target="_blank"

                                   >

                            <ItemStyle Width="" HorizontalAlign="center"/>

                            </asp:HyperLinkColumn>

       <asp:BoundColumn DataField="user_name" HeaderText="订货人">

</asp:BoundColumn>

       <asp:BoundColumn DataField="sub_adds" HeaderText="地址">

</asp:BoundColumn>

              <asp:BoundColumn DataField="sub_date" HeaderText="日期">

</asp:BoundColumn>

              <asp:EditCommandColumn ButtonType="LinkButton" EditText="查看">

</asp:EditCommandColumn>

              <asp:ButtonColumn Text="删除" CommandName="Delete">

</asp:ButtonColumn>

              <asp:TemplateColumn>

              <ItemTemplate>

                     <asp:CheckBox id="chkExport" runat="server"></asp:CheckBox>

              </ItemTemplate>

              <EditItemTemplate>

              <asp:CheckBox id="chkExportON" runat="server"></asp:CheckBox>

              </EditItemTemplate>

                     </asp:TemplateColumn>

                            </Columns>

                            <PagerStyle HorizontalAlign="CENTER" ForeColor="#000000"

  BackColor="#F7F9FD" Mode="NumericPages"></PagerStyle>

                     </asp:datagrid>

                     </td>

                     </tr>

                            </table>

                                   </TD>

                            </TR>

                                       <TR>

                                   <TD align="center">

       <asp:label id="lblPageCount" runat="server"></asp:label>

       <asp:label id="lblCurrentIndex" runat="server"></asp:label>

       <asp:linkbutton id="btnFirst" οnclick="PageButtonClick" runat="server" Font-Name="verdana" CommandArgument="0">最首页&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnPrev" οnclick="PageButtonClick" runat="server" CommandArgument="prev">前一页&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnNext" οnclick="PageButtonClick" runat="server" CommandArgument="next">下一页&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnLast" οnclick="PageButtonClick" runat="server" CommandArgument="last">最后页&nbsp;</asp:linkbutton>

              <asp:button id="cmdSelectAll" runat="server" Text="全选"></asp:button>

              <asp:button id="cmdFindSelected" runat="server" Text="删除选择项"></asp:button>

                               

5.3  网站信息设置模块设计

5.3.1  汇款方式管理模块

汇款方式的选择有多种形式,可以根据用户自己使用的方便性选择不同的汇款方式。对于不方便或用户基本不使用的汇款方式可以删除不用。由于汇款方式过多可以通过翻页管理汇款方式。该模块对应文件名称为:ad_booktype.aspx

实现模块效果图如5.4所示:

图5.4  汇款方式模块设计效果图

相应设计代码为:

              <form id="Form1" method="post" runat="server">

              <table align="center">

              <tr>

              <td align="center" width="602">

              <br><br>

              <table cellSpacing="1" cellPadding="0" width="99%" bgcolor="#A7BDEB">

              <tr><td align="center" valign="top" height="20" bgcolor="#F7F9FD"

background="img/lframe_t.gif">        

                     <font color="white"><B><asp:Label id="label1" runat="server">

                     </asp:Label></B></font>

              </td></tr>

              <tr><td>

                     <asp:datagrid id="dgCustomPage"

                            runat="server" Width="600px" AutoGenerateColumns="False"

CellPadding="4" BackColor="#F7F9FD"  DataKeyField="id"

                            BorderWidth="1px" BorderStyle="None" BorderColor="#ffffff" Height="20px" AllowPaging="True"

                            AllowCustomPaging="false" PageSize="5"

                            >

                            <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>

                            <ItemStyle ForeColor="#000000" BackColor="#F7F9FD" Height="23"></ItemStyle>

                            <HeaderStyle Font-Bold="True" ForeColor="#000000"

 HorizontalAlign="center" Height="25" BackColor="#EDF1F8"></HeaderStyle>

                            <FooterStyle ForeColor="#F7F9FD"

 BackColor="#F7F9FD"></FooterStyle>

                            <Columns>

              <asp:TemplateColumn HeaderText="编号">

              <ItemTemplate>

              <ItemStyle HorizontalAlign="center" VerticalAlign="top"/>

              <asp:Label id=lblColumn runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.id") %>'>

              </asp:Label>

                     </ItemTemplate>

                     </asp:TemplateColumn>

                                   <asp:HyperLinkColumn

                                          HeaderText="标题"

                                          DataNavigateUrlField="id"

                                          DataTextField="title"

                                          DataNavigateUrlFormatString="ad_edit.aspx?id={0}"

                                          Target="_blank"

                                   >

              <ItemStyle Width="" HorizontalAlign="center" VerticalAlign="top"/>

                            </asp:HyperLinkColumn>

                                   <asp:BoundColumn DataField="nr" HeaderText="内容">

                                                 <ItemStyle HorizontalAlign="left"/>

                                                 </asp:BoundColumn>

              <asp:ButtonColumn Text="删除" CommandName="Delete">

<ItemStyle HorizontalAlign="center"  VerticalAlign="top"/></asp:ButtonColumn>

                     <asp:TemplateColumn>

                     <ItemTemplate >

                     <asp:CheckBox id="chkExport" runat="server"></asp:CheckBox>

                            </ItemTemplate>

                            <EditItemTemplate>

              <asp:CheckBox id="chkExportON" runat="server"></asp:CheckBox>

                            </EditItemTemplate>

                            </asp:TemplateColumn>

                            </Columns>

                            <PagerStyle HorizontalAlign="CENTER" ForeColor="#000000"

 BackColor="#F7F9FD" Mode="NumericPages"></PagerStyle>

                     </asp:datagrid>

                     </td>

                     </tr>

                            </table>

                                   </TD>

                            </TR>

                                                 <TR>

                                   <TD align="center" bgcolor="#F7F9FD">

                                   <asp:label id="lblPageCount" runat="server"></asp:label>

                                   <asp:label id="lblCurrentIndex" runat="server"></asp:label>

                                   <asp:linkbutton id="btnFirst" οnclick="PageButtonClick" runat="server" Font-Name="verdana" CommandArgument="0">最首页&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnPrev" οnclick="PageButtonClick"

 runat="server" CommandArgument="prev">前一页

&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnNext" οnclick="PageButtonClick" runat="server"

CommandArgument="next">下一页

&nbsp;</asp:linkbutton>

              <asp:linkbutton id="btnLast" οnclick="PageButtonClick" runat="server"

 CommandArgument="last">最后页&nbsp;</asp:linkbutton>

              <asp:button id="cmdSelectAll" runat="server" Text="全选">

</asp:button>

              <asp:button id="cmdFindSelected" runat="server" Text="删除选择项">

</asp:button>

5.3.2  送货方式管理模块

考虑到不同用户的需要,给用户带去全方位的服务和最终完成网上交易,所以设计了该模块,提供给用户不同的送货方式,送货方式基本框架和汇款方式相同所以用同样的代码实现,用TYPEID识别。如下定购方式、售后服务和关于我们性质相同,所以在以下不再重复相同代码。相应文件名称:ad_booktype.aspx。实现该功能效果图如图5.5所示:

图5.5  送货方式模块设计效果图

5.3.3  定购方式管理模块

定购方式同样有多种,根据用户自己的喜好可以选择不同的方式,管理该项时可以删除不合理的定购方式,其它功能同上。相应文件名称:ad_booktype.aspx。实现该功能效果图如图5.5所示:

图5.6  订购方式模块设计效果图

5.3.4  关于我们管理模块

关于我们相关内容为商业使用说明、版权说明、功能介绍等。使用户能够更全面的了解本网站。相关文件为:ad_booktype.aspx。实现效果图如图5.7所示:

图5.7  关于我们设计效果图