删除时客户持久覆盖给NextMove问题

问题描述 投票:0回答:1

尝试删除客户时出现以下错误:

An unhandled exception has occurred in the function 'MoveNext'

enter image description here

我认为我需要添加此if语句或类似内容。

if(Base.BAccount.Cache.GetStatus(CCustomer) != PXEntryStatus.InsertedDeleted || Base.BAccount.Cache.GetStatus(CCustomer) != PXEntryStatus.Deleted)

我发现了几个与此问题有关的链接,但并非特定于客户页面的链接。

public delegate void PersistDelegate();
    [PXOverride]
    public void Persist(PersistDelegate baseMethod)
    {
        using (var scope = new PXTransactionScope())
        {
            Customer row = this.Base.BAccount.Current;
            if (row.ParentBAccountID == null)
            {
                CustomerMaint businessAccount = PXGraph.CreateInstance<CustomerMaint>();
                PXResultset<Customer> Children = PXSelect<Customer, Where<Customer.parentBAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.BAccountID);
                foreach (Customer item in Children)
                {
                    businessAccount.Clear();
                    businessAccount.BAccount.Current = PXSelectorAttribute.Select<Customer.bAccountID>(this.Base.BAccount.Cache, item.BAccountID) as Customer;
                    item.TermsID = row.TermsID;
                    item.Status = row.Status;
                    Contact defContact = PXSelect<Contact, Where<Contact.bAccountID, Equal<Required<BAccount.bAccountID>>, And<Contact.contactID, Equal<Required<BAccount.defContactID>>>>>.Select(businessAccount, item.BAccountID, item.DefContactID);
                    defContact.EMail = this.Base.DefContact.Current.EMail;
                    businessAccount.DefContact.Update(defContact);
                    businessAccount.BAccount.Update(item);
                    businessAccount.Save.PressButton();
                }
            }
            baseMethod();
            scope.Complete();
        }
       }

我希望可以进行检查,或者在删除时可以消除MoveNext错误。

acumatica
1个回答
0
投票

[尝试使用与使用UpdateChildAccountsGetChildAccounts方法修改子帐户的基本CustomerMaint类相同的模式。

protected virtual void Customer_PrintDunningLetters_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
    Customer row = (Customer)e.Row;
    CheckExcludedFromDunning(cache, row);
    UpdateChildAccounts<Customer.printDunningLetters>(cache, row, GetChildAccounts(sharedCreditPolicy: true));
}

protected virtual void Customer_Status_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
    Customer row = e.Row as Customer;
    if (row == null) return;

    if (row.ParentBAccountID == null)
    {
        Func<Customer, bool> func;
        string newValue = GetSharedCreditChildStatus(row.Status, out func);
        UpdateChildAccounts<Customer.status>(cache, row, GetChildAccounts(sharedCreditPolicy: true).Where(func), newValue);
    }
}
protected virtual void Customer_ConsolidateToParent_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
    Customer row = (Customer)e.Row;
    if (row == null) return;

    if (row.ParentBAccountID == null)
    {
        IEnumerable<Customer> childs;
        string message = PXMessages.LocalizeFormatNoPrefix(Messages.RelatedFieldChangeOnParentWarning,
            PXUIFieldAttribute.GetDisplayName<Customer.consolidateToParent>(sender));

        if ((childs = GetChildAccounts()).Any() && e.ExternalCall)
        {
            if (CurrentCustomer.Ask(message, MessageButtons.YesNo) == WebDialogResult.Yes)
            {
                UpdateChildAccounts<Customer.consolidateToParent>(sender, row, childs);
            }
        }

        row.SharedCreditPolicy &= row.ConsolidateToParent;
    }
    else if (row.SharedCreditPolicy == true && row.ConsolidateToParent != true && (bool?)e.OldValue == true)
    {
        sender.SetValueExt<Customer.sharedCreditPolicy>(row, false);
    }
}

否则,将创建一个继承自Customer的新DAC,以容纳子项并在图中为其创建数据视图。然后,您可以在该数据视图中修改子级,当用户从UI调用“保存”操作时,它们将自动保留。

[Serializable]
public partial class OtherCustomer : Customer
{
    public new abstract class bAccountID : PX.Data.BQL.BqlInt.Field<bAccountID> { }
}

PXSelect<OtherCustomer, Where< … >> OtherCustomers;
热门问题
推荐问题
最新问题