public void changeLocationOfLocation(CswPrimaryKey PrevLocationId, CswPrimaryKey CurrentLocationId) { Collection <CswNbtObjClassInventoryLevel> PrevLevels; Collection <CswNbtObjClassInventoryLevel> CurrentLevels; _getInventoryLevelCollections(out PrevLevels, out CurrentLevels, PrevLocationId, CurrentLocationId); Collection <CswNbtObjClassInventoryLevel> AppliesToLevels = new Collection <CswNbtObjClassInventoryLevel>(); foreach (CswNbtObjClassInventoryLevel Prev in PrevLevels) { if (false == CurrentLevels.Contains(Prev)) { AppliesToLevels.Add(Prev); } } foreach (CswNbtObjClassInventoryLevel Current in CurrentLevels) { if (false == PrevLevels.Contains(Current) && false == AppliesToLevels.Contains(Current)) { AppliesToLevels.Add(Current); } } foreach (CswNbtObjClassInventoryLevel LevelToUpdate in AppliesToLevels) { CswNbtSdInventoryLevelMgr Mgr = new CswNbtSdInventoryLevelMgr(_CswNbtResources); LevelToUpdate.CurrentQuantity.Quantity = Mgr.getCurrentInventoryLevel(LevelToUpdate); LevelToUpdate.postChanges(true); } }
public bool changeLocationOfQuantity(double Quantity, CswPrimaryKey UnitId, string Reason, CswPrimaryKey MaterialId, CswPrimaryKey PrevLocationId, CswPrimaryKey CurrentLocationId) { bool Ret = false; if (CswTools.IsPrimaryKey(MaterialId) && CswTools.IsPrimaryKey(PrevLocationId) && CswTools.IsPrimaryKey(CurrentLocationId)) { Collection <CswNbtObjClassInventoryLevel> PrevLevels; Collection <CswNbtObjClassInventoryLevel> CurrentLevels; _getInventoryLevelCollections(out PrevLevels, out CurrentLevels, PrevLocationId, CurrentLocationId, MaterialId); Collection <CswNbtObjClassInventoryLevel> AppliesToPrevLevels = new Collection <CswNbtObjClassInventoryLevel>(); foreach (CswNbtObjClassInventoryLevel Prev in PrevLevels) { if (false == CurrentLevels.Contains(Prev)) { AppliesToPrevLevels.Add(Prev); } } //These Inventory Levels are losing inventory _applyQuantityToInventoryLevels(AppliesToPrevLevels, -(Quantity), UnitId, Reason); Collection <CswNbtObjClassInventoryLevel> AppliesToCurrentLevels = new Collection <CswNbtObjClassInventoryLevel>(); foreach (CswNbtObjClassInventoryLevel Current in CurrentLevels) { if (false == PrevLevels.Contains(Current)) { AppliesToCurrentLevels.Add(Current); } } //These Inventory Levels are gaining inventory _applyQuantityToInventoryLevels(AppliesToCurrentLevels, Quantity, UnitId, Reason); Ret = true; } return(Ret); }