protected void shoppingCartPromoGiftList_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName.Equals("change")) { int num = System.Convert.ToInt32(e.CommandArgument.ToString()); if (num > 0) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo current in shoppingCart.LineGifts) { if (current.GiftId == num) { this.ShowMessage("购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!", false); return; } } } int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); if (this.shoppingCartPromoGiftList.SumNum > giftItemQuantity) { ShoppingCartProcessor.AddGiftItem(num, 1, PromoteType.SentGift); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); return; } this.ShowMessage("礼品兑换失败,您不能超过最多兑换数", false); } } }
private void BindShoppingCart() { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart == null) { this.pnlShopCart.Visible = false; this.litNoProduct.Visible = true; ShoppingCartProcessor.ClearShoppingCart(); } else { this.pnlShopCart.Visible = true; this.litNoProduct.Visible = false; if (shoppingCart.LineItems.Values.Count > 0) { this.shoppingCartProductList.DataSource = shoppingCart.LineItems.Values; this.shoppingCartProductList.DataBind(); this.shoppingCartProductList.ShowProductCart(); } if (shoppingCart.LineGifts.Count > 0) { System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable = from shoppingCartGiftInfo_0 in shoppingCart.LineGifts where shoppingCartGiftInfo_0.PromoType == 0 select shoppingCartGiftInfo_0; System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 = from shoppingCartGiftInfo_0 in shoppingCart.LineGifts where shoppingCartGiftInfo_0.PromoType == 5 select shoppingCartGiftInfo_0; this.shoppingCartGiftList.DataSource = enumerable; this.shoppingCartGiftList.FreeDataSource = enumerable2; this.shoppingCartGiftList.DataBind(); this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0); } if (shoppingCart.IsSendGift) { int num = 1; int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts(); if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0) { this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts; this.shoppingCartPromoGiftList.DataBind(); this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num); } } if (shoppingCart.IsReduced) { this.lblAmoutPrice.Text = string.Format("商品金额:{0}", shoppingCart.GetAmount().ToString("F2")); this.hlkReducedPromotion.Text = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2")); this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[] { shoppingCart.ReducedPromotionId }); } this.lblTotalPrice.Money = shoppingCart.GetTotal(); } }
protected void shoppingCartPromoGiftList_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName.Equals("change")) { int num = System.Convert.ToInt32(e.CommandArgument.ToString()); if (num > 0) { int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); if (this.shoppingCartPromoGiftList.SumNum > giftItemQuantity) { ShoppingCartProcessor.AddGiftItem(num, 1, PromoteType.SentGift); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } else { this.ShowMessage("礼品兑换失败,您不能超过最多兑换数", false); } } } }
private void BindShoppingCart() { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart == null) { this.pnlShopCart.Visible = false; this.pnlNoProduct.Visible = true; ShoppingCartProcessor.ClearShoppingCart(); return; } this.pnlShopCart.Visible = true; this.pnlNoProduct.Visible = false; if (shoppingCart.LineItems.Count > 0) { decimal tax = shoppingCart.CalTotalTax(); if (tax <= 50) { this.lblTax.Text = string.Format("商品关税:<span style='text-decoration: line-through;'>{0}</span>", tax.ToString("F2")); } else { this.lblTax.Text = string.Format("商品关税:{0}", tax.ToString("F2")); } //this.lblTax.Text = string.Format("商品关税:{0}", tax <50 ? "0.00" : tax.ToString("F2")); //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems) //{ // item.TaxRate = Math.Round(item.TaxRate * 100, 0); //} decimal activityReduct = shoppingCart.GetActivityPrice(); this.lblReducedActivity.Text = string.Format("活动优惠:{0}", activityReduct == 0 ? "0.00" : activityReduct.ToString("F2")); this.lblTotalPrice.Money = shoppingCart.GetNewTotalIncludeTax(); var query = from q in shoppingCart.LineItems group q by new { id = q.SupplierId } into g select new { SupplierId = g.FirstOrDefault().SupplierId, SupplierName = g.FirstOrDefault().SupplierName, Logo = g.FirstOrDefault().Logo, ProductId = g.FirstOrDefault().ProductId, SkuId = g.FirstOrDefault().SkuId, Name = g.FirstOrDefault().Name, ThumbnailUrl60 = g.FirstOrDefault().ThumbnailUrl60, TaxRate = g.FirstOrDefault().TaxRate, MemberPrice = g.FirstOrDefault().MemberPrice, Quantity = g.FirstOrDefault().Quantity, SKU = g.FirstOrDefault().SKU, ShippQuantity = g.FirstOrDefault().ShippQuantity, PromotionId = g.FirstOrDefault().PromotionId, PromotionName = g.FirstOrDefault().PromotionName, SubNewTotal = g.FirstOrDefault().SubNewTotal, NewTaxRate = GetNewTaxRate(g.FirstOrDefault().TaxRate, g.FirstOrDefault().MinTaxRate, g.FirstOrDefault().MaxTaxRate) //itemInfo = g.FirstOrDefault() }; this.shoppingCartProductList.DataSource = query; this.shoppingCartProductList.DataBind(); this.shoppingCartProductList.ShowProductCart(); } if (shoppingCart.LineGifts.Count > 0) { System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable = from s in shoppingCart.LineGifts where s.PromoType == 0 select s; System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 = from s in shoppingCart.LineGifts where s.PromoType == 5 select s; this.shoppingCartGiftList.DataSource = enumerable; this.shoppingCartGiftList.FreeDataSource = enumerable2; this.shoppingCartGiftList.DataBind(); this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0); } if (shoppingCart.IsSendGift) { int num = 1; int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts(); if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0) { this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts; this.shoppingCartPromoGiftList.DataBind(); this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num); } } //if (shoppingCart.IsReduced) //{ this.lblAmoutPrice.Text = string.Format("商品金额:{0}", shoppingCart.GetNewAmount().ToString("F2")); this.hlkReducedPromotion.Text = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2")); if (shoppingCart.ReducedPromotionId != 0) { this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[] { shoppingCart.ReducedPromotionId }); } //} HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"]; if (cookieSkuIds != null) { //cookieSkuIds.Expires = DateTime.Now.AddDays(-1); this.Page.Response.AppendCookie(cookieSkuIds); } }