unit Chitatel20;

interface

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

type
  TForm20 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    DBGrid2: TDBGrid;
    DataSource2: TDataSource;
    ADOQuery3: TADOQuery;
    Button5: TButton;
    Button6: TButton;
    Label9: TLabel;
    RadioGroup1: TRadioGroup;
    Edit1: TEdit;
    procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button5MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button3MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button4MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure DBGrid2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button6MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure RadioGroup1Click(Sender: TObject);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Button6Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form20: TForm20;

implementation

uses DobavCh3, UdalCh10, RedaktCh8, ProsmCh6, Menu1;

{$R *.dfm}

procedure TForm20.Button4Click(Sender: TObject);
begin
DobavCh3.Form3.showModal;
end;

procedure TForm20.Button3Click(Sender: TObject);
begin
UdalCh10.form10.showModal;
end;

procedure TForm20.Button2Click(Sender: TObject);
begin
RedaktCh8.form8.showModal;
end;

procedure TForm20.Button1Click(Sender: TObject);
begin
Close();
end;

procedure TForm20.Button5Click(Sender: TObject);
begin
ProsmCh6.form6.showModal;
end;

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

procedure TForm20.Button6Click(Sender: TObject);
var
excel, list, data,shapka,dp: variant;
i,j,ii,jj:integer;
begin
Chitatel20.form20.ADOQuery3.open;
ii:= Chitatel20.form20.ADOQuery3.RecordCount;
jj:=Chitatel20.form20.ADOQuery3.FieldCount;
excel:=createoleobject('excel.application');
excel.workBooks.add;
Data:=vararraycreate([1,ii,1,jj],varvariant);
Chitatel20.form20.ADOQuery3.First;
for i:=1 to ii do
begin
for j:=1 to jj do
begin
data[i,j]:=Chitatel20.form20.ADOQuery3.Fields[j-1].AsString;
end;
Chitatel20.form20.ADOQuery3.Next;
end;
Shapka:= varArrayCreate([1,jj],varvariant);
for i:=1 to jj do
shapka[i]:= Chitatel20.form20.DBGrid2.Columns[i-1].Title.caption;;
list:=excel.worksheets[1];
Dp:=list.range[list.cells[3,2],list.cells[3,jj]];
begin
list.name:='Читатели';
list.rows[1].font.size:=14;
list.range['b1'].value:='Читатели';
Dp.value:=shapka;
Dp:=list.range[list.cells[4,2],list.cells[3+ii,jj]];
Dp.value:=Data;
for i:=1 to jj do
if i<>2 then
list.columns.item[i].autofit;
list.columns[2].columnwidth:=16 ;
list.range[list.cells[3,2],list.cells[ii+3,jj]].borders.linestyle:=1;
excel.visible:=true;
end;
end;

procedure TForm20.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
case radiogroup1.ItemIndex of
0: begin
  ADOQuery3.SQL.Text:='select * from formuliar_chitatelia2 where 1=1 and upper(familia) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery3.Open;
    end;
1:  begin
  ADOQuery3.SQL.Text:='select * from formuliar_chitatelia2 where 1=1 and upper(cex) Like '+''''+AnsiUpperCase(trim(Edit1.Text))+'%''';
    ADOQuery3.Open;
    end;
end;
end;

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

procedure TForm20.Button6MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
Menu1.form1.StatusBar1.Panels[0].Text:='Для перевода информации из таблицы в Excel ' ;
end;

procedure TForm20.DBGrid2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Картатека читателей';
end;

procedure TForm20.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Поле для поиска читателей';
end;

procedure TForm20.Button4MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Добавление в картатеку нововых читателей';
end;

procedure TForm20.Button3MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Удаление из картатеки информации о читателе';
end;

procedure TForm20.Button2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Редактирование читательских карточек';
end;

procedure TForm20.Button5MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Подробный просмотр информации о читателе';
end;

procedure TForm20.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
form1.StatusBar1.Panels[0].Text:='Закрытие картатеки читателей';
end;

end.
