0

I have a form with two datasources that are linked by using an outer join. It is written to the database by using Form Datasource Unit of Work framework.

As of now, the data gets written when moving from one datasource form control to another form datasource control. I want to only activate/write using Form Datasource Unit of Framework when a button is clicked.

Is there a way to prevent automated write function when moving from one Form Control to another?

4

1 回答 1

1

首先看一下HowTo: Unit of work implementation for a Form以检查您是否与它保持一致。官方文档是Change Group and Optional Record Modes

发出写入是因为您“离开”了一条记录,请参阅从记录中删除焦点时的事件方法序列

这是validateWrite返回 true 时的顺序:

  1. 离开记录返回真
  2. 验证写入返回真
  3. 写作
  4. 书面
  5. 离开记录返回真
  6. leaveRecord 返回真(再次)

这是validateWrite返回 false 时的顺序:

  1. 离开记录返回真
  2. 验证写入返回假
  3. 离开记录返回假

validateWrite因此,当您不想保存时,您可以覆盖以静默返回 false。super()当您确实想保存时,请务必致电!

或者您可以调用leaveRecord自己强制写入:

if (record_ds.leaveRecord(true))
{}

调用 record_ds.leaveRecord(true) 时请注意它可能不会保存记录,例如如果验证失败。在这种情况下,leaveRecord 将返回 false。

观察您正在“反对”标准工作,这将使您的表单与其他表单的工作方式不同。

于 2013-01-05T23:09:40.803 回答