private void btnBatchBuy_Click(object sender, System.EventArgs e) { int num = 0; string text = this.Page.Request.Form["chkskus"]; if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; string text3 = this.Page.Request.Form[text2]; if (!string.IsNullOrWhiteSpace(text3) && int.Parse(text3) > 0) { ShoppingCartProcessor.AddLineItem(text2, int.Parse(text3.Trim()), 0); num++; } } } if (num > 0) { this.ShowMessage("选择的商品已经放入购物车", true); } else { this.ShowMessage("请选择要购买的商品!", false); } this.BindProducts(); }
protected void btnSKU_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { this.ShowMessage("请输入货号", false, "", 1); } else { IList <string> skuIdsBysku = ShoppingProcessor.GetSkuIdsBysku(this.txtSKU.Text.Trim()); if (skuIdsBysku == null || skuIdsBysku.Count == 0) { this.ShowMessage("货号无效,请确认后重试", false, "", 1); } else { bool flag = false; foreach (string item in skuIdsBysku) { if (ShoppingCartProcessor.GetSkuStock(item, 0) > 1) { ShoppingCartProcessor.AddLineItem(item, 1, false, 0); } else { flag = true; } } if (flag) { this.ShowMessage("指定的货号库存不足", false, "", 1); } this.BindShoppingCart(); } } }
private void btnBatchBuy_Click(object sender, EventArgs e) { int num = 0; foreach (GridViewRow row in this.batchbuys.Rows) { CheckBox box = (CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { string skuId = this.batchbuys.DataKeys[row.RowIndex].Value.ToString(); TextBox box2 = (TextBox)row.FindControl("txtBuyNum"); if (string.IsNullOrEmpty(box2.Text.Trim()) || (int.Parse(box2.Text.Trim()) <= 0)) { this.ShowMessage("购买数量值不存在或为非法值", true); return; } ShoppingCartProcessor.AddLineItem(skuId, int.Parse(box2.Text.Trim())); num++; } } if (num > 0) { this.ShowMessage("选择的商品已经放入购物车", true); } else { this.ShowMessage("请选择要购买的商品!", false); } }
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 btnBatchBuy_Click(object sender, EventArgs e) { int num = 0; string text = this.Page.Request.Form["chkskus"]; if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(','); string[] array2 = array; foreach (string text2 in array2) { string text3 = this.Page.Request.Form[text2]; if (!string.IsNullOrWhiteSpace(text3) && int.Parse(text3) > 0) { ShoppingCartProcessor.AddLineItem(text2, int.Parse(text3.Trim()), false, 0); num++; } } } if (num > 0) { this.ShowMessage("选择的商品已经放入购物车", true, "", 1); } else { this.ShowMessage("请选择要购买的商品!", false, "", 1); } this.BindProducts(); }
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() + "\"}"); }
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\"}"); }
protected void btnSKU_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { this.ShowMessage("请输入货号", false); return; } System.Collections.Generic.IList <string> skuIdsBysku = ShoppingProcessor.GetSkuIdsBysku(this.txtSKU.Text.Trim()); if (skuIdsBysku == null || skuIdsBysku.Count == 0) { this.ShowMessage("货号无效,请确认后重试", false); return; } foreach (string current in skuIdsBysku) { ShoppingCartProcessor.AddLineItem(current, 1, 0); } this.BindShoppingCart(); }
void btnBatchBuy_Click(object sender, EventArgs e) { bool flag = false; foreach (GridViewRow row in this.batchbuys.Rows) { CheckBox box = (CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { string skuId = this.batchbuys.DataKeys[row.RowIndex].Value.ToString(); TextBox box2 = (TextBox)row.FindControl("txtBuyNum"); Literal literal = (Literal)row.FindControl("litProductId"); if (string.IsNullOrEmpty(box2.Text.Trim()) || (int.Parse(box2.Text.Trim()) <= 0)) { this.ShowMessage("购买数量值不存在或为非法值", true); return; } DataTable skuContentBySku = ControlProvider.Instance().GetSkuContentBySku(skuId); string skuContent = string.Empty; foreach (DataRow row2 in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(row2["AttributeName"].ToString()) && !string.IsNullOrEmpty(row2["ValueStr"].ToString())) { object obj2 = skuContent; skuContent = string.Concat(new object[] { obj2, row2["AttributeName"], ":", row2["ValueStr"], "; " }); } } flag = true; ShoppingCartProcessor.AddLineItem(int.Parse(literal.Text), skuId, skuContent, int.Parse(box2.Text.Trim())); } } if (flag) { this.ShowMessage("选择的商品已经放入购物车", true); } else { this.ShowMessage("请选择要购买的商品!", false); } }
protected void btnSKU_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { this.ShowMessage("请输入货号", false); } else { IList <string> skuIdsBysku = ShoppingProcessor.GetSkuIdsBysku(this.txtSKU.Text.Trim()); if ((skuIdsBysku == null) || (skuIdsBysku.Count == 0)) { this.ShowMessage("货号无效,请确认后重试", false); } else { foreach (string str in skuIdsBysku) { ShoppingCartProcessor.AddLineItem(str, 1); } this.BindShoppingCart(); } } }
protected void btnSKU_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { this.ShowMessage("请输入货号", false); } else { IList <string> skuIdsBysku = ShoppingProcessor.GetSkuIdsBysku(this.txtSKU.Text.Trim()); if ((skuIdsBysku == null) || (skuIdsBysku.Count == 0)) { this.ShowMessage("货号无效,请确认后重试", false); } else { foreach (string str in skuIdsBysku) { DataTable productInfoBySku = ShoppingProcessor.GetProductInfoBySku(str); if ((productInfoBySku != null) && (productInfoBySku.Rows.Count > 0)) { string skuContent = string.Empty; foreach (DataRow row in productInfoBySku.Rows) { if (!string.IsNullOrEmpty(row["AttributeName"].ToString()) && !string.IsNullOrEmpty(row["ValueStr"].ToString())) { object obj2 = skuContent; skuContent = string.Concat(new object[] { obj2, row["AttributeName"], ":", row["ValueStr"], "; " }); } } ShoppingCartProcessor.AddLineItem((int)productInfoBySku.Rows[0]["ProductId"], str, skuContent, 1); } } this.BindShoppingCart(); } } }
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\"}"); } }