# Линейный связанный список. Создание базы данных для отдела кадров, страница 3

GotoXY(4, 7);

GotoXY(4, 8);

GotoXY(4, 9);

GotoXY(4, 10);

end;

Inc(n);

GotoXY(4, 12);

Write('Ввод успешно завершен. Вводить еще? [Enter/Escape]: ');

repeat

until Ord(Key) in [13, 27];

if Ord(Key)=27 then Quit:=True;

end;

end;

procedure OutputData(n: Integer; var BGTU: Link); {III пункт меню}

var Start, Finish, zicl: Integer;

Quit: Boolean;

Ch: Char;

procedure PrintPart(Start, Finish: Word; Buff: Link);

var zicl, zicl2: Word;

begin

GotoXY(4,3);

for zicl:=Start to Finish do

begin

Write('[');

if zicl<100 then Write('0');

if zicl<10 then Write('0');

Write(zicl,']');

With Buff^ do

begin

GotoXY(10,WhereY); Write(Name);

for zicl2:=1 to 20-Length(Name) do Write(' ');

GotoXY(35, WhereY); Write(Facultet);

GotoXY(36, WhereY); Write(Group);

for zicl2:=1 to 3-Length(Group) do Write(' ');

GotoXY(44, WhereY); Write(Phone);

for zicl2:=1 to 20-Length(Phone) do Write(' ');

GotoXY(4, WhereY+1);

end;

Buff:=Buff^.Next;

end;

GotoXY(1, 25);

end;

begin {OutputData}

ClrScr;

GotoXY(23, 1);

Write('Вывод сведений о всех сотрудниках');

PrintMainFraime(2, 2, 78, 23);

if n=0 then

begin

GotoXY(4, 4);

Write('База данных пуста...');

PressKey;

end

else

begin

Buff:=BGTU;

Quit:=False;

Start:=1;

if n>20 then Finish:=20 else Finish:=n;

PrintPart(Start, Finish, Buff);

repeat

case Ord(Ch) of

27: Quit:=True;

72: if Start>1 then

begin

Buff:=Buff^.Pred;

Dec(Start); Dec(Finish);

PrintPart(Start, Finish, Buff);

end;

80: if Finish<n then

begin

Buff:=Buff^.Next;

Inc(Start); Inc(Finish);

PrintPart(Start, Finish, Buff);

end;

81: if Finish<n then

begin

if Finish+20>=n then

begin

Finish:=n;

while Start<=n-20 do

begin

Inc(Start);

Buff:=Buff^.Next;

end;

end

else

begin

Inc(Start, 20);

Inc(Finish, 20);

for zicl:=1 to 20 do Buff:=Buff^.Next;

end;

PrintPart(Start, Finish, Buff);

end;

73: if Start>1 then

begin

if Start-20>=1 then

begin

Dec(Start, 20);

Dec(Finish, 20);

for zicl:=1 to 20 do Buff:=Buff^.Pred;

end

else

begin

Start:=1;

if n<=20 then Finish:=n else Finish:=20;

Buff:=BGTU;

end;

PrintPart(Start, Finish, Buff);

end;

71: if Start>1 then

begin

Start:=1;

if n>20 then Finish:=20 else Finish:=n;

Buff:=BGTU;

PrintPart(Start, Finish, Buff);

end;

79: if Finish<n then

begin

Finish:=n;

while Start<=n-20 do

begin

Buff:=Buff^.Next;

Inc(Start);

end;

PrintPart(Start, Finish, Buff);

end;

end;

until Quit;

end;

end;

procedure FindData(n: Integer; BGTU: Link); {IV Пункт меню}

Quit, QuitAll: Boolean;

Ch: Char;

zicl: Integer;

begin

Clear(18, 14, 70, 19);

with Temp^ do

begin

GotoXY(4, 13); Write('Фамилия:      ',Name);

GotoXY(4, 14); Write('Год рождения: ',BirthYear);

GotoXY(4, 16); Write('Телефон:      ',Phone);

GotoXY(4, 17); Write('Факультет:    ',Facultet);

GotoXY(4, 18); Write('Группа:       ',Group);

end;

end;

begin {FindData}

ClrScr;

GotoXY(38, 1);

Write('Поиск');

PrintMainFraime(2, 2, 78, 22);

GotoXY(4,4);

if n=0 then

begin

Write('База данных пуста...');

PressKey;

end

else

begin

New(Search);

with Search^ do

begin

GotoXY(4, 5); Write('Год Рождения: '); BirthYear:=SafeRead(4, 0, 1);

GotoXY(4, 7); Write('Телефон:      '); Phone:=SafeRead(20, 0, 0);

GotoXY(4, 8); Write('Факультет:    '); Facultet:=SafeRead(10, 0, 0);

GotoXY(4, 9); Write('Группа:       '); Group:=SafeRead(5, 0, 0);

end;

GotoXY(4, 11); Write('Результаты поиска:');

GotoXY(4, 20); Write('Чтобы выйти из Поиска, нажмите Esc');

GotoXY(4, 21); Write('Чтобы продолжить Поиск, нажмите Enter');

Temp:=BGTU;

QuitAll:=False;

while (Temp<>Nil) and not QuitAll do

begin

SpSearch(Temp, Search);

if Temp<>Nil then

begin

PrintAllData(Temp);

Quit:=False;

repeat

case Ord(ch) of

27: begin Quit:=True; QuitAll:=True; end;

13: begin Quit:=True; if Temp<>Nil then Temp:=Temp^.Next; end;

end;

until Quit;

end;

end;

Dispose(Search);

end;

if not QuitAll then PressKey;

end;

procedure ChangeData(n: Integer; var BGTU: Link); {V пункт меню}