65.9K
CodeProject 正在变化。 阅读更多。
Home

ASP.NET 和 Commerce Server

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.40/5 (4投票s)

2006年3月16日

viewsIcon

22990

downloadIcon

103

本文概述了使用 ASP.NET 开发 Commerce 应用。

Sample Image - slcs.jpg

引言

如果您想开发 Commerce Server 应用程序,请记住先安装 Visual Studio .NET,然后再安装 Commerce Server。安装完成后,您会在“新建项目”列表中找到“Commerce 项目”选项。

以下代码将向您展示如何与 Commerce Server 交互的一个大致概念。

1. 从目录中获取类别

私有的 voidCategoryBind()

{

ProductCatalog ProdCtlg = CommerceContext.Current.CatalogSystem.GetCatalog("LevisJeans");

DataSet ds =newDataSet();

ds = ProdCtlg.GetRootCategories();

drpCategory.DataSource = ds.Tables[0].DefaultView;

drpCategory.DataTextField = "CategoryName";

drpCategory.DataValueField = "OrigCategoryName";

drpCategory.DataBind();

}

2. 根据所选类别绑定产品

私有的 voidDataBind()

{

ProductCatalog ProdCtlg = CommerceContext.Current.CatalogSystem.GetCatalog("LevisJeans");

Category Cg;

Cg = ProdCtlg.GetCategory(drpCategory.SelectedValue);

DataGrid4.DataSource = Cg.GetProducts();

DataGrid4.DataBind();

}

<img src="slcs/productlist.jpg">

 以下获取添加到购物车的产品列表

私有的 voidDataBind()

{

TransactionContext txContext = TransactionContext.Current;

#ifDEBUG

System.Console.WriteLine("HERE");

#endif

tot_qty = 0;

tot_price = 0;

DataGrid1.DataSource = txContext.CartOrderForm.LineItems;

DataGrid1.DataBind();

lblTot_Qty.Text = Convert.ToString(tot_qty);

lblTot_Price.Text = Convert.ToString(tot_price);

}

<img src="slcs/cart.jpg">

以下代码用于删除一项

intd = Convert.ToInt16(deleted[j]);

txContext.CartOrderForm.LineItems.Remove(d)

 

© . All rights reserved.