public void DemandsAddAll(Demands demands) { foreach (var demand in demands) { DemandsAdd(demand); } // T_ProductionOrderOperation IStackSet <ProductionOrderOperation> tProductionOrderOperations = new StackSet <ProductionOrderOperation>(); foreach (var productionOrderBom in _productionOrderBoms) { T_ProductionOrderBom tProductionOrderBom = (T_ProductionOrderBom)productionOrderBom.ToIDemand(); if (tProductionOrderBom != null) { ((ProductionOrderBom)productionOrderBom).EnsureOperationIsLoadedIfExists(); if (tProductionOrderBom.ProductionOrderOperation == null) { throw new MrpRunException( "Every tProductionOrderBom must have an operation."); } tProductionOrderOperations.Push(new ProductionOrderOperation( tProductionOrderBom.ProductionOrderOperation)); } } _productionOrderOperations.AddAll(tProductionOrderOperations); }
public ProductionOrderBom GetAnyProductionOrderBomByProductionOrderOperation( ProductionOrderOperation productionOrderOperation) { T_ProductionOrderBom productionOrderBom = _dbTransactionData.ProductionOrderBomGetAll() .GetAllAs <T_ProductionOrderBom>().Find(x => x.ProductionOrderOperationId.Equals(productionOrderOperation.GetId() .GetValue())); if (productionOrderBom == null) { throw new MrpRunException( "How could an productionOrderOperation without an T_ProductionOrderBom exists?"); } return(new ProductionOrderBom(productionOrderBom)); }
/// <summary> /// /// </summary> /// <param name="articleBom"></param> /// <param name="parentProductionOrder"></param> /// <param name="dbMasterDataCache"></param> /// <param name="quantity">of production article to produce /// --> is used for childs as: articleBom.Quantity * quantity</param> /// <param name="productionOrderOperation">use already created, null if no one was created before</param> /// <returns></returns> public static ProductionOrderBom CreateTProductionOrderBom(M_ArticleBom articleBom, Provider parentProductionOrder, ProductionOrderOperation productionOrderOperation, Quantity quantity) { T_ProductionOrderBom productionOrderBom = new T_ProductionOrderBom(); if (quantity == null || quantity.GetValue() == 0) { throw new MrpRunException("Quantity is not set."); } productionOrderBom.Quantity = articleBom.Quantity * quantity.GetValue(); // TODO: PASCAL .GetValueOrDefault(); productionOrderBom.ProductionOrderParent = (T_ProductionOrder)parentProductionOrder.ToIProvider(); productionOrderBom.ProductionOrderParentId = productionOrderBom.ProductionOrderParent.Id; // bom is toPurchase if articleBom.Operation == null if (productionOrderOperation != null) { productionOrderBom.ProductionOrderOperation = productionOrderOperation.GetValue(); productionOrderBom.ProductionOrderOperationId = productionOrderBom.ProductionOrderOperation.Id; } if (productionOrderOperation == null && articleBom.Operation != null) { productionOrderBom.ProductionOrderOperation = ProductionManager.CreateProductionOrderOperation(articleBom, parentProductionOrder, quantity); productionOrderBom.ProductionOrderOperationId = productionOrderBom.ProductionOrderOperation.Id; } productionOrderBom.ArticleChild = articleBom.ArticleChild; productionOrderBom.ArticleChildId = articleBom.ArticleChildId; return(new ProductionOrderBom(productionOrderBom)); }
public ProductionOrderBom(IDemand demand) : base(demand) { _productionOrderBom = (T_ProductionOrderBom)_demand; // EnsureOperationIsLoadedIfExists(); }