Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 15 - Project RWBlocks

Project Structure

RWBlocks.dpr
program RWBlocks;

uses
  Forms,
  MainForm in 'MainForm.pas' {FormMain},
  CompaniesForm in 'CompaniesForm.pas' {FormCompanies},
  MainData in 'MainData.pas' {DmMain: TDataModule},
  FreeQueryForm in 'FreeQueryForm.pas' {FormFreeQuery},
  CompaniesData in 'CompaniesData.pas' {DmCompanies: TDataModule},
  ClassesForm in 'ClassesForm.pas' {FormClasses},
  ClassesData in 'ClassesData.pas' {DmClasses: TDataModule};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TDmMain, DmMain);
  Application.CreateForm(TFormMain, FormMain);
  Application.Run;
end.
MainForm.pas
unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, Menus, ComCtrls, ToolWin, DBActns, ActnList,
  ImgList;

type
  TFormMain = class(TForm)
    ToolBar1: TToolBar;
    StatusBar1: TStatusBar;
    ImageList1: TImageList;
    ActionList1: TActionList;
    DataSetCancel1: TDataSetCancel;
    DataSetDelete1: TDataSetDelete;
    DataSetEdit1: TDataSetEdit;
    DataSetFirst1: TDataSetFirst;
    DataSetInsert1: TDataSetInsert;
    DataSetLast1: TDataSetLast;
    DataSetNext1: TDataSetNext;
    DataSetPost1: TDataSetPost;
    DataSetPrior1: TDataSetPrior;
    DataSetRefresh1: TDataSetRefresh;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    PageControl1: TPageControl;
    TabCompanies: TTabSheet;
    TabClasses: TTabSheet;
    TabFreeQ: TTabSheet;
    procedure FormCreate(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure PageControl1Change(Sender: TObject);
  public
    procedure ShowForm (Form: TForm; Tab: TTabSheet); overload;
  end;

var
  FormMain: TFormMain;

implementation

uses
  MainData, CompaniesForm,
  FreeQueryForm, ClassesForm;

{$R *.DFM}

procedure TFormMain.FormCreate(Sender: TObject);
begin
  ShortDateFormat := 'dd/mm/yyyy';
  ShowForm (TFormCompanies.Create (self), TabCompanies);
end;

procedure TFormMain.ShowForm (Form: TForm; Tab: TTabSheet);
begin
  Form.BorderStyle := bsNone;
  Form.Align := alClient;
  Form.Parent := Tab;
  Form.Show;
end;

procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
  i: integer;
begin
  // ask permission to close each subform
  CanClose := True;
  for i := 0 to Screen.FormCount - 1 do
    if Screen.Forms[I] <> self then
      CanClose := CanClose and Screen.Forms[I].CloseQuery;
end;

procedure TFormMain.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePage.ControlCount = 0 then
    if PageControl1.ActivePage = TabFreeQ then
      ShowForm (TFormFreeQuery.Create (self), TabFreeQ)
    else if PageControl1.ActivePage = TabClasses then
      ShowForm (TFormClasses.Create (self), TabClasses);
end;

end.
CompaniesForm.pas
unit CompaniesForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, DBCtrls, StdCtrls, Mask, Db, Grids, DBGrids,
  CompaniesData, Buttons, ComCtrls;

type
  TFormCompanies = class(TForm)
    dsCompanies: TDataSource;
    DBGridLocations: TDBGrid;
    DBGridPeople: TDBGrid;
    dsLocations: TDataSource;
    dsPeople: TDataSource;
    Panel1: TPanel;
    PageControlSearch: TPageControl;
    TabSheet1: TTabSheet;
    btnSearch: TButton;
    edSearch: TEdit;
    TabSheet2: TTabSheet;
    edTown: TEdit;
    btnTown: TButton;
    DBGridCompanies: TDBGrid;
    btnCancel: TBitBtn;
    btnOK: TBitBtn;
    Splitter1: TSplitter;
    Splitter2: TSplitter;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure btnSearchClick(Sender: TObject);
    procedure edSearchChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnTownClick(Sender: TObject);
    procedure edTownChange(Sender: TObject);
  private
    { Private declarations }
  public
    dm: TDmCompanies;
    class function SelectCompany (var CompanyName: string;
      var CompanyId: Integer): Boolean;
    class function SelectPerson (CompanyId: Integer;
      var PersonId: Integer; var PersonName: string): Boolean;
  end;

var
  FormCompanies: TFormCompanies;

implementation

uses
  MainData;

{$R *.DFM}

procedure TFormCompanies.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
  Msg: string;
begin
  CanClose := True;

  if dsCompanies.State in dsEditModes then
  begin
    CanClose := False;
    Msg := 'Companies';
  end;

  if dsLocations.State in dsEditModes then
  begin
    CanClose := False;
    Msg := 'Locations';
  end;

  if dsPeople.State in dsEditModes then
  begin
    CanClose := False;
    Msg := 'People';
  end;

  if not CanClose then
    ShowMessage (Msg + ': Cancel or accept changes before closing');
end;

procedure TFormCompanies.btnSearchClick(Sender: TObject);
begin
  dm.DataCompanies.Close;
  dm.DataCompanies.SelectSQL.Text :=
    'select c.id, c.name, c.tax_code' +
    '  from companies c ' +
    '  where name_upper starting with ''' +
    UpperCase (edSearch.Text) + '''';
  dm.DataCompanies.Open;
  dm.DataLocations.Open;
  dm.DataPeople.Open;
end;

procedure TFormCompanies.edSearchChange(Sender: TObject);
begin
  btnSearch.Enabled := edSearch.Text <> '';
  if Length (edSearch.Text) >= 3 then
    btnSearch.OnClick (Sender);
end;

procedure TFormCompanies.FormCreate(Sender: TObject);
begin
  dm := TDmCompanies.Create (self);
  dsCompanies.Dataset := dm.DataCompanies;
  dsLocations.Dataset := dm.DataLocations;
  dsPeople.Dataset := dm.DataPeople;
end;

procedure TFormCompanies.btnTownClick(Sender: TObject);
begin
  with dm.DataCompanies do
  begin
    Close;
    SelectSQL.Text :=
      'select c.id, c.name, c.tax_code' +
      '  from companies c ' +
      '  where exists (select loc.id from locations loc ' +
      '  where loc.id_company = c.ID and UPPER(loc.town) = ''' + UpperCase(edTown.Text) + ''' )';
    Open;
    dm.DataLocations.Open;
    dm.DataPeople.Open;
  end;
end;

procedure TFormCompanies.edTownChange(Sender: TObject);
begin
  btnTown.Enabled := edTown.Text <> '';
end;

class function TFormCompanies.SelectCompany (var CompanyName: string;
  var CompanyId: Integer): Boolean;
var
  FormComp: TFormCompanies;
begin
  Result := False;
  FormComp := TFormCompanies.Create (Application);
  FormComp.Caption := 'Select Company';
  try
    // activate dialog buttons
    FormComp.btnCancel.Visible := True;
    FormComp.btnOK.Visible := True;
    // select company
    if CompanyId > 0 then
      FormComp.dm.DataCompanies.SelectSQL.Text :=
        'select c.id, c.name, c.tax_code' +
        '  from companies c ' +
        '  where c.id = ' + IntToStr (CompanyId)
    else
      FormComp.dm.DataCompanies.SelectSQL.Text :=
        'select c.id, c.name, c.tax_code' +
        '  from companies c ' +
        '  where name_upper starting with ''a''';
    FormComp.dm.DataCompanies.Open;
    FormComp.dm.DataLocations.Open;
    FormComp.dm.DataPeople.Open;

    if FormComp.ShowModal = mrOK then
    begin
      Result := True;
      CompanyId := FormComp.dm.DataCompanies.FieldByName ('id').AsInteger;
      CompanyName := FormComp.dm.DataCompanies.FieldByName ('name').AsString;
    end;
  finally
    FormComp.Free;
  end;
end;

class function TFormCompanies.SelectPerson(CompanyId: Integer;
   var PersonId: Integer; var PersonName: string): Boolean;
var
  FormComp: TFormCompanies;
begin
  Result := False;
  FormComp := TFormCompanies.Create (Application);
  FormComp.Caption := 'Select Person';
  try
    with FormComp.dm.DataCompanies do
    begin
      SelectSQL.Text :=
          'select c.id, c.name, c.tax_code' +
          '  from companies c ' +
          '  where c.id = ' + IntToStr (CompanyId);
      Open;
    end;
    FormComp.dm.DataLocations.Open;
    FormComp.dm.DataPeople.Open;

    // activate dialog buttons
    FormComp.btnCancel.Visible := True;
    FormComp.btnOK.Visible := True;
    // read-only, no further searches
    FormComp.dsCompanies.AutoEdit := False;
    FormComp.DBGridCompanies.ReadOnly := True;
    FormComp.PageControlSearch.Visible := False;
    // select person
    if PersonId <> 0 then
      FormComp.dm.DataPeople.Locate ('ID', PersonId, []);
    FormComp.ActiveControl := FormComp.DBGridPeople;
    if FormComp.ShowModal = mrOK then
    begin
      Result := True;
      PersonId := FormComp.dm.DataPeople.FieldByName ('id').AsInteger;
      PersonName := FormComp.dm.DataPeople.FieldByName ('name').AsString
    end;
  finally
    FormComp.Free;
  end;
end;

end.
MainData.pas
unit MainData;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBTables, IBQuery, IBCustomDataSet, IBTable, IBDatabase;

type
  TDmMain = class(TDataModule)
    IBDatabase1: TIBDatabase;
    QueryId: TIBQuery;
    IBTransaction2: TIBTransaction;
  public
    function GetNewId: Integer;
  end;

var
  DmMain: TDmMain;

implementation

{$R *.DFM}

function TDmMain.GetNewId: Integer;
begin
  // return the next value of the generator
  QueryId.Open;
  try
    Result := QueryId.Fields[0].AsInteger;
  finally
    QueryId.Close;
  end;
end;

end.
FreeQueryForm.pas
unit FreeQueryForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DBCtrls, StdCtrls, ExtCtrls, Grids, DBGrids, IBDatabase, Db,
  IBCustomDataSet, IBQuery;

type
  TFormFreeQuery = class(TForm)
    MemoSql: TMemo;
    Splitter1: TSplitter;
    DBGrid1: TDBGrid;
    Panel1: TPanel;
    ButtonRun: TButton;
    DBNavigator1: TDBNavigator;
    dsQueryFree: TDataSource;
    QueryFree: TIBQuery;
    IBTransaction1: TIBTransaction;
    ComboTables: TComboBox;
    procedure ButtonRunClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboTablesChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormFreeQuery: TFormFreeQuery;

implementation

uses MainData;

{$R *.DFM}

procedure TFormFreeQuery.ButtonRunClick(Sender: TObject);
begin
  QueryFree.Close;
  QueryFree.SQL := MemoSql.Lines;
  QueryFree.Open;
end;

procedure TFormFreeQuery.FormCreate(Sender: TObject);
begin
  DmMain.IBDatabase1.GetTableNames (ComboTables.Items);
end;

procedure TFormFreeQuery.ComboTablesChange(Sender: TObject);
begin
  MemoSql.Lines.Text :=
    'select * from ' + ComboTables.Text;
end;

end.
CompaniesData.pas
unit CompaniesData;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, IBCustomDataSet, IBDatabase;

type
  TDmCompanies = class(TDataModule)
    DataCompanies: TIBDataSet;
    DataLocations: TIBDataSet;
    DataPeople: TIBDataSet;
    dsCompanies: TDataSource;
    IBTransaction1: TIBTransaction;
    DataLocationsID: TIntegerField;
    DataLocationsID_COMPANY: TIntegerField;
    DataLocationsADDRESS: TIBStringField;
    DataLocationsFAX: TIBStringField;
    DataLocationsPHONE: TIBStringField;
    DataLocationsSTATE: TIBStringField;
    DataLocationsTOWN: TIBStringField;
    DataLocationsZIP: TIBStringField;
    DataPeopleID: TIntegerField;
    DataPeopleID_COMPANY: TIntegerField;
    DataPeopleID_LOCATION: TIntegerField;
    DataPeopleKEY_CONTACT: TIBStringField;
    DataPeopleNAME: TIBStringField;
    DataPeopleEMAIL: TIBStringField;
    DataPeopleFAX: TIBStringField;
    DataPeoplePHONE: TIBStringField;
    DataCompaniesID: TIntegerField;
    DataCompaniesNAME: TIBStringField;
    DataCompaniesTAX_CODE: TIBStringField;
    procedure DataLocationsAfterInsert(DataSet: TDataSet);
    procedure DataPeopleAfterInsert(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses
  MainData;

{$R *.DFM}

procedure TDmCompanies.DataLocationsAfterInsert(DataSet: TDataSet);
begin
  // initialize the data of the detail record
  // with a reference to the master record
  DataLocationsID_COMPANY.AsInteger :=
    DataCompaniesID.AsInteger;
end;

procedure TDmCompanies.DataPeopleAfterInsert(DataSet: TDataSet);
begin
  // initialize the data of the detail record
  // with a reference to the master record
  DataPeopleID_COMPANY.AsInteger :=
    DataCompaniesID.AsInteger;
  // the suggested location is the active one, if available
  if not DataLocations.IsEmpty then
    DataPeopleID_LOCATION.AsInteger :=
      DataLocationsID.AsInteger;
  // the first person added becomes the key contact
  // (checks if the filtered dataset of people is empty)
  DataPeopleKEY_CONTACT.AsBoolean := DataPeople.IsEmpty;
end;

end.
ClassesForm.pas
unit ClassesForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, Db, ClassesData, StdCtrls, ComCtrls, DBCtrls, ExtCtrls;

type
  TFormClasses = class(TForm)
    dsClassReg: TDataSource;
    dsClasses: TDataSource;
    Tab: TTabControl;
    DBGridClasses: TDBGrid;
    DBGridPeopleReg: TDBGrid;
    dsPeopleReg: TDataSource;
    Splitter1: TSplitter;
    Panel1: TPanel;
    DBGridClassReg: TDBGrid;
    MemoNote: TDBMemo;
    Splitter2: TSplitter;
    Splitter3: TSplitter;
    procedure FormCreate(Sender: TObject);
    procedure TabChange(Sender: TObject);
    procedure DBGridClassRegEditButtonClick(Sender: TObject);
    procedure DBGridPeopleRegEditButtonClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    dm: TDmClasses;
    SqlCommands: TStringList;
  public
    { Public declarations }
  end;

var
  FormClasses: TFormClasses;

implementation

uses
  CompaniesForm;

{$R *.DFM}

procedure TFormClasses.FormCreate(Sender: TObject);
begin
  dm := TDmClasses.Create (self);
  // connect the datasets to the datasources
  dsClasses.Dataset := dm.IBClasses;
  dsClassReg.DataSet := dm.IBClassReg;
  dsPeopleReg.DataSet := dm.IBPeopleReg;
  // open the datasets
  dm.IBClasses.Active := True;
  dm.IBClassReg.Active := True;
  dm.IBPeopleReg.Active := True;

  // prepare the SQL for the three tabs
  SqlCommands := TStringList.Create;
  SqlCommands.Add (' where Starts_On > ''NOW''');
  SqlCommands.Add (' where Starts_On <= ''NOW'' and ' +
    ' extract (year from Starts_On) >= extract(year from current_timestamp)');
  SqlCommands.Add (' where Extract (YEAR from Starts_On) < ' +
    ' Extract(YEAR from current_timestamp)');
end;

procedure TFormClasses.TabChange(Sender: TObject);
begin
  dm.IBClasses.Active := False;
  dm.IBClasses.SelectSQL [1] :=
    SqlCommands [Tab.TabIndex];
  dm.IBClasses.Active := True;
end;

procedure TFormClasses.DBGridClassRegEditButtonClick(Sender: TObject);
var
  CompanyName: string;
  CompanyId: Integer;
begin
  CompanyId := dm.IBClassReg.FieldByName ('id_Company').AsInteger;
  if TFormCompanies.SelectCompany (CompanyName, CompanyId) then
  begin
    dm.IBClassReg.Edit;
    dm.IBClassReg.FieldByName (
      'Name').AsString := CompanyName;
    dm.IBClassReg.FieldByName (
      'id_Company').AsInteger := CompanyId;
  end;
end;

procedure TFormClasses.DBGridPeopleRegEditButtonClick(Sender: TObject);
var
  PersonName: string;
  CompanyId, PersonId: Integer;
begin
  PersonId := 0;
  CompanyId := dm.IBClassReg.FieldByName ('id_Company').AsInteger;
  if not dm.IBPeopleReg.FieldByName ('id_Person').IsNull then
    PersonId := dm.IBPeopleReg.FieldByName ('id_Person').AsInteger;
  if TFormCompanies.SelectPerson (CompanyId, PersonId, PersonName) then
  begin
    if not (dm.IBPeopleReg.State in dsEditModes) then
      dm.IBPeopleReg.Edit;
    dm.IBPeopleReg.FieldByName (
      'Name').AsString := PersonName;
    dm.IBPeopleReg.FieldByName (
      'ID_Person').AsInteger := PersonId;
  end;
end;

procedure TFormClasses.FormDestroy(Sender: TObject);
begin
  SqlCommands.Free;
end;

end.
ClassesData.pas
unit ClassesData;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  IBCustomDataSet, IBDatabase, Db, IBQuery;

type
  TDmClasses = class(TDataModule)
    IBTransaction1: TIBTransaction;
    IBClassReg: TIBDataSet;
    dsClasses: TDataSource;
    IBClasses: TIBDataSet;
    IBPeopleReg: TIBDataSet;
    dsReg: TDataSource;
    procedure IBClassRegAfterInsert(DataSet: TDataSet);
    procedure IBPeopleRegAfterInsert(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DmClasses: TDmClasses;

implementation

uses MainData;

{$R *.DFM}

procedure TDmClasses.IBClassRegAfterInsert(DataSet: TDataSet);
begin
  IBClassReg.FieldByName ('ID_CLASS').AsString :=
    IBClasses.FieldByName ('ID').AsString;
end;

procedure TDmClasses.IBPeopleRegAfterInsert(DataSet: TDataSet);
begin
  IBPeopleReg.FieldByName ('ID_CLASSES_REG').AsString :=
    IBClassReg.FieldByName ('ID').AsString;
end;

end.
MainForm.dfm
object FormMain: TFormMain
  Left = 123
  Top = 159
  Width = 811
  Height = 469
  Caption = 'RWBlocks'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poDefault
  OnCloseQuery = FormCloseQuery
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object ToolBar1: TToolBar
    Left = 0
    Top = 0
    Width = 803
    Height = 40
    AutoSize = True
    ButtonHeight = 36
    ButtonWidth = 50
    Caption = 'ToolBar1'
    Images = ImageList1
    ShowCaptions = True
    TabOrder = 0
    object ToolButton1: TToolButton
      Left = 0
      Top = 2
      Action = DataSetFirst1
    end
    object ToolButton2: TToolButton
      Left = 50
      Top = 2
      Action = DataSetPrior1
    end
    object ToolButton3: TToolButton
      Left = 100
      Top = 2
      Action = DataSetNext1
    end
    object ToolButton4: TToolButton
      Left = 150
      Top = 2
      Action = DataSetLast1
    end
    object ToolButton5: TToolButton
      Left = 200
      Top = 2
      Action = DataSetInsert1
    end
    object ToolButton6: TToolButton
      Left = 250
      Top = 2
      Action = DataSetDelete1
    end
    object ToolButton7: TToolButton
      Left = 300
      Top = 2
      Action = DataSetEdit1
    end
    object ToolButton8: TToolButton
      Left = 350
      Top = 2
      Action = DataSetPost1
    end
    object ToolButton9: TToolButton
      Left = 400
      Top = 2
      Action = DataSetCancel1
    end
    object ToolButton10: TToolButton
      Left = 450
      Top = 2
      Action = DataSetRefresh1
    end
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 423
    Width = 803
    Height = 19
    Panels = <>
    SimplePanel = False
  end
  object PageControl1: TPageControl
    Left = 0
    Top = 40
    Width = 803
    Height = 383
    ActivePage = TabCompanies
    Align = alClient
    TabIndex = 0
    TabOrder = 2
    OnChange = PageControl1Change
    object TabCompanies: TTabSheet
      Caption = 'Companies'
    end
    object TabClasses: TTabSheet
      Caption = 'Classes'
      ImageIndex = 1
    end
    object TabFreeQ: TTabSheet
      Caption = 'Free Query'
      ImageIndex = 2
    end
  end
  object ImageList1: TImageList
    Left = 136
    Top = 69
    Bitmap = {
      494C01010A000F00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000004000000001001000000000000020
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000001042
      0000104200000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      1042000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000010420000000000000000000000000000000000000000000000001042
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      1042000000000000000000000000000000000000000000001042000010420000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000010420000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000010420000
      0000000000000000000000000000000000000000000000000000000010420000
      0000000010420000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      1042000000000000000000000000000000000000000000001042000000001042
      0000104200000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000010420000000000000000000000000000000000000000000000000000
      0000000000000000104200000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000010420000
      0000000010420000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000000000000104200000000000000000000000000000000000000001042
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000001042
      0000000000000000104200000000000000000000000000000000000000000000
      0000104200000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000104200000000104200000000000000000000000000000000000000000000
      0000000000001042000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000001042104200000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000104200000000104200000000000000000000000000000000000000000000
      0000000000001042000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000001042
      0000000000000000104200000000000000000000000000000000000000000000
      0000104200000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000000000000104200000000000000000000000000000000000000001042
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000000000000104200000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000010420000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      1042000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104210420000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      1042000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000010420000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000104200000000
      0000000000000000104200000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000400000000100010000000000000200000000000000000000
      000000000000000000000000FFFFFF0000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000FFFFFFFF00000000FFFFFFFF00000000
      FFFFFFFF00000000FFFFFC7F00000000FFFFF0FF00000000FF9FF1FF00000000
      FE1FE3FF00000000F81FE7FF00000000F01FE70700000000F81FE38700000000
      FE1FE10700000000FF9FF00700000000FFFFF83700000000FFFFFFFF00000000
      FFFFFFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7FFFFFFFFFFBFFFC7FE7E7F9FFF1FF
      FC7FE1E7F87FE0FFE00FE067F81FC47FE00FE007F80FCE3FE00FE067F81FFF1F
      FC7FE1E7F87FFF8FFC7FE7E7F9FFFFC7FC7FFFFFFFFFFFE7FFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3E7FFFFFFFFFFFFF1C7FFFFFFFFE7E7
      F88FFFFFE007E787FC1FE007F00FE607FE3FE007F81FE007FC1FE007FC3FE607
      F88FFFFFFE7FE787F1C7FFFFFFFFE7E7F3E7FFFFFFFFFFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000
      000000000000}
  end
  object ActionList1: TActionList
    Images = ImageList1
    Left = 136
    Top = 125
    object DataSetCancel1: TDataSetCancel
      Category = 'Dataset'
      Caption = '&Cancel'
      Hint = 'Cancel'
      ImageIndex = 0
    end
    object DataSetDelete1: TDataSetDelete
      Category = 'Dataset'
      Caption = '&Delete'
      Hint = 'Delete'
      ImageIndex = 1
    end
    object DataSetEdit1: TDataSetEdit
      Category = 'Dataset'
      Caption = '&Edit'
      Hint = 'Edit'
      ImageIndex = 2
    end
    object DataSetFirst1: TDataSetFirst
      Category = 'Dataset'
      Caption = '&First'
      Hint = 'First'
      ImageIndex = 3
    end
    object DataSetInsert1: TDataSetInsert
      Category = 'Dataset'
      Caption = '&Insert'
      Hint = 'Insert'
      ImageIndex = 4
    end
    object DataSetLast1: TDataSetLast
      Category = 'Dataset'
      Caption = '&Last'
      Hint = 'Last'
      ImageIndex = 5
    end
    object DataSetNext1: TDataSetNext
      Category = 'Dataset'
      Caption = '&Next'
      Hint = 'Next'
      ImageIndex = 6
    end
    object DataSetPost1: TDataSetPost
      Category = 'Dataset'
      Caption = 'P&ost'
      Hint = 'Post'
      ImageIndex = 7
    end
    object DataSetPrior1: TDataSetPrior
      Category = 'Dataset'
      Caption = '&Prior'
      Hint = 'Prior'
      ImageIndex = 8
    end
    object DataSetRefresh1: TDataSetRefresh
      Category = 'Dataset'
      Caption = '&Refresh'
      Hint = 'Refresh'
      ImageIndex = 9
    end
  end
end
CompaniesForm.dfm
object FormCompanies: TFormCompanies
  Left = 204
  Top = 137
  Width = 666
  Height = 447
  Caption = 'Clienti'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poDefaultPosOnly
  OnCloseQuery = FormCloseQuery
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 121
    Width = 658
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object Splitter2: TSplitter
    Left = 0
    Top = 224
    Width = 658
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object DBGridLocations: TDBGrid
    Left = 0
    Top = 124
    Width = 658
    Height = 100
    Align = alTop
    DataSource = dsLocations
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object DBGridPeople: TDBGrid
    Left = 0
    Top = 227
    Width = 658
    Height = 193
    Align = alClient
    DataSource = dsPeople
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 658
    Height = 121
    Align = alTop
    TabOrder = 2
    object PageControlSearch: TPageControl
      Left = 1
      Top = 1
      Width = 137
      Height = 119
      ActivePage = TabSheet1
      Align = alLeft
      TabIndex = 0
      TabOrder = 0
      object TabSheet1: TTabSheet
        Caption = 'By Name'
        object btnSearch: TButton
          Left = 2
          Top = 40
          Width = 121
          Height = 25
          Caption = 'Search'
          Enabled = False
          TabOrder = 0
          OnClick = btnSearchClick
        end
        object edSearch: TEdit
          Left = 2
          Top = 8
          Width = 121
          Height = 21
          TabOrder = 1
          OnChange = edSearchChange
        end
      end
      object TabSheet2: TTabSheet
        Caption = 'By Town'
        ImageIndex = 1
        object edTown: TEdit
          Left = 8
          Top = 8
          Width = 113
          Height = 21
          TabOrder = 0
          OnChange = edTownChange
        end
        object btnTown: TButton
          Left = 8
          Top = 44
          Width = 112
          Height = 25
          Caption = 'Search'
          Enabled = False
          TabOrder = 1
          OnClick = btnTownClick
        end
      end
    end
    object DBGridCompanies: TDBGrid
      Left = 138
      Top = 1
      Width = 391
      Height = 119
      Align = alLeft
      DataSource = dsCompanies
      TabOrder = 1
      TitleFont.Charset = DEFAULT_CHARSET
      TitleFont.Color = clWindowText
      TitleFont.Height = -11
      TitleFont.Name = 'MS Sans Serif'
      TitleFont.Style = []
    end
    object btnCancel: TBitBtn
      Left = 542
      Top = 16
      Width = 75
      Height = 25
      TabOrder = 2
      Visible = False
      Kind = bkCancel
    end
    object btnOK: TBitBtn
      Left = 542
      Top = 56
      Width = 75
      Height = 25
      TabOrder = 3
      Visible = False
      Kind = bkOK
    end
  end
  object dsCompanies: TDataSource
    Left = 224
    Top = 64
  end
  object dsLocations: TDataSource
    Left = 40
    Top = 184
  end
  object dsPeople: TDataSource
    Left = 40
    Top = 320
  end
end
MainData.dfm
object DmMain: TDmMain
  OldCreateOrder = False
  Left = 404
  Top = 204
  Height = 299
  Width = 291
  object IBDatabase1: TIBDatabase
    Connected = True
    DatabaseName = 'c:\md6code\15\data\mastering.gdb'
    Params.Strings = (
      'user_name=SYSDBA'
      'password=masterkey')
    LoginPrompt = False
    IdleTimer = 0
    SQLDialect = 1
    TraceFlags = []
    Left = 96
    Top = 56
  end
  object QueryId: TIBQuery
    Database = IBDatabase1
    Transaction = IBTransaction2
    BufferChunks = 1000
    CachedUpdates = False
    SQL.Strings = (
      'select prossimo_id from v_prossimo_id;')
    Left = 48
    Top = 112
  end
  object IBTransaction2: TIBTransaction
    Active = False
    DefaultDatabase = IBDatabase1
    Params.Strings = (
      'concurrency'
      'nowait')
    AutoStopAction = saNone
    Left = 112
    Top = 128
  end
end
FreeQueryForm.dfm
object FormFreeQuery: TFormFreeQuery
  Left = 226
  Top = 158
  Width = 696
  Height = 480
  Caption = 'Free Query'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 122
    Width = 688
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object MemoSql: TMemo
    Left = 0
    Top = 33
    Width = 688
    Height = 89
    Align = alTop
    Lines.Strings = (
      'select * from classes')
    TabOrder = 0
  end
  object DBGrid1: TDBGrid
    Left = 0
    Top = 125
    Width = 688
    Height = 328
    Align = alClient
    DataSource = dsQueryFree
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 688
    Height = 33
    Align = alTop
    TabOrder = 2
    object ButtonRun: TButton
      Left = 174
      Top = 5
      Width = 75
      Height = 25
      Caption = '&Run'
      TabOrder = 0
      OnClick = ButtonRunClick
    end
    object DBNavigator1: TDBNavigator
      Left = 255
      Top = 4
      Width = 240
      Height = 25
      DataSource = dsQueryFree
      TabOrder = 1
    end
    object ComboTables: TComboBox
      Left = 8
      Top = 8
      Width = 153
      Height = 21
      Style = csDropDownList
      ItemHeight = 13
      TabOrder = 2
      OnChange = ComboTablesChange
    end
  end
  object dsQueryFree: TDataSource
    DataSet = QueryFree
    Left = 32
    Top = 216
  end
  object QueryFree: TIBQuery
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    BufferChunks = 1000
    CachedUpdates = False
    SQL.Strings = (
      'select * from v_fatture_non_pagate')
    Left = 32
    Top = 168
  end
  object IBTransaction1: TIBTransaction
    Active = False
    DefaultDatabase = DmMain.IBDatabase1
    Params.Strings = (
      'concurrency'
      'nowait')
    Left = 96
    Top = 168
  end
end
CompaniesData.dfm
object DmCompanies: TDmCompanies
  OldCreateOrder = False
  Left = 304
  Top = 161
  Height = 370
  Width = 417
  object DataCompanies: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from COMPANIES'
      'where'
      '  ID = :OLD_ID and'
      '  NAME = :OLD_NAME and'
      '  TAX_CODE = :OLD_TAX_CODE')
    InsertSQL.Strings = (
      'insert into COMPANIES'
      '  (ID, NAME, TAX_CODE)'
      'values'
      '  (:ID, :NAME, :TAX_CODE)')
    RefreshSQL.Strings = (
      'Select '
      '  ID,'
      '  NAME,'
      '  TAX_CODE,'
      '  NAME_UPPER'
      'from COMPANIES '
      'where'
      '  ID = :ID and'
      '  NAME = :NAME and'
      '  TAX_CODE = :TAX_CODE')
    SelectSQL.Strings = (
      'select c.id, c.name, c.tax_code from companies c')
    ModifySQL.Strings = (
      'update COMPANIES'
      'set'
      '  ID = :ID,'
      '  NAME = :NAME,'
      '  TAX_CODE = :TAX_CODE'
      'where'
      '  ID = :OLD_ID and'
      '  NAME = :OLD_NAME and'
      '  TAX_CODE = :OLD_TAX_CODE')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    Left = 48
    Top = 40
    object DataCompaniesID: TIntegerField
      FieldName = 'ID'
      Required = True
    end
    object DataCompaniesNAME: TIBStringField
      FieldName = 'NAME'
      Size = 50
    end
    object DataCompaniesTAX_CODE: TIBStringField
      FieldName = 'TAX_CODE'
      Size = 16
    end
  end
  object DataLocations: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    AfterInsert = DataLocationsAfterInsert
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from LOCATIONS'
      'where'
      '  ID = :OLD_ID')
    InsertSQL.Strings = (
      'insert into LOCATIONS'
      '  (ID, ID_COMPANY, ADDRESS, FAX, PHONE, STATE, TOWN, ZIP)'
      'values'

              '  (:ID, :ID_COMPANY, :ADDRESS, :FAX, :PHONE, :STATE, :TOWN, :ZIP' +
        ')')
    RefreshSQL.Strings = (
      'Select '
      '  ID,'
      '  ID_COMPANY,'
      '  ADDRESS,'
      '  TOWN,'
      '  ZIP,'
      '  STATE,'
      '  PHONE,'
      '  FAX'
      'from LOCATIONS '
      'where'
      '  ID = :ID')
    SelectSQL.Strings = (
      'select ID, ID_COMPANY,  ADDRESS, FAX, '
      '  PHONE, STATE, TOWN, ZIP '
      'from LOCATIONS'
      'where ID_COMPANY = :id')
    ModifySQL.Strings = (
      'update LOCATIONS'
      'set'
      '  ID = :ID,'
      '  ID_COMPANY = :ID_COMPANY,'
      '  ADDRESS = :ADDRESS,'
      '  FAX = :FAX,'
      '  PHONE = :PHONE,'
      '  STATE = :STATE,'
      '  TOWN = :TOWN,'
      '  ZIP = :ZIP'
      'where'
      '  ID = :OLD_ID')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    DataSource = dsCompanies
    Left = 48
    Top = 104
    object DataLocationsID: TIntegerField
      FieldName = 'ID'
      Required = True
    end
    object DataLocationsID_COMPANY: TIntegerField
      FieldName = 'ID_COMPANY'
      Required = True
    end
    object DataLocationsADDRESS: TIBStringField
      FieldName = 'ADDRESS'
      Size = 40
    end
    object DataLocationsFAX: TIBStringField
      FieldName = 'FAX'
      Size = 15
    end
    object DataLocationsPHONE: TIBStringField
      FieldName = 'PHONE'
      Size = 15
    end
    object DataLocationsSTATE: TIBStringField
      FieldName = 'STATE'
      Size = 4
    end
    object DataLocationsTOWN: TIBStringField
      FieldName = 'TOWN'
      Size = 30
    end
    object DataLocationsZIP: TIBStringField
      FieldName = 'ZIP'
      Size = 10
    end
  end
  object DataPeople: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    AfterInsert = DataPeopleAfterInsert
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from PEOPLE'
      'where'
      '  ID = :OLD_ID')
    InsertSQL.Strings = (
      'insert into PEOPLE'

              '  (ID, ID_COMPANY, ID_LOCATION, KEY_CONTACT, NAME, EMAIL, FAX, P' +
        'HONE)'
      'values'

              '  (:ID, :ID_COMPANY, :ID_LOCATION, :KEY_CONTACT, :NAME, :EMAIL, ' +
        ':FAX, :PHONE)')
    RefreshSQL.Strings = (
      'Select '
      '  ID,'
      '  ID_COMPANY,'
      '  ID_LOCATION,'
      '  NAME,'
      '  PHONE,'
      '  FAX,'
      '  EMAIL,'
      '  KEY_CONTACT'
      'from PEOPLE '
      'where'
      '  ID = :ID')
    SelectSQL.Strings = (

              'select ID, ID_COMPANY, ID_LOCATION, KEY_CONTACT, NAME, EMAIL, FA' +
        'X, PHONE'
      'from PEOPLE'
      'where ID_COMPANY = :id')
    ModifySQL.Strings = (
      'update PEOPLE'
      'set'
      '  ID = :ID,'
      '  ID_COMPANY = :ID_COMPANY,'
      '  ID_LOCATION = :ID_LOCATION,'
      '  KEY_CONTACT = :KEY_CONTACT,'
      '  NAME = :NAME,'
      '  EMAIL = :EMAIL,'
      '  FAX = :FAX,'
      '  PHONE = :PHONE'
      'where'
      '  ID = :OLD_ID')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    DataSource = dsCompanies
    Left = 48
    Top = 168
    object DataPeopleID: TIntegerField
      FieldName = 'ID'
      Required = True
    end
    object DataPeopleID_COMPANY: TIntegerField
      FieldName = 'ID_COMPANY'
      Required = True
    end
    object DataPeopleID_LOCATION: TIntegerField
      FieldName = 'ID_LOCATION'
      Required = True
    end
    object DataPeopleKEY_CONTACT: TIBStringField
      FieldName = 'KEY_CONTACT'
      Required = True
      Size = 1
    end
    object DataPeopleNAME: TIBStringField
      FieldName = 'NAME'
      Required = True
      Size = 50
    end
    object DataPeopleEMAIL: TIBStringField
      FieldName = 'EMAIL'
      Size = 50
    end
    object DataPeopleFAX: TIBStringField
      FieldName = 'FAX'
      Size = 15
    end
    object DataPeoplePHONE: TIBStringField
      FieldName = 'PHONE'
      Size = 15
    end
  end
  object dsCompanies: TDataSource
    DataSet = DataCompanies
    Left = 120
    Top = 40
  end
  object IBTransaction1: TIBTransaction
    Active = False
    DefaultDatabase = DmMain.IBDatabase1
    Params.Strings = (
      'read_committed'
      'rec_version'
      'nowait')
    AutoStopAction = saNone
    Left = 120
    Top = 104
  end
