Exemple #1
0
        /// <summary>
        /// Validate Product
        /// </summary>
        /// <param name="product">product</param>
        /// <returns>Info</returns>
        private String ValidateProduct(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 <MProduct>();
            if (!ValidateOldProduct(_product))
            {
                _product.SetIsVerified(false);
                _product.Save();
                return(_product.GetName() + " @NotValid@");
            }

            //	New Structure
            MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null);
            for (int i = 0; i < boms.Length; i++)
            {
                _products = new List <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(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 <MProduct>();
            if (!ValidateOldProduct(_product))
            {
                _product.SetIsVerified(false);
                _product.Save();
                return(_product.GetName() + " @NotValid@");
            }

            //	New Structure
            MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null);
            for (int i = 0; i < boms.Length; i++)
            {
                //When BOM Type = Manufacturing then system will not allow to verify the BOM if sum of component is less or greater then 1
                if (boms[i].GetBOMUse() == "M")
                {
                    _product = product;
                    Decimal count = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT SUM(BOMQty) FROM M_BOMProduct WHERE IsActive = 'Y' AND M_BOM_ID=" + boms[i].GetM_BOM_ID(), null, null));
                    if (count != 1)
                    {
                        _product.SetIsVerified(false);
                        _product.Save();
                        return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@");
                    }
                }

                _products = new List <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(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 <MProduct>();
            if (!ValidateOldProduct(_product))
            {
                _product.SetIsVerified(false);
                _product.Save();
                return(_product.GetName() + " @NotValid@");
            }

            //	New Structure
            MBOM[] boms = 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 <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@");
        }