unit PoiskK11;

interface

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

type
  TForm11 = class(TForm)
    Panel1: TPanel;
    Button2: TButton;
    Edit1: TEdit;
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    Label1: TLabel;
    RadioGroup1: TRadioGroup;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form11: TForm11;

implementation

{$R *.dfm}


procedure TForm11.Button2Click(Sender: TObject);
begin
close();
end;

procedure TForm11.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
case radiogroup1.ItemIndex of
0: begin
    if edit1.text<>'' then
    ADOQuery1.SQL.STRINGS[1]:='where inv_nomer='+(Edit1.Text)
else
    ADOQuery1.SQL.STRINGS[1]:='where 1=1';
    ADOQuery1.Open;
    end;
1: begin
  ADOQuery1.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(fam_avtor) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery1.Open;
    end;
2:  begin
  ADOQuery1.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(nazvanie) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery1.Open;
    end;
3: begin
if edit1.text<>'' then
    ADOQuery1.SQL.STRINGS[1]:='where num_v_kinv='+(Edit1.Text)
else
    ADOQuery1.SQL.STRINGS[1]:='where 1=1';
    ADOQuery1.Open;
    end;
end;
end;

procedure TForm11.RadioGroup1Click(Sender: TObject);
begin
edit1.SetFocus;
end;

procedure TForm11.FormActivate(Sender: TObject);
begin
ADOQuery1.Open;
radiogroup1.ItemIndex:=0;
end;

procedure TForm11.Button1Click(Sender: TObject);
begin
  ADOQuery1.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and god_izdan<#19800101#';
  ADOQuery1.Open;
end;

end.
