您可以自己跟踪未决更新:在您的表AfterDelete
和AfterPost
事件中打开标志;将其关闭AfterTransactionEnd
:
// IBTable1.AfterDelete
procedure TForm1.IBTable1AfterDelete(DataSet: TDataSet);
begin
FPendingUpdates := True;
end;
// IBTable1.AfterPost
procedure TForm1.IBTable1AfterPost(DataSet: TDataSet);
begin
FPendingUpdates := True;
end;
// IBTable1.AfterTransactionEnd
procedure TForm1.IBTable1AfterTransactionEnd(Sender: TObject);
begin
FPendingUpdates := False;
end;
// Form1.OnCloseQuery
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
DlgResult: TModalResult;
begin
CanClose := False;
if FPendingUpdates then
DlgResult := MessageDlg('Commit pending updates before closing?', mtConfirmation,
[mbYes, mbNo, mbCancel], 0, mbCancel)
else
DlgResult := mrNo;
case DlgResult of
mrYes:
IBTransaction1.Commit;
mrNo:
IBTransaction1.Rollback;
mrCancel:
Exit;
end;
CanClose := True;
end;