unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    Table1: TTable;
    DBGrid1: TDBGrid;
    DBMemo1: TDBMemo;
    DBImage1: TDBImage;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    Label1: TLabel;
    RadioGroup1: TRadioGroup;
    CheckBox2: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
var s: string;
begin
   s:=Edit1.Text;
   //ustawienie filtra
   Table1.Filter:='NAZWISKO='+QuotedStr(s);
   Table1.Filtered:=CheckBox1.Checked;
   if Table1.Filtered then Table1.Refresh;

end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
   Table1.Filtered:=CheckBox2.Checked;
   if Table1.Filtered then Table1.Refresh;
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';
  DBGrid1.Columns.Add;
  DBGrid1.Columns[4].Fieldname:='SR_OCEN';
  //nazwa kolumny może być inna niz nazwa kolumny w bazie
  DBGrid1.Columns.Items[4].Title.Caption:='ŚREDNIA';

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

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
   case RadioGroup1.ItemIndex of
    0:  Table1.Filter:='NAZWISKO>=''N''';
    1:  Table1.Filter:='IMIE=''A*''';
    2:  Table1.Filter:='WIEK>15';
    3:  Table1.Filter:='SR_OCEN>3';
    4:  Table1.Filter:='SR_OCEN>3 AND NAZWISKO=''N*''';
    5:  Table1.Filter:='SR_OCEN>3 OR NAZWISKO=''N*''';
   end;
end;

end.
