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); } } }
protected bool CheckProductStock(string ckproductids) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, true, -1); if (shoppingCart == null) { return(false); } bool result = true; if (!string.IsNullOrEmpty(ckproductids)) { string[] source = ckproductids.Split(','); foreach (ShoppingCartItemInfo lineItem in shoppingCart.LineItems) { if (source.Contains(lineItem.SkuId)) { int skuStock = ShoppingCartProcessor.GetSkuStock(lineItem.SkuId, 0); if (skuStock < lineItem.Quantity) { result = false; break; } } } } return(result); }
protected void btnClearCart_Click(object sender, EventArgs e) { if (this.btnClearCart.Text == "请登录方能兑换" || HiContext.Current.User == null) { this.Page.Response.Redirect("Login.aspx?ReturnUrl=" + HttpContext.Current.Request.RawUrl, true); } else if (int.Parse(this.litNeedPoints.Text) <= int.Parse(this.litHasPoints.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts) { if (lineGift.GiftId == this.giftId) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>$(function(){alert_h(\"购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!\")});</script>"); return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet, this.isExemptionPostage)) { this.Page.Response.Redirect("/WapShop/ShoppingCart", true); } } }
private void btnChage_Click(object sender, EventArgs e) { if (this.btnChage.Text == "请登录方能兑换") { this.Page.Response.Redirect("/User/Login.aspx?ReturnUrl=" + HttpContext.Current.Request.RawUrl); } else if (HiContext.Current.User == null) { this.Page.Response.Redirect("/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("请登录后才能购买")); } else if (int.Parse(this.litNeedPoint.Text) <= int.Parse(this.litCurrentPoint.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts) { if (lineGift.GiftId == this.giftId) { string str = string.Format("ShowMsg(\"{0}\", false);", "购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); if (!this.Page.ClientScript.IsClientScriptBlockRegistered("ServerMessageScript")) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); } return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet, this.isexemptionpostage)) { this.Page.Response.Redirect("/ShoppingCart", true); } } }
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; this.BindDiscountName(shoppingCart); if (shoppingCart.LineItems.Values.Count > 0) { this.shoppingCartProductList.DataSource = shoppingCart.LineItems.Values; this.shoppingCartProductList.DataBind(); this.shoppingCartProductList.ShowProductCart(); } if (shoppingCart.LineGifts.Count > 0) { this.shoppingCartGiftList.DataSource = shoppingCart.LineGifts; this.shoppingCartGiftList.DataBind(); this.shoppingCartGiftList.ShowGiftCart(); } this.lblAmoutPrice.Money = shoppingCart.GetAmount(); this.lblTotalPrice.Money = shoppingCart.GetTotal(); } }
protected override void AttachChildControls() { this.rptCartProducts = (AppshopTemplatedRepeater)this.FindControl("rptCartProducts"); this.litTotal = (Literal)this.FindControl("litTotal"); this.hidUserPoints = (HtmlInputHidden)this.FindControl("hidUserPoints"); this.rptCartGifts = (AppshopTemplatedRepeater)this.FindControl("rptCartGifts"); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null) { this.rptCartProducts.DataSource = shoppingCart.LineItems; this.rptCartProducts.DataBind(); this.litTotal.Text = shoppingCart.GetAmount(false).F2ToString("f2"); if (shoppingCart.LineGifts.Count > 0) { IEnumerable <ShoppingCartGiftInfo> dataSource = from s in shoppingCart.LineGifts where s.PromoType == 0 select s; this.rptCartGifts.DataSource = dataSource; this.rptCartGifts.DataBind(); } this.hidUserPoints.Value = HiContext.Current.User.Points.ToString(); } PageTitle.AddSiteNameTitle("购物车"); }
decimal GetCartTotalPrice() { ShoppingCartInfo groupBuyShoppingCart; int num; string str; if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out num) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "groupBuy"))) { str = this.Page.Request.QueryString["productSku"]; groupBuyShoppingCart = ShoppingCartProcessor.GetGroupBuyShoppingCart(str, num); } else if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out num) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "countDown"))) { str = this.Page.Request.QueryString["productSku"]; groupBuyShoppingCart = ShoppingCartProcessor.GetCountDownShoppingCart(str, num); } else if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out num) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "signBuy"))) { str = this.Page.Request.QueryString["productSku"]; groupBuyShoppingCart = ShoppingCartProcessor.GetShoppingCart(str, num); } else { groupBuyShoppingCart = ShoppingCartProcessor.GetShoppingCart(); } decimal total = 0M; if (groupBuyShoppingCart != null) { total = groupBuyShoppingCart.GetTotal(); } return(total); }
void ProcessAddToCartBySkus(HttpContext context) { context.Response.ContentType = "application/json"; int quantity = int.Parse(context.Request["quantity"], NumberStyles.None); string skuId = context.Request["productSkuId"]; DataTable productInfoBySku = ShoppingProcessor.GetProductInfoBySku(skuId); if ((productInfoBySku == null) || (productInfoBySku.Rows.Count <= 0)) { context.Response.Write("{\"Status\":\"0\"}"); } else if ((((int)productInfoBySku.Rows[0]["Stock"]) <= 0) || (((int)productInfoBySku.Rows[0]["Stock"]) < quantity)) { context.Response.Write("{\"Status\":\"1\"}"); } else { string skuContent = string.Empty; foreach (DataRow row in productInfoBySku.Rows) { if (((row["AttributeName"] != DBNull.Value) && !string.IsNullOrEmpty((string)row["AttributeName"])) && ((row["ValueStr"] != DBNull.Value) && !string.IsNullOrEmpty((string)row["ValueStr"]))) { object obj2 = skuContent; skuContent = string.Concat(new object[] { obj2, row["AttributeName"], ":", row["ValueStr"], "; " }); } } ShoppingCartProcessor.AddLineItem((int)productInfoBySku.Rows[0]["ProductId"], skuId, skuContent, quantity); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); context.Response.Write("{\"Status\":\"OK\",\"TotalMoney\":\"" + shoppingCart.GetTotal().ToString(".00") + "\",\"Quantity\":\"" + shoppingCart.Quantity.ToString() + "\"}"); } }
private void btnChage_Click(object sender, System.EventArgs e) { if (this.btnChage.Text == "请登录方能兑换") { this.Page.Response.Redirect(Globals.ApplicationPath + "/Login.aspx"); return; } if (HiContext.Current.User.UserRole != UserRole.Member) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("请登录后才能购买")); return; } if (int.Parse(this.litNeedPoint.Text) <= int.Parse(this.litCurrentPoint.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo current in shoppingCart.LineGifts) { if (current.GiftId == this.giftId) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet)) { this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } } }
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(); } }
private void CalculateFreight(System.Web.HttpContext context)//海美生活 运费计算方法 { decimal money = 0m; if (!string.IsNullOrEmpty(context.Request["RegionId"])) { //int modeId = int.Parse(context.Request["ModeId"], System.Globalization.NumberStyles.None); decimal num = 0m; decimal.TryParse(context.Request["Weight"], out num); //int shippingId = int.Parse(context.Request["shippingId"], System.Globalization.NumberStyles.None); int regionId = int.Parse(context.Request["RegionId"], System.Globalization.NumberStyles.None); //ShippingModeInfo shippingMode = ShoppingProcessor.GetShippingMode(modeId, true); int buyAmount; ShoppingCartInfo shoppingCart; if (int.TryParse(context.Request["buyAmount"], out buyAmount) && !string.IsNullOrWhiteSpace(context.Request["productSku"])) { string productSkuId = System.Convert.ToString(context.Request["productSku"]); shoppingCart = ShoppingCartProcessor.GetShoppingCart(productSkuId, buyAmount, 0); } else { int boundlingid; if (int.TryParse(context.Request["buyAmount"], out buyAmount) && int.TryParse(context.Request["Bundlingid"], out boundlingid)) { shoppingCart = ShoppingCartProcessor.GetShoppingCart(boundlingid, buyAmount); } else { // HttpCookie cookieSkuIds = context.Request.Cookies["UserSession-SkuIds"]; if (cookieSkuIds == null || string.IsNullOrEmpty(cookieSkuIds.Value)) { shoppingCart = ShoppingCartProcessor.GetShoppingCart(); } else { shoppingCart = ShoppingCartProcessor.GetPartShoppingCartInfo(cookieSkuIds.Value); } } } // ShippingAddressInfo memberDefaultShippingAddressInfo = MemberProcessor.GetShippingAddress(shippingId); money = ShoppingCartProcessor.GetFreight(shoppingCart, regionId, false); //money = ShoppingProcessor.CalcShoppingCartFreight(shoppingCart, regionId); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{"); stringBuilder.Append("\"Status\":\"OK\","); stringBuilder.AppendFormat("\"Price\":\"{0}\"", Globals.FormatMoney(money)); stringBuilder.Append("}"); context.Response.ContentType = "text/plain"; context.Response.Write(stringBuilder.ToString()); } }
private void ProcessAddToCartBySkus(HttpContext context) { context.Response.ContentType = "application/json"; int quantity = int.Parse(context.Request["quantity"], NumberStyles.None); string skuId = context.Request["productSkuId"]; ShoppingCartProcessor.AddLineItem(skuId, quantity); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); context.Response.Write("{\"Status\":\"OK\",\"TotalMoney\":\"" + shoppingCart.GetTotal().ToString(".00") + "\",\"Quantity\":\"" + shoppingCart.GetQuantity().ToString() + "\"}"); }
protected override void AttachChildControls() { this.cartMoney = (FormatedMoneyLabel)this.FindControl("cartMoney"); this.cartNum = (Literal)this.FindControl("cartNum"); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null && (shoppingCart.LineGifts.Count > 0 || shoppingCart.LineItems.Count > 0)) { this.cartMoney.Money = shoppingCart.GetTotal(); this.cartNum.Text = shoppingCart.GetQuantity().ToString(); } }
protected override void OnInit(EventArgs e) { if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "groupBuy"))) { this.productSku = this.Page.Request.QueryString["productSku"]; this.isGroupBuy = true; this.shoppingCart = ShoppingCartProcessor.GetGroupBuyShoppingCart(this.productSku, this.buyAmount); this.buytype = "GroupBuy"; } else if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "countDown"))) { this.productSku = this.Page.Request.QueryString["productSku"]; this.isCountDown = true; this.shoppingCart = ShoppingCartProcessor.GetCountDownShoppingCart(this.productSku, this.buyAmount); this.buytype = "CountDown"; } else if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "signBuy"))) { this.productSku = this.Page.Request.QueryString["productSku"]; this.isSignBuy = true; this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.productSku, this.buyAmount); } else if ((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["Bundlingid"])) && (!string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "Bundling"))) { this.productSku = this.Page.Request.QueryString["Bundlingid"]; if (int.TryParse(this.productSku, out this.bundlingid)) { this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.bundlingid, this.buyAmount); this.isBundling = true; this.buytype = "Bundling"; } } else { this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if ((this.shoppingCart != null) && (this.shoppingCart.GetQuantity() == 0)) { this.buytype = "0"; } } if (this.shoppingCart == null) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("该件商品已经被管理员删除")); } else { if (this.SkinName == null) { this.SkinName = "Skin-SubmmitOrder.html"; } base.OnInit(e); } }
protected override void OnInit(EventArgs e) { if (this.SkinName == null) { this.SkinName = "Skin-OrderStoresSet.html"; } string text = ""; this.from = this.Page.Request.QueryString["from"].ToNullString().ToLower(); this.productSku = this.Page.Request.QueryString["productSku"].ToNullString(); this.buyAmount = this.Page.Request.QueryString["buyAmount"].ToInt(0); this.shippingModeId = this.Page.Request.QueryString["ShippingModeId"].ToInt(0); this.storeId = this.Page.Request.QueryString["ChooseStoreId"].ToInt(0); this.paymentModeId = this.Page.Request.QueryString["paymentModeId"].ToInt(0); this.deliveryTime = this.Page.Request.QueryString["deliveryTime"].ToNullString(); this.fightGroupActivityId = this.Page.Request.QueryString["fightGroupActivityId"].ToInt(0); if (this.deliveryTime != "任意时间" && this.deliveryTime != "工作日" && this.deliveryTime != "节假日") { this.deliveryTime = "任意时间"; } if (this.shippingModeId != 0 && this.shippingModeId != -2) { this.shippingModeId = 0; } this.productSku = this.Page.Request.QueryString["productSku"].ToNullString(); if (string.IsNullOrEmpty(this.productSku)) { this.productSku = this.Page.Request.QueryString["ckids"].ToNullString(); } if (!string.IsNullOrEmpty(this.productSku)) { string[] array = this.productSku.Split(','); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('|'); if (!string.IsNullOrEmpty(this.newProductSku)) { this.newProductSku += ","; } this.newProductSku += array2[0]; } } this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.from, this.productSku, this.buyAmount, 0, true, this.storeId, this.fightGroupActivityId); if (this.shoppingCart == null) { base.GotoResourceNotFound("购物车中没有任何商品"); } else { base.OnInit(e); } }
private void ProcessAddToCartBySkus(System.Web.HttpContext context) { context.Response.ContentType = "application/json"; int quantity = int.Parse(context.Request["quantity"], System.Globalization.NumberStyles.None); string skuId = context.Request["productSkuId"]; //判断库存 int oldQuan = ShoppingCartProcessor.GetSkuStock(skuId); if (quantity > oldQuan) { context.Response.Write("{\"Status\":\"1\",\"oldQuan\":\"" + oldQuan + "\"}"); return; } //检查商品是否超过限购数量 Member member = HiContext.Current.User as Member; if (member != null) { int MaxCount = 0; int Payquantity = ProductHelper.CheckPurchaseCount(skuId, member.UserId, out MaxCount); if ((Payquantity + quantity) > MaxCount && MaxCount != 0) //当前购买数量大于限购剩余购买数量 { context.Response.Write("{\"Status\":\"4\"}"); return; } } if (ShoppingCartProcessor.AddLineItem(skuId, quantity, 0) != AddCartItemStatus.Successed) { context.Response.Write("{\"Status\":\"2\"}"); return; } DataTable dt = ProductHelper.GetAdOrderInfo(skuId); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { context.Response.Write(string.Concat(new object[] { "{\"Status\":\"OK\",\"TotalMoney\":\"", shoppingCart.GetTotal().ToString(".00"), "\",\"Quantity\":\"", shoppingCart.GetQuantity().ToString(), "\",\"SkuQuantity\":\"", shoppingCart.GetQuantity_Sku(skuId), "\",\"data\":", Newtonsoft.Json.JsonConvert.SerializeObject(dt), "}" })); return; } context.Response.Write("{\"Status\":\"3\"}"); }
string UserLogin(string userName, string password) { string str = string.Empty; Member member = Users.GetUser(0, userName, false, true) as Member; if ((member == null) || member.IsAnonymous) { return("用户名或密码错误"); } if (HiContext.Current.SiteSettings.IsDistributorSettings) { if (member.ParentUserId.HasValue) { if (member.ParentUserId.Value == HiContext.Current.SiteSettings.UserId) { goto Label_00B2; } } return("您不是本站会员,请您进行注册"); } if (member.ParentUserId.HasValue && (member.ParentUserId.Value != 0)) { return("您不是本站会员,请您进行注册"); } Label_00B2: member.Password = password; switch (MemberProcessor.ValidLogin(member)) { case LoginUserStatus.AccountPending: return("用户账号还没有通过审核"); case LoginUserStatus.InvalidCredentials: return("用户名或密码错误"); case LoginUserStatus.Success: { HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false); member.GetUserCookie().WriteCookie(authCookie, 30, false); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); HiContext.Current.User = member; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } member.OnLogin(); return(str); } } return("未知错误"); }
protected override void AttachChildControls() { this.rptCartProducts = (AliOHTemplatedRepeater)this.FindControl("rptCartProducts"); this.litTotal = (System.Web.UI.WebControls.Literal) this.FindControl("litTotal"); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { this.rptCartProducts.DataSource = shoppingCart.LineItems; this.rptCartProducts.DataBind(); this.litTotal.Text = shoppingCart.GetAmount().ToString("F2"); } PageTitle.AddSiteNameTitle("购物车"); }
private void CalculateFreight1(System.Web.HttpContext context)//原有的计算运费方法 { decimal money = 0m; if (!string.IsNullOrEmpty(context.Request.Params["ModeId"]) && !string.IsNullOrEmpty(context.Request["RegionId"])) { int modeId = int.Parse(context.Request["ModeId"], System.Globalization.NumberStyles.None); decimal num = 0m; decimal.TryParse(context.Request["Weight"], out num); int regionId = int.Parse(context.Request["RegionId"], System.Globalization.NumberStyles.None); ShippingModeInfo shippingMode = ShoppingProcessor.GetShippingMode(modeId, true); int buyAmount; ShoppingCartInfo shoppingCart; if (int.TryParse(context.Request["buyAmount"], out buyAmount) && !string.IsNullOrWhiteSpace(context.Request["productSku"])) { string productSkuId = System.Convert.ToString(context.Request["productSku"]); shoppingCart = ShoppingCartProcessor.GetShoppingCart(productSkuId, buyAmount, 0); } else { int boundlingid; if (int.TryParse(context.Request["buyAmount"], out buyAmount) && int.TryParse(context.Request["Bundlingid"], out boundlingid)) { shoppingCart = ShoppingCartProcessor.GetShoppingCart(boundlingid, buyAmount); } else { shoppingCart = ShoppingCartProcessor.GetShoppingCart(); } } if (!shoppingCart.IsFreightFree) { if (shoppingCart.LineItems.Count((ShoppingCartItemInfo a) => !a.IsfreeShipping) > 0 || shoppingCart.LineGifts.Count > 0) { money = ShoppingProcessor.CalcFreight(regionId, shoppingCart.Weight, shippingMode); } } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{"); stringBuilder.Append("\"Status\":\"OK\","); stringBuilder.AppendFormat("\"Price\":\"{0}\"", Globals.FormatMoney(money)); stringBuilder.Append("}"); context.Response.ContentType = "text/plain"; context.Response.Write(stringBuilder.ToString()); }
protected override void AttachChildControls() { this.rptCartProducts = (VshopTemplatedRepeater)this.FindControl("rptCartProducts"); this.litTotal = (Literal)this.FindControl("litTotal"); this.divShowTotal = (HtmlGenericControl)this.FindControl("divShowTotal"); this.aLink = (HtmlAnchor)this.FindControl("aLink"); this.Page.Session["stylestatus"] = "0"; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { this.rptCartProducts.DataSource = shoppingCart.LineItems; this.rptCartProducts.DataBind(); this.litTotal.Text = shoppingCart.GetAmount().ToString("F2"); } PageTitle.AddSiteNameTitle("购物车"); }
private object GetProductQuantityInShoppingCart(int productId, Dictionary <string, SKUItem> dict) { var defaultValue = from item in dict select new { SkuId = item.Value.SkuId, Count = 0 }; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart == null || shoppingCart.LineItems.Count <= 0) { return(defaultValue); } IEnumerable <ShoppingCartItemInfo> items = shoppingCart.LineItems.Where(p => p.ProductId == productId); if (items == null || items.Count() <= 0) { return(defaultValue); } return(items.Select(p => new { SkuId = p.SkuId, Count = p.Quantity })); }
public string GetQuantity_Product(int productId) { string text = ""; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { foreach (ShoppingCartItemInfo current in shoppingCart.LineItems) { if (current.ProductId == productId) { string str = current.SkuId + "|" + current.Quantity; text = text + ((text == "") ? "" : ",") + str; } } return(text); } return(""); }
public static VWShoppingCartInfo GetCartSession() { #region 重新获取购物车SESSSION System.Web.HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies[Core.SysCookieName.ComBineCart]; string result = "0"; if (cookie != null) { result = cookie.Value; } if (result == "1") { RemoveCartSession(); ShoppingCartProcessor.WriteShoppingCartCookieByLogin(); CookieBLL.ComBineCart(0); } #endregion VWShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); return(shoppingCart); }
protected override void AttachChildControls() { this.txtSKU = (System.Web.UI.WebControls.TextBox) this.FindControl("txtSKU"); this.btnSKU = (System.Web.UI.WebControls.Button) this.FindControl("btnSKU"); this.btnClearCart = (ImageLinkButton)this.FindControl("btnClearCart"); this.shoppingCartProductList = (Common_ShoppingCart_ProductList)this.FindControl("Common_ShoppingCart_ProductList"); this.shoppingCartGiftList = (Common_ShoppingCart_GiftList)this.FindControl("Common_ShoppingCart_GiftList"); this.shoppingCartPromoGiftList = (Common_ShoppingCart_PromoGiftList)this.FindControl("Common_ShoppingCart_PromoGiftList"); this.lblTotalPrice = (FormatedMoneyLabel)this.FindControl("lblTotalPrice"); this.lblAmoutPrice = (System.Web.UI.WebControls.Literal) this.FindControl("lblAmoutPrice"); this.lblTax = (System.Web.UI.WebControls.Literal) this.FindControl("lblTax"); this.lblReducedActivity = (System.Web.UI.WebControls.Literal) this.FindControl("lblReducedActivity"); this.hlkReducedPromotion = (System.Web.UI.WebControls.HyperLink) this.FindControl("hlkReducedPromotion"); this.btnCheckout = (System.Web.UI.WebControls.Button) this.FindControl("btnCheckout"); this.pnlShopCart = (System.Web.UI.WebControls.Panel) this.FindControl("pnlShopCart"); this.pnlPromoGift = (System.Web.UI.WebControls.Panel) this.FindControl("pnlPromoGift"); this.pnlNoProduct = (System.Web.UI.WebControls.Panel) this.FindControl("pnlNoProduct"); this.hfdIsLogin = (System.Web.UI.WebControls.HiddenField) this.FindControl("hfdIsLogin"); this.btnSKU.Click += new System.EventHandler(this.btnSKU_Click); this.btnClearCart.Click += new System.EventHandler(this.btnClearCart_Click); this.shoppingCartProductList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.shoppingCartProductList_ItemCommand); this.shoppingCartProductList.ItemDataBound += shoppingCartProductList_ItemDataBound; this.shoppingCartGiftList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.shoppingCartGiftList_ItemCommand); this.shoppingCartGiftList.FreeItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.shoppingCartGiftList_FreeItemCommand); this.shoppingCartPromoGiftList.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.shoppingCartPromoGiftList_ItemCommand); this.btnCheckout.Click += new System.EventHandler(this.btnCheckout_Click); shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (!HiContext.Current.SiteSettings.IsOpenSiteSale) { this.btnSKU.Visible = false; this.btnCheckout.Visible = false; } if (!HiContext.Current.User.IsAnonymous) { this.hfdIsLogin.Value = "logined"; } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); this.BindShoppingCart(); sw.Stop(); ErrorLog.Write("PC端购物车加载所用的时间(毫秒):" + sw.ElapsedMilliseconds.ToString()); }
void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem) { System.Web.UI.HtmlControls.HtmlInputHidden promotionProductId = (System.Web.UI.HtmlControls.HtmlInputHidden)e.Item.FindControl("promotionProductId"); System.Web.UI.WebControls.Repeater dtPresendPro = (System.Web.UI.WebControls.Repeater)e.Item.FindControl("dtPresendPro"); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { // 赠送活动 List <ShoppingCartPresentInfo> presentList = (List <ShoppingCartPresentInfo>)shoppingCart.LinePresentPro; if (presentList != null && presentList.Count > 0) { var p = presentList.Where(m => m.PromotionProductId == (string.IsNullOrWhiteSpace(promotionProductId.Value) ? 0 : Convert.ToInt32(promotionProductId.Value))).Select(n => n); dtPresendPro.DataSource = p; dtPresendPro.DataBind(); } } } }
private string GetShoppingcartQuantityByUserId(string userId) { Member member = GetMember(userId.ToSeesionId()); string strQuantity = ""; if (member != null) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(member); if (shoppingCart != null) { int Quantity = shoppingCart.GetQuantity(); if (Quantity > 0) { strQuantity = Quantity.ToString(); } } } return(strQuantity); }
private void BindShoppingCart() { this.cartInfo = ShoppingCartProcessor.GetShoppingCart(null, true, true, -1); if (this.cartInfo == null) { this.pnlShopCart.Visible = false; this.pnlNoProduct.Visible = true; ShoppingCartProcessor.ClearShoppingCart(); } else { this.pnlShopCart.Visible = true; this.pnlNoProduct.Visible = false; if (this.cartInfo.LineItems.Count > 0) { this.shoppingCartProductList.ListCartItems = this.cartInfo.LineItems; this.shoppingCartProductList.settings = this.setting; this.shoppingCartProductList.DataBind(); this.shoppingCartProductList.ShowProductCart(); this.shoppingCartStoreList.ListCartItems = this.cartInfo.LineItems; this.shoppingCartStoreList.DataBind(); } if (this.cartInfo.LineGifts.Count > 0) { IEnumerable <ShoppingCartGiftInfo> enumerable = from s in this.cartInfo.LineGifts where s.PromoType == 0 select s; IEnumerable <ShoppingCartGiftInfo> enumerable2 = from s in this.cartInfo.LineGifts where s.PromoType == 5 select s; this.hidPointGifts.Value = enumerable.Count().ToString(); this.shoppingCartGiftList.DataSource = enumerable; this.shoppingCartGiftList.DataBind(); this.shoppingCartGiftList.ShowGiftCart(enumerable.Count() > 0); } this.lblTotalPrice.Money = this.cartInfo.GetTotal(false); } }
protected void listOrders_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem) { System.Web.UI.HtmlControls.HtmlInputHidden hidsupplierId = (System.Web.UI.HtmlControls.HtmlInputHidden)e.Item.FindControl("hidsupplierId"); System.Web.UI.WebControls.Repeater repeater = (System.Web.UI.WebControls.Repeater)e.Item.FindControl("rpProduct"); if (repeater != null) { repeater.ItemDataBound += repeater_ItemDataBound; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { List <ShoppingCartItemInfo> list = (List <ShoppingCartItemInfo>)shoppingCart.LineItems; var llist = list.Where(p => p.SupplierId == Convert.ToInt32(hidsupplierId.Value)).Select(c => c); repeater.DataSource = llist; repeater.DataBind(); } } } }
/// <summary> /// 单击兑换按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buyButton_Click(object sender, EventArgs e) { //传递到购物车 ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (((shoppingCart != null) && (shoppingCart.LineGifts != null)) && (shoppingCart.LineGifts.Count > 0)) { foreach (ShoppingCartGiftInfo info2 in shoppingCart.LineGifts) { if (info2.GiftId == this.GiftId) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); return; } } } //获取数量 int buyNum = Convert.ToInt32(System.Web.HttpContext.Current.Request.Form.Get("buyNum")); if (ShoppingCartProcessor.AddGiftItem(this.GiftId, buyNum)) { this.Page.Response.Redirect("/Vshop/ShoppingCart.aspx"); } }
private void ProcessAddToCartBySkus(HttpContext context) { context.Response.ContentType = "application/json"; int quantity = int.Parse(context.Request["quantity"], NumberStyles.None); string skuId = context.Request["productSkuId"]; int num = context.Request["productSkuId"].ToNullString().Split('_')[0].ToInt(0); if (ShoppingCartProcessor.AddLineItem(skuId, quantity, false, 0) == AddCartItemStatus.Successed) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null) { context.Response.Write("{\"Status\":\"OK\",\"TotalMoney\":\"" + shoppingCart.GetTotal(false).ToString(".00") + "\",\"Quantity\":\"" + shoppingCart.GetQuantity(false).ToString() + "\",\"SkuQuantity\":\"" + shoppingCart.GetQuantity_Sku(skuId) + "\"}"); } else { context.Response.Write("{\"Status\":\"3\"}"); } } else { context.Response.Write("{\"Status\":\"2\"}"); } }