(Peoples.Items[LPeoples[i].Father] as TPeople).AddChildren(Peoples.Items[i] as TPeople);
if LPeoples[i].Mother > -1 then
(Peoples.Items[LPeoples[i].Mother] as TPeople).AddChildren(Peoples.Items[i] as TPeople);
end;
for i:= 0 to RManager.CountMarriage - 1 do
begin
BlockRead(F, RSLMarriage, sizeof(RSLMarriage));
with RSLMarriage do
begin
RMarriage.Family:= Family;
RMarriage.Husband:= Peoples.Items[Husband] as TPeople;
RMarriage.Wife:= Peoples.Items[Wife] as TPeople;
RMarriage.DateOfStart:= DateOfStart;
RMarriage.DateOfEnd:= DateOfEnd;
RMarriage.Commentary:= Commentary;
AddMarriage(RMarriage);
end;
end;
CloseFile(F);
end;
procedure TManager.Process(Proc: TPPeople; RFilter: TRFilter; People: TPeople = nil);
var
j: Integer;
begin
for j := 0 to Peoples.Count - 1 do
if ((People = nil) or ((People <> nil) and (Peoples.Items[j] <> People))) and ValidateFilter(RFilter, Peoples.Items[j] as TPeople) then
Proc(Peoples.Items[j] as TPeople);
end;
procedure TManager.ProcessBrother(Proc: TPPeople; People: TPeople);
var
i: Integer;
ObjectList: TObjectList;
begin
//ObjectList:= TObjectList.Create(false);
ObjectList:= People.getBrothers;
for i:= 0 to ObjectList.Count - 1 do
Proc(ObjectList.Items[i] as TPeople);
end;
procedure TManager.ProcessChildren(Proc: TPPeople; People: TPeople);
var
i: Integer;
begin
for i := 0 to People.Childrens.Count - 1 do
Proc(People.Childrens.Items[i] as TPeople);
end;
procedure TManager.ProcessMarriage(Proc: TPMarriage; People: TPeople);
var
i: Integer;
Him: Boolean;
begin
for i := 0 to People.Marriages.Count - 1 do
begin
if People = (People.Marriages.Items[i] as TMarriage).Husband then
Him:= true
else
Him:= false;
Proc(People.Marriages.Items[i] as TMarriage, Him);
end;
end;
procedure TManager.ProcessNotChildren(Proc: TPPeople; People: TPeople);
var
i: Integer;
begin
for i := 0 to Peoples.Count - 1 do
begin
if (People <> Peoples.Items[i]) and
((People.Sex and ((Peoples.Items[i] as TPeople).Father = nil)) or (not People.Sex and ((Peoples.Items[i] as TPeople).Mother = nil))) and
not ValidateParent(People, Peoples.Items[i] as TPeople) and
not ValidateParent(Peoples.Items[i] as TPeople, People) then
Proc((Peoples.Items[i] as TPeople));
end;
end;
procedure TManager.ProcessParent(Proc: TPPeople; People: TPeople; Sex: Boolean = true);
var
i: Integer;
begin
for i := 0 to Peoples.Count - 1 do
if (People <> Peoples.Items[i]) and
((Sex and (Peoples.Items[i] as TPeople).Sex) or (not Sex and not (Peoples.Items[i] as TPeople).Sex)) and
not ValidateParent(People, Peoples.Items[i] as TPeople) and
not People.ValidateBrother(Peoples.Items[i] as TPeople) then
Proc(Peoples.Items[i] as TPeople);
end;
procedure TManager.ProcessSelectMarriage(Proc: TPPeople; People: TPeople);
var
i: Integer;
begin
for i := 0 to Peoples.Count - 1 do
if (People <> Peoples.Items[i]) and
not ValidateParent(People, Peoples.Items[i] as TPeople) and
not ValidateParent(Peoples.Items[i] as TPeople, People) and
not People.ValidateBrother(Peoples.Items[i] as TPeople) then
Proc((Peoples.Items[i] as TPeople));
end;
function TManager.ValidateFilter(RFilter: TRFilter; People: TPeople): Boolean;
var
bool: Boolean;
begin
Result:= false;
with RFilter do
if Sort then
begin
if (Family <> '') and (Family <> People.Family) then Exit;
if (Name <> '') and (Name <> People.Name) then Exit;
if (Patronymic <> '') and (Patronymic <> People.Patronymic) then Exit;
if ((Children = 0) and (People.Childrens.Count = 0)) or ((Children = 1) and (People.Childrens.Count > 0)) then Exit;
if ((Marriage = 0) and (People.Marriages.Count = 0)) or ((Marriage = 1) and (People.Marriages.Count > 0)) then Exit;
if ((Sex = 0) and not People.Sex) or ((Sex = 1) and People.Sex) then Exit;
if ((Parent = 0) and (People.Father = nil) and (People.Mother = nil)) or ((Parent = 1) and ((People.Father <> nil) or (People.Mother <> nil))) then Exit;
if (Brother <> 2) then
begin
if (((People.Father <> nil) and (People.Father.Childrens.Count > 1)) or
((People.Mother <> nil) and (People.Mother.Childrens.Count > 1))) then
bool:= true
else
bool:= false;
if ((Brother = 0) and not bool) or ((Brother = 1) and bool) then Exit;
end;
end;
Result:= True;
end;
function TManager.ValidateParent(People, Children: TPeople): Boolean;
var
i: Integer;
begin
for i:= 0 to People.Childrens.Count - 1 do
begin
if People.Childrens.Items[i] = Children then
begin
Result:= true;
Exit;
end
else
begin
Result:= ValidateParent(People.Childrens.Items[i] as TPeople, Children);
if Result then
Exit;
end;
end;
Result:= false;
end;
{ TMarriage }
constructor TMarriage.Create;
begin
inherited Create();
Family:= RMarriage.Family;
Husband:= RMarriage.Husband;
Wife:= RMarriage.Wife;
DateOfStart:= RMarriage.DateOfStart;
DateOfEnd:= RMarriage.DateOfEnd;
Commentary:= RMarriage.Commentary;
//Записываем в список браков мужа и жены, ссылку на брак
Husband.Marriages.Add(self);
Wife.Marriages.Add(self);
end;
destructor TMarriage.Destroy;
begin
if Husband <> nil then
Husband.Marriages.Extract(self);
if Wife <> nil then
Wife.Marriages.Extract(self);
inherited Destroy;
end;
end.
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.