unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBCtrls, StdCtrls, Grids, DBGrids, DB, DBTables, ExtCtrls, ExtDlgs;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    Table1: TTable;
    DBGrid1: TDBGrid;
    DBMemo1: TDBMemo;
    DBImage1: TDBImage;
    DBNavigator1: TDBNavigator;
    OpenPictureDialog1: TOpenPictureDialog;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure DBImage1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//procedura obsługuje zdarzenie kliknięcia komponentu TDBImage1
//dodanie dwóch rekordów (tylko pola Nazwisko) na początku
procedure TForm1.Button1Click(Sender: TObject);
begin
  Table1.First;
  Table1.Insert;
  Table1.Edit;
  Table1.FieldByName('Nazwisko').AsString:='Accc';
  Table1.Insert;
  Table1.Edit;
  Table1.FieldByName('Nazwisko').AsString:='Bccc';
  Table1.Post;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Table1.MoveBy(1);
  Table1.Delete;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Table1.First;
  Table1.MoveBy(2);
  Table1.Edit;
  Table1.FieldByName('Imie').AsString:='Antoni';
  Table1.Post;
end;

procedure TForm1.DBImage1Click(Sender: TObject);
begin
  Table1.Edit; //edycja rekordu
  if OpenPicturedialog1.Execute then   //otwarcie okna wyboru pliku
  DBImage1.Picture.Loadfromfile(OpenPicturedialog1.Filename);
 // Table1.Post; lub kliknac przycisk v w DBNawigatorze
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   Table1.Active:=false;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Table1.TableName:='nowa2.dbf';
  Table1.IndexName:='LP';
  DBGrid1.Columns.Add;
  DBGrid1.Columns[0].Fieldname:='LP';
  DBGrid1.Columns.Add;
  DBGrid1.Columns[1].Fieldname:='NAZWISKO';
  DBGrid1.Columns.Add;
  DBGrid1.Columns[2].Fieldname:='IMIE';
  DBGrid1.Columns.Add;
  DBGrid1.Columns[3].Fieldname:='WIEK';

  DBMemo1.DataField:='UWAGI';
  DBImage1.DataField:='OBRAZ';
  Table1.Active:=true;
end;

end.
