我在货币汇率屏幕(CM301000)、“汇率描述”和“货币结束日期”上创建了两个用户定义的字段,如屏幕截图1中突出显示的。这两个字段是从货币汇率类型屏幕(CM201000)中填充的,其中描述字段(在屏幕快照2中突出显示)根据屏幕快照2的速率类型ID填充速率描述字段,货币结束日期(屏幕快照1)根据屏幕快照2上的有效字段计算每个货币类型到期的天数。
屏幕截图1

屏幕截图2

货币汇率(CM301000)屏幕上的“货币汇率条目”选项卡上的两个字段工作得很好,并相应地进行更新。货币结束日期将被更新并正确显示为货币汇率类型(CM201000)上的“有效”更改的天数,以及如果货币汇率类型(CM201000)上的“描述”发生更改时的汇率描述。但是,我还需要在货币汇率屏幕的“有效货币汇率”选项卡上添加相同的字段,并且该选项卡上的字段仅在保存更改时显示更改,而不显示更改,因为更改是在货币汇率类型屏幕上按预期的方式进行的,而_RowSelected没有保存。
代码片段
protected void CurrencyRate_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (CurrencyRate)e.Row;
if (row == null) return;
CurrencyRateType currencyRateType = PXSelect<CurrencyRateType,
Where<CurrencyRateType.curyRateTypeID, Equal<Required<CurrencyRate.curyRateType>>>,
OrderBy<Desc<CurrencyRate.curyEffDate>>>.Select(Base, row.CuryRateType);
CurrencyRateExt currencyRateExt = row.GetExtension<CurrencyRateExt>();
if (currencyRateType == null) return;
cache.SetValueExt<CurrencyRateExt.usrCurrencyEndDate>(row, row.CuryEffDate.Value.AddDays(currencyRateType.RateEffDays.Value));
currencyRateExt.UsrDescription = currencyRateType.Descr;
cache.SetValueExt<CurrencyRateExt.usrDescription>(row, currencyRateType.Descr);
#endregion
}检查“货币汇率条目”选项卡的元素

检查“有效货币汇率”选项卡的元素

NB:“有效货币汇率”字段的检查元素显示CurrencyRate2,但仍然是CurrencyRate数据类,与“货币汇率条目”上的字段相同。
这两个选项卡使用相同的数据库表/DAC,但在字段元素上显示的视图不同。
如何更改代码,以便在“货币汇率(CM201000)”屏幕上的“有效货币汇率”屏幕上的“汇率描述”和“货币结束日期”的值更新,即使页面尚未保存,但在货币汇率类型屏幕上发生更改时显示相应的更改?
发布于 2022-03-11 04:23:16
两件事,
在RowSelected事件处理程序上进行选择对于屏幕的性能来说是非常糟糕的。
我们应该始终避免在行选择的事件处理程序上分配值。
相反,您应该尝试更改代码,在CurrencyRateFieldUpdated上添加对CurrencyRateFieldUpdated的搜索。
protected virtual void _(Events.FieldUpdated<CurrencyRate, CurrencyRate.curyRateType> e)
{
if(row == null)
return;
CurrencyRateType currencyRateType = PXSelect<CurrencyRateType,
Where<CurrencyRateType.curyRateTypeID, Equal<Required<CurrencyRate.curyRateType>>>,
OrderBy<Desc<CurrencyRate.curyEffDate>>>.Select(Base, row.CuryRateType);
CurrencyRateExt currencyRateExt = row.GetExtension<CurrencyRateExt>();
if (currencyRateType == null) return;
cache.SetValueExt<CurrencyRateExt.usrCurrencyEndDate>(row, row.CuryEffDate.Value.AddDays(currencyRateType.RateEffDays.Value));
cache.SetValueExt<CurrencyRateExt.usrDescription>(row, currencyRateType.Descr);
}https://stackoverflow.com/questions/71422590
复制相似问题