public static bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId) { SalesProvider provider = SalesProvider.Instance(); int currentPOrderItemQuantity = provider.GetCurrentPOrderItemQuantity(POrderId, item.SkuId); if (currentPOrderItemQuantity == 0) { return(provider.AddPurchaseOrderItem(item, POrderId)); } return(provider.UpdatePurchaseOrderQuantity(POrderId, item.SkuId, item.Quantity + currentPOrderItemQuantity)); }
private PurchaseShoppingCartItemInfo AddPurchaseShoppingCartItemInfo(string skuId, int quantity) { PurchaseShoppingCartItemInfo purchaseShoppingCartItemInfo = new PurchaseShoppingCartItemInfo(); System.Data.DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId); if (quantity > (int)skuContentBySku.Rows[0]["Stock"]) { return(null); } foreach (System.Data.DataRow dataRow in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(dataRow["AttributeName"].ToString()) && !string.IsNullOrEmpty(dataRow["ValueStr"].ToString())) { PurchaseShoppingCartItemInfo expr_7A = purchaseShoppingCartItemInfo; object sKUContent = expr_7A.SKUContent; expr_7A.SKUContent = string.Concat(new object[] { sKUContent, dataRow["AttributeName"], ":", dataRow["ValueStr"], "; " }); } } purchaseShoppingCartItemInfo.SkuId = skuId; purchaseShoppingCartItemInfo.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } purchaseShoppingCartItemInfo.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; purchaseShoppingCartItemInfo.Quantity = quantity; purchaseShoppingCartItemInfo.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; purchaseShoppingCartItemInfo.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["CostPrice"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.CostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } return(purchaseShoppingCartItemInfo); }
public void grdSkus_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { Grid grid = (Grid)sender; int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; string text = (string)grid.DataKeys[rowIndex].Value; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); System.Web.UI.WebControls.LinkButton linkButton = (System.Web.UI.WebControls.LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); int quantity; if (int.TryParse(textBox.Text.Trim(), out quantity) && int.Parse(textBox.Text.Trim()) > 0 && !textBox.Text.Trim().Contains(".")) { if (e.CommandName == "add") { if (linkButton.Text == "添加") { PurchaseShoppingCartItemInfo purchaseShoppingCartItemInfo = new PurchaseShoppingCartItemInfo(); purchaseShoppingCartItemInfo = this.AddPurchaseShoppingCartItemInfo(text, quantity); if (purchaseShoppingCartItemInfo == null) { this.ShowMsg("商品库存不够", false); return; } if (SubsiteSalesHelper.AddPurchaseItem(purchaseShoppingCartItemInfo)) { this.BindData(); return; } this.ShowMsg("添加商品失败", false); return; } else { if (SubsiteSalesHelper.DeletePurchaseShoppingCartItem(text)) { this.BindData(); return; } this.ShowMsg("删除失败", false); } } return; } this.ShowMsg("数量不能为空,必需为大于零的正整数", false); }
public void grdSkus_RowCommand(object sender, GridViewCommandEventArgs e) { int num; Grid grid = (Grid)sender; int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; string skuId = (string)grid.DataKeys[rowIndex].Value; TextBox box = (TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); LinkButton button = (LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); if ((!int.TryParse(box.Text.Trim(), out num) || (int.Parse(box.Text.Trim()) <= 0)) || box.Text.Trim().Contains(".")) { ShowMsg("数量不能为空,必需为大于零的正整数", false); } else if (e.CommandName == "add") { if (button.Text == "添加") { PurchaseShoppingCartItemInfo item = new PurchaseShoppingCartItemInfo(); item = AddPurchaseShoppingCartItemInfo(skuId, num); if (item == null) { ShowMsg("商品库存不够", false); } else if (SubsiteSalesHelper.AddPurchaseItem(item)) { BindData(); } else { ShowMsg("添加商品失败", false); } } else if (SubsiteSalesHelper.DeletePurchaseShoppingCartItem(skuId)) { BindData(); } else { ShowMsg("删除失败", false); } } }
public abstract bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId);
public abstract bool AddPurchaseItem(PurchaseShoppingCartItemInfo item);
public void grdSkus_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { Grid grid = (Grid)sender; int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; string skuId = (string)grid.DataKeys[rowIndex].Value; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); System.Web.UI.WebControls.LinkButton linkButton = (System.Web.UI.WebControls.LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); int num; if (int.TryParse(textBox.Text.Trim(), out num) && int.Parse(textBox.Text.Trim()) > 0 && !textBox.Text.Trim().Contains(".")) { if (e.CommandName == "add" && linkButton.Text == "添加") { PurchaseShoppingCartItemInfo purchaseShoppingCartItemInfo = new PurchaseShoppingCartItemInfo(); System.Data.DataTable skuContentBySkuBuDistorUserId = ProductHelper.GetSkuContentBySkuBuDistorUserId(skuId, this.distorUserId); if (num > (int)skuContentBySkuBuDistorUserId.Rows[0]["Stock"]) { this.ShowMsg("商品库存不够", false); return; } foreach (System.Data.DataRow dataRow in skuContentBySkuBuDistorUserId.Rows) { if (!string.IsNullOrEmpty(dataRow["AttributeName"].ToString()) && !string.IsNullOrEmpty(dataRow["ValueStr"].ToString())) { PurchaseShoppingCartItemInfo expr_190 = purchaseShoppingCartItemInfo; object sKUContent = expr_190.SKUContent; expr_190.SKUContent = string.Concat(new object[] { sKUContent, dataRow["AttributeName"], ":", dataRow["ValueStr"], "; " }); } } purchaseShoppingCartItemInfo.SkuId = skuId; purchaseShoppingCartItemInfo.ProductId = (int)skuContentBySkuBuDistorUserId.Rows[0]["ProductId"]; if (skuContentBySkuBuDistorUserId.Rows[0]["SKU"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.SKU = (string)skuContentBySkuBuDistorUserId.Rows[0]["SKU"]; } if (skuContentBySkuBuDistorUserId.Rows[0]["Weight"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ItemWeight = (decimal)skuContentBySkuBuDistorUserId.Rows[0]["Weight"]; } purchaseShoppingCartItemInfo.ItemPurchasePrice = (decimal)skuContentBySkuBuDistorUserId.Rows[0]["PurchasePrice"]; purchaseShoppingCartItemInfo.Quantity = num; purchaseShoppingCartItemInfo.ItemListPrice = (decimal)skuContentBySkuBuDistorUserId.Rows[0]["SalePrice"]; purchaseShoppingCartItemInfo.ItemDescription = (string)skuContentBySkuBuDistorUserId.Rows[0]["ProductName"]; if (skuContentBySkuBuDistorUserId.Rows[0]["CostPrice"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.CostPrice = (decimal)skuContentBySkuBuDistorUserId.Rows[0]["CostPrice"]; } if (skuContentBySkuBuDistorUserId.Rows[0]["ThumbnailUrl40"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ThumbnailsUrl = (string)skuContentBySkuBuDistorUserId.Rows[0]["ThumbnailUrl40"]; } if (SalesHelper.AddPurchaseOrderItem(purchaseShoppingCartItemInfo, this.purchaseOrderId)) { this.UpdatePurchaseOrder(); this.BindOrderItems(); this.ReBindData(true, false); this.ShowMsg("添加规格商品成功", true); return; } this.ShowMsg("添加规格商品失败", false); } return; } this.ShowMsg("数量不能为空,必需为大于零的正整数", false); }
public void grdSkus_RowCommand(object sender, GridViewCommandEventArgs e) { int num2; Grid grid = (Grid)sender; int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; string skuId = (string)grid.DataKeys[rowIndex].Value; TextBox box = (TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); LinkButton button = (LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); if ((!int.TryParse(box.Text.Trim(), out num2) || (int.Parse(box.Text.Trim()) <= 0)) || box.Text.Trim().Contains(".")) { this.ShowMsg("数量不能为空,必需为大于零的正整数", false); } else if ((e.CommandName == "add") && (button.Text == "添加")) { PurchaseShoppingCartItemInfo item = new PurchaseShoppingCartItemInfo(); DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId); if (num2 > ((int)skuContentBySku.Rows[0]["Stock"])) { this.ShowMsg("商品库存不够", false); } else { foreach (DataRow row in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(row["AttributeName"].ToString()) && !string.IsNullOrEmpty(row["ValueStr"].ToString())) { object sKUContent = item.SKUContent; item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " }); } } item.SkuId = skuId; item.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != DBNull.Value) { item.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != DBNull.Value) { item.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } item.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; item.Quantity = num2; item.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; item.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["CostPrice"] != DBNull.Value) { item.CostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != DBNull.Value) { item.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } if (SubsiteSalesHelper.AddPurchaseOrderItem(item, this.purchaseOrderId)) { this.UpdatePurchaseOrder(); this.BindOrderItems(); this.ReBindData(true, false); } else { this.ShowMsg("添加商品失败", false); } } } }
private void lkbtnAdddCheck_Click(object sender, EventArgs e) { int num = 0; bool flag = true; Dictionary <string, int> dictionary = new Dictionary <string, int>(); foreach (GridViewRow row in grdAuthorizeProducts.Rows) { GridView view = row.FindControl("grdSkus") as GridView; foreach (GridViewRow row2 in view.Rows) { CheckBox box = (CheckBox)row2.FindControl("checkboxCol"); TextBox box2 = row2.FindControl("txtNum") as TextBox; if ((box != null) && box.Checked) { int num2; num++; if ((!int.TryParse(box2.Text.Trim(), out num2) || (int.Parse(box2.Text.Trim()) <= 0)) || box2.Text.Trim().Contains(".")) { flag = false; break; } dictionary.Add(view.DataKeys[row2.RowIndex].Value.ToString(), num2); } } if (!flag) { break; } } if (num == 0) { ShowMsg("请先选择要添加的商品", false); } else if (!flag) { ShowMsg("数量不能为空,必需为大于零的正整数", false); } else { int num3 = 0; foreach (KeyValuePair <string, int> pair in dictionary) { PurchaseShoppingCartItemInfo item = new PurchaseShoppingCartItemInfo(); item = AddPurchaseShoppingCartItemInfo(pair.Key, Convert.ToInt32(pair.Value)); if (item == null) { ShowMsg("商品库存不够", false); break; } if (!SubsiteSalesHelper.AddPurchaseItem(item)) { break; } num3++; } if (num3 > 0) { ShowMsg(string.Format("成功添加了{0}件商品", num3), true); BindData(); } else { ShowMsg("添加商品失败", false); } } }
public static bool AddPurchaseItem(PurchaseShoppingCartItemInfo item) { return(SubsiteSalesProvider.Instance().AddPurchaseItem(item)); }
private void lkbtnAdddCheck_Click(object sender, System.EventArgs e) { int num = 0; bool flag = true; System.Collections.Generic.Dictionary <string, int> dictionary = new System.Collections.Generic.Dictionary <string, int>(); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdAuthorizeProducts.Rows) { System.Web.UI.WebControls.GridView gridView = gridViewRow.FindControl("grdSkus") as System.Web.UI.WebControls.GridView; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow2 in gridView.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow2.FindControl("checkboxCol"); System.Web.UI.WebControls.TextBox textBox = gridViewRow2.FindControl("txtNum") as System.Web.UI.WebControls.TextBox; if (checkBox != null && checkBox.Checked) { num++; int value; if (!int.TryParse(textBox.Text.Trim(), out value) || int.Parse(textBox.Text.Trim()) <= 0 || textBox.Text.Trim().Contains(".")) { flag = false; break; } dictionary.Add(gridView.DataKeys[gridViewRow2.RowIndex].Value.ToString(), value); } } if (!flag) { break; } } if (num == 0) { this.ShowMsg("请先选择要添加的商品", false); return; } if (!flag) { this.ShowMsg("数量不能为空,必需为大于零的正整数", false); return; } int num2 = 0; foreach (System.Collections.Generic.KeyValuePair <string, int> current in dictionary) { PurchaseShoppingCartItemInfo purchaseShoppingCartItemInfo = new PurchaseShoppingCartItemInfo(); purchaseShoppingCartItemInfo = this.AddPurchaseShoppingCartItemInfo(current.Key, System.Convert.ToInt32(current.Value)); if (purchaseShoppingCartItemInfo == null) { this.ShowMsg("商品库存不够", false); break; } if (SubsiteSalesHelper.AddPurchaseItem(purchaseShoppingCartItemInfo)) { num2++; } } if (num2 > 0) { this.ShowMsg(string.Format("成功添加了{0}件商品", num2), true); this.BindData(); return; } this.ShowMsg("添加商品失败", false); }