1. Продажа программных продуктов.
Наименование Фирма-изготовитель Стоимость, руб. Объем, Мбайт. Количество на складе
.... ...... ...... ...... ......
program kursovik;
{$APPTYPE CONSOLE}
uses
SysUtils,console;
type
Stnaz=string[30];
Stfirma=string[50];
Stsumma=string[12];
Stves=string[10];
Stkolvo=string[10];
RecBook=record
naz:Stnaz;
firma:Stfirma;
summa:Stsumma;
ves:Stves;
kolvo:Stkolvo;
end;
var
bookfile:file of RecBook;
Work:RecBook;
Vid:byte;
End_Menu:boolean;
Name:string[12];
procedure Name_File;
begin
write('file name>');
readln(Name);
end;
procedure AddRec;
begin
writeln('information ¹',FilePos(BookFile)+1);
with Work do
begin
writeln('name:');
readln(naz);
writeln('Firma:');
readln(firma);
writeln('stoimost:');
readln(summa);
writeln('ves v metrah:');
readln(ves);
writeln('kolichestvo na sklade:');
readln(kolvo);
write(BookFile,work);
end;
end;
procedure Create_Book;
var
ind, Count:integer;
begin
Name_File;
Assign(BookFile, Name);
Rewrite(BookFile);
writeln('Sozdanie zapisej fajla', Name);
writeln('vvedite chislo zapisej');
readln(count);
for ind:=1 to count do
AddRec;
writeln('file sozdan');
writeln('file imeet',FileSize(BookFile),'zapisi');
Close(BookFile);
end;
procedure OutputRec;
begin
read(BookFile,Work);
with Work do
begin
writeln('zapis ¹',FilePos(BookFile),':');
writeln('name:',naz,'Firma:',firma,'stoimost:',summa,'ves v metrah:',
ves,'kolichestvo na sklade:',kolvo);
end;
end;
procedure OutputAllRec;
begin
Name_File;
assign(BookFile, Name);
{$I-}
reset(BookFile);
{$I+}
if IOresult=0 then
begin
Seek(BookFile,0);
writeln('*** vyvod dannyh ',Name,'***');
while (not Eof(BookFile)) do
OutputRec;
end
else
writeln('file'+Name+' not found');
end;
procedure UpdateRec;
var
NumRec:LongInt;
begin
Name_File;
assign(BookFile, Name);
{$I-}
reset(BookFile);
{$I+}
if IOresult=0 then
begin
writeln('ukazhite nomer izmenyaemoj zapisi:');
readln(NumRec);
Seek(BookFile, NumRec-1);
writeln('-- staroe znachenie --');
OutputRec;
Seek(BookFile,NumRec-1);
writeln('zadaem novoe znachenie',NumRec,'zapisi');
AddRec;
Close(BookFile);
end
else
writeln('file'+Name+'not found');
end;
procedure AddRecToEnd;
begin
Name_File;
assign(BookFile,Name);
{$I-}
reset(BookFile);
{$I+}
if IOresult=0 then
begin
Seek(BookFile,FileSize(BookFile));
AddRec;
writeln('izmenennyj file dannyh imeet',FileSize(BookFile),'zapisi');
close(BookFile);
end
else
writeln('file'+Name+'not found');
end;
procedure FindNaz;
var
BookFile:file of RecBook;
Work:RecBook;
Maska:Stnaz;
Rez_Find:boolean;
CountRec:integer;
begin
Name_File;
assign(BookFile,Name);
{$I-}
reset(BookFile);
{$I+}
if IOresult=0 then
begin
writeln('vvedite nazvanie produkta:');
readln(Maska);
Rez_Find:=false;
CountRec:=0;
while (not Eof(BookFile)) do
begin
read(BookFile,Work);
with work do
if Pos(Maska,naz)<>0 then
begin
Rez_Find:=true;
Inc(CountRec);
writeln('name:',naz,'Firma:',firma,'stoimost:',summa,'ves v metrah:',
ves,'kolichestvo na sklade:',kolvo);
end;
end;
if Rez_Find then
writeln('chislo zapisej dly',Maska,'=',CountRec)
else
writeln('not found',Maska);
Close(BookFile);
end
else
writeln('file'+Name+'not found');
end;
begin
End_Menu:=false;
repeat
clrscr;
writeln('*** Prodazha programnyh produktov ***');
writeln('Vyberite vid raboty');
writeln('1- create new file');
writeln('2- prosmotr spiska');
writeln('3- izmenenie zapisi');
writeln('4- dopolnenie spiska');
writeln('5- poisk produkta');
writeln('0- Exit');
readln(vid);
case vid of
1: Create_Book;
2: OutputAllRec;
3: UpdateRec;
4: AddRecToEnd;
5: Findnaz;
0: exit;
end;
writeln('please Enter for next');
readln;
until End_Menu;
readln;
end.