在随后的保存时,CRCase

编程入门 行业动态 更新时间:2024-10-25 16:29:19
在随后的保存时,CRCase_RowSelecting会触发下一个案例(CRCase_RowSelecting fires with next case on subsequent save)

我为CRCaseMaint创建了一个扩展,并添加了事件CRCase_RowSelecting 。 这是我目前使用的代码:

protected virtual void CRCase_RowSelecting(PXCache sender, PXRowSelectingEventArgs e) { CRCase row = e.Row as CRCase; if (row == null) return; PXDatabase.ResetSlot<List<CRCase>>("OriginalCase"); List<CRCase> originalCaseSlot = PXDatabase.GetSlot<List<CRCase>>("OriginalCase"); if (originalCaseSlot.Count == 0) { originalCaseSlot.Add(sender.CreateCopy(row) as CRCase); } else { originalCaseSlot[0] = sender.CreateCopy(row) as CRCase; } }

当我第一次打开一个案例时,这个事件会触发几次,并且在最后一次触发时,当前案例被正确存储在e.Row中,所以这段代码很好。 当我单击保存时,我有一个RowPersisting事件,它将存储在originalCaseSlot中的案例与更新后的案例进行比较。 最后,它将原始案例槽设置为更新后的案例。 这也很好。

但是,当我在不离开案例的情况下进行另一次更改并单击保存时, RowSelecting事件中的RowSelecting现在将存储下一个案例,而不是当前案例。 由于我没有以任何方式触及下一个案件,我很惊讶这发生了。

我的问题是,我是否应该使用不同的事件而不是RowSelecting ,还是还有其他我缺少的东西?

感谢大家的帮助。

I created an extension for CRCaseMaint, and added the event CRCase_RowSelecting. Here is the code I am currently using:

protected virtual void CRCase_RowSelecting(PXCache sender, PXRowSelectingEventArgs e) { CRCase row = e.Row as CRCase; if (row == null) return; PXDatabase.ResetSlot<List<CRCase>>("OriginalCase"); List<CRCase> originalCaseSlot = PXDatabase.GetSlot<List<CRCase>>("OriginalCase"); if (originalCaseSlot.Count == 0) { originalCaseSlot.Add(sender.CreateCopy(row) as CRCase); } else { originalCaseSlot[0] = sender.CreateCopy(row) as CRCase; } }

When I first open a case, this event will fire a couple times, and the last time it fires, the current case is correctly stored in e.Row, so this code works great. When I click Save, I have a RowPersisting event that compares the case stored in the originalCaseSlot with the updated case. At the end, it sets the original case slot to the updated case. This also works well.

However, when I make another change without leaving the case, and click save, e.Row on the RowSelecting event now has the next case stored on it rather than the current case. Since I am not touching the next case in any way, I am surprised that this is happening.

My question is, should I be using a different event instead of RowSelecting, or is there something else I am missing?

Thank you all for your help.

更多推荐

本文发布于:2023-08-06 15:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1451579.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在随后   CRCase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!