Пример #1
0
        }       //	isSubscribed

        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override Boolean AfterSave(Boolean newRecord, Boolean success)
        {
            if (success && newRecord && IsSubscribed())
            {
                MInterestArea ia = MInterestArea.Get(GetCtx(), GetR_InterestArea_ID());
                if (ia.GetR_Source_ID() != 0)
                {
                    String summary = "Subscribe: " + ia.GetName();
                    //
                    MSource source = MSource.Get(GetCtx(), ia.GetR_Source_ID());
                    MUser   user   = null;
                    if (Get_TrxName() == null)
                    {
                        user = MUser.Get(GetCtx(), GetAD_User_ID());
                    }
                    else
                    {
                        user = new MUser(GetCtx(), GetAD_User_ID(), Get_TrxName());
                    }
                    //	Create Request
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Request.Equals(source.GetSourceCreateType()))
                    {
                        MRequest request = new MRequest(GetCtx(), 0, Get_TrxName());
                        request.SetClientOrg(this);
                        request.SetSummary(summary);
                        request.SetAD_User_ID(GetAD_User_ID());
                        request.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        request.SetR_Source_ID(source.GetR_Source_ID());
                        request.Save();
                    }
                    //	Create Lead
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Lead.Equals(source.GetSourceCreateType()))
                    {
                        MLead lead = new MLead(GetCtx(), 0, Get_TrxName());
                        lead.SetClientOrg(this);
                        lead.SetDescription(summary);
                        lead.SetAD_User_ID(GetAD_User_ID());
                        lead.SetR_InterestArea_ID(GetR_InterestArea_ID());
                        lead.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        lead.SetR_Source_ID(source.GetR_Source_ID());
                        lead.Save();
                    }
                }
            }
            return(success);
        }       //	afterSave
Пример #2
0
        /**
         *  Create Request from Lead
         *  @param R_RequestType_ID request type
         *	@return error message
         */
        private String CreateRequest(int R_RequestType_ID)
        {
            if (GetR_Request_ID() != 0)
            {
                return("@AlreadyExists@: @R_Request_ID@ (ID=" + GetR_Request_ID() + ")");
            }
            if (GetC_BPartner_ID() == 0)
            {
                String retValue = CreateBP();
                if (retValue != null)
                {
                    return(retValue);
                }
            }
            _request = new MRequest(GetCtx(), 0, Get_TrxName());
            _request.SetAD_Org_ID(GetAD_Org_ID());
            String summary = GetName();

            if (summary == null)
            {
                summary = GetHelp();
            }
            if (summary == null)
            {
                summary = GetSummary();
            }
            if (summary == null)
            {
                summary = GetDescription();
            }
            _request.SetSummary(summary);
            //
            _request.SetR_RequestType_ID(R_RequestType_ID);
            if (IsR_Status_IDValid(GetR_Status_ID()))
            {
                _request.SetR_Status_ID(GetR_Status_ID());
            }
            else
            {
                _request.SetR_Status_ID();
            }
            //
            _request.SetC_Lead_ID(GetC_Lead_ID());
            //
            _request.SetC_BPartner_ID(GetC_BPartner_ID());
            _request.SetAD_User_ID(GetAD_User_ID());
            _request.SetC_Project_ID(GetC_Project_ID());
            _request.SetC_Campaign_ID(GetC_Campaign_ID());
            _request.SetR_Source_ID(GetR_Source_ID());
            _request.SetC_BPartnerSR_ID(GetC_BPartnerSR_ID());
            _request.SetC_SalesRegion_ID(GetC_SalesRegion_ID());

            _request.SetSalesRep_ID(GetSalesRep_ID());
            if (!_request.Save())
            {
                return("@SaveError@");
            }
            //
            SetR_Request_ID(_request.GetR_Request_ID());
            return(null);
        }