Выбор языка и среды разработки 2Техническое задание 10


end; { чтение файла } procedure



страница11/11
Дата13.12.2022
Размер0,55 Mb.
#196694
ТипТехническое задание
1   2   3   4   5   6   7   8   9   10   11
Связанные:
Курсовая работа ООАиП (Деятельность салона красоты)

end;

{ чтение файла }


procedure ReadFile(var f: c_file);
var
gm: client;
begin
clrscr;
ResFile(f);
writeln('Содержимое файла: ':40);
PrintTable;
while not eof(f) do
begin
read(f, gm);
with gm do
begin
gotoXY(1, whereY); write('| ', name);
gotoXY(45, whereY); write('| ', service);
gotoXY(81, whereY); write('| ');
if date.day < 10 then write('0');
write(date.day);
write('.');
if date.month < 10 then write('0');
write(date.month);
write('.', date.year);
gotoXY(96, whereY); write('| ');
if date.hh < 10 then write('0');
write(date.hh, ':');
if date.mm < 10 then write('0');
write(date.mm);
gotoXY(106, whereY); write(' | ', price);
gotoXY(130, whereY); writeln;
end;
end;
writeln('---------------------------------------------------------------------------------------------------------------------------------');
readln;
end;

{ прибыль за день }


procedure DayProfit(var f: c_file);
var
gm: client;
day, month, profit: integer;
begin
ResFile(f);
write(' День: ');
readln(day);
write(' Месяц: ');
readln(month);
profit := 0;
while not eof(f) do
begin
read(f, gm);
if (gm.date.year = 2021) and (gm.date.month = month)
and (gm.date.day = day) then profit := profit + gm.price;
end;
write('Прибыль за ');
if day < 10 then write('0');
write(day, '.');
if month < 10 then write('0');
writeln(month, ': ', profit, ' рублей.');
readln;
end;

{ прибыль за месяц }


procedure MonthProfit(var f: c_file);
var
gm: client;
month, profit: integer;
begin
ResFile(f);
write(' Месяц: ');
readln(month);
profit := 0;
while not eof(f) do
begin
read(f, gm);
if (gm.date.year = 2021) and (gm.date.month = month) then
profit := profit + gm.price;
end;
writeln('Прибыль за месяц ', month, ': ', profit, ' рублей.');
readln;
end;


var
f: c_file;
w: char;


begin
clrscr;
assign(f, fname); { связывание переменной с файлом на диске }
repeat
clrscr;
{ меню программы }
writeln('Выберите действие:');
writeln('1 - cоздать новый файл');
writeln('2 - добавить запись');
writeln('3 - редактировать запись');
writeln('4 - удалить запись');
writeln('5 - прочитать файл');
writeln('6 - найти прибыль за месяц');
writeln('7 - найти прибыль за день');
writeln('другое - выход');
readln(w);
case w of
'1': CreateNewFile(f);
'2': AddClient(f);
'3': EditClient(f);
'4': RemoveClient(f);
'5': ReadFile(f);
'6': MonthProfit(f);
'7': DayProfit(f);
else exit;
end;
until not (w in ['1'..'7']);
end.

Поделитесь с Вашими друзьями:
1   2   3   4   5   6   7   8   9   10   11




База данных защищена авторским правом ©psihdocs.ru 2023
обратиться к администрации

    Главная страница