unit RedaktK7;

interface

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

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

var
  Form7: TForm7;

implementation

{$R *.dfm}


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

procedure TForm7.FormActivate(Sender: TObject);
begin
ADOQuery1.Open;
DBGrid1.ReadOnly:=true;
button3.Visible:=false;
radiogroup1.ItemIndex:=0;
end;

procedure TForm7.Button3Click(Sender: TObject);
begin
DBGrid1.ReadOnly:=true;
Button3.Visible:=false;
end;

procedure TForm7.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
case radiogroup1.ItemIndex of
0: begin
  ADOQuery1.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(fam_avtor) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery1.Open;
    end;
1:  begin
  ADOQuery1.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(nazvanie) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery1.Open;
    end;
end;
end;

procedure TForm7.Button2Click(Sender: TObject);
begin
DBGrid1.ReadOnly:=false;
Button3.Visible:=true;
end;

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

end.
