unit
  FRM_Company;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids,

  IB_Session,
  IB_Components,
  IB_Grid,
  IB_Process,
  IB_Script,
  IB_SessionProps;

type
  TfrmCompany = class(TForm)
    cnCompany: TIB_Connection;
    qrCompany: TIB_Query;
    dsCompany: TIB_DataSource;
    CompanyLabel: TLabel;
    scCompany: TIB_Script;
    spCpmpany: TIB_SessionProps;
    grCompany: TIB_Grid;
    tr: TIB_Transaction;
    procedure FormCreate(Sender: TObject);
    procedure cnCompanyBeforeConnect(Sender: TIB_Connection);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure scCompanyMacroSubstitute(Sender: TComponent;
      const ATextBlock: String; var ATextResult: String);
    procedure cnCompanyAfterConnect(Sender: TIB_Connection);
  private
  public
  end;

var
  frmCompany: TfrmCompany;

implementation

uses
  FRM_Employee, IB_Samples;

{$R *.DFM}


procedure TfrmCompany.FormCreate(Sender: TObject);
begin
  ReadDefaultPath(cnCompany,'COMPANYPath');

  qrCompany.Open;
  TfrmEmployee.Create( Self );
end;

procedure TfrmCompany.cnCompanyBeforeConnect(Sender: TIB_Connection);
begin
  if NeedToCreateDataBase then
    scCompany.Execute;
end;

procedure TfrmCompany.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  CanClose := tr.CloseWithConfirm = mrOk;
end;

procedure TfrmCompany.scCompanyMacroSubstitute(Sender: TComponent;
  const ATextBlock: String; var ATextResult: String);
begin
  DefaultMacroSubstitute(ATextBlock, ATextResult);
end;

procedure TfrmCompany.cnCompanyAfterConnect(Sender: TIB_Connection);
begin
  WriteDefaultPath;
end;

end.

