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;