public static bool UpdateSKUList(ItemSKU _skuItem, List<ItemSKU> toDeleteSKUItemList) { using (var session = NHibernateHelper.OpenSession()) { using (var tx = session.BeginTransaction()) { try { session.SaveOrUpdate(_skuItem); //Delete SKU foreach (var skuItem in toDeleteSKUItemList) { /* skuItem.StockQuantity = 0; session.SaveOrUpdate(skuItem); */ session.Delete(skuItem); } tx.Commit(); return true; } catch (Exception ex) { tx.Rollback(); log.Error(ex); return false; } } } }
public static bool SaverPurchaseOrder(PurchaseOrder order) { using (var session = NHibernateHelper.OpenSession()) { using (var tx = session.BeginTransaction()) { try { //update itemprice and also check if item is inReserve foreach (var itemprice in order.ItemPriceList) { itemprice.Purchase = order; if (itemprice.Item.InReserve && itemprice.Item.ReserveStock < (itemprice.PackageQuantity * itemprice.QuantityPerPack)) itemprice.Item.InReserve = false; } // update/create skuItem. foreach (var priceItem in order.ItemPriceList) { ItemSKU skuItem; skuItem = Builders.ItemSKUBuilder.GetItemSKUBasedOnPrice(priceItem.Item.ID, priceItem.Retail, priceItem.Wholesale); if (skuItem != null) skuItem.StockQuantity += priceItem.QuantityPerPack * priceItem.PackageQuantity; else skuItem = new ItemSKU(priceItem.Item, priceItem.QuantityPerPack * priceItem.PackageQuantity, priceItem.Retail, priceItem.Wholesale); session.SaveOrUpdate(skuItem); } session.SaveOrUpdate(order); tx.Commit(); log.Info("Purchase Order Added."); } catch (Exception ex) { tx.Rollback(); log.Error(ex); return false; } return true; } } }
public static bool SaveSKUInfo(ItemSKU skuItem) { using (var session = NHibernateHelper.OpenSession()) { using (var tx = session.BeginTransaction()) { try { session.SaveOrUpdate(skuItem); tx.Commit(); return true; } catch (Exception ex) { tx.Rollback(); log.Error(ex); return false; } } } }
private bool UpdateSKUQuantity(ItemSKU toSKU, List<ItemSKU> fromSKUList) { foreach (var item in fromSKUList) { toSKU.StockQuantity += item.StockQuantity; } bool success = Savers.ItemSKUSavers.UpdateSKUList(toSKU, fromSKUList); if (success) return true; return false; }