- Fix to allow changing the filter while filtered

git-svn-id: trunk@1204 -
This commit is contained in:
joost 2005-09-27 16:45:55 +00:00
parent ec4d287fd8
commit 294bf06cda

View File

@ -190,6 +190,7 @@ type
procedure Execute; procedure Execute;
Procedure SQLParser(var SQL : string); Procedure SQLParser(var SQL : string);
procedure ApplyFilter;
Function AddFilter(SQLstr : string) : string; Function AddFilter(SQLstr : string) : string;
protected protected
// abstract & virtual methods of TBufDataset // abstract & virtual methods of TBufDataset
@ -208,6 +209,7 @@ type
function ApplyRecUpdate(UpdateKind : TUpdateKind) : boolean; override; function ApplyRecUpdate(UpdateKind : TUpdateKind) : boolean; override;
Function IsPrepared : Boolean; virtual; Function IsPrepared : Boolean; virtual;
procedure SetFiltered(Value: Boolean); override; procedure SetFiltered(Value: Boolean); override;
procedure SetFilterText(const Value: string); override;
public public
procedure Prepare; virtual; procedure Prepare; virtual;
procedure UnPrepare; virtual; procedure UnPrepare; virtual;
@ -576,30 +578,45 @@ begin
Result := SQLstr; Result := SQLstr;
end; end;
procedure TSQLQuery.SetFiltered(Value: Boolean); procedure TSQLQuery.ApplyFilter;
var S : String; var S : String;
begin
FreeFldBuffers;
(Database as tsqlconnection).UnPrepareStatement(FCursor);
FIsEOF := False;
inherited internalclose;
s := FSQLBuf;
if Filtered then s := AddFilter(s);
(Database as tsqlconnection).PrepareStatement(Fcursor,(transaction as tsqltransaction),S,FParams);
Execute;
inherited InternalOpen;
First;
end;
procedure TSQLQuery.SetFiltered(Value: Boolean);
begin begin
if Value and not FParseSQL then DatabaseErrorFmt(SNoParseSQL,['Filtering ']); if Value and not FParseSQL then DatabaseErrorFmt(SNoParseSQL,['Filtering ']);
if (Filtered <> Value) and Active then if (Filtered <> Value) then
begin begin
FreeFldBuffers; inherited setfiltered(Value);
(Database as tsqlconnection).UnPrepareStatement(FCursor); if active then ApplyFilter;
FIsEOF := False; end;
inherited internalclose; end;
s := FSQLBuf; procedure TSQLQuery.SetFilterText(const Value: string);
begin
if Value then s := AddFilter(s); if Value <> Filter then
begin
(Database as tsqlconnection).PrepareStatement(Fcursor,(transaction as tsqltransaction),S,FParams); inherited SetFilterText(Value);
if active then ApplyFilter;
Execute;
inherited InternalOpen;
First;
end; end;
inherited setfiltered(Value);
end; end;
procedure TSQLQuery.Prepare; procedure TSQLQuery.Prepare;