购物车系统实验报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
publicpartialclass结á账?: System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!IsPostBack)
{
TextBox2.Text = (string)Session["KH"];
GridView2.DataSource = Session["SP2"];
GridViewRow row = GridView3.Rows[index];
string bhText = row.Cells[0].Text;
string mcText = row.Cells[2].Text;
string dyText = row.Cells[3].Text;
string djText = row.Cells[4].Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ShoppingNET
{
public partial class主页: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
Session["SP2"] = C;
}
C = (System.Data.DataTable)Session["SP2"];
if (TextBox1.Text == "")
{
Validate();
}
else
{
Session["KH"] = TextBox1.Text;
int index = Convert.ToInt32(e.CommandArgument);
代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespaceShoppingNET
{
}
protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
{
System.Data.DataTable Cart = new System.Data.DataTable();
if (e.CommandName == "select")
GridViewRow row = GridView2.Rows[index];
TextBox tt = (System.Web.UI.WebControls.TextBox)row.Cells[1].FindControl("TextBox3");
string dg1 = tt.Text;
int dg = int.Parse(dg1);
for(intii = 0; ii < GridView2.Rows.Count; ii++)
{
CheckBoxcc =
(CheckBox)GridView2.Rows[ii].Cells[0].FindControl("CheckBox1");
if(cc.Checked)
{
sum = sum + (double.Parse(GridView2.Rows[ii].Cells[7].Text));
}
}
TextBox3.Text = sum.ToString();
}
}
}
当保存到订单之后,后显示给用户或者售货员查看,主要利用的是Gridview,界面如下:
运行结果如下:
首先我们进入主页,了解商品种类信息之后,确定购买商品,点击确定:
然后我们需要购买的商品就会加入到购物车,如下:
我们输入购买数量以及用户备注,如:商品1我们购买8个,商品8我们购买15个,然后输入客户姓名,kangsheng,会将结果尽心汇总到账单,如下:
rr["单价"] = dj;
rr["订购数量"] = dg;
int zk = 1;
rr["折扣"] = zk;
double hj = dj * dg * zk;
rr["合计"] = hj;
C.Rows.Add(rr);
Session["SP2"] = C;
}
}
}
}
}最后进行结账,在这一块主要涉及的还是GridView,而且要利用复选框对选项进行确定,以及Button控件、Textbox控件,界面如
if (dg < 1) dg = 1;
string bhText = row.Cells[2].Text;
string mcText = row.Cells[3].Text;
string dyText = row.Cells[4].Text;
string djText = row.Cells[5].Text;
rr["单价"] = dj;
Cart.Rows.Add(rr);
Session["shoppingCart"] = Cart;
}
}
}
}
其次,当运行完主页,点击我们选购的商品,会进入到购物车这一块,利用Gridview进行数据显示,用Session对象保存购货车,并且利用Textbox设计用户标签,在Gridview控件中加入模板列,放入Textbox控件,以便于输入上平数量,然后再Gridview控件中加入Button控件,将其CommondName属性进行设置,如下图:
DataBind();
}
}
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void GridView2_RowCommand1(object sender,
GridViewCommandEventArgs e)
三张表分别如下:
2
首先从母版页开始介绍,模板页主要利用GridViewFra Baidu bibliotek行设计的,如下图:
然后介绍主页,利用gridview将商品罗列出来如下图:
内部的方法代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
int bh = int.Parse(bhText);
double dj = double.Parse(djText);
System.Data.DataRow rr = C.NewRow();
rr["商品编号"] = bh;
rr["商品名称"] = mcText;
rr["单元含量"] = dyText;
Cart.Columns.Add("单价", typeof(double));
Session["shoppingCart"] = Cart;
}
Cart = (System.Data.DataTable)Session["shoppingCart"];
int index = Convert.ToInt32(e.CommandArgument);
{
public partial class购物车: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView2.DataSource = Session["shoppingCart"];
{
System.Data.DataTable C = new System.Data.DataTable();
if (e.CommandName == "buy")
{
if (Session["SP2"] == null)
{
C.Columns.Add("商品编号", typeof(int));
C.Columns.Add("商品名称", typeof(string));
从而汇总到服务员那里,最会生成订单那,供客户查看,该系统完成。
四、
1、通过这次试验我弄懂了很多控件的用途以及关于数据绑定的一些基本知识
2、这个系统虽然最后的订单查看这一块我虽然没有完成,但是我还是学会了不少东西
3、通过一学期的学习,基本会一些最简单功能的网页的设计,希望在不断练习下逐渐了解多功能系统的设计,这个购物车系统是一个很典型的例子,我要笑话他,以后遇见了别的网页,不至于无从下手!
C.Columns.Add("单元含量", typeof(string));
C.Columns.Add("单价", typeof(double));
C.Columns.Add("订购数量", typeof(int));
C.Columns.Add("折扣", typeof(double));
C.Columns.Add("合计", typeof(double));
GridView2.DataBind();
}
}
protectedvoidGridView2_SelectedIndexChanged(objectsender,EventArgse)
{
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
doublesum=0.0;
应用软件开发课程设计报告
----购物车与订单系统
姓名:刘升
学号:201113040117
专业:软件工程
一、实验目的:
1.利用用户控件和母版页进行界面设计
2.实现数据表多表之间的同步
3.完成对数据表的显示、修改和统计
二、
1
主页面的设计
商品的分类显示
选购和调整购物车
集中结算
存储订单
查看订单
三、详细设计
1
{
if (Session["shoppingCart"] == null)
{
Cart.Columns.Add("商品编号", typeof(int));
Cart.Columns.Add("商品名称", typeof(string));
Cart.Columns.Add("单位含量", typeof(string));
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ShoppingNET
int bh = int.Parse(bhText);
double dj = double.Parse(djText);
System.Data.DataRow rr = Cart.NewRow();
rr["商品编号"] = bh;
rr["商品名称"] = mcText;
rr["单位含量"] = dyText;
相关文档
最新文档