Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program libray; // copyright by Wojciech Glapiak
- uses crt,dos;
- type
- uzytkownik = record
- imie,nazwisko,haslo,id,data,admin,autoryzacja:string;
- end;
- baza_danych = file of uzytkownik;
- ksiazka = record
- imie,nazwisko,tytul,sygnatura,id_user,data_wyp,opis:string;
- max_wyp:integer;
- kara:real;
- end;
- ksiegozbior = file of ksiazka;
- var
- licznik_id:text;
- licznik_syg:text;
- baza:baza_danych;
- ksiazki:ksiegozbior;
- temp:ksiegozbior;
- book:ksiazka;
- user:uzytkownik;
- c,c1,c2:char;
- tablica:array[1..1000] of string;
- y:byte;
- procedure files;
- begin
- assign(licznik_id,'id.db');
- assign(baza,'baza_danych.db');
- assign(ksiazki,'ksiegozbior.db');
- assign(licznik_syg,'sygnatury.db');
- assign(temp,'temp.db');
- end;
- function czas:string;
- var
- godz,min,sek,sek100:word;
- sgodz,smin,ssek,time:string;
- begin
- gettime(godz,min,sek,sek100);
- str(godz,sgodz);
- if length(sgodz)=1 then sgodz:='0'+sgodz;
- str(min,smin);
- if length(smin)=1 then smin:='0'+smin;
- str(sek,ssek);
- if length(ssek)=1 then ssek:='0'+ssek;
- time:=' '+sgodz+':'+smin+':'+ssek;
- czas:=time;
- end;
- function data:string;
- const
- dni:array[0..6] of string=('Niedziela','Poniedzialek','Wtorek','Sroda','Czwartek','Piatek','Sobota');
- var
- rok, miesiac, dzien, dztyg:word;
- sdzien,smiesiac,srok,date:string;
- begin
- getdate(rok, miesiac, dzien, dztyg);
- str(dzien,sdzien);
- if length(sdzien)=1 then sdzien:='0'+sdzien;
- str(miesiac,smiesiac);
- if length(smiesiac)=1 then smiesiac:='0'+smiesiac;
- str(rok,srok);
- date:=dni[dztyg]+' '+sdzien+'.'+smiesiac+'.'+srok;
- data:=date;
- end;
- procedure intro;
- begin
- clrscr;
- writeln(data);
- writeln('godzina',czas);
- writeln;
- writeln('Witam w programie Bibiloteka');
- writeln('Zaloguj się lub zarejestruj');
- gotoxy(59,1);
- writeln('Wcisnij ESC aby wyjsc');
- end;
- function identyfikator:string;
- var
- a,b,id:string;
- c,i,d,kod:integer;
- begin
- clrscr;
- {$I-}
- reset(licznik_id);
- if ioresult <>0 then
- begin
- rewrite(licznik_id);
- writeln(licznik_id,'1');
- end;
- {$I+}
- close(licznik_id);
- reset(licznik_id);
- readln(licznik_id,id);
- a:='cz';
- a:=a+id;
- c:=6-length(a);
- if (c>0) then
- begin
- for i:=1 to c do
- insert('0',a,length(a))
- end;
- val(id,d,kod);
- inc(d);
- str(d,id);
- rewrite(licznik_id);
- write(licznik_id,id);
- close(licznik_id);
- identyfikator:=a;
- end;
- function first_pass(dl:byte):string;
- var
- a:string;
- i:integer;
- begin
- randomize;
- a:='';
- for i:=1 to dl do
- begin
- a:=a+Chr(Ord('a')+Random(26));
- end;
- first_pass:=a;
- end;
- procedure rejestracja;
- begin
- clrscr;
- {$I-}
- reset(baza);
- if ioresult <>0 then
- begin
- rewrite(baza);
- end;
- close(baza);
- {$I+}
- reset(baza);
- while not eof(baza) do
- begin
- read(baza,user);
- end;
- user.id:=identyfikator;
- writeln('Podaj imie');
- readln(user.imie);
- writeln('Podaj Nazwisko');
- readln(user.nazwisko);
- clrscr;
- writeln('Witaj ',user.imie,'!');
- writeln('Twoje ID sluzace do logowania to: ',user.id);
- user.haslo:=first_pass(6);
- writeln('Twoje haslo tymczasowe to: ',user.haslo);
- user.data:=data;
- writeln;
- user.autoryzacja:='false';
- user.admin:='false';
- write(baza,user);
- writeln('Konto czeka na autoryzacje przez administratora');
- writeln;
- writeln('Gdy administrator autoryzuje Twoje konto bedziesz mogl m.in.:');
- writeln('- wypozyczyc ksiazke');
- writeln('- zarzadzac kontem');
- readln;
- end;
- function id_k:string;
- var
- a,b,syg:string;
- c,i,d,kod:integer;
- begin
- clrscr;
- {$I-}
- reset(licznik_syg);
- if ioresult <>0 then
- begin
- rewrite(licznik_syg);
- writeln(licznik_syg,'1');
- end;
- {$I+}
- close(licznik_syg);
- reset(licznik_syg);
- readln(licznik_syg,syg);
- a:='K';
- a:=a+syg;
- c:=4-length(a);
- if (c>0) then
- begin
- for i:=1 to c do
- insert('0',a,length(a)-1)
- end;
- val(syg,d,kod);
- inc(d);
- str(d,syg);
- rewrite(licznik_syg);
- write(licznik_syg,syg);
- close(licznik_syg);
- id_k:=a;
- end;
- procedure zakladanie;
- begin
- clrscr;
- {$I-}
- reset(ksiazki);
- if IOresult<>0 then
- rewrite(ksiazki);
- {$I+}
- close(ksiazki);
- reset(ksiazki);
- while not eof(ksiazki) do
- read(ksiazki,book);
- writeln('Podaj imie autora');
- readln(book.imie);
- writeln('Podaj nazwisko autora');
- readln(book.nazwisko);
- writeln('Podaj tytul ksiazki');
- readln(book.tytul);
- writeln('Podaj krotki opis ksiazki');
- readln(book.opis);
- book.sygnatura:=id_k;
- book.id_user:='';
- book.data_wyp:='';
- writeln('Na ile mozna wypozyczyc ',book.tytul,' ?');
- readln(book.max_wyp);
- write(ksiazki,book);
- clrscr;
- writeln('Dane nowo dodanej ksiazki:');
- writeln('Autor: ',book.imie,' ',book.nazwisko);
- writeln('Tytul: ',book.tytul);
- writeln('Sygnatura: ',book.sygnatura);
- writeln('Opis: ');
- writeln(book.opis);
- writeln('Maksymalna dlugosc wypozyczenia: ',book.max_wyp,'dni');
- readln;
- close(ksiazki);
- clrscr;
- writeln('Czy chcesz dodac nastepna ksiazke?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then zakladanie;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- procedure usuwanie_k;
- var
- counter,i:integer;
- begin
- clrscr;
- counter:=0;
- writeln('Wybierz ksiazke do usuniecia');
- {$I-}
- reset(ksiazki);
- if (IOresult <> 0) then
- writeln('Brak ksiegozbioru! Opreracja niemozliwa do wykonania')
- else
- begin
- while not eof(ksiazki) do
- begin
- read(ksiazki,book);
- inc(counter);
- tablica[counter]:=book.tytul;
- end;
- close(ksiazki);
- if tablica[1]='' then
- writeln('Brak ksiazek! Operacja niemozliwa do wykoniania')
- else
- begin
- while (y <> counter+1) do
- begin
- textcolor(15);
- for y:=1 to counter do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=counter;
- if y=(counter+1) then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if c1=chr(13) then
- begin
- reset(ksiazki);
- for i:=y to counter-1 do
- begin
- seek(ksiazki,i);
- read(ksiazki,book);
- seek(ksiazki,i-1);
- write(ksiazki,book);
- end;
- seek(ksiazki,counter-1);
- truncate(ksiazki);
- close(ksiazki);
- end;
- writeln('Usunieto!');
- readln;
- clrscr;
- writeln('Czy chcesz usunac nastepna ksiazke?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then usuwanie_k;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- end;
- end;
- {$I+}
- end;
- procedure usuwanie_cz;
- var
- counter,i:integer;
- begin
- clrscr;
- counter:=0;
- i:=0;
- writeln('Wybierz czytelnika do usuniecia');
- {$I-}
- reset(baza);
- if (IOresult <> 0) then
- writeln('Brak bazy danych! Opreracja niemozliwa do wykonania')
- else
- begin
- while not eof(baza) do
- begin
- read(baza,user);
- inc(counter);
- tablica[counter]:=user.id;
- end;
- close(baza);
- if tablica[1]='' then
- writeln('Baza danych pusta! Operacja niemozliwa do wykonania')
- else
- begin
- while (y <> counter+1) do
- begin
- textcolor(15);
- for y:=1 to counter do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=counter;
- if y=(counter+1) then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if c1=chr(13) then
- begin
- reset(baza);
- for i:=y to counter-1 do
- begin
- seek(baza,i);
- read(baza,user);
- seek(baza,i-1);
- write(baza,user);
- end;
- seek(baza,counter-1);
- truncate(baza);
- close(baza);
- end;
- writeln('Usunieto!');
- readln;
- clrscr;
- writeln('Czy chcesz usunac nastepnego uzytkownika?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then usuwanie_cz;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- end;
- end;
- {$I+}
- end;
- procedure autoryzacja;
- var
- counter,i,check:integer;
- begin
- clrscr;
- counter:=0;
- writeln('Wybierz czytelnika do autoryzacji');
- {$I-}
- reset(baza);
- if (IOresult <> 0) then
- writeln('Brak bazy danych! Opreracja niemozliwa do wykonania')
- else
- begin
- while not eof(baza) do
- begin
- read(baza,user);
- if user.autoryzacja='false' then
- begin
- inc(counter);
- tablica[counter]:=user.id;
- end;
- end;
- close(baza);
- if tablica[1]='' then
- writeln('Baza danych pusta! Operacja niemozliwa do wykoniania')
- else
- begin
- while (y <> counter+1) do
- begin
- textcolor(15);
- for y:=1 to counter do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=counter;
- if y=(counter+1) then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if c1=chr(13) then
- begin
- {$I-}
- reset(baza);
- if IOresult<>0 then
- writeln('Brak bazy danych, zmiana nie mozliwa')
- else
- begin
- repeat
- read(baza,user);
- if (user.id=tablica[y]) then
- begin
- inc(check);
- user.autoryzacja:='true';
- end;
- until (check<>0) or eof(baza);
- if check=0 then
- writeln('Blad')
- else
- begin
- clrscr;
- writeln('Autoryzowano!');
- end;
- end;
- write(baza,user);
- close(baza);
- {$I+}
- end;
- readln;
- clrscr;
- writeln('Czy chcesz autoryzowac konto nastepnego uzytkownika?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then autoryzacja;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- end;
- end;
- {$I+}
- end;
- procedure lista_cz;
- begin
- {$i-}
- clrscr;
- reset(baza);
- if IOresult<>0 then
- writeln('Barak pliku')
- else
- begin
- while not eof(baza) do
- begin
- read(baza,user);
- writeln(user.imie,' ',user.nazwisko,' ',user.id,' ',user.data,' ',user.autoryzacja);
- end;
- end;
- close(baza);
- {$I+}
- readln;
- end;
- procedure baza_cz;
- begin
- while y<>4 do
- begin
- clrscr;
- tablica[1]:=' Autoryzacja ';
- tablica[2]:=' Lista ';
- tablica[3]:=' Usuwanie ';
- textcolor(15);
- for y:=1 to 3 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=3;
- if y=4 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then autoryzacja;
- if y=2 then lista_cz;
- if y=3 then usuwanie_cz;
- end;
- end;
- procedure karanie;
- const
- dniowka=1.5;
- var
- dzien,dzien_ob,miesiac,miesiac_ob,rok,rok_ob,k,z,d,roznica_d,roznica_m,roznica_r:integer;
- x:string;
- begin
- while not eof(ksiazki) do
- begin
- d:=0;
- z:=0;
- x:='';
- d:=length(book.data_wyp);
- x:=book.data_wyp;
- z:=pos(' ',x);
- x:=copy(x,z+1,d);
- d:=length(x);
- z:=pos(' ',x);
- val(copy(x,1,z-1),dzien,k);;
- x:=copy(x,z+1,d);
- d:=length(x);
- z:=pos(' ',x);
- val(copy(x,1,z-1),miesiac,k);
- x:=copy(x,z+1,d);
- val(x,rok,k);
- d:=length(data);
- x:=data;
- z:=pos(' ',x);
- x:=copy(x,z+1,d);
- d:=length(x);
- z:=pos(' ',x);
- val(copy(x,1,z-1),dzien_ob,k);;
- x:=copy(x,z+1,d);
- d:=length(x);
- z:=pos(' ',x);
- val(copy(x,1,z-1),miesiac_ob,k);
- x:=copy(x,z+1,d);
- val(x,rok_ob,k);
- roznica_d:=(((rok_ob-rok)*12+miesiac_ob-miesiac)*30)+dzien_ob-dzien;
- if roznica_d >=365 then
- begin
- {$I-}
- reset(baza);
- if IOresult <> 0 then writeln('Brak uzytkownikow')
- else
- begin
- while not eof(baza) do
- begin
- read(baza,user);
- if user.id=book.id_user then
- user.autoryzacja:='false';
- writeln(user.id,' ma zablokowane konto z powodu trzymania ksiazki dluzej niz rok');
- end;
- end;
- close(baza);
- {$I+}
- end
- else
- begin
- {$I-}
- reset(baza);
- if IOresult <> 0 then writeln('Brak uzytkownikow')
- else
- begin
- while not eof(baza) do
- begin
- read(baza,user);
- if user.id=book.id_user then
- begin
- book.kara:=roznica_d*dniowka;
- writeln(user.id,' ','przetrzymuje ',book.tytul,' ',roznica_d,'dni');
- writeln('kara: ',book.kara);
- end;
- end;
- end;
- close(baza);
- {$I+}
- end;
- end;
- end;
- procedure stan;
- var
- counter,oddane:integer;
- begin
- clrscr;
- counter:=0;
- write('Ilosc czytelnikow: ');
- {$I-}
- reset(baza);
- if IOresult<>0 then writeln('0')
- else
- writeln(filesize(baza)-1);
- close(baza);
- {$i+}
- {$I-}
- counter:=0;
- reset(ksiazki);
- write('Ilosci ksiazek w bazie: ');
- if IOresult<>0 then writeln('brak bazy')
- else
- begin
- while not eof(ksiazki) do
- begin
- read(ksiazki,book);
- inc(counter);
- end;
- writeln(counter);
- end;
- close(ksiazki);
- {$I+}
- {$I-}
- write('Ksiazki przetrzymywane przez uzytkownikow: ');
- reset(baza);
- reset(ksiazki);
- if IOresult<>0 then writeln('brak bazy uzytkownikow lub ksiazek')
- else
- karanie;
- close(baza);
- close(ksiazki);
- {$I+}
- readln;
- end;
- procedure bibliotekarz;
- begin
- clrscr;
- writeln('Witamy w panelu bibliotekarza');
- writeln('Wybierz jedna z ponizszych mozliwosci');
- while y<>5 do
- begin
- clrscr;
- tablica[1]:=' Zakladanie ksiegozbioru ';
- tablica[2]:=' Usuwanie pozycji ksiegozbioru ';
- tablica[3]:=' Baza Czytelników ';
- tablica[4]:=' Stan Biblioteki ';
- textcolor(15);
- for y:=1 to 4 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(23,10+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(23,10+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(23,10+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=4;
- if y=5 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then zakladanie;
- if y=2 then usuwanie_k;
- if y=3 then baza_cz;
- if y=4 then stan;
- y:=1;
- end;
- end;
- procedure wypozycz;
- var
- counter,i,uzytek,dlugosc:integer;
- begin
- clrscr;
- counter:=0;
- uzytek:=0;
- writeln('Wybierz ksiazke do wypozyczenia');
- {$I-}
- reset(ksiazki);
- if (IOresult <> 0) then
- writeln('Brak ksiegozbioru! Opreracja niemozliwa do wykonania')
- else
- begin
- while not eof(ksiazki) do
- begin
- read(ksiazki,book);
- inc(counter);
- if book.id_user=user.id then
- inc(uzytek);
- tablica[counter]:=book.tytul;
- end;
- close(ksiazki);
- if tablica[1]='' then
- writeln('Brak ksiazek! Operacja niemozliwa do wykoniania')
- else
- begin
- if uzytek >=3 then
- writeln('Masz juz 3 wypozyczone ksiazki, wiecej nie mozesz')
- else
- begin
- while (y <> counter+1) do
- begin
- textcolor(15);
- for y:=1 to counter do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=counter;
- if y=(counter+1) then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if c1=chr(13) then
- begin
- reset(ksiazki);
- for i:=y to counter-1 do
- begin
- book.id_user:=user.id;
- book.data_wyp:=data;
- book.kara:=0;
- write(ksiazki,book);
- dlugosc:=book.max_wyp;
- end;
- close(ksiazki);
- end;
- writeln('Wpozyczono!');
- writeln('Mozesz trzmac ta ksiazke przez ',dlugosc,' dni');
- readln;
- clrscr;
- writeln('Czy chcesz wypozyczyc nastepna ksiazke?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then wypozycz;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- end;
- end;
- {$I+}
- end;
- end;
- procedure oddaj;
- var
- counter,i,uzytek,dlugosc:integer;
- begin
- clrscr;
- counter:=0;
- uzytek:=0;
- writeln('Wybierz ksiazke do oddania');
- {$I-}
- reset(ksiazki);
- if (IOresult <> 0) then
- writeln('Brak ksiegozbioru! Opreracja niemozliwa do wykonania')
- else
- begin
- while not eof(ksiazki) do
- begin
- read(ksiazki,book);
- inc(counter);
- if book.id_user=user.id then
- tablica[counter]:=book.tytul;
- end;
- close(ksiazki);
- if tablica[1]='' then
- writeln('Brak ksiazek! Nie masz nic wypozyczonego')
- else
- begin
- while (y <> counter+1) do
- begin
- textcolor(15);
- for y:=1 to counter do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=counter;
- if y=(counter+1) then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if c1=chr(13) then
- begin
- if book.kara = 0 then
- begin
- reset(ksiazki);
- for i:=y to counter-1 do
- begin
- book.id_user:='';
- book.data_wyp:='';
- book.kara:=0;
- write(ksiazki,book);
- end;
- close(ksiazki);
- writeln('Oddano');
- end
- else
- writeln('Nie mozesz oddac ksiazki poniewaz masz kare wysokosci ',book.kara,'zł za przetrzymywanie ksiazki');
- readln;
- clrscr;
- writeln('Czy chcesz oddac inna ksiazke?');
- while y<>3 do
- begin
- tablica[1]:=' TAK ';
- tablica[2]:=' NIE ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(15,5+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(15,5+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then oddaj;
- if y=2 then
- begin
- clrscr;
- exit;
- end;
- end;
- end;
- end;
- {$I+}
- end;
- end;
- end;
- procedure stan_konta;
- begin
- writeln('Uzytkownik ',user.imie,' ',user.nazwisko);
- writeln('Twoje ID: ',user.id);
- writeln('Konto utworzone w dniu: ',user.data);
- writeln('Wypozyczone ksiazki:');
- reset(ksiazki);
- while not eof(ksiazki) do
- begin
- if book.id_user=user.id then
- begin
- writeln(' ',book.tytul);
- writeln(' Autor: ',book.imie,' ',book.nazwisko);
- writeln(' Data wypozyczenia: ',book.data_wyp);
- writeln(' Ksiazka zostala wypozyczona na: ',book.max_wyp,' dni');
- if book.kara<>0 then
- writeln(' Kara za przetrzymanie wynosi: ',book.kara,' zl');
- end;
- end;
- close(ksiazki);
- readln;
- end;
- procedure zmien_haslo;
- begin
- end;
- procedure otworz_biblioteke;
- begin
- end;
- procedure usun_konto;
- begin
- end;
- procedure czytelnik;
- begin
- clrscr;
- if user.autoryzacja='false' then
- begin
- writeln('Twoje konto nie jest autoryzowane przez administratora lub zostalo zablokowane');
- writeln('sproboj pozniej lub skontaktuj sie z administratorem');
- end
- else
- begin
- writeln('Witamy w panelu czytelnika');
- writeln('Wybierz jedna z ponizszych mozliwosci');
- while y<>7 do
- begin
- clrscr;
- tablica[1]:=' Wyporzycz ksiazke ';
- tablica[2]:=' Oddaj ksiazke ';
- tablica[3]:=' Stan konta ';
- tablica[4]:=' Zmien haslo ';
- tablica[5]:=' Ksiegozbior ';
- tablica[6]:=' USUN Konto ';
- textcolor(15);
- for y:=1 to 6 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(23,10+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(23,10+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(23,10+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if y=0 then y:=6;
- if y=7 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then wypozycz;
- if y=2 then oddaj;
- if y=3 then stan_konta;
- if y=4 then zmien_haslo;
- if y=5 then otworz_biblioteke;
- if y=6 then usun_konto;
- end;
- end;
- end;
- procedure logowanie;
- var
- login,has:string;
- check,licznik:byte;
- c:char;
- begin
- has:='';
- licznik:=0;
- clrscr;
- check:=0;
- write('login: ');
- readln(login);
- clrscr;
- write('haslo: ');
- while c<>chr(13) do
- begin
- c:=readkey;
- inc(licznik);
- has[licznik]:=c;
- has:=has+has[licznik];
- write('*');
- end;
- has:=copy(has,1,length(has)-1);
- begin
- {$I-}
- reset(baza);
- if IOresult<>0 then
- begin
- writeln;
- writeln;
- writeln('Brak bazy danych, operacja niemozliwa');
- writeln('Nastapi cofniecie na strone glowna');
- delay(3000);
- end
- else
- begin
- repeat
- read(baza,user);
- if (login=user.id) then
- begin
- if (has=user.haslo) then
- begin
- inc(check);
- if user.admin='true' then
- bibliotekarz
- else
- czytelnik;
- end;
- end;
- until (check<>0) or eof(baza);
- if check=0 then
- writeln('Zle dane lub nie masz zalozonego konta');
- close(baza);
- readln;
- end;
- {$I+}
- end;
- end;
- procedure be_admin;
- const
- max=5;
- var
- ad,has,access:string;
- check,i:byte;
- c:char;
- begin
- clrscr;
- access:='';
- check:=0;
- writeln('Podaj haslo: ');
- for i:=1 to max do
- begin
- c:=readkey;
- write('*');
- access[i]:=c;
- access:=access+access[i];
- end;
- if (access = 'l0pht') then
- begin
- clrscr;
- writeln('Uwaga ten panel ingeruje gleboko w baze danych, uzywaj go rozwaznie!');
- writeln('Podaj ID do zmiany konta uzytkownika na konto administratora');
- readln(ad);
- writeln('Nowe haslo');
- readln(has);
- {$I-}
- reset(baza);
- if IOresult<>0 then
- writeln('Brak bazy danych, zmiana nie mozliwa')
- else
- begin
- repeat
- read(baza,user);
- if (user.id=ad) then
- begin
- seek(baza,filepos(baza)-1);
- inc(check);
- user.haslo:=has;
- user.id:='bibliotekarz';
- user.admin:='true';
- user.autoryzacja:='true';
- end;
- until (check<>0) or eof(baza);
- if check=0 then
- writeln('Uzytkownik o podanym ID nie istnieje')
- else
- begin
- writeln('Twoje NOWE ID to "bibliotekarz"');
- writeln('Powodzenia w administrowaniu biblioteka');
- end;
- write(baza,user);
- close(baza);
- readln;
- end;
- {$I+}
- end
- else
- exit;
- end;
- procedure menu;
- begin
- clrscr;
- intro;
- writeln;
- while y<>3 do
- begin
- tablica[1]:=' Logowanie ';
- tablica[2]:=' Rejestracja w systemie ';
- textcolor(15);
- for y:=1 to 2 do
- begin
- textcolor(15);
- textbackground(0);
- gotoxy(30,10+y);
- write(tablica[y]);
- end;
- y:=1;
- repeat
- textcolor(0);
- textbackground(15);
- gotoxy(30,10+y);
- write(tablica[y]);
- c1:=readkey;
- c2:=' ';
- if c1=chr(0) then c2:=readkey;
- textcolor(15);
- textbackground(0);
- gotoxy(30,10+y);
- write(tablica[y]);
- if c2='H' then dec(y);
- if c2='P' then inc(y);
- if c2='M' then
- begin
- be_admin;
- clrscr;
- menu;
- end;
- if y=0 then y:=2;
- if y=3 then y:=1;
- if c1=chr(27) then exit;
- until (c1=chr(27)) or (c1=chr(13));
- if y=1 then logowanie;
- if y=2 then rejestracja;
- clrscr;
- intro;
- end;
- end;
- begin
- clrscr;
- files;
- menu;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement