课程设计(论文)-电子书店Web系统.doc

上传人:yyf 文档编号:3292934 上传时间:2019-08-08 格式:DOC 页数:18 大小:923.51KB
返回 下载 相关 举报
课程设计(论文)-电子书店Web系统.doc_第1页
第1页 / 共18页
课程设计(论文)-电子书店Web系统.doc_第2页
第2页 / 共18页
课程设计(论文)-电子书店Web系统.doc_第3页
第3页 / 共18页
课程设计(论文)-电子书店Web系统.doc_第4页
第4页 / 共18页
课程设计(论文)-电子书店Web系统.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《课程设计(论文)-电子书店Web系统.doc》由会员分享,可在线阅读,更多相关《课程设计(论文)-电子书店Web系统.doc(18页珍藏版)》请在三一文库上搜索。

1、Web技术课程论文电子书店Web系统【内容摘要】电子书店系统是基于Web平台,SQL Server 2005数据库构建的网络店铺。该系统一共包含六个网页,利用Visual Studio 2008软件平台进行开发,包括用户登录、用户注册、商品查询、商品订购、购物车和服务台等网页,各网页之间的连接性较强,能很好的完成用户从注册登录到浏览、挑选商品和进行购买等一系列过程。数据库是利用SQL Server 2005进行开发,数据库中包含两个表,分别为用户表和书籍信息表。用户表用来绑定用户的登录和注册。书籍信息表用来绑定用户的查询和书籍购买等。经测试,电子书店系统能够在IIS服务器上良好的运行。【关键字

2、】电子书店;WEB平台;SQL Server 2005数据库;算法设计随着网络技术的发展和人们观念的提高,越来越多的出版社将书籍放到网络上进行销售,如著名的China-Pub就是其中的一个代表。网络商店的特点是方便、安全。它能够允许用户自由地在网站上浏览商品,并且评价和选购合适的商品,由于无需实际的店面场地,节省了大量的资金开支,同时也可以为用户提供足不出户的 营销模式。本系统将实现一个具有基本功能的网络书店,用户可以在网络书店内自由的浏览和挑选自己喜欢的书籍,然后付款购买。一、功能描述(一)用户管理用户管理的功能是给用户提供下订单和记录历史记录等功能。出于安全方面的考虑,在用户管理模块中,用

3、户自身的注册,登录以及验证等环节必不可少。这个模块包含以下功能:1. 用户注册:新用户通过提供自身的信息提交关于用户的具体资料。2. 用户登录:用户需要验证才能紧系下订单的工作。(二)书籍列表网络书店的功能就是以书籍为商品,向用户进行推销,以获得利润。在这个模块中,设计了书籍这种商品的浏览模式,用户可以自由地、往复地进行阅读和挑选,直到挑选到满意的商品为止,用户还可以查询自己需要的书籍。(三)服务台服务台相当于网站的首页或中转站,用户可以通过服务台跳往各个网页,也可以从各个网页回到服务台。(四)购物车购物车模块是帮助用户记录所购买书籍的模块,其中包含了购物的具体细节和具体的价格情况。二、系统结

4、构 电子书店系统包含六个网页,网页之间的结构关系如图1所示:书籍订购购物车服务台用户注册用户登录 开始 (首页)书籍查询 图 1 系统结构图三、页面设计(一)用户登录页此页面是由1个Table控件、两个TextBox控件、两个RequiredFieldValidator验证控件(用来验证输入是否为空)、一个Button控件(用来表示登录)、一个Label控件(用来显示信息)和一个HyperLink控件(用来调整到注册页面)组成。最后的界面如图2所示:图2 用户登录界面(二)用户注册界面此页面是由8个TextBox控件、两个RadioButton控件(用来选择性别)、两个Button控件(分别用

5、来表示登录和内容重置)、一个CompareValidator控件(用来验证两次输入的密码是否相同)、两个RequiredFieldValidator控件(用来验证输入是否为空)、一个Lable控件(用来显示信息)和衣个HyperLink控件(用来跳转到登录页面)组成。最后是界面如图三所示:图 3 用户注册页面(三)服务台页面此页面是由三个LinkButton控件(分别用来跳转到书籍查询页面、书籍订购页面和购物车页面)组成。最后的界面如图4所示:图 4 服务台页面(四)书籍订购页面此页面是由一个Table控件、三个Image控件、六个LinkButton控件、一个SqlDataSource控件和

6、一个DataList控件组成。最后的界面如图5所示:图 5 书籍订购页面(五)书籍信息查询页面此页面是由一个TextBox控件、两个Button控件、一个GridView控件、一个LinkButton控件(用来跳往书籍订购页面)和一个SqlDataSource控件组成。最后的界面如图6所示:图 6 书籍查询页面(六)购物车页面 此页面是由一个GridView控件、四个Button控件和一个Label控件(用来显示信息)组成。最后的界面如图7所示:图7 购物车页面四、算法设计(一)、用户登录页面的算法设计如下所示:算法:using System;using System.Data;using S

