function CacheNotSave(mDataSet: TCustomADODataSet): Boolean;
var
vFiltered: Boolean;
vFilterGroup: TFilterGroup;
vBookmark: string;
begin
Result := False;
if not mDataSet.Active then
Exit;
if mDataSet.LockType <> ltBatchOptimistic then
Exit;
vBookmark := mDataSet.Bookmark;
mDataSet.DisableControls;
try
vFiltered := mDataSet.Filtered;
vFilterGroup := mDataSet.FilterGroup;
try
mDataSet.Filtered := True;
mDataSet.FilterGroup := fgPendingRecords;
Result := mDataSet.RecordCount > 0;
finally
mDataSet.Filtered := vFiltered;
mDataSet.FilterGroup := vFilterGroup;
end;
finally
mDataSet.Bookmark := vBookmark;
mDataSet.EnableControls;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOTable1.UpdateBatch;
CheckBox1.Checked := CacheNotSave(ADOTable1);
end;
procedure TForm1.ADOTable1AfterCancel(DataSet: TDataSet);
begin
CheckBox1.Checked := CacheNotSave(TCustomADODataSet(DataSet));
end;
procedure TForm1.ADOTable1AfterPost(DataSet: TDataSet);
begin
CheckBox1.Checked := CacheNotSave(TCustomADODataSet(DataSet));
end;
procedure TForm1.ADOTable1AfterDelete(DataSet: TDataSet);
begin
CheckBox1.Checked := CacheNotSave(TCustomADODataSet(DataSet));
end;
procedure TForm1.ADOTable1AfterOpen(DataSet: TDataSet);
begin
CheckBox1.Checked := CacheNotSave(TCustomADODataSet(DataSet));
end;