书签 分享 收藏 举报 版权申诉 / 25

类型net网上购物车课程设计.docx

  • 文档编号:4267969
  • 上传时间:2022-11-28
  • 格式:DOCX
  • 页数:25
  • 大小:570.99KB

用户控件后台文件:

usingSystem;

usingSystem.Data;

usingSystem.Configuration;

usingSystem.Collections;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Web.UI.HtmlControls;

publicpartialclassWebUserControl:

System.Web.UI.UserControl

{

protectedvoidPage_Load(objectsender,EventArgse)

{

DateTimed=DateTime.Now;

Label2.Text=d.ToLongDateString()+d.ToLongTimeString();

}

}

4.1.2主控页的设计

主控页源代码:

<%@MasterLanguage="C#"AutoEventWireup="true"CodeFile="MasterPage.master.cs"Inherits="MasterPage"%>

<%@RegisterSrc="WebUserControl.ascx"TagName="WebUserControl"TagPrefix="uc1"%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

无标题页

 

center">

20cm;height:

15cm;background-image:

url(image/h.jpg);">

20cm;height:

3cm">

 

WebUserControlID="WebUserControl1"runat="server"/>

10cm;height:

10cm">

GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataKeyNames="CategoryID"

DataSourceID="SqlDataSource1">

HyperLinkFieldDataNavigateUrlFields="CategoryID"DataNavigateUrlFormatString="商品.aspx?

CategoryID={0}"

HeaderText="选择"Text="商品"/>

BoundFieldDataField="CategoryID"HeaderText="类型ID"InsertVisible="False"ReadOnly="True"

SortExpression="CategoryID"/>

BoundFieldDataField="CategoryName"HeaderText="类型名"SortExpression="CategoryName"/>

GridView>

SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ConnectionStrings:

NorthwindConnectionString%>"

SelectCommand="SELECT[CategoryName],[CategoryID]FROM[Categories]">

SqlDataSource>

 

10cm;height:

10cm">

contentplaceholderid="ContentPlaceHolder1"runat="server">

contentplaceholder>

20cm;height:

2cm">Copyright©2012网络食品在线

4.2内容页的设计

4.2.1主页的设计

主页源代码:

<%@PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="主页.aspx.cs"Inherits="Default2"Title="UntitledPage"%>

ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

center">

350px;height:

154px">

100px">

欢 迎

100px">

100px">

100px">

100px">

选 购

100px">

100px">

100px">

100px">

Content>

4.2.2商品网页的设计

商品页源代码:

<%@PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="商品.aspx.cs"Inherits="Default2"Title="UntitledPage"%>

ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataKeyNames="ProductID"

DataSourceID="SqlDataSource1"OnRowCommand="GridView1_RowCommand">

ButtonFieldCommandName="select"HeaderText="选择"Text="选购"/>

BoundFieldDataField="ProductID"HeaderText="产品ID"InsertVisible="False"ReadOnly="True"

SortExpression="ProductID"/>

BoundFieldDataField="ProductName"HeaderText="产品名"SortExpression="ProductName"/>

BoundFieldDataField="CategoryID"HeaderText="类型ID"SortExpression="CategoryID"/>

BoundFieldDataField="QuantityPerUnit"HeaderText="单元数量"SortExpression="QuantityPerUnit"/>

BoundFieldDataField="UnitPrice"HeaderText="单价"SortExpression="UnitPrice"/>

GridView>

SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ConnectionStrings:

NorthwindConnectionString%>"

SelectCommand="SELECT[ProductID],[ProductName],[CategoryID],[QuantityPerUnit],[UnitPrice]FROM[Products]WHERE([CategoryID]=@CategoryID)">

QueryStringParameterName="CategoryID"QueryStringField="CategoryID"Type="Int32"/>

SqlDataSource>

 

Content>

商品页后台文件:

usingSystem;

usingSystem.Data;

usingSystem.Configuration;

usingSystem.Collections;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Web.UI.HtmlControls;

publicpartialclassDefault2:

System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

}

protectedvoidGridView1_RowCommand(objectsender,GridViewCommandEventArgse)

{

System.Data.DataTableCart=newSystem.Data.DataTable();

if(e.CommandName=="select")

{

if(Session["ShoppingCart"]==null)

{

Cart.Columns.Add("商品编号",typeof(int));

Cart.Columns.Add("商品名称",typeof(string));

Cart.Columns.Add("单元含量",typeof(string));

Cart.Columns.Add("单价",typeof(double));

Session["ShoppingCart"]=Cart;

}

Cart=(System.Data.DataTable)Session["ShoppingCart"];

intindex=Convert.ToInt32(e.CommandArgument);

GridViewRowrow=GridView1.Rows[index];

stringbhText=row.Cells[1].Text;

stringmcText=row.Cells[2].Text;

stringdyText=row.Cells[4].Text;

stringdjText=row.Cells[5].Text;

intbh=int.Parse(bhText);

doubledj=double.Parse(djText);

System.Data.DataRowrr=Cart.NewRow();

rr["商品编号"]=bh;

rr["商品名称"]=mcText;

rr["单元含量"]=dyText;

rr["单价"]=dj;

Cart.Rows.Add(rr);

Session["ShoppingCart"]=Cart;

}

}

}

4.2.3购物车网页的设计

购物车页源代码:

<%@PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="购物车.aspx.cs"Inherits="Default2"Title="UntitledPage"%>

ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

客户标志:

TextBoxID="TextBox1"runat="server"Width="55px">

TextBox>

RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"ControlToValidate="TextBox1"

ErrorMessage="请输入客户标志">

RequiredFieldValidator>

GridViewID="GridView1"runat="server"OnRowCommand="GridView1_RowCommand">

ButtonFieldCommandName="buy"HeaderText="购买"Text="确认"/>

TemplateFieldHeaderText="数量">

TextBoxID="TextBox2"runat="server"Text="<%#1%>"Width="57px">

TextBox>

TemplateField>

GridView>

Content>

购物车页后台文件:

usingSystem;

usingSystem.Data;

usingSystem.Configuration;

usingSystem.Collections;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Web.UI.HtmlControls;

publicpartialclassDefault2:

System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

if(!

IsPostBack)

{

GridView1.DataSource=Session["ShoppingCart"];

DataBind();

}

}

protectedvoidGridView1_RowCommand(objectsender,GridViewCommandEventArgse)

{

System.Data.DataTableCart=newSystem.Data.DataTable();

if(e.CommandName=="buy")

{

if(Session["ShoppingCart2"]==null)

{

Cart.Columns.Add("商品编号",typeof(int));

Cart.Columns.Add("商品名称",typeof(string));

Cart.Columns.Add("单元含量",typeof(string));

Cart.Columns.Add("单价",typeof(double));

Cart.Columns.Add("订购数量",typeof(int));

Cart.Columns.Add("折扣",typeof(double));

Cart.Columns.Add("合计",typeof(double));

Session["ShoppingCart2"]=Cart;

}

Cart=(System.Data.DataTable)Session["ShoppingCart2"];

if(TextBox1.Text=="")

{

Validate();

}

else

{

Session["khbz"]=TextBox1.Text;

intindex

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
net 网上 购物 课程设计
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:net网上购物车课程设计.docx
链接地址:https://www.bdocx.com/doc/4267969.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开