unit Person;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Mask, StdCtrls, ExtCtrls, Buttons;

type
 ENoMotherSpecified = class(Exception);
 EInvalidDOB = class(Exception);

{type}
  TPersonForm = class(TForm)
    pName: TEdit;
    pFather: Tedit;
    pMother: TEdit;
    pSpouse: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    pDOB: TMaskEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure GetPersonInfo(var Name, BirthDate, Spouse, Mother, Father: String);

var
  PersonForm: TPersonForm;

implementation

{$R *.DFM}

procedure GetPersonInfo(var Name, BirthDate, Spouse, Mother, Father: String);
var
 ReturnCode: Integer;
begin

 { wywoujemy okienko dialogowe PersonForm}
 ReturnCode := PersonForm.ShowModal;

 { sprawdzamy, w jaki sposb je zamknlimy }
 if ReturnCode = mrCancel then
 begin
  Name := '';   { jeli Cancel, zerujemy zmienna Name }
  Exit;
 end;

 { pobieramy z dialogu wprowadzone dane }
 Name := PersonForm.pName.Text;
 BirthDate := PersonForm.pDOB.Text;
 Spouse := PersonForm.pSpouse.Text;
 Mother := PersonForm.pMother.Text;
 Father := PersonForm.pFather.Text;

 if Length(Mother) = 0 then
  Raise ENoMotherSpecified.Create('Nie podae imienia matki');

 try
  StrToDate(BirthDate);
 except
  on EConvertError do
   Raise EInvalidDOB.Create('le wprowadzona data');
 end;

end;

end.