예제 #1
0
        protected virtual void DefaultRecords(Document row, Contact oldContact, Address oldAddress)
        {
            PXCache cache = Documents.Cache;

            if (row.AllowOverrideContactAddress == true && (row.LocationID != null || row.ContactID != null) &&
                !IsDefaultContactAdress() && !IsContactAddressNoChanged(oldContact, oldAddress))
            {
                WebDialogResult dialogResult = this.Documents.View.Ask((object)null, CR.Messages.Warning, CR.Messages.ReplaceContactDetails,
                                                                       MessageButtons.AbortRetryIgnore,
                                                                       new Dictionary <WebDialogResult, string>()
                {
                    { WebDialogResult.Abort, "Yes" },
                    { WebDialogResult.Retry, "No" },
                    { WebDialogResult.Ignore, "Cancel" }
                }, MessageIcon.Warning);

                if (dialogResult == WebDialogResult.Abort)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
                else if (dialogResult == WebDialogResult.Ignore)
                {
                    cache.SetValue <Document.bAccountID>(row, cache.GetValueOriginal <Document.bAccountID>(cache.GetMain(row)));
                    cache.SetValue <Document.contactID>(row, cache.GetValueOriginal <Document.contactID>(cache.GetMain(row)));
                }
            }
            else
            {
                if (row.LocationID != null || row.ContactID != null)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
            }

            if (row.LocationID == null && row.ContactID == null && row.BAccountID == null)
            {
                if (row.AllowOverrideContactAddress == false)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
            }

            if (IsDefaultContactAdress())
            {
                cache.SetValue <Document.allowOverrideContactAddress>(row, true);
            }
        }
예제 #2
0
        protected virtual void DefaultRecords(Document row, ChangedData changedForContactInfo, ChangedData changedForShippingInfo)
        {
            PXCache cache = Documents.Cache;

            bool needAskFromContactAddress         = AskForConfirmationForAddress(row, changedForContactInfo);
            bool needAskFromShippingContactAddress = AskForConfirmationForShippingAddress(row, changedForShippingInfo);

            if ((needAskFromContactAddress || needAskFromShippingContactAddress) && (row.LocationID != null || row.ContactID != null))
            {
                string message = needAskFromContactAddress && needAskFromShippingContactAddress ?
                                 CR.Messages.ReplaceContactDetailsAndShippingInfo :
                                 needAskFromContactAddress ? CR.Messages.ReplaceContactDetails :
                                 CR.Messages.ReplaceShippingInfo;
                WebDialogResult dialogResult = this.Documents.View.Ask((object)null, CR.Messages.Warning, message,
                                                                       MessageButtons.AbortRetryIgnore,
                                                                       new Dictionary <WebDialogResult, string>()
                {
                    { WebDialogResult.Abort, "Yes" },
                    { WebDialogResult.Retry, "No" },
                    { WebDialogResult.Ignore, "Cancel" }
                }, MessageIcon.Warning);

                if (dialogResult == WebDialogResult.Abort)
                {
                    if (needAskFromContactAddress)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }
                    if (needAskFromShippingContactAddress)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
                else if (dialogResult == WebDialogResult.Ignore)
                {
                    cache.SetValue <Document.bAccountID>(row, cache.GetValueOriginal <Document.bAccountID>(cache.GetMain(row)));
                    cache.SetValue <Document.contactID>(row, cache.GetValueOriginal <Document.contactID>(cache.GetMain(row)));
                }
                else if (dialogResult == WebDialogResult.Retry)
                {
                    if (row.AllowOverrideContactAddress == false)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }
                    else if (row.AllowOverrideShippingContactAddress == false)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
            }
            else
            {
                if (IsThereSomeContactAddressSourceValue(cache, row))
                {
                    if (changedForContactInfo.CanBeReplace)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }

                    if (changedForShippingInfo.CanBeReplace)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
            }

            if (row.LocationID == null && row.ContactID == null && row.BAccountID == null)
            {
                if (row.AllowOverrideContactAddress == false)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
                if (row.AllowOverrideShippingContactAddress == false)
                {
                    CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                    CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    PXCache cacheContact = GetContactCache();
                    var     contact      = GetCurrentContact();
                    cacheContact.RaiseRowUpdated(contact, contact);
                    PXCache cacheAddress = GetAddressCache();
                    var     address      = GetCurrentAddress();
                    cacheAddress.RaiseRowUpdated(address, address);
                }
            }

            if (IsDefaultContactAdress())
            {
                cache.SetValue <Document.allowOverrideContactAddress>(row, true);
            }
        }