public static bool UpdateLineItem(string sku, OrderInfo order, int quantity) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); order.LineItems[sku].ShipmentQuantity = quantity; order.LineItems[sku].Quantity = quantity; order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; if (!provider.UpdateLineItem(order.OrderId, order.LineItems[sku], dbTran)) { dbTran.Rollback(); return(false); } if (!provider.UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool UpdateLineItem(string sku, OrderInfo order, int quantity) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); int userId = order.UserId; if (userId == 0x44c) { userId = 0; } Member user = Users.GetUser(userId) as Member; if (user != null) { int num; string str; int num2; int num3; string str2; decimal?nullable; int gradeId = user.GradeId; provider.GetLineItemPromotions(order.LineItems[sku].ProductId, quantity, out num, out str, out num2, out num3, out str2, out nullable, gradeId); order.LineItems[sku].PurchaseGiftId = num; order.LineItems[sku].PurchaseGiftName = str; order.LineItems[sku].ShipmentQuantity = quantity + num2; order.LineItems[sku].WholesaleDiscountId = num3; order.LineItems[sku].WholesaleDiscountName = str2; order.LineItems[sku].Quantity = quantity; if (nullable.HasValue) { decimal itemListPrice = order.LineItems[sku].ItemListPrice; order.LineItems[sku].ItemAdjustedPrice = Convert.ToDecimal((itemListPrice * nullable) / 100M); } else { order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; } } else { order.LineItems[sku].ShipmentQuantity = quantity; order.LineItems[sku].Quantity = quantity; order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; } if (!provider.UpdateLineItem(order.OrderId, order.LineItems[sku], dbTran)) { dbTran.Rollback(); return(false); } if (!provider.UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }