On our main data entry screen, we have an OK/Cancel dialog in the OnBeforePost event.
- OK lets things take their course
- Cancel right now does a Dataset.Cancel;
Which does what it's meant to, roll back any changes and puts the dataset into browse mode.
This is fine for most of the clients, but we have been asked if it can be changed to
- Cancel, Abort the Post and stay in edit mode with the current changes kept.
If they want to cancel, they can use the cancel button.
Looking at the source for procedure TDataSet.Post; it does not look possible to use the event this way.
Dose anyone have any thoughts on a way this could be done?
Follow Up: this is how I have chosen to handle it now
case MessageDlg('Save Changes?', mtWarning, [mbYes, mbNo, mbAbort], 0) of mrYes: ; mrNo: Dataset.Cancel; mrAbort: Abort; mrNone: Abort; end;
Calling the method Abort (from the unit System, if I recall correctly) raises a silent EAbort exception, which cancels just the current operation. That should work.
(Btw: this method of cancelling a databaset operation is also described somewhere deep in the help system as the 'normal' way to achieve this --- that's where I got this technique from originally).
在主数据输入屏幕上,OnBeforePost事件中有一个OK / Cancel对话框。
- em>让事情顺利进行
- 取消现在做一个 Dataset.Cancel;
这是什么意思,回滚任何更改并将数据集置于浏览模式。
这对大多数客户来说都不错,但是我们被问及是否可以更改为
- 取消,中止帖子并保持编辑模式,保留当前的更改。
如果他们想取消,他们可以使用取消按钮。
查看源代码程序TDataSet.Post; 它看起来不可能使用
任何人都有任何想法可以做到这一点吗?
跟进:这是我现在如何选择处理它
case MessageDlg('保存C挂起?',mtWarning,[mbYes,mbNo,mbAbort],0)
mrYes:;
mrNo:Dataset.Cancel;
mrAbort:中止
mrNone:中止
结束
调用方法 / code>(从单元 System ,如果我记得正确)引发了一个静默的 EAbort 异常,仅取消当前操作。 (btw:这种取消数据库操作的方法也在帮助系统深处被描述为"正常"的方式来实现这一点---这是我从最初得到这种技术的地方)。