unit Unit13;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, Buttons;

type
  TForm13 = class(TForm)
    DBGrid1: TDBGrid;
    DBGrid2: TDBGrid;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    Query1: TQuery;
    Query2: TQuery;
    Query3: TQuery;
    Query3id: TIntegerField;
    Query3IdMagazuny: TIntegerField;
    Query3IdTovary: TIntegerField;
    Query3Kilkist: TFloatField;
    Query3CinaOblikova: TFloatField;
    Query3CinaRozdribna: TFloatField;
    Query3id_1: TIntegerField;
    Query3nazvatovary: TStringField;
    BitBtn1: TBitBtn;
    Query1id: TIntegerField;
    Query1NazvaMagazuny: TStringField;
    Query1AdresaMagazuny: TStringField;
    Query1PIB: TStringField;
    Query1IdSpivrobitnuka: TIntegerField;
    Query3CinaRoz: TIntegerField;
    procedure Query1AfterScroll(DataSet: TDataSet);
    procedure Query3CalcFields(DataSet: TDataSet);
    procedure BitBtn1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form13: TForm13;

implementation

{$R *.dfm}


procedure TForm13.Query1AfterScroll(DataSet: TDataSet);
begin
Query3.Close();
if Query1.IsEmpty then exit;
Query3.SQL.Clear();
Query3.SQL.Add('Select nayavnistvmagazuni.id, nayavnistvmagazuni.IdMagazuny, nayavnistvmagazuni.IdTovary, nayavnistvmagazuni.Kilkist, nayavnistvmagazuni.CinaOblikova, nayavnistvmagazuni.CinaRozdribna, magazunu.id, tovary.nazvatovary');
Query3.SQL.Add('From nayavnistvmagazuni, magazunu, tovary');
Query3.SQL.Add('Where nayavnistvmagazuni.Idmagazuny = magazunu.id AND nayavnistvmagazuni.IdTovary = tovary.id');
Query3.SQL.Add('and nayavnistvmagazuni.Idmagazuny='+Query1Id.AsString);
Query3.Open();
end;

procedure TForm13.Query3CalcFields(DataSet: TDataSet);
begin
    Query3CinaRoz.AsFloat:=Query3CinaOblikova.AsFloat*1.25;
end;

procedure TForm13.BitBtn1Click(Sender: TObject);
begin
 Close;
end;

end.