7、ystem.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class userlogin : System.Web.UI.Page protec

8、ted void Page_Load(object sender, EventArgs e) protected void Button3_Click(object sender, EventArgs e) string userID, password; userID = TextBox1.Text.Trim(); password = TextBox2.Text.Trim(); if (userID.Length = 0) Label1.Text = 用户名不能为空!; return; SqlConnection conn = new SqlConnection(); string str

9、conn; strconn = Data Source=LIUQIN-PCSQLEXPRESS; + Integrated Security=True;Pooling=False;Initial Catalog=书籍商店; conn.ConnectionString = strconn; conn.Open(); string sql; sql = select userid from 用户信息 + where userid= + userID + and userpassword= + password + ; SqlCommand cmd = new SqlCommand(); cmd.C

10、onnection = conn; cmd.CommandText = sql; SqlDataReader rd = cmd.ExecuteReader(); bool ok; ok = rd.Read(); rd.Close(); conn.Close(); if (ok) Session.Add(userID, userID); Response.Redirect(/服务台.aspx); else Label1.Text = 用户名或密码出错!; (二)用户注册页面代码如下所示:算法:using System;using System.Data;using System.Configur

11、ation;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class userzhuce : System.Web.UI.Page protected void Page_

12、Load(object sender, EventArgs e) protected void Button2_Click(object sender, EventArgs e) string user, password1, password2, sex, tel, email, address, zipcode,realname; user = TextBox3.Text.Trim(); password1 = TextBox4.Text.Trim(); password2 = TextBox2.Text.Trim(); sex = (RadioButton2.Checked ? 男 :

13、女); tel = TextBox7.Text.Trim(); email = TextBox1.Text.Trim(); address = TextBox5.Text.Trim(); zipcode = TextBox9.Text.Trim(); realname = TextBox8.Text.Trim(); SqlConnection conn = new SqlConnection(); string strconn; strconn = Data Source=LIUQIN-PCSQLEXPRESS; + Integrated Security=True;Pooling=False

14、;Initial Catalog=书籍商店; conn.ConnectionString = strconn; conn.Open(); string sql; sql = select userid from 用户信息 where userid= + user + ; SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Connection = conn; SqlDataReader rd = cmd.ExecuteReader (); bool bl; bl = rd.Read(); rd.Close(); if (b

15、l) Label10.Text = 该用户ID已被注册!; return; sql = insert into 用户信息(userid,userpassword,username,usersex,usertel,useremail,useraddress,userzipcode)+ values( + user + , + password1 + ,+realname+,+ sex +,+tel+,+email+,+address+,+zipcode+); cmd.CommandText = sql; int ok; ok = cmd.ExecuteNonQuery(); if (ok = 1

16、) Label10.Text = 注册成功!; else Label10.Text = 注册失败!; protected void Button1_Click(object sender, EventArgs e) TextBox3.Text = ; TextBox4.Text = ; TextBox2.Text = ; TextBox7.Text = ; TextBox1.Text = ; TextBox5.Text = ; TextBox9.Text = ; TextBox8.Text = ; TextBox3.Focus(); (三)书籍信息查询页代码如下所示:算法:using Syst

17、em;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class _Default

18、: System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) string Search_Name = % + TextBox1.Text.Trim() + %; string Sql_Search = select 书籍号,书籍名称,书籍类型,书籍简介,价格 + from 书籍信息 where 书籍名称 LIKE + Search_Name + ; string Conn_Str = Data

19、Source=LIUQIN-PCSQLEXPRESS;+ Integrated Security=True;Pooling=False;Initial Catalog=书籍商店; SqlConnection conn = new SqlConnection(Conn_Str); SqlDataAdapter adp = new SqlDataAdapter(Conn_Str, conn); DataSet ds = new DataSet(); adp.Fill(ds, 书籍信息); if (ds.Tables书籍信息.Rows.Count 0) GridView1.DataSource =

20、ds.Tables书籍信息.DefaultView; GridView1.DataBind(); protected void Button2_Click(object sender, EventArgs e) Response.Redirect(/服务台.aspx); (四)服务台页面没有代码,它是直接用LinkButton控件的PostBackUrl属性来实现页面的跳转。(五)书籍订购页面的代码如下所示:算法:using System;using System.Collections.Generic;using System.Linq;using System.Web;using Syst

21、em.Web.UI;using System.Web.UI.WebControls;using System.Collections;public partial class shujidinggou : System.Web.UI.Page /声明一个哈希表 Hashtable hashCar; protected void Page_Load(object sender, EventArgs e) protected void LinkButton4_Command(object sender, CommandEventArgs e) /如果没有分配购物车 if (SessionuserC

22、ar = null) /新生成一个购物车 hashCar = new Hashtable(); /添加一个书籍 hashCar.Add(e.CommandArgument, 1); /分配给用户 SessionuserCar = hashCar; else /用户已经有购物车,得到购物车的哈希表 hashCar = (Hashtable)SessionuserCar; /购物车中已经有此书籍,书籍数加1 if (hashCar.Contains(e.CommandArgument) /得到购买书籍的数量 int num = Int32.Parse(hashCare.CommandArgumen

23、t.ToString(); /设置其数量+1 hashCare.CommandArgument = (num + 1).ToString(); else /如果没有此书籍,则新添加一个项 hashCar.Add(e.CommandArgument, 1); /页面跳转 Response.Redirect(/购物车.aspx); (六)购物车页面的代码如下所示:算法:using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web

24、.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class 购物车 : System.Web.UI.Page string strsql; WebService webservice = new WebService(); /初始化WebService DataTable detable;

25、 /声明数据表 Hashtable hashCar; /声明哈希表 protected void Page_Load(object sender, EventArgs e) if(!Page .IsPostBack ) /如果用户登录,并是第一次进入页面 if(Session userCar=null) /如果没有购物,则给出相应信息 this.Label1 .Text =您还没有购物; this.Button1 .Enabled =false; this.Button2 .Enabled =false; this.Button3 .Enabled =false; this.Button4 .

26、Enabled =false; else /如果已经购物过 hashCar =(Hashtable )Session userCar; /得到其购物车 if(hashCar .Count =0) /判断购物车是否为空 /如果没有购物,则给出相应的信息 this.Label1 .Text =您还没有购物; this.Button1 .Enabled =false; this.Button2 .Enabled =false; this.Button3 .Enabled =false; this.Button4 .Enabled =false; else detable=new DataTable

27、(); /如果购物了 /初始化新列 DataColumn column1=new DataColumn (no); DataColumn column2=new DataColumn (bookid); DataColumn column3=new DataColumn (bookname); DataColumn column4=new DataColumn (price); DataColumn column5=new DataColumn (GoodsNum); DataColumn column6=new DataColumn (totalprice); /添加列 detable .C

28、olumns .Add (column1 ); detable .Columns .Add (column2 ); detable .Columns .Add (column3 ); detable .Columns .Add (column4 ); detable .Columns .Add (column5 ); detable .Columns .Add (column6 ); DataRow row; foreach (object key in hashCar.Keys ) /遍历索引哈希表中的键 row =detable .NewRow (); /添加新行 row bookid=k

29、ey.ToString (); /得到书籍ID rowGoodsNum=hashCar key.ToString (); /得到书籍数量 detable .Rows .Add (row); /添加该行 /计算价格 DataTable table; int i=1; float price; int num; float totalprice=0; foreach (DataRow drrow in detable .Rows ) /计算总价 strsql =Select 书籍名称,价格 from 书籍信息 where 书籍号=+drrow bookid.ToString ()+; /设置SQL

30、 table =webservice .ExcuteSelect(strsql ); /得到数据表 drrow no=i; /设置列值 drrow bookname=table .Rows 0书籍名称.ToString (); drrow price=table .Rows 0价格.ToString (); price =float .Parse (table .Rows 0价格.ToString (); /得到单价 num=Int32 .Parse (drrow GoodsNum.ToString (); /得到数量 drrowtotalprice = (price * num).ToStr

31、ing(); /计算单类书籍总价 totalprice +=price *num ; /计算全部购物价格 i+; this.Label1 .Text =总价: +totalprice .ToString (); /显示总价 this.GridView1 .DataSource =detable.DefaultView ; /绑定数据源 this.GridView1 .DataBind (); protected void Button4_Click(object sender, EventArgs e) hashCar = (Hashtable)SessionuserCar; foreach

32、(GridViewRow gvr in this.GridView1.Rows) /对GridView控件的每一个行进行遍历 int index = gvr.RowIndex; /获得其索引 TextBox tb = (TextBox)gvr.FindControl(TextBox1); /找到用咯爱输入数量的TextBox控件 int num = Int32.Parse(tb.Text); /获得用户输入的数量值 string bookID = gvr.Cells1.Text; /得到该书籍的ID hashCarbookID = num; /更新哈希表 SessionuserCar = ha

33、shCar; /更新购物车 Response.Redirect(/书籍订购.aspx); protected void Button1_Click(object sender, EventArgs e) SessionuserCar = null; /清空购物车 Response.Redirect(/书籍订购.aspx); protected void Button2_Click(object sender, EventArgs e) Response.Redirect(/书籍订购.aspx); protected void Button3_Click(object sender, EventArgs e) Response.Redirect(/服务台.aspx); 五、运行说明从用户注册开始,到用户登录,再到查询书籍,最后进入书籍订购页面。(一)用户注册,注册用户名为“199329999”,密码为“1234”,性别为“男”,用户电话为“13487594941”,用户Email为 ,用户地址为“湖南商学院信息学院”,邮编为“410204”,真实姓名为“刘勤”。如图8所示:图8 用户注册注册成功后,点击用户登录按钮,跳转到用户登录页面,再用刚才注册的用户名和密码登录。运行结果如图9所示:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 研究报告 > 信息产业


经营许可证编号:宁ICP备18001539号-1