Пример #1
0
        /**
         *  Create BP Location from Lead
         *	@return error message
         */
        private String CreateBPLocation()
        {
            if (GetC_BPartner_Location_ID() != 0 ||
                GetC_Country_ID() == 0)         //	mandatory
            {
                return(null);
            }

            //	Something to save
            if ((GetAddress1() != null && GetAddress1().Length > 0) ||
                (GetPostal() != null && GetPostal().Length > 0) ||
                (GetCity() != null && GetCity().Length > 0) ||
                (GetRegionName() != null && GetRegionName().Length > 0)
                )
            {
                ;
            }
            else
            {
                log.Fine("No BP Location Info to save");
                return(null);
            }

            //	Address
            MLocation location = new MLocation(GetCtx(), GetC_Country_ID(),
                                               GetC_Region_ID(), GetCity(), Get_TrxName());

            location.SetAddress1(GetAddress1());
            location.SetAddress2(GetAddress2());
            location.SetPostal(GetPostal());
            location.SetPostal_Add(GetPostal_Add());
            location.SetRegionName(GetRegionName());
            if (location.Save())
            {
                MBPartnerLocation bpl = new MBPartnerLocation(_bp);
                bpl.SetC_Location_ID(location.GetC_Location_ID());
                bpl.SetPhone(GetPhone());
                bpl.SetPhone2(GetPhone2());
                bpl.SetFax(GetFax());
                bpl.SetC_SalesRegion_ID(GetC_SalesRegion_ID());
                if (bpl.Save())
                {
                    SetC_BPartner_Location_ID(bpl.GetC_BPartner_Location_ID());
                }
            }
            return(null);
        }