uses crt,dos; const bmax=5; type color = 1..10; str10 = string[10]; str15 = string[15]; str20 = string[20]; str25 = string[25]; studentrec = record name : str25;{student name} code : str10;{student code} isbn : str20;{student isbn} lenddate : str10;{date of lend student} end; strec = record fname:str15;{student first name} lname : str20;{student last name} id : str20;{student id} field : str20;{student field} regdata : str10;{student registration date} student : array[1..bmax] of studentrec;{maximum student can be lended = 5} boksnum : integer;{number of student that student lended} end;{type} {define variables} var stinfo : strec; db,bcupdb : file of strec;{define database and backup from database} regs:registers; i:byte; j,key:integer; function chekdb:boolean; begin assign(db,'db.db'); {$I-} reset(db); {$I+} if IOResult = 0 then chekdb:=true else chekdb:=false; close(db); end; { ------------------------------------------} procedure registration; var yn:char;stchek:strec;sfind:boolean;c:char; begin textcolor(2); gotoxy(26,28);writeln(' Please enter student information '); with stinfo do{Input student information} begin sfind:=false; gotoxy(30,30); writeln('FirstName : '); gotoxy(41,30);readln(fname); gotoxy(30,32); writeln('LastName : '); gotoxy(40,32);readln(lname); gotoxy(30,34);writeln('ID : '); gotoxy(36,34); readln(ID); assign(db,'db.db'); {$I-} reset(db); {$I+} if IOResult = 0 then begin (****************) while not eof(db) do begin read(db,stchek); if stchek.id=id then begin sfind:=true; break; end;{if} end;{while} clrscr; gotoxy(10,7); (****************) if not sfind then begin seek(db,filesize(db)); write(db,stinfo); close(db); end{if not sfind} end;{if ioresult=0} textcolor(5); gotoxy(30,31); writeln('Registration complete!');delay(1000);clrscr; end;{with} gotoxy(10,7); end; {***********************} procedure displayall; var i,e:byte;page:integer;c:char; begin i:=0;e:=0;clrscr; if chekdb then begin textcolor(13); gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); reset(db); while not eof(db) do begin i:=i+1; e:=e+1; read(db,stinfo); with stinfo do begin gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); if i=45 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if} if i=90 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' studen ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if}if i=135 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if}if i=180 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if}if i=225 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if}if i=270 then begin c:=readkey; c:=readkey;clrscr;i:=0; gotoxy(1,1);write(' student ID FirstName LastName '); gotoxy(1,2);write('----------------------------------------------------------'); gotoxy(1,3+i); writeln(id:15,fname:18,lname:18,'':3,e:5); end;{if,if} end;{with} {if}end; end;{while} close(db); c:=readkey;clrscr; gotoxy(28,10); end; {-----------------------------------------------------} {#################SEARCH student INFORMATION by id#############} procedure viewstinfoid; var find:boolean; stid:str20; i:color;c:char; copfield:str15; begin clrscr; find:=false; if chekdb then begin gotoxy(30,1);write('Please enter student id:'); gotoxy(54,1);readln(stid); if stid='' then begin clrscr;exit; end; reset(db); while not eof(db) do begin read(db,stinfo); with stinfo do begin if id=stid then begin find:=true; gotoxy(30,2);writeln(' student Information '); gotoxy(30,3);writeln('__________________________________'); gotoxy(30,4);writeln('First name:');gotoxy(43,4);writeln(fname); gotoxy(30,5);write('Last name:');gotoxy(43,5); writeln(lname); gotoxy(30,6);writeln('student id : '); gotoxy(43,6);writeln(stid); end;{if} end;{with} end;{while}c:=readkey; clrscr; if not find then begin writeln('student not found!'); delay(2000); clrscr; end; close(db); end else begin writeln(9,'Database not found!');delay(1000); end; clrscr; end; {------------- Main ---------------------} begin clrscr; while true do begin clrscr; textcolor(13); gotoxy(25,8);writeln('student registration programming by "Safa" '); gotoxy(30,10);writeln('1)student registration '); gotoxy(30,12);writeln('2)Display all IDs '); gotoxy(30,14);writeln('3)Search '); gotoxy(30,16);writeln('4)Quit the program '); readln(key); case key of 1:registration; 2:displayall; 3:viewstinfoid; 4:halt; end; end; end.