예제 #1
0
 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);
 }
예제 #2
0
 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);
         }
     }
 }
예제 #3
0
파일: SalesData.cs 프로젝트: davinx/himedi
 public override bool AddPurchaseItem(PurchaseShoppingCartItemInfo item)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_PurchaseShoppingCarts (SkuId, ProductId,SKU,DistributorUserId,CostPrice,Quantity,ItemListPrice,ItemPurchasePrice,ItemDescription,ThumbnailsUrl,Weight,SKUContent)VALUES(@SkuId, @ProductId,@SKU,@DistributorUserId,@CostPrice,@Quantity,@ItemListPrice,@ItemPurchasePrice,@ItemDescription,@ThumbnailsUrl,@Weight,@SKUContent)");
     database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, item.SkuId);
     database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, item.ProductId);
     database.AddInParameter(sqlStringCommand, "SKU", DbType.String, item.SKU);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, item.Quantity);
     database.AddInParameter(sqlStringCommand, "ItemListPrice", DbType.Currency, item.ItemListPrice);
     database.AddInParameter(sqlStringCommand, "ItemPurchasePrice", DbType.Currency, item.ItemPurchasePrice);
     database.AddInParameter(sqlStringCommand, "CostPrice", DbType.Currency, item.CostPrice);
     database.AddInParameter(sqlStringCommand, "ItemDescription", DbType.String, item.ItemDescription);
     database.AddInParameter(sqlStringCommand, "ThumbnailsUrl", DbType.String, item.ThumbnailsUrl);
     database.AddInParameter(sqlStringCommand, "Weight", DbType.Int32, item.ItemWeight);
     database.AddInParameter(sqlStringCommand, "SKUContent", DbType.String, item.SKUContent);
     try
     {
         return (database.ExecuteNonQuery(sqlStringCommand) == 1);
     }
     catch
     {
         return 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") && (button.Text == "添加"))
     {
         PurchaseShoppingCartItemInfo item = new PurchaseShoppingCartItemInfo();
         DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId);
         if (num > ((int)skuContentBySku.Rows[0]["Stock"]))
         {
             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 = (int)skuContentBySku.Rows[0]["Weight"];
             }
             item.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"];
             item.Quantity = num;
             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, purchaseOrderId))
             {
                 UpdatePurchaseOrder();
                 BindOrderItems();
                 ReBindData(true, false);
             }
             else
             {
                 ShowMsg("添加商品失败", false);
             }
         }
     }
 }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
 private PurchaseShoppingCartItemInfo AddPurchaseShoppingCartItemInfo(string skuId, int quantity)
 {
     PurchaseShoppingCartItemInfo info = new PurchaseShoppingCartItemInfo();
     DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId);
     if (quantity > ((int)skuContentBySku.Rows[0]["Stock"]))
     {
         return null;
     }
     foreach (DataRow row in skuContentBySku.Rows)
     {
         if (!(string.IsNullOrEmpty(row["AttributeName"].ToString()) || string.IsNullOrEmpty(row["ValueStr"].ToString())))
         {
             object sKUContent = info.SKUContent;
             info.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " });
         }
     }
     info.SkuId = skuId;
     info.ProductId = (int)skuContentBySku.Rows[0]["ProductId"];
     if (skuContentBySku.Rows[0]["SKU"] != DBNull.Value)
     {
         info.SKU = (string)skuContentBySku.Rows[0]["SKU"];
     }
     if (skuContentBySku.Rows[0]["Weight"] != DBNull.Value)
     {
         info.ItemWeight = (int)skuContentBySku.Rows[0]["Weight"];
     }
     info.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"];
     info.Quantity = quantity;
     info.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"];
     info.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"];
     if (skuContentBySku.Rows[0]["CostPrice"] != DBNull.Value)
     {
         info.CostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"];
     }
     if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != DBNull.Value)
     {
         info.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"];
     }
     return info;
 }
예제 #7
0
파일: DataMapper.cs 프로젝트: davinx/himedi
 public static PurchaseShoppingCartItemInfo PopulatePurchaseShoppingCartItemInfo(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     PurchaseShoppingCartItemInfo info = new PurchaseShoppingCartItemInfo();
     info.SkuId = (string) reader["SkuId"];
     info.SKUContent = (reader["SKUContent"] != DBNull.Value) ? ((string) reader["SKUContent"]) : string.Empty;
     info.SKU = (reader["SKU"] != DBNull.Value) ? ((string) reader["SKU"]) : string.Empty;
     info.ProductId = (int) reader["ProductId"];
     info.ThumbnailsUrl = (reader["ThumbnailsUrl"] != DBNull.Value) ? ((string) reader["ThumbnailsUrl"]) : string.Empty;
     info.Quantity = (int) reader["Quantity"];
     info.ItemDescription = (string) reader["ItemDescription"];
     info.ItemWeight = (int) reader["Weight"];
     info.ItemListPrice = (decimal) reader["ItemListPrice"];
     info.ItemPurchasePrice = (decimal) reader["ItemPurchasePrice"];
     if (DBNull.Value != reader["CostPrice"])
     {
         info.CostPrice = (decimal) reader["CostPrice"];
     }
     return info;
 }
예제 #8
0
파일: SalesData.cs 프로젝트: davinx/himedi
 public override bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("INSERT INTO Hishop_PurchaseOrderItems (PurchaseOrderId,SkuId, ProductId,SKU,CostPrice,Quantity,ItemListPrice,ItemPurchasePrice,ItemDescription,ItemHomeSiteDescription,ThumbnailsUrl,Weight,SKUContent)");
     builder.Append("VALUES(@PurchaseOrderId,@SkuId, @ProductId,@SKU,@CostPrice,@Quantity,@ItemListPrice,@ItemPurchasePrice,@ItemDescription,@ItemHomeSiteDescription,@ThumbnailsUrl,@Weight,@SKUContent);");
     DbCommand sqlStringCommand = database.GetSqlStringCommand(builder.ToString());
     database.AddInParameter(sqlStringCommand, "PurchaseOrderId", DbType.String, POrderId);
     database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, item.SkuId);
     database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, item.ProductId);
     database.AddInParameter(sqlStringCommand, "SKU", DbType.String, item.SKU);
     database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, item.Quantity);
     database.AddInParameter(sqlStringCommand, "ItemListPrice", DbType.Currency, item.ItemListPrice);
     database.AddInParameter(sqlStringCommand, "ItemPurchasePrice", DbType.Currency, item.ItemPurchasePrice);
     database.AddInParameter(sqlStringCommand, "CostPrice", DbType.Currency, item.CostPrice);
     database.AddInParameter(sqlStringCommand, "ItemDescription", DbType.String, item.ItemDescription);
     database.AddInParameter(sqlStringCommand, "ItemHomeSiteDescription", DbType.String, item.ItemDescription);
     database.AddInParameter(sqlStringCommand, "ThumbnailsUrl", DbType.String, item.ThumbnailsUrl);
     database.AddInParameter(sqlStringCommand, "Weight", DbType.Int32, item.ItemWeight);
     database.AddInParameter(sqlStringCommand, "SKUContent", DbType.String, item.SKUContent);
     try
     {
         return (database.ExecuteNonQuery(sqlStringCommand) >= 1);
     }
     catch
     {
         return false;
     }
 }
예제 #9
0
 public abstract bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId);
예제 #10
0
 public static bool AddPurchaseItem(PurchaseShoppingCartItemInfo item)
 {
     return SubsiteSalesProvider.Instance().AddPurchaseItem(item);
 }