unit ProsmK5;

interface

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

type
  TForm5 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    DBText1: TDBText;
    DBText2: TDBText;
    DBText3: TDBText;
    DBText4: TDBText;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    DBText5: TDBText;
    DBText6: TDBText;
    Edit1: TEdit;
    Label7: TLabel;
    DataSource2: TDataSource;
    ADOQuery2: TADOQuery;
    DBGrid1: TDBGrid;
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Edit2KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure sqlfilter();
    private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

{$R *.dfm}
procedure Tform5.sqlfilter();
begin
    ADOQuery2.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(fam_avtor) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery2.Open;
end;

procedure TForm5.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
DBGrid1.DataSource:=datasource2;
sqlfilter();
end;

procedure TForm5.Edit2KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
sqlfilter();
end;

procedure TForm5.FormActivate(Sender: TObject);
begin
edit1.SetFocus;
ADOQuery2.Open;
end;

procedure TForm5.Button1Click(Sender: TObject);
begin
close();
end;

end.
