|
ATESTAT INFORMATICA
Lucrarea de atestat consta realizarea unei aplicatii in Fox Pro care presupune:
Actualizari :
actualizarea bazei de date prin adaugarea unei noi tari;
actualizarea bazei de date prin modificari de date cu privire la anumite tari (suprafata, populatie, clima, densitate, limba oficiala, etc.);
actualizarea bazei de date prin stergerea unei tari din baza de date;
Listari:
listarea datelor despre o tara data;
listarea intregii baze de date;
Cautari:
cauta si listeaza toate tarile care incep cu o anumita litera ;
cauta si listeaza toate tarile dintr-un continent dat;
cauta si listeaza toate tarile cu suprafata cuprinsa intre anumite limite;
cauta si listeaza toate tarile cu venitul cuprins intre anumite limite;
cauta si listeaza toate tarile cu densitatea intre anumite limite;
cauta si listeaza toate tarile cu un anumit tip de clima;
Iesire:
realizeaza iesirea din aplicatie in Fox;
realizeaza iesirea din aplicatie in Dos;
Aplicatia foloseste sase programe:
un program principal : FIRST.PRG;
cinci programe de lucru, care sunt apelate in programul principal:
ACTUALIZARE.PRG
INDEXARE.PRG
LISTARI.PRG
ORDONARI.PRG
IESIRE.PRG
Aplicatia prelucreaza datele preluate dintr-o baza de date BAZA1.DBF cu urmatoarea structura:
TARA
C
15
CONTINENT
C
15
SUPRAFATA
N
15
POPULATIA
N
10
DENSITATEA
N
8
MONEDA
C
8
VENIT_LOC
N
10
LIMBA_OF
C
10
CLIMA
C
10
Se creaza prin programe inca opt baze de date BAZA2.DBF, BAZA3.DBF, BAZA4.DBF,. BAZA9.DBF, care au aceeasi structura ca si baza initiala dar articolele sunt sortate, indexate, modificate, actualizate sterse in functie de optiunea aleasa.
In continuare vor fi prezentate programele sursa folosite in aceasta aplicatie .
PROGRAM PRINCIPAL
FIRST.PRG
set default to c:fpd26atlas
set century on
set date to british
set talk off
set safety off
clear
set display to vga25
*set display to vga50
define menu m
define pad p1 of m prompt ' Actualizari ' at 1,0 message 'ACTUALIZARE BAZA DE DATE '
define pad p2 of m prompt ' Listari ' at 1,19 message ' LISTARI DATE EXISTENTE'
define pad p3 of m prompt ' Cautari ' at 1,39 message ' CAUTARI IN BAZA DE DATE DUPA DIFERITE CRITERII'
define pad p7 of m prompt 'Iesire' at 1,59 message ' IESIRE DIN PROGRAM'
on selection pad p1 of m activate popup pp1
define popup pp1 from 2,0 to 6,16 shadow
define bar 1 of pp1 prompt 'Adaugare tara' message 'TARA NOUA'
define bar 2 of pp1 prompt 'Modificari date' MESSAGE 'MODIFICARI TARA EXISTANTA'
define bar 3 of pp1 prompt 'Stergere tara' Message ' STERGERE TARA EXISTENTA IN BAZA; DE DATE'
define popup pp2 from 2,19 to 5,34 shadow
on selection pad p2 of m activate popup pp2
define bar 1 of pp2 prompt 'Fiecare tara' MESSAGE ' LISTARE DUPA NUME DAT'
define bar 2 of pp2 prompt 'Listarea bazei' MESSAGE ' LISTAREA INTREGII BAZE DE DATE '
define popup pp3 from 2,39 to 10,53 shadow
on selection pad p3 of m activate popup pp3
define bar 1 of pp3 prompt 'Nume' MESSAGE 'CAUTARE DUPA PRIMA LITERA'
define bar 2 of pp3 prompt 'Continent' MESSAGE 'CAUTARE DUPA CONTINENT'
define bar 3 of pp3 prompt 'Suprafata' MESSAGE 'CAUTARE DUPA SUPRAFATA'
define bar 4 of pp3 prompt 'Populatie' MESSAGE 'CAUTARE DUPA POPULATIE'
define bar 5 of pp3 prompt 'Venit/loc' MESSAGE 'CAUTARE DUPA VENIT '
define bar 6 of pp3 prompt 'Densitate' MESSAGE 'CAUTARE DUPA DENSITATE (+CALCUL)'
define bar 7 of pp3 prompt 'Clima' MESSAGE 'CAUTARE DUPA CLIMA'
define popup pp7 from 2,59 to 5,67 shadow
on selection pad p7 of m activate popup pp7
define bar 1 of pp7 prompt 'In FOX' MESSAGE ' IESIRE IN FOX-PRO'
define bar 2 of pp7 prompt 'In S.O.' MESSAGE 'IESIRE IN MS-DOS'
define window fer0 double shadow from 0,0 to srows()-2,scols()-1 color w+/b+
activate window fer0
@ 0,1 SAY 'BAZA DE DATE A GEOGRAFIEI LUMII LA DATA DE ' + DTOC(DATE())
on selection popup pp1 do Actualiz
on selection popup pp2 do Listari
on selection popup pp3 do Ordonari
on selection popup pp7 do iesire
activate menu m
PROGRAM ACTUALIZARE BAZE DE DATE
ACTUALIZARE.PRG
define window fer1 from 5,5 to 22,70
activate window fer1
do case
case bar()=2
use baza1
n1=space (15)
opt=space(2)
opt=' '
@ 0,0 say ' Modificari asupra informatiilor unei tari specificate'
* @ 1,1 SAY ' '
@ 1,1 say 'Numele tarii' get n1
read
locate for alltrim(upper(n1))=alltrim(upper(tara))
if .not.found()
@ 2,2 say 'Nu exista in baza de date ; incercati introducere tara noua'
else
do while (VAL(opt)<>10)
@ 2,1 say 'Datele existente despre ' + n1
@ 3,1 say ' '
@ 3,1 say '1: continent (' + rtrim(continent) +')'
@ 4,1 say ' '
@ 4,1 say '2: populatie (' + ltrim(str(populatie)) +')'
@ 5,1 say ' '
@ 5,1 say '3: suprafata (' + alltrim(upper(str(suprafata))) +')'
@ 6,1 say ' '
@ 6,1 say '4: limba oficiala ('+ rtrim(limba_of) +')'
@ 7,1 say ' '
@ 7,1 say '5: clima (' + rtrim(clima) +')'
@ 8,1 say ' '
@ 8,1 say '6: venit_loc ('+ ltrim(str(venit_loc))+ ' $ )'
@ 9,1 say ' '
@ 9,1 say '7: moneda oficiala (' + rtrim(moneda) +')'
@ 10,1 say '10: EXIT ..'
@ 11,1 say 'Alegeti optiunea (1-10) ' get opt
read
do case
case val(opt)=1
n=space(15)
@ 13,1 say 'Noul continent' get n
read
replace continent with n
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=6
n=space(15)
@ 13,1 say 'Noul venit pe locuitor' get n
read
replace venit_loc with val(n)
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=2
n=space(15)
@ 13,1 say 'Noua populatie' get n
read
replace populatie with val(n)
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=3
n=space(15)
@ 13,1 say 'Noua suprafata' get n
read
replace suprafata with val(n)
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=10
exit
case val(opt)=4
n=space(15)
@ 13,1 say 'Noua limba oficiala' get n
read
replace limba_of with n
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=5
n=space(15)
@ 13,1 say 'Noua clima' get n
read
replace clima with n
@ 14,1 say 'Modificari O.K.!!'
case val(opt)=7
n=space(15)
@ 13,1 say 'Noua moneda oficiala' get n
read
replace moneda with n
@ 14,1 say 'Modificari O.K.!!'
endcase
OPT=' '
WAIT ''
@ 13,1 SAY ' '
@ 14,1 SAY ' '
loop
enddo
endif
case bar()=1
define window fer1 from 5,5 to 20,70
activate window fer1
use baza1
*append blank
scatter memvar blank
@ 1,1 say 'Noua tara' get m.tara
read
do while m.tara=' '
if m.tara=' '
@ 1,1 say 'Noua tara' get m.tara
read
endif
enddo
locate for alltrim(upper(m.tara))=alltrim(upper(tara))
if found()
@ 1,20 say ' tara deja existenta in baza de date '
else
@ 2,1 say 'Continent' get m.continent
read
do while m.continent=' '
if m.continent=' '
@ 2,1 say 'Continent' get m.continent
read
endif
enddo
@ 3,1 say 'Populatie' get m.populatie
read
do while str(m.populatie)=' '
if str(m.populatie)=' '
@ 3,1 say 'Populatie' get m.populatie
read
endif
enddo
@ 4,1 say 'Suprafata' get m.suprafata
read
do while m.suprafata=' '
if m.suprafata=' '
@ 4,1 say 'Suprafata' get m.suprafata
read
endif
enddo
@ 5,1 say 'Limba oficiala' get m.limba_of
read
do while m.limba_of=' '
if m.limba_of=' '
@ 5,1 say 'Limba oficiala' get m.limba_of
read
endif
enddo
@ 6,1 say 'Venit / loc. ' get m.venit_loc
read
do while m.venit_loc=' '
if m.venit_loc=' '
@ 6,1 say 'Venit / loc' get m.venit_loc
read
endif
enddo
@ 7,1 say 'Clima ' get m.clima
read
do while m.clima=' '
if m.clima=' '
@ 7,1 say 'Clima' get m.clima
read
endif
enddo
@ 8,1 say 'Moneda' get m.moneda
read
do while m.moneda=' '
if m.moneda=' '
@ 8,1 say 'Moneda' get m.moneda
read
endif
enddo
@ 10,1 SAY ' Apasati <Esc> pentru anulare'
read
IF LASTKEY() = 27
@ 12,1 say ' introducere anulata .try again .'
else
append blank
replace tara with m.tara, continent with m.continent, populatie with m.populatie, suprafata with m.suprafata, clima with m.clima,venit_loc with m.venit_loc, moneda with m.moneda, limba_of with m.limba_of
endif
endif
case bar()=3
define window fer1 from 5,5 to 20,70
activate window fer1
use baza1
n1=space(10)
@ 1,1 say 'Introduceti numele tarii de sters' get n1
read
locate for alltrim(upper(tara)) = alltrim(upper(n1))
if .not.found()
@ 3,1 say ' Tara inexistenta incercati altceva '
else
delete record recno()
pack
@ 3,1 say ' Stergere efectuata : OK!!'
endif
endcase
wait ' '
do indexare
deactivate window fer1
clear
close databases
INDEXAREA BAZEI DE DATE
INDEXARE.PRG
clear
set talk off
use baza1
locate
do while found()
replace tara with alltrim(upper(tara));
continent with alltrim(upper(continent));
limba_of with alltrim(upper(limba_of));
clima with alltrim(upper(clima));
moneda with alltrim(upper(moneda));
densitate with (populatie/suprafata)
continue
enddo
close all
ORDONAREA UNEI BAZE DE DATE
ORDONARE.PRG
set safety off
set talk off
define window fer1 from 4,5 to 20,70
activate window fer1
do indexare
do case
case bar()=1
n=space(1)
i=1
j=1
@ 1,1 say 'Introduceti prima litera a tarilor cautate' get n
read
use baza1
delete file baza2.dbf
sort to baza2 on tara /ac
use baza2
locate for alltrim(upper(n))=alltrim(upper(substr(tara,1,1)))
if .not.found()
@ 2,1 say 'Nu exista nici o tara care incepe cu litera ' + n +' in baza de date'
else
@ 1,1 say 'Tarile gasite in baza de date sunt: '
do while found()
i=i+1
j=j+1
if (i=12)
wait ''
i=2
for k=i-1 to 13
@ k,1 say ' '
endfor
endif
@ i,1 say str(j-1) + ' : ' + upper(tara)
continue
enddo
endif
case bar()=2
n=space(10)
i=1
j=1
@ 1,1 say 'Introduceti continentul cautat' get n
read
use baza1
delete file baza3.dbf
sort to baza3 on continent,tara /ac
use baza3
locate for alltrim(upper(n))=alltrim(upper(continent))
if .not.found()
@ 2,1 say 'Nu exista nici o tara de pe continentul ' + upper(rtrim(n)) +' in baza de date'
else
@ 1,1 say ' Tarile gasite pe continentul ' + alltrim(upper(n)) + ' sunt: '
do while found()
i=i+1
if (i=12)
wait ''
i=2
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-1) + ' ' + (tara)
continue
enddo
endif
case bar()=3
STORE 0 TO N1,N2
i=3
j=3
@ 1,1 say 'Introduceti limita inferioara a suprafetei' get n1
read
@ 2,1 SAY 'Introduceti limita superioara a suprafetei' GET N2
READ
use baza1
delete file baza4.dbf
sort to baza4 on suprafata,tara /ac
use baza4
locate for (SUPRAFATA>=N1).AND.(SUPRAFATA<=N2)
if .not.found()
@ 3,1 say 'Nu exista nici o tara cu suprafata intre '+ alltrim(str(n1)) +' si ' + alltrim(str(n2))
else
@ 3,1 say 'Tari cu suprafata intre '+alltrim(str(n1)) + ' si '+ alltrim(str(n2))
do while found()
i=i+1
if (i=14)
wait ''
i=4
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-3) + ' ' + upper(tara)+ ' -- suprafata de : '+alltrim(str(suprafata))
continue
enddo
endif
case bar()=4
STORE 0 TO N1,N2
i=3
j=3
@ 1,1 say 'Introduceti limita inferioara a populatiei' get n1
read
@ 2,1 SAY 'Introduceti limita superioara a populatiei' get n2
READ
use baza1
delete file baza5.dbf
sort to baza5 on populatie,tara /ac
use baza5
locate for (POPULATIE>=N1).AND.(POPULATIE<=N2)
if .not.found()
@ 3,1 say 'Nu exista nici o tara cu populatia intre '+ alltrim(str(n1)) +' si ' + alltrim(str(n2))
else
@ 3,1 say 'Tari cu populatia intre '+alltrim(str(n1)) + ' si '+ alltrim(str(n2))
do while found()
i=i+1
if (i=14)
wait ''
i=4
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-3) + ' ' + upper(tara)+ ' -- populatia de : '+alltrim(str(populatie))
continue
enddo
endif
case bar()=5
STORE 0 TO N1,N2
i=3
j=3
@ 1,1 say 'Introduceti limita inferioara a venitului' get n1
read
@ 2,1 SAY 'Introduceti limita superioara a venitului' get n2
read
use baza1
delete file baza6.dbf
sort to baza6 on venit_loc,tara /ac
use baza6
locate for (VENIT_LOC>=N1).AND.(VENIT_LOC<=N2)
if .not.found()
@ 3,1 say 'Nu exista nici o tara cu venit/loc. intre '+ alltrim(str(n1)) +' si ' + alltrim(str(n2))
else
@ 3,1 say 'Tari cu venit/loc. intre '+alltrim(str(n1)) + ' si '+ alltrim(str(n2))
do while found()
i=i+1
if (i=14)
wait ''
i=4
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-3) + ' ' + upper(tara)+ ' -- venit_loc de : '+alltrim(str(venit_loc))
continue
enddo
endif
case bar()=6
STORE 0 TO N1,N2
i=3
j=3
@ 1,1 say 'Introduceti limita inferioara a densitatii' get n1
read
@ 2,1 SAY 'Introduceti limita superioara a densitatii' get n2
read
use baza1
delete file baza7.dbf
sort to baza7 on densitate,tara /ac
use baza7
locate for (densitate>=n1).and.(densitate<=n2)
if .not.found()
@ 3,1 say 'Nu exista nici o tara cu densitatea intre '+ alltrim(str(n1)) +' si ' + alltrim(str(n2))
else
@ 3,1 say 'Tari cu densitatea intre '+ alltrim(str(n1)) + ' si '+ alltrim(str(n2))
do while found()
i=i+1
if (i=14)
wait ''
i=4
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-3) + ' ' + upper(tara)+ ' -- densitate de : '+alltrim(str(densitate,5,3))
continue
enddo
endif
case bar()=7
n=space(10)
i=1
j=1
@ 1,1 say 'Introduceti clima cautata' get n
read
use baza1
delete file baza8.dbf
sort to baza8 on clima,tara /ac
use baza8
locate for alltrim(upper(n))=alltrim(upper(clima))
if .not.found()
@ 2,1 say 'Nu exista nici o tara cu clima ' + upper(rtrim(n)) +' in baza de date'
else
@ 1,1 say 'Tarile cu clima '+ alltrim(upper(n))+' sunt: '
do while found()
i=i+1
if (i=12)
wait ''
i=2
for k=i+1 to 14
@ k,1 say ' '
endfor
endif
j=j+1
@ i,1 say ' ' + str(j-1) + ' ' + (tara)
continue
enddo
endif
endcase
wait ' '
deactivate window fer1
close all
*clear
use
LISTAREA UNEI TARI SAU A INTREGII BAZE DE DATE
LISTARE.PRG
NOTE programul de listari de date
do case
case bar()=1
define window fer1 from 5,5 to 20,70
activate window fer1
n=space(10)
@ 0,0 say ' Cautam informatii despre o anumita tara'
@ 1,1 say 'Numele tarii' get n
read
use baza1
locate for alltrim(upper(n))=alltrim(upper(tara))
if .not.found()
@ 2,1 say 'Nu exista in baza de date'
else
@ 2,1 say 'continent :' + LTRIM(Continent)
@ 3,1 SAY 'suprafata :' + LTRIM(str(suprafata))
@ 4,1 say 'populatie :' + LTRIM(str(populatie))
@ 5,1 SAY 'densitate a pop:' + LTRIM(str(densitate,5,3))
@ 6,1 say 'moneda oficiala :' + LTRIM(moneda)
@ 7,1 say 'limba oficiala :' + LTRIM(limba_of)
@ 8,1 say 'clima :' + LTRIM(clima)
endif
wait ' '
deactivate window fer1
use
case bar()=2
define window fer2 from 3,1 to 22,78 shadow
activate window fer2
@ 0,0 say 'Listare baza de date in ordine alfabetica'
use baza1
delete file baza9.dbf
sort to baza9 on tara /ac
use baza9
i=1
j=1
locate
if .not.found()
@ 2,1 say ' Baza vida ; incercati ..Actualizari.. '
else
@ 1,0 say ' Numele Continent Suprafata PopulatieClimaLimba '
do while found()
i=i+1
j=j+1
if j<=10
@ i,1 say ltrim(str(j-1)) +':'
else
@ i,0 say ltrim(str(j-1))+':'
endif
@ i,4 say rtrim(tara)
@ i,15 say rtrim(continent)
@ i,28 say ltrim(str(suprafata,8,0))
@ i,41 say ltrim(str(populatie,8,0))
@ i,53 say rtrim(clima)
@ i,64 say rtrim(limba_of)
if i=16
wait ' '
i=1
for k=1 to 16
@ k+1,0 say ''
loop
endfor
endif
continue
enddo
endif
wait ' '
deactivate window fer2
endcase
wait ' '
do indexare
use
IESIREA DIN APLICATIE
IESIRE.PRG
do case
case bar()=1.or.bar()=2
deactivate window fer0
close all * inchideri baze de date
release all * eliberare memorie variabile
clear
if bar()=1
cancel *iesire in fox
else
quit *iesire in dos
endif
endcase.