private void AdjustInventory(Guid documentId,Guid storeId)
        {
            tblSourcingDocument document = ExistingDocument(documentId);
            foreach (var lineItem in document.tblSourcingLineItem)
            {

                var inventory = _context.tblCommoditySupplierInventory.FirstOrDefault(p=>p.CommodityId==lineItem.CommodityId && p.GradeId==lineItem.GradeId && p.WareHouseId==storeId && p.SupplierId==document.DocumentRecipientCostCentreId);
                if(inventory==null)
                {
                    inventory=new tblCommoditySupplierInventory();
                    inventory.id = Guid.NewGuid();
                    inventory.CommodityId = lineItem.CommodityId.Value;
                    inventory.GradeId = lineItem.GradeId.Value;
                    inventory.WareHouseId = storeId;
                    inventory.SupplierId = document.DocumentRecipientCostCentreId;
                    inventory.IM_Status = 0;
                    inventory.Balance = 0;
                    inventory.IM_DateCreated = DateTime.Now;
                    _context.tblCommoditySupplierInventory.AddObject(inventory);

                }
                var balance = lineItem.Weight.Value - lineItem.FinalWeight.Value;
                inventory.Balance += balance;
                inventory.IM_DateLastUpdated = DateTime.Now;
                _context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblCommoditySupplierInventory EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblCommoditySupplierInventory(tblCommoditySupplierInventory tblCommoditySupplierInventory)
 {
     base.AddObject("tblCommoditySupplierInventory", tblCommoditySupplierInventory);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new tblCommoditySupplierInventory object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="wareHouseId">Initial value of the WareHouseId property.</param>
 /// <param name="commodityId">Initial value of the CommodityId property.</param>
 /// <param name="supplierId">Initial value of the SupplierId property.</param>
 /// <param name="gradeId">Initial value of the GradeId property.</param>
 /// <param name="unavailableBalance">Initial value of the UnavailableBalance property.</param>
 /// <param name="iM_DateCreated">Initial value of the IM_DateCreated property.</param>
 /// <param name="iM_DateLastUpdated">Initial value of the IM_DateLastUpdated property.</param>
 /// <param name="iM_Status">Initial value of the IM_Status property.</param>
 public static tblCommoditySupplierInventory CreatetblCommoditySupplierInventory(global::System.Guid id, global::System.Guid wareHouseId, global::System.Guid commodityId, global::System.Guid supplierId, global::System.Guid gradeId, global::System.Decimal unavailableBalance, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblCommoditySupplierInventory tblCommoditySupplierInventory = new tblCommoditySupplierInventory();
     tblCommoditySupplierInventory.id = id;
     tblCommoditySupplierInventory.WareHouseId = wareHouseId;
     tblCommoditySupplierInventory.CommodityId = commodityId;
     tblCommoditySupplierInventory.SupplierId = supplierId;
     tblCommoditySupplierInventory.GradeId = gradeId;
     tblCommoditySupplierInventory.UnavailableBalance = unavailableBalance;
     tblCommoditySupplierInventory.IM_DateCreated = iM_DateCreated;
     tblCommoditySupplierInventory.IM_DateLastUpdated = iM_DateLastUpdated;
     tblCommoditySupplierInventory.IM_Status = iM_Status;
     return tblCommoditySupplierInventory;
 }