unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, Buttons, ExtCtrls, StdCtrls,
  //
  DataModule;

type
  TFMain = class(TForm)
    Panel1: TPanel;
    SpeedButton1: TSpeedButton;
    DBGrid: TDBGrid;
    SpeedButton2: TSpeedButton;
    Label1: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);

  private
    lp : integer;

  public

  end;

var
  FMain: TFMain;

implementation

{$R *.dfm}

procedure TFMain.SpeedButton1Click(Sender: TObject);
begin
   Close();
end;

procedure TFMain.FormCreate(Sender: TObject);
begin
   lp := 1;
end;

procedure TFMain.SpeedButton2Click(Sender: TObject);
begin
   Inc(lp);

   if lp = 5 then begin
      lp := 1;
   end;

   if lp = 1 then begin
      DM.TableXBase.Active := False;
      DBGrid.DataSource    := NIL;

      DM.TableXBase.TableName := 'Wydawnic';
      DM.TableXBase.Active    := True;
      DBGrid.DataSource       := DM.dsXBase;

      Label1.Caption := 'Table: Wydawnictwa';
   end;

   if lp = 2 then begin
      DM.TableXBase.Active := False;
      DBGrid.DataSource    := NIL;

      DM.TableXBase.TableName := 'Autorzy';
      DM.TableXBase.Active    := True;
      DBGrid.DataSource       := DM.dsXBase;

      Label1.Caption := 'Table: Autorzy';
   end;

   if lp = 3 then begin
      DM.TableXBase.Active := False;
      DBGrid.DataSource    := NIL;

      DM.TableXBase.TableName := 'Osoby';
      DM.TableXBase.Active    := True;
      DBGrid.DataSource       := DM.dsXBase;

      Label1.Caption := 'Table: Osoby';
   end;

   if lp = 4 then begin
      DM.TableXBase.Active := False;
      DBGrid.DataSource    := NIL;

      DM.TableXBase.TableName := 'Ksiazki';
      DM.TableXBase.Active    := True;
      DBGrid.DataSource       := DM.dsXBase;

      Label1.Caption := 'Table: Ksiazki';
   end;

end;

end.
