本文整理汇总了C#中ShoppingCart.DeleteBookItemFromShoppingCart_方法的典型用法代码示例。如果您正苦于以下问题:C# ShoppingCart.DeleteBookItemFromShoppingCart_方法的具体用法?C# ShoppingCart.DeleteBookItemFromShoppingCart_怎么用?C# ShoppingCart.DeleteBookItemFromShoppingCart_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShoppingCart
的用法示例。
在下文中一共展示了ShoppingCart.DeleteBookItemFromShoppingCart_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: gridview_ShoppingCart_OnRowCommand
/// <summary>
/// 控件动作监听模块
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gridview_ShoppingCart_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
ShoppingCart shoppingCart = new ShoppingCart();
//获取到用户购物车
if (Session["ShoppingCart"] != null)
{
shoppingCart = (ShoppingCart)Session["ShoppingCart"];
}
if (e.CommandName == "Plus" || e.CommandName == "Reduce" || e.CommandName == "DeleteBook")
{
int index = Convert.ToInt32(e.CommandArgument);//获取到当前索引
Label lbl_bookAmount = (Label)gridview_ShoppingCart.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("lblSCBookNum");
BookItem bookItem = shoppingCart.bookItemList[index];//获取需要变化数量的图书
if (e.CommandName == "Plus")
{
lbl_bookAmount.Text = (Convert.ToInt32(lbl_bookAmount.Text) + 1).ToString();//增加label的值
shoppingCart.AddBookItemToShoppingCart(bookItem);//将图书添加到购物车
}
if (e.CommandName == "Reduce")
{
if (bookItem.bookAmount > 1)
{
lbl_bookAmount.Text = (Convert.ToInt32(lbl_bookAmount.Text) - 1).ToString();//减小label的值
shoppingCart.DeleteBookItemFromShoppingCart(bookItem);//将图书添加到购物车
}
}
if (e.CommandName == "DeleteBook")
{
shoppingCart.DeleteBookItemFromShoppingCart_(bookItem);//删除选定的图书
gridview_ShoppingCart.DataSource = shoppingCart.bookItemList;
gridview_ShoppingCart.DataBind();//刷新购物车
}
}
}