这样跟踪:
Dim e As FormEventArgs = args(0)
Dim Result As DialogResult
MssageBox.Show("开关值 =" & Vars("开关"))
If Vars("开关") = True Then
MssageBox.Show("开关开启了")
If Tables(e.form.Name).DataTable.HasChanges Then
MssageBox.Show(e.Form.Name & "有变动了 ,所以会提示!")
Result = MessageBox.Show("是否将更改并保存本单据?", "提示!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
If Tables(e.form.Name).Rows.Count>0 Then
Tables(e.form.Name).Current("修改人") = _UserName
Tables(e.form.Name).Current("修改时间") = Date.Now()
Tables(e.form.Name).DataTable.Save()
If e.form.ExistControl("Table1") =True Then
If Tables(e.form.Name & "_Table1").DataTable.DataRows.Count>0 Then
Tables(e.form.Name & "_Table1").DataTable.Save
End If
End If
End If
MessageBox.show(2)
ElseIf Result = DialogResult.No Then
If Tables(e.form.Name).DataTable.HasChanges Then
Tables(e.form.Name).DataTable.RejectChanges()
If e.form.ExistControl("Table1") =True Then
If Tables(e.form.Name & "_Table1").DataTable.DataRows.Count>0 Then
Tables(e.form.Name & "_Table1").DataTable.RejectChanges()
End If
For Each re As Relation In Relations
Tables(Re.ChildTable.Name).DataTable.RejectChanges()
Next
End If
Else
e.Cancel=True
End If
End If
End If
Else '如果不是新单
MssageBox.Show("开关关闭了")
If e.form.ExistControl("Table1") =True Then
MssageBox.Show("窗口有Tabl1控件")
If Tables(e.form.Name & "_Table1").DataTable.HasChanges Then '如果子表有变动
MssageBox.Show(e.form.Name & "_Table1") & "有变动,所以要提示")
Result = MessageBox.Show("是否将更改并保存本单据?", "提示!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Tables(e.form.Name & "_Table1").DataTable.Save '则无条件保存
ElseIf Result = DialogResult.No Then
Tables(e.form.Name & "_Table1").DataTable.RejectChanges()
Else
e.Cancel=True
End If
vars("开关") = False
End If
End If
End If
下次更新会加一个参数,返回Table控件对应的DataTable