end
ClassesForm.dfm
object FormClasses: TFormClasses
  Left = 200
  Top = 141
  Width = 658
  Height = 458
  Caption = 'Corsi'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 161
    Width = 650
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object Splitter3: TSplitter
    Left = 0
    Top = 273
    Width = 650
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object Tab: TTabControl
    Left = 0
    Top = 0
    Width = 650
    Height = 161
    Align = alTop
    TabOrder = 0
    Tabs.Strings = (
      'Open'
      'Closed'
      'Past')
    TabIndex = 0
    OnChange = TabChange
    object DBGridClasses: TDBGrid
      Left = 4
      Top = 24
      Width = 642
      Height = 133
      Align = alClient
      DataSource = dsClasses
      TabOrder = 0
      TitleFont.Charset = DEFAULT_CHARSET
      TitleFont.Color = clWindowText
      TitleFont.Height = -11
      TitleFont.Name = 'MS Sans Serif'
      TitleFont.Style = []
      Columns = <
        item
          Expanded = False
          FieldName = 'ID'
          ReadOnly = True
          Visible = True
        end
        item
          Expanded = False
          FieldName = 'DESCRIPTION'
          Visible = True
        end
        item
          Expanded = False
          FieldName = 'STARTS_ON'
          Visible = True
        end>
    end
  end
  object DBGridPeopleReg: TDBGrid
    Left = 0
    Top = 276
    Width = 650
    Height = 155
    Align = alClient
    DataSource = dsPeopleReg
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    OnEditButtonClick = DBGridPeopleRegEditButtonClick
    Columns = <
      item
        Expanded = False
        FieldName = 'ID'
        ReadOnly = True
        Visible = True
      end
      item
        ButtonStyle = cbsEllipsis
        Expanded = False
        FieldName = 'NAME'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'AMOUNT'
        Visible = True
      end>
  end
  object Panel1: TPanel
    Left = 0
    Top = 164
    Width = 650
    Height = 109
    Align = alTop
    TabOrder = 2
    object Splitter2: TSplitter
      Left = 305
      Top = 1
      Width = 3
      Height = 107
      Cursor = crHSplit
    end
    object DBGridClassReg: TDBGrid
      Left = 1
      Top = 1
      Width = 304
      Height = 107
      Align = alLeft
      DataSource = dsClassReg
      TabOrder = 0
      TitleFont.Charset = DEFAULT_CHARSET
      TitleFont.Color = clWindowText
      TitleFont.Height = -11
      TitleFont.Name = 'MS Sans Serif'
      TitleFont.Style = []
      OnEditButtonClick = DBGridClassRegEditButtonClick
      Columns = <
        item
          Expanded = False
          FieldName = 'ID'
          ReadOnly = True
          Visible = True
        end
        item
          ButtonStyle = cbsEllipsis
          Expanded = False
          FieldName = 'NAME'
          Width = 164
          Visible = True
        end>
    end
    object MemoNote: TDBMemo
      Left = 308
      Top = 1
      Width = 341
      Height = 107
      Align = alClient
      DataField = 'NOTES'
      DataSource = dsClassReg
      TabOrder = 1
    end
  end
  object dsClassReg: TDataSource
    Left = 80
    Top = 208
  end
  object dsClasses: TDataSource
    Left = 48
    Top = 56
  end
  object dsPeopleReg: TDataSource
    Left = 80
    Top = 320
  end
end
ClassesData.dfm
object DmClasses: TDmClasses
  OldCreateOrder = False
  Left = 336
  Top = 148
  Height = 404
  Width = 598
  object IBTransaction1: TIBTransaction
    Active = False
    DefaultDatabase = DmMain.IBDatabase1
    Params.Strings = (
      'read_committed'
      'rec_version'
      'nowait')
    Left = 272
    Top = 32
  end
  object IBClassReg: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    AfterInsert = IBClassRegAfterInsert
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from CLASSES_REG'
      'where'
      '  ID = :OLD_ID')
    InsertSQL.Strings = (
      'insert into CLASSES_REG'
      '  (ID, ID_CLASS, ID_COMPANY, NOTES)'
      'values'
      '  (:ID, :ID_CLASS, :ID_COMPANY, :NOTES)')
    RefreshSQL.Strings = (
      'select reg.ID, reg.ID_CLASS, reg.ID_COMPANY, reg.NOTES, c.Name '
      'from CLASSES_REG reg'
      'join COMPANIES c on reg.ID_COMPANY = c.id'
      'where id = :id')
    SelectSQL.Strings = (
      'select reg.ID, reg.ID_CLASS, reg.ID_COMPANY, reg.NOTES, c.Name '
      'from CLASSES_REG reg'
      'join COMPANIES c on reg.ID_COMPANY = c.id'
      'where id_class = :id')
    ModifySQL.Strings = (
      'update CLASSES_REG'
      'set'
      '  ID = :ID,'
      '  ID_CLASS = :ID_CLASS,'
      '  ID_COMPANY = :ID_COMPANY,'
      '  NOTES = :NOTES'
      'where'
      '  ID = :OLD_ID')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    DataSource = dsClasses
    Left = 32
    Top = 88
  end
  object dsClasses: TDataSource
    DataSet = IBClasses
    Left = 80
    Top = 32
  end
  object IBClasses: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from CLASSES'
      'where'
      '  ID = :OLD_ID and'
      '  STARTS_ON = :OLD_STARTS_ON')
    InsertSQL.Strings = (
      'insert into CLASSES'
      '  (ID, DESCRIPTION, STARTS_ON)'
      'values'
      '  (:ID, :DESCRIPTION, :STARTS_ON)')
    RefreshSQL.Strings = (
      'Select '
      '  ID,'
      '  DESCRIPTION,'
      '  STARTS_ON'
      'from CLASSES '
      'where'
      '  ID = :ID and'
      '  STARTS_ON = :STARTS_ON')
    SelectSQL.Strings = (
      'select ID, DESCRIPTION, STARTS_ON from CLASSES'
      'where STARTS_ON > ''NOW'''    )
    ModifySQL.Strings = (
      'update CLASSES'
      'set'
      '  ID = :ID,'
      '  DESCRIPTION = :DESCRIPTION,'
      '  STARTS_ON = :STARTS_ON'
      'where'
      '  ID = :OLD_ID and'
      '  STARTS_ON = :OLD_STARTS_ON')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    Left = 32
    Top = 32
  end
  object IBPeopleReg: TIBDataSet
    Database = DmMain.IBDatabase1
    Transaction = IBTransaction1
    AfterInsert = IBPeopleRegAfterInsert
    BufferChunks = 1000
    CachedUpdates = False
    DeleteSQL.Strings = (
      'delete from PEOPLE_REG'
      'where'
      '  ID = :OLD_ID')
    InsertSQL.Strings = (
      'insert into PEOPLE_REG'
      '  (ID, ID_CLASSES_REG, ID_PERSON, AMOUNT)'
      'values'
      '  (:ID, :ID_CLASSES_REG, :ID_PERSON, :AMOUNT)')
    RefreshSQL.Strings = (

              'select preg.ID, preg.ID_CLASSES_REG, preg.ID_PERSON,   preg.AMOU' +
        'NT, p.Name '
      'from PEOPLE_REG preg'
      'join People p on p.id = preg.id_person'
      'where ID = :ID')
    SelectSQL.Strings = (

              'select preg.ID, preg.ID_CLASSES_REG, preg.ID_PERSON,   preg.AMOU' +
        'NT, p.Name '
      'from PEOPLE_REG preg'
      'join People p on p.id = preg.id_person'
      'where preg.id_classes_reg = :id')
    ModifySQL.Strings = (
      'update PEOPLE_REG'
      'set'
      '  ID = :ID,'
      '  ID_CLASSES_REG = :ID_CLASSES_REG,'
      '  ID_PERSON = :ID_PERSON,'
      '  AMOUNT = :AMOUNT'
      'where'
      '  ID = :OLD_ID')
    GeneratorField.Field = 'ID'
    GeneratorField.Generator = 'G_MASTER'
    DataSource = dsReg
    Left = 32
    Top = 144
  end
  object dsReg: TDataSource
    DataSet = IBClassReg
    Left = 80
    Top = 88
  end
end