unit Main;

interface

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

type
  TForm1 = class(TForm)

    AddPerson: TButton;
    TheFamily: TStringGrid;
     { TheFamily: TStringGrid;}
    procedure FormCreate(Sender: TObject);
    procedure AddPersonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses Person;   { korzystamy z moduu Person }

{$R *.DFM}

procedure TForm1.AddPersonClick(Sender: TObject);
var
 Name, BirthDate, Spouse, Mother, Father: String;
 TmpRowCount: Integer;
begin
 try
  GetPersonInfo(Name, BirthDate, Spouse, Mother, Father);
  if Length(Name) > 0 then
  begin
    TmpRowCount := TheFamily.RowCount  - 2;
   TheFamily.Cells[0, TmpRowCount] := Name;
   TheFamily.Cells[1, TmpRowCount] := BirthDate;
   TheFamily.Cells[2, TmpRowCount] := Spouse;
   TheFamily.Cells[3, TmpRowCount] := Mother;
   TheFamily.Cells[4, TmpRowCount] := Father;
  end;
 except
  On ENoMotherSpecified do
   MessageDlg('Brak danych dotyczcych matki', mtError, [mbOK], 0);
  On EInvalidDOB do
   MessageDlg('Bdnie wprowadzona data urodzenia', mtError, [mbOK], 0);
 end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 TheFamily.Cells[0,0] := 'Name';
 TheFamily.Cells[1,0] := 'BirthDate';
 TheFamily.Cells[2,0] := 'Spouse';
 TheFamily.Cells[3,0] := 'Mother';
 TheFamily.Cells[4,0] := 'Father';
end;

end.