网上图书商城实验报告--vs&sql

更新时间:2024-03-22 03:37:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验报告

《数据库开发技术》实验报告 题 目:网上图书商城 实验环境: 操作系统:Windows XP 运行软件:Microsoft SQL Server 2005、Microsoft Visual Studio 2005 实验内容与完成情况: 实验内容: 姓名 王小红 日期 2012-5-30 数据库开发与技术:Web应用系统案例——网上图书商城 完成情况: 一.数据库设计 建立客户(User)、员工(Employee)、图书类别(Category)、图书(Book)、出版社(Publish)、订单(Orders)、订单明细项(OrderItem)、入库单(StockIn)、入库明细项(StockInItem)、购物车(Cart)数据表,如下图所示:

二、数据传输对象、数据访问层、数据传输层设计: 数据传输对象(DTO)分为Book、Cart、Category、Order、OrderItem、User六各类;数据访问层中的类有数据访问帮助类DBObject和各个实体对应的数据访问类;业务逻辑层中的业务逻辑类封装了业务规则,并且在本设计方案中还封装了事务处理。如下图所示: 三.页面设计 1、登录页面界面设计运行如下:

代码如下: using System; using System.Data; using System.Configuration; 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; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { UserBll userBll = new UserBll(); if (userBll.Verify(TextBox1.Text, TextBox2.Text)) { Session[\] = TextBox1.Text; Session[\] = true; Session[\] = \; Session[\] = TextBox2.Text; Response.Redirect(\); } else { Session[\] = \; Session[\] = false; Session[\] = \; Label3.Visible = true; } } } 2、图书信息运行网页如下:

代码如下: public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void ImageButton1_Command(object sender, CommandEventArgs e) { Response.Redirect(\+e.CommandArgument .ToString ()); } protected void LinkButton1_Command(object sender, CommandEventArgs e) { Response.Redirect(\ + e.CommandArgument.ToString()); } protected void LinkButton2_Command(object sender, CommandEventArgs e) { Cart cart = new Cart(); cart.CartID = Session[\].ToString(); cart.BookID = int.Parse(e.CommandArgument.ToString()); cart.Amount = 1;

cart.CreateDate = DateTime.Now; CartBll cartbll = new CartBll(); cartbll.Add(cart ); RegisterStartupScript(\,\成功加入购物车!\\\); } } 3、网上图书的详细信息运行网页如下:

网上图书的详细信息网页代码如下: public partial class Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void LinkButton1_Click(object sender, EventArgs e) { Cart cart = new Cart(); cart.CartID = Session[\].ToString(); cart.BookID = int.Parse(Request .QueryString [\]); cart.Amount = 1; cart.CreateDate = DateTime.Now; CartBll cartbll = new CartBll(); cartbll.Add(cart); RegisterStartupScript(\, \成功加入购物车!\\\); } } 4、网上图书的我的购物车运行网页如下:

我的购物车网页代码如下: public partial class Default4 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row .RowType ==DataControlRowType .DataRow ) { Label bookID = (Label)e.Row.FindControl(\); Label bookName = (Label)e.Row.FindControl(\); Label price = (Label)e.Row.FindControl(\); Book book = new BookBll().GetBookByBookID(int.Parse(bookID.Text)); bookName.Text = book.BookName; price.Text = book.Price.ToString(); } } protected void Button_Click(object sender, EventArgs e) { Server.Transfer(\); } } 5、网上图书的订单信息运行网页如下:

订单信息网页代码如下: public partial class Default5 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userName = Session[\].ToString(); User user = new UserBll().GetUserByUserName(userName); if (user == null) return; TextBox1.Text = user.Address; TextBox2.Text = user.Zip; TextBox3.Text = user.Phone; TextBox4.Text = user.Mobile; } } //“确认下单”按钮代码如下: protected void Button1_Click(object sender, EventArgs e) { Order order = new Order(); order.UserName = Session[\].ToString(); order.ShipAddress = TextBox1.Text; order.ShipZip = TextBox2.Text;

order.ShipPhone = TextBox3.Text; order.ShipMobile = TextBox4.Text; order.InvoiceCompany = TextBox5.Text; List carts = new CartBll().GetAllByCartID(Session[\].ToString()); List orderItems = new List(); foreach (Cart cart in carts) { OrderItem orderItem = new OrderItem(); orderItem.BookID = cart.BookID; orderItem.Amout = cart.Amout; orderItem.Price = new BookBll().GetBookByBookID(cart.BookID).Price; order.OrderItemSet.Add(orderItem); } new OrderBll().Add(order); Label7.Text = \订单添加成功!!!\; Label7.Visible = true; } //“返回浏览图书”按钮代码 protected void LinkButton1_Click(object sender, EventArgs e) { Server.Transfer(\); } } 出现的问题:

出点击“我的购物车”出现以上错误: 解决方案(列出遇到的问题和解决办法,列出没有解决的问题):

改为即可

本文来源:https://www.bwwdw.com/article/xja8.html

Top