unit KObarotV15;

interface

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

type
  TForm15 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    DBGrid1: TDBGrid;
    Edit2: TEdit;
    DateTimePicker1: TDateTimePicker;
    Panel1: TPanel;
    Button1: TButton;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DataSource3: TDataSource;
    ADOQuery3: TADOQuery;
    ADOQuery4: TADOQuery;
    DataSource4: TDataSource;
    DBGrid3: TDBGrid;
    Edit4: TEdit;
    Label5: TLabel;
    DateTimePicker2: TDateTimePicker;
    Label6: TLabel;
    Button2: TButton;
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    DataSource2: TDataSource;
    ADOQuery2: TADOQuery;
    DataSource5: TDataSource;
    ADOQuery5: TADOQuery;
    Label7: TLabel;
    DataSource6: TDataSource;
    DBGrid2: TDBGrid;
    ADOQuery6: TADOQuery;
    procedure DBEdit2KeyPress(Sender: TObject; var Key: Char);
    procedure Button2MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
    procedure DateTimePicker2Click(Sender: TObject);
    procedure DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
    procedure DateTimePicker1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Edit4KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Edit2KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form15: TForm15;

implementation

{$R *.dfm}

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

procedure TForm15.Edit2KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    ADOQuery3.SQL.Text:='select * from inventarnaia_kniga1 where 1=1 and upper(fam_avtor) Like '+''''+AnsiUpperCase(trim(Edit2.Text))+'%''';
    ADOQuery3.Open;
end;

procedure TForm15.Edit4KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    ADOQuery4.SQL.Text:='select * from formuliar_chitatelia2 where 1=1 and upper(familia) Like '+''''+AnsiUpperCase(trim(Edit4.Text))+'%''';
    ADOQuery4.Open;
end;

procedure TForm15.Button2Click(Sender: TObject);
begin
with ADOQuery1 do begin
Parameters.Items[0].value:=StrToFloat(trim(Label7.Caption));
Parameters.Items[1].value:=StrToFloat(trim(DBEdit2.Text));
Parameters.Items[2].value:=StrToFloat(trim(DBEdit1.Text));
Parameters.Items[3].value:=datetostr(DateTimePicker1.Date);
Parameters.Items[4].Value:=DateTimePicker2.Date;
execSQL;
ADOQuery6.Close;
ADOQuery6.Open;
end;

end;


procedure TForm15.FormActivate(Sender: TObject);
begin
ADOQuery2.Close;
ADOQuery2.SQL.Text:='select max(num)+1 from vidacha_knig31';
ADOQuery2.Open;
ADOQuery6.Open;
ADOQuery4.Open;
ADOQuery3.Open;
label7.Caption:=floattostr(AdoQuery2.Fields[0].AsFloat);
end;

procedure TForm15.DateTimePicker1Click(Sender: TObject);
begin
DateTimePicker2.DateTime:= DateTimePicker1.DateTime+10;
end;

procedure TForm15.DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
begin
DateTimePicker2.DateTime:= DateTimePicker1.DateTime+10;
end;

procedure TForm15.DateTimePicker2Click(Sender: TObject);
begin
DateTimePicker2.DateTime:= DateTimePicker1.DateTime+10;
end;

procedure TForm15.Button2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
DateTimePicker2.DateTime:= DateTimePicker1.DateTime+10;
end;

procedure TForm15.DBEdit2KeyPress(Sender: TObject; var Key: Char);
begin
DateTimePicker1.SetFocus;
end;

end.
