unit uMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
  FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait, Data.DB,
  FireDAC.Comp.Client, FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
  FireDAC.DApt, Vcl.Grids, Vcl.DBGrids, FireDAC.Comp.DataSet, Vcl.StdCtrls, Vcl.ExtCtrls,

  //myUnits

  uDBPagination

  ;

type
  TfMain = class(TForm)
    FDConnection: TFDConnection;
    pTopPanel: TPanel;
    bPrevious: TButton;
    bNext: TButton;
    FDQuery: TFDQuery;
    DataSource: TDataSource;
    DBGrid1: TDBGrid;
    bTest: TButton;
    procedure bNextClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure bTestClick(Sender: TObject);
  private
    { Private declarations }

   FDBPagination:TDBPagination;

    procedure LoadNextRecords(NumberOfRecords:integer);

  public
    { Public declarations }

    constructor Create(AOwner: TComponent); override;

  end;

var
  fMain: TfMain;

implementation

{$R *.dfm}

procedure TfMain.bNextClick(Sender: TObject);
begin

{
FDQuery.Close;
FDQuery.FetchOptions.RecsSkip := 0;
FDQuery.FetchOptions.RecsMax := 5;
FDQuery.Open;
}

LoadNextRecords(10);

end;

procedure TfMain.bTestClick(Sender: TObject);
begin

//SELECT * FROM coffeetest_db.foldersandfilesonserver;
{
FDQuery.Disconnect();

FDQuery.Close;

FDQuery.SQL.Text:=
'SELECT * FROM coffeetest_db.foldersandfilesonserver LIMIT 0,5 ';


FDQuery.Open;
}


FDBPagination.InitialUpdate;


end;

constructor TfMain.Create(AOwner: TComponent);
begin
  inherited;

 FDBPagination:=TDBPagination.Create(Self);


 FDBPagination.FDQuery:=FDQuery;
 FDBPagination.RowCountToLoad:=10;





end;

procedure TfMain.FormCreate(Sender: TObject);
begin

//FDQuery.Close;
//FDQuery.FetchOptions.RecsSkip := 0;
//FDQuery.FetchOptions.RecsMax := 20;
//FDQuery.Open;

end;

procedure TfMain.LoadNextRecords(NumberOfRecords: integer);
begin

FDQuery.Unprepare;
FDQuery.Disconnect;
//FDQuery.FetchOptions.RecsSkip := NumberOfRecords;
FDQuery.Open;

end;

end.
