資源簡介
aspx 購物車詳細源碼,一個不錯的購物車源碼研究程序
代碼片段和文件信息
using?System;
using?System.Data;
using?System.Configuration;
using?System.Collections;
using?System.Linq;
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.xml.Linq;
public?partial?class?Cart1?:?System.Web.UI.Page
{
????string?m;
????string?GoodsID;
????string?GoodsName;
????string?GoodsPrice;
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
?????????m?=?Request.Params[“m“];
?????????GoodsID?=?Request.QueryString[“GoodsID“];
?????????GoodsName?=?Request.QueryString[“GoodsName“];
?????????GoodsPrice?=?Request.QueryString[“GoodsPrice“];
???????
????if(!IsPostBack)
????{
????????switch?(m)
????????{
????????????case?“buy“:
? Response.Write(?“你剛買了:“+GoodsName??);
????????????????UpdateShoppingCart();
????????????????Response.Write(“ript>window.opener=null;window.close(); ript>“);//???不會彈出詢問
????????????????
???????????????
????????????????//Response.Redirect(“products.aspx“);
????????????????break;
????????????case?“see“:
????????????????ViewShoppingCart();???//查看購物車
????????????????break;
????????}
????????}
???????//?Response.Write(“ript>window.opener=null;window.close(); ript>“);//???不會彈出詢問
????}
????///?
????////創建購物車用的內存表
????///?
????public?void?CreateCartTable()??//創建購物車用的表
????{
????????DataSet?ds?=?new?DataSet();
????????DataTable?CTable?=?new?DataTable(“CartTable“);
????????ds.Tables.Add(CTable);
????????DataColumn?newDC;
????????newDC?=?new?DataColumn(“ProdID“?System.Type.GetType(“System.Int32“));
????????ds.Tables[“CartTable“].Columns.Add(newDC);
????????newDC?=?new?DataColumn(“ProdCount“?System.Type.GetType(“System.Int32“));
????????newDC.DefaultValue?=?1;
????????ds.Tables[“CartTable“].Columns.Add(newDC);
????????newDC?=?new?DataColumn(“ProName“?System.Type.GetType(“System.String“));
????????ds.Tables[“CartTable“].Columns.Add(newDC);
????????newDC?=?new?DataColumn(“UnitPrice“?System.Type.GetType(“System.Double“));
????????ds.Tables[“CartTable“].Columns.Add(newDC);
????????newDC?=?new?DataColumn(“TotalPrice“?System.Type.GetType(“System.Double“));
????????ds.Tables[“CartTable“].Columns.Add(newDC);
????????newDC?=?new?DataColumn(“IsDeleted“?System.Type.GetType(“System.Int32“));
????????newDC.DefaultValue?=?0;??????????????????????????????????????????????????????//????public?void?WriteShoppingCart()?中?newDR[5]=“0“;?行,已被注銷,
????????ds.Tables[“CartTable“].Columns.Add(newDC);
???????
????????Session[“myCartTable“]?=?CTable;//放入session中
????}
????///?
????///向購物車內存表中寫數據
????///?
????public?void?WriteShoppingCart()
????{
????????if?(Request.Params[“m“]?!=?“view“)???????????????????????????????//檢查是否是直接查看購物車,如果直接查看,就不再寫MYCARTTABLE
????????{
????????????DataTable?nowTable?=?new?DataTable(“nowCartTable“);//創建一個新表
????????????nowTable?=?(D
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1067??2008-02-02?14:04??App_Data\App_Code\sdb.cs
?????文件????2097152??2008-02-24?15:27??App_Data\shop.MDF
?????文件?????516096??2008-02-24?15:27??App_Data\shop_Log.ldf
?????文件???????5124??2008-02-24?14:36??cart.aspx
?????文件??????12041??2008-02-24?15:21??cart.aspx.cs
?????文件????????654??2008-02-24?14:28??checkout.aspx
?????文件???????1803??2008-02-24?14:28??checkout.aspx.cs
?????文件???????3783??2008-02-24?14:45??products.aspx
?????文件????????520??2008-02-02?14:04??products.aspx.cs
?????文件???????7470??2007-03-03?09:30??web.config
?????目錄??????????0??2009-03-23?21:34??App_Data\App_Code
?????目錄??????????0??2009-03-23?21:34??App_Data
-----------?---------??----------?-----??----
??????????????2645710????????????????????12
評論
共有 條評論