Skip to content

Commit

Permalink
dbdataprocess, cache current rectno and use next prior on getvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
riderkick committed Jan 30, 2018
1 parent f8d6305 commit 4058a67
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions baseunits/DBDataProcess.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ TDBDataProcess = class(TObject)
FSQLSelect: String;
FFilterSQL: String;
FLinks: TStringList;
FRecNo: Integer;
function GetLinkCount: Integer;
procedure ResetRecNo(Dataset: TDataSet);
protected
procedure CreateTable;
procedure ConvertNewTable;
Expand Down Expand Up @@ -302,6 +304,11 @@ function TDBDataProcess.GetLinkCount: Integer;
Result := 0;
end;

procedure TDBDataProcess.ResetRecNo(Dataset: TDataSet);
begin
FRecNo := 0;
end;

procedure TDBDataProcess.CreateTable;
begin
if FConn.Connected then
Expand Down Expand Up @@ -478,7 +485,17 @@ function TDBDataProcess.GetValue(RecIndex, FieldIndex: Integer): String;
Result:='';
if FQuery.Active=False then Exit;
try
FQuery.RecNo:=RecIndex+1;
if FRecNo<>RecIndex then
begin
if FRecNo=RecIndex+1 then
FQuery.Prior
else
if FRecNo=RecIndex-1 then
FQuery.Next
else
FQuery.RecNo:=RecIndex+1;
FRecNo:=RecIndex;
end;
Result:=FQuery.Fields[FieldIndex].AsString;
except
end;
Expand All @@ -491,7 +508,17 @@ function TDBDataProcess.GetValueInt(RecIndex, FieldIndex: Integer): Integer;
if not (FieldIndex in [DATA_PARAM_NUMCHAPTER,DATA_PARAM_JDN]) then
Exit;
try
FQuery.RecNo:=RecIndex+1;
if FRecNo<>RecIndex then
begin
if FRecNo=RecIndex+1 then
FQuery.Prior
else
if FRecNo=RecIndex-1 then
FQuery.Next
else
FQuery.RecNo:=RecIndex+1;
FRecNo:=RecIndex;
end;
Result:=FQuery.Fields[FieldIndex].AsInteger;
except
end;
Expand Down Expand Up @@ -601,6 +628,13 @@ constructor TDBDataProcess.Create;
FFilterApplied := False;
FFilterSQL := '';
FAllSitesAttached := False;

ResetRecNo(nil);
FQuery.AfterOpen := @ResetRecNo;
FQuery.AfterInsert := @ResetRecNo;
FQuery.AfterDelete := @ResetRecNo;
FQuery.AfterEdit := @ResetRecNo;
FQuery.AfterRefresh := @ResetRecNo;
end;

destructor TDBDataProcess.Destroy;
Expand Down

0 comments on commit 4058a67

Please sign in to comment.