/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(VAdvantage.Model.MProduct product) { //count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); // JID_0690: If manufaturing Module is not downloaded validate BOM Process was not working. if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <VAdvantage.Model.MProduct>(); // Check applied if the product is of item type recipee, then bom should validate from second tab of product i.e Bill Of Material else from BOM and BM Components. // Change by mohit to validate the BOM if created from recipee manaement form.- 28 June 2019. if (Env.IsModuleInstalled("VA019_") && product.GetVA019_ItemType().Equals(VAdvantage.Model.X_M_Product.VA019_ITEMTYPE_Recipe)) { if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } } // New Structure else { if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } VAdvantage.Model.MBOM[] boms = VAdvantage.Model.MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); // if manufacturing module exist and BOM not contain any record against this product then not to verify Product // JID_0690: If manufaturing Module is not downloaded validate BOM Process was not working. //if (count > 0 && boms.Length == 0) //{ // _product.SetIsVerified(false); // _product.Save(); // return _product.GetName() + " @NotValid@"; //} for (int i = 0; i < boms.Length; i++) { _products = new List <VAdvantage.Model.MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(VAdvantage.Model.MProduct product) { if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <VAdvantage.Model.MProduct>(); if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } // New Structure VAdvantage.Model.MBOM[] boms = VAdvantage.Model.MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); for (int i = 0; i < boms.Length; i++) { _products = new List <VAdvantage.Model.MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(VAdvantage.Model.MProduct product) { count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <VAdvantage.Model.MProduct>(); if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } // New Structure VAdvantage.Model.MBOM[] boms = VAdvantage.Model.MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); // if manufacturing module exist and BOM not contain any record against this product then not to verify Product if (count > 0 && boms.Length == 0) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } for (int i = 0; i < boms.Length; i++) { _products = new List <VAdvantage.Model.MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
protected override bool AfterDelete(bool success) { // when we delete BOM, then set IsVerified False on Product VAdvantage.Model.MProduct product = new VAdvantage.Model.MProduct(GetCtx(), GetM_Product_ID(), Get_Trx()); product.SetIsVerified(false); if (!product.Save()) { log.SaveError("Error", "Verified not updated on Product : " + product.GetValue()); } return(true); }
} // beforeSave protected override bool AfterSave(bool newRecord, bool success) { //set verified on Product as False when we change BOMType AND BOMUse if (newRecord || Is_ValueChanged("BOMType") || Is_ValueChanged("BOMUse") || Is_ValueChanged("IsActive")) { VAdvantage.Model.MProduct product = new VAdvantage.Model.MProduct(GetCtx(), GetM_Product_ID(), Get_Trx()); product.SetIsVerified(false); if (!product.Save()) { log.SaveError("Error", "Verified not updated on Product : " + product.GetValue()); } } return(true); }