重寫在自定義BLC沒有不同,那麼覆蓋在C#中的任何虛擬方法persist方法:
public class ARSalesPriceMaint : PXGraph<ARSalesPriceMaint>
{
...
public override void Persist()
{
foreach (ARSalesPrice price in Records.Cache.Inserted)
{
ARSalesPrice lastPrice = FindLastPrice(this, price);
if (lastPrice?.EffectiveDate > price.EffectiveDate && price.ExpirationDate == null)
{
Records.Cache.RaiseExceptionHandling<ARSalesPrice.expirationDate>(price, price.ExpirationDate, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName<ARSalesPrice.expirationDate>(Records.Cache)));
throw new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName<ARSalesPrice.expirationDate>(Records.Cache));
}
ValidateDuplicate(this, Records.Cache, price);
}
foreach (ARSalesPrice price in Records.Cache.Updated)
{
ARSalesPrice lastPrice = FindLastPrice(this, price);
if (lastPrice?.EffectiveDate > price.EffectiveDate && price.ExpirationDate == null)
{
Records.Cache.RaiseExceptionHandling<ARSalesPrice.expirationDate>(price, price.ExpirationDate, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName<ARSalesPrice.expirationDate>(Records.Cache)));
throw new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName<ARSalesPrice.expirationDate>(Records.Cache));
}
ValidateDuplicate(this, Records.Cache, price);
}
base.Persist();
}
...
}
難道我只是需要讓.Persist();函數調用在我的邏輯結束,它繼續其正常的保存過程?我提出這個問題的原因是因爲我確實執行了覆蓋void Persist(),但它沒有執行實際的保存。 –
正確的,你應該在你的邏輯之後調用'base.Persist();'來啓動實際的保存過程。 – RuslanDev