我为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.
更多推荐
发布评论