Você está na página 1de 7

Program Registro ;

type
tbaluno=record
matricula:integer;
nome:string[30];
curso:string[15];
turno:string[15];
end;
procedure menu;
begin
textcolor(red);
textbackground(white);
clrscr;
gotoxy(15,10);write('==============================');
gotoxy(15,11);write('|
|');
gotoxy(15,12);write('|
Menu Principal
|');
gotoxy(15,13);write('|
|');
gotoxy(15,14);write('| 1 - Cadastrar
|');
gotoxy(15,15);write('| 2 - Consultar
|');
gotoxy(15,16);write('| 3 - Alterar
|');
gotoxy(15,17);write('| 4 - Excluir
|');
gotoxy(15,18);write('| 5 - Imprimir
|');
gotoxy(15,19);write('| 6 - Finalizar
|');
gotoxy(15,20);write('|
|');
gotoxy(15,21);write('| Escolha a opcao: ____
|');
gotoxy(15,22);write('==============================');
end;
procedure menucadastro;
begin
textcolor(red);
textbackground(white);
clrscr;
gotoxy(15,10);write('==============================');
gotoxy(15,11);write('|
|');
gotoxy(15,12);write('|
Menu Cadastro
|');
gotoxy(15,13);write('|
|');
gotoxy(15,14);write('| Matricula: ___________ |');
gotoxy(15,15);write('| Nome: ________________ |');
gotoxy(15,16);write('| Curso: _______________ |');
gotoxy(15,17);write('| Turno: _______________ |');
gotoxy(15,18);write('|
|');
gotoxy(15,19);write('==============================');
end;
procedure menuconsulta;
begin
textcolor(red);
textbackground(white);
clrscr;
gotoxy(15,10);write('==============================');
gotoxy(15,11);write('|
|');
gotoxy(15,12);write('|
Menu Consulta
|');
gotoxy(15,13);write('|
|');
gotoxy(15,14);write('| Matricula: ___________ |');
gotoxy(15,15);write('| Nome: ________________ |');
gotoxy(15,16);write('| Curso: _______________ |');
gotoxy(15,17);write('| Turno: _______________ |');
gotoxy(15,18);write('|
|');

gotoxy(15,19);write('==============================');
end;
procedure menualterar;
begin
textcolor(red);
textbackground(white);
clrscr;
gotoxy(15,10);write('==============================');
gotoxy(15,11);write('|
|');
gotoxy(15,12);write('|
Menu alterar
|');
gotoxy(15,13);write('|
|');
gotoxy(15,14);write('| Matricula: ___________ |');
gotoxy(15,15);write('| Nome: ________________ |');
gotoxy(15,16);write('| Curso: _______________ |');
gotoxy(15,17);write('| Turno: _______________ |');
gotoxy(15,18);write('|
|');
gotoxy(15,19);write('==============================');
end;
var
tb_aluno:array[1..8] of tbaluno;
aluno:tbaluno;
op,opb,id,idb,mat,x:integer;
p:boolean;
r,nom:string;
Begin
id:=0;
repeat
menu;
gotoxy(35,21);read(op);
clrscr;
case op of
1:begin
p:=false;
while(id<8)and(p=false)do
begin
inc(id);
menucadastro;
gotoxy(30,14);read(aluno.matricu
la);
gotoxy(25,15);read(aluno.nome);
gotoxy(26,16);read(aluno.curso);
gotoxy(26,17);read(aluno.turno);
tb_aluno[id]:=aluno;
gotoxy(17,18);write('Deseja cont
inuar S/N: __');
gotoxy(39,18);read(r);
if upcase(r)='N' then p:=true;
end;
if (id=8)and(p=false) then
begin
clrscr;
gotoxy(15,16);write('Tabela chei
a!');
readkey;
end;
end;
2:begin
p:=false;

idb:=0;
opb:=0;
repeat
clrscr;
write('Deseja consultar pela Matricula(1
) ou pelo Nome(2)?');
read(opb);
if opb=1 then
begin
write('Digite a Matricul
a: ');
read(mat);
end
else if opb=2 then
begin
write('Digite o Nome: ')
;
read(nom);
end;
until (opb>0)and(opb<3);
while (idb<8)and(p=false) do
begin
inc(idb);
if opb=1 then
if tb_aluno[idb].matricu
la=mat then
begin
p:=true;
menucons
ulta;
gotoxy(3
0,14);write(tb_aluno[idb].matricula);
gotoxy(2
5,15);write(tb_aluno[idb].nome);
gotoxy(2
6,16);write(tb_aluno[idb].curso);
gotoxy(2
6,17);write(tb_aluno[idb].turno);
end
else
if tb_aluno[idb].nome=no
m then
begin
p:=true;
menucons
ulta;
gotoxy(3
0,14);write(tb_aluno[idb].matricula);
gotoxy(2
5,15);write(tb_aluno[idb].nome);
gotoxy(2
6,16);write(tb_aluno[idb].curso);
gotoxy(2
6,17);write(tb_aluno[idb].turno);
end;
end;
if (idb=8)and(p=false) then
begin

clrscr;
gotoxy(15,15);write('Registro no
encontrado!');
end;
readkey;
end;
3:begin
p:=false;
idb:=0;
opb:=0;
repeat
clrscr;
write('Deseja alterar pela Matricula(1)
ou pelo Nome(2)?');
read(opb);
if opb=1 then
begin
write('Digite a Matricul
a: ');
read(mat);
end
else if opb=2 then
begin
write('Digite o Nome: ')
;
read(nom);
end;
until (opb>0)and(opb<3);
while (idb<8)and(p=false) do
begin
inc(idb);
if opb=1 then
if tb_aluno[idb].matricu
la=mat then
begin
p:=true;
menualte
rar;
gotoxy(3
0,14);read(tb_aluno[idb].matricula);
gotoxy(2
5,15);read(tb_aluno[idb].nome);
gotoxy(2
6,16);read(tb_aluno[idb].curso);
gotoxy(2
6,17);read(tb_aluno[idb].turno);
tb_aluno
[x]:=aluno;
end
else
if tb_aluno[idb].nome=no
m then
begin
p:=true;
menualte
rar;
gotoxy(3
0,14);read(tb_aluno[idb].matricula);

gotoxy(2
5,15);read(tb_aluno[idb].nome);
gotoxy(2
6,16);read(tb_aluno[idb].curso);
gotoxy(2
6,17);read(tb_aluno[idb].turno);
tb_aluno
[x]:=aluno;
end;
end;
clrscr;
if (idb=8)and(p=false) then
begin
gotoxy(15,15);write('Opo invlida!')
;
end
else
begin
gotoxy(15,15);write('Registro alter
ado com sucesso!');
end;
readkey;
end;
4:begin
p:=false;
idb:=0;
opb:=0;
repeat
clrscr;
write('Deseja excluir pela Matricula(1)
ou pelo Nome(2)?');
read(opb);
if opb=1 then
begin
write('Digite a Matricul
a: ');
read(mat);
end
else if opb=2 then
begin
write('Digite o Nome: ')
;
read(nom);
end;
until (opb>0)and(opb<3);
while (idb<8)and(p=false) do
begin
inc(idb);
if opb=1 then
if tb_aluno[idb].matricu
la=mat then
begin
p:=true;
menucons
ulta;
gotoxy(3
0,14);write(tb_aluno[idb].matricula);
gotoxy(2

5,15);write(tb_aluno[idb].nome);
gotoxy(2
6,16);write(tb_aluno[idb].curso);
gotoxy(2
6,17);write(tb_aluno[idb].turno);
end
else
if tb_aluno[idb].nome=no
m then
begin
p:=true;
menucons
ulta;
gotoxy(3
0,14);write(tb_aluno[idb].matricula);
gotoxy(2
5,15);write(tb_aluno[idb].nome);
gotoxy(2
6,16);write(tb_aluno[idb].curso);
gotoxy(2
6,17);write(tb_aluno[idb].turno);
end;
end;
clrscr;
if (idb=8)and(p=false) then
begin
gotoxy(15,15);write('Registro no
encontrado!');
end
else
begin
tb_aluno[idb].matricula:=0;
tb_aluno[idb].nome:='';
tb_aluno[idb].curso:='';
tb_aluno[idb].turno:='';
gotoxy(15,15);write('Registro exclu
ido com sucesso!');
end;
readkey;
end;
5:begin
if id<>0 then
begin
textcolor(red);
textbackground(white);
clrscr;
writeln('===============
=================');
writeln('|
|');
writeln('|
o

Relatri

|');
writeln('|
|');
for x:=1 to id do
begin
writeln('Matricu

la: ',tb_aluno[x].matricula);
writeln('Nome: '

,tb_aluno[x].nome);
writeln('Curso:
',tb_aluno[x].curso);
writeln('Turno:
',tb_aluno[x].turno);
writeln;
end;
end
else
begin
gotoxy(15,16);write('Efetue cada
stro primeiro');
end;
readkey;
end;
end;
until op=6;
clrscr;
gotoxy(15,16);write('Sistema finalizado com sucesso!');
End.

Você também pode gostar