/// <summary> /// Validate BOM /// </summary> /// <param name="bom">bom</param> /// <returns>true if valid</returns> private bool ValidateBOM(MBOM bom) { MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }
/// <summary> /// Validate BOM /// </summary> /// <param name="bom">bom</param> /// <returns>true if valid</returns> private bool ValidateBOM(MBOM bom) { count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); // if manufacturing module exist and BOM Componet not contain any record against this BOM then not to verify Product if (count > 0 && BOMproducts.Length == 0) { return(false); } for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <param name="BOMType"></param> /// <param name="BOMUse"></param> /// <returns>true if valid</returns> private bool ValidateProduct(MProduct product, String BOMType, String BOMUse) { if (!product.IsBOM()) { return(true); } // String restriction = "BOMType='" + BOMType + "' AND BOMUse='" + BOMUse + "'"; MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), restriction); if (boms.Length != 1) { log.Warning(restriction + " - Length=" + boms.Length); return(false); } if (_products.Contains(product)) { log.Warning(_product.GetName() + " recursively includes " + product.GetName()); return(false); } _products.Add(product); log.Fine(product.GetName()); // MBOM bom = boms[0]; MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }