Esempio n. 1
0
        public virtual void DoConvert(bool redirect)
        {
            ConversionResult <BAccount> result;

            using (var ts = new PXTransactionScope())
            {
                result = AccountExt.Convert(new AccountConversionOptions
                {
                    HoldCurrentsCallback = ContactExt.HoldCurrents
                });

                var contact = ContactExt.Convert(new ContactConversionOptions
                {
                    GraphWithRelation = result.Graph
                });

                if (AccountExt.Documents.Current.RefContactID == null)
                {
                    throw new PXException(Messages.CannotCreateAccount);
                }

                ts.Complete();
            }

            if (redirect)
            {
                AccountExt.Redirect(result);
            }
        }
        public virtual void DoConvert(bool redirect)
        {
            ConversionResult <CROpportunity> result;

            using (var ts = new PXTransactionScope())
            {
                // to save original value because it would be changed during contact/account creation
                var overrideContact =
                    OpportunityExt.Documents.Cache.GetValueOriginal <Document.overrideRefContact>(OpportunityExt.Documents.Current) as bool?;

                var account = AccountExt.Convert(new AccountConversionOptions
                {
                    HoldCurrentsCallback = AccountExt.JoinHoldCurrents(ContactExt.HoldCurrents, OpportunityExt.HoldCurrents)
                });

                var contact = ContactExt.Convert(new ContactConversionOptions
                {
                    HoldCurrentsCallback = OpportunityExt.HoldCurrents,
                    GraphWithRelation    = account.Graph
                });

                result = OpportunityExt.Convert(new OpportunityConversionOptions
                {
                    ForceOverrideContact = overrideContact,
                });

                if (OpportunityExt.Documents.Current.RefContactID == null)
                {
                    throw new PXException(Messages.CannotCreateOpportunity);
                }

                ts.Complete();
            }

            if (redirect)
            {
                OpportunityExt.Redirect(result);
            }
        }