Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Агапов Александр.doc
Скачиваний:
0
Добавлен:
16.12.2018
Размер:
746.5 Кб
Скачать

1.5.Описание программы

Запускаем программу Delphi 7. FileOpen

Открыть.

Выводиться форма моей программы:

Запускаем программу Run (F9).

Нажимаем “Файл” выводится:

Вписываем данные в первую строку и нажимаем на кнопку ФорматированиеЧтение(данная строка формируется и читается);

Также можно Добавлять, Удалять, Сортировать, Изменять, Очищать строки.

Нажимаем на кнопку Выход, выводится первоначальная форма.

Нажимаем на вкладку Ведомость, выводится

Нажимаем на вкладку Задолжники, выводится: Информация о задолжниках.

Нажимаем на кнопку выборка и выводятся данные из входного файла.

Нажимаем на кнопку Выход и выходим в начальную форму:

Нажимаем на вкладку Ведомость, выводится

Нажимаем на вкладку “Успеваемость по специальности”, выводится: Информация о Успеваемости по специальности .

Нажимаем на кнопку выборка и выводятся данные из входного файла.

Нажимаем на кнопку Выход и выходим в начальную форму:

Нажимаем на вкладку Ведомость, выводится

Нажимаем на вкладку “Успеваемость по курсам”, выводится

Нажимаем на кнопку выборка и выводятся данные из входного файла.

Нажимаем выход и выходим из программы.

Приложение А

Листинг программы

Unit1

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Menus;

type

TForm1 = class(TForm)

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

procedure N3Click(Sender: TObject);

procedure N1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.N3Click(Sender: TObject);

begin

CLOSE;

end;

procedure TForm1.N1Click(Sender: TObject);

begin

form2.show;

end;

end.

Unit2

unit Unit2;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Grids;

type

TForm2 = class(TForm)

StringGrid1: TStringGrid;

Button1: TButton;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Button5: TButton;

Edit1: TEdit;

Button6: TButton;

Button7: TButton;

Button8: TButton;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

procedure Button8Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

z1=record

NMG:string[6];

KS:integer;

NMR_SPEC:longint;

Klv_ch_v_gp:integer;

Klv_sdav_5:integer;

Klv_sdav_4_5:integer;

Klv_sdav_3_4:integer;

Klv_sdav_3:integer;

Sr_gp:real;

Pc_chv:real;

Pc_usp:real;

Klv_dol:integer;

Fam:string[15];

Name:string[15];

Oth:string[15];

Pr_zadolg:string[15];

end;

var

Form2: TForm2;

rf,rf1:file of z1;

x:z1;

i, n:integer;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);

begin

assignfile(rf,'rf');rewrite(rf);

n:=strtoint(edit1.text);

for i:=1 to n do begin

x.NMG:=stringgrid1.Cells[0,i];

x.KS:=strtoint(stringgrid1.Cells[1,i]);

x.NMR_SPEC:=strtoint(stringgrid1.Cells[2,i]);

x.Klv_ch_v_gp:=strtoint(stringgrid1.Cells[3,i]);

x.Klv_sdav_5:=strtoint(stringgrid1.Cells[4,i]);

x.Klv_sdav_4_5:=strtoint(stringgrid1.Cells[5,i]);

x.Klv_sdav_3_4:=strtoint(stringgrid1.Cells[6,i]);

x.Klv_sdav_3:=strtoint(stringgrid1.Cells[7,i]);

x.Sr_gp:=strtofloat(stringgrid1.Cells[8,i]);

x.Pc_chv:=strtofloat(stringgrid1.Cells[9,i]);

x.Pc_usp:=strtofloat(stringgrid1.Cells[10,i]);

x.Klv_dol:=strtoint(stringgrid1.Cells[11,i]);

x.Fam:=stringgrid1.Cells[12,i];

x.Name:=stringgrid1.Cells[13,i];

x.Oth:=stringgrid1.Cells[14,i];

x.Pr_zadolg:=stringgrid1.Cells[15,i];

write(rf,x);

end;closefile(rf);

end;

procedure TForm2.Button2Click(Sender: TObject);

begin

assignfile(rf,'rf');reset(rf);i:=1;

while not eof (rf) do begin

read(rf,x);

stringgrid1.Cells[0,i]:=(x.NMG);

stringgrid1.Cells[1,i]:=inttostr(x.KS);

stringgrid1.Cells[2,i]:=inttostr(x.NMR_SPEC);

stringgrid1.Cells[3,i]:=inttostr(x.Klv_ch_v_gp);

stringgrid1.Cells[4,i]:=inttostr(x.Klv_sdav_5);

stringgrid1.Cells[5,i]:=inttostr(x.Klv_sdav_4_5);

stringgrid1.Cells[6,i]:=inttostr(x.Klv_sdav_3_4);

stringgrid1.Cells[7,i]:=inttostr(x.Klv_sdav_3);

stringgrid1.Cells[8,i]:=floattostr(x.Sr_gp);

stringgrid1.Cells[9,i]:=floattostr(x.Pc_chv);

stringgrid1.Cells[10,i]:=floattostr(x.Pc_usp);

stringgrid1.Cells[11,i]:=floattostr(x.Klv_dol);

stringgrid1.Cells[12,i]:=(x.Fam);

stringgrid1.Cells[13,i]:=(x.Name);

stringgrid1.Cells[14,i]:=(x.Oth);

stringgrid1.Cells[15,i]:=(x.Pr_zadolg);

i:=i+1;

end;closefile(rf);

end;

procedure TForm2.Button6Click(Sender: TObject);

var i,j:integer;

begin

for i:=0 to stringgrid1.ColCount-1 do

for j:=1 to stringgrid1.RowCount-1 do

stringgrid1.Cells[i,j]:=' ';

end;

procedure TForm2.Button3Click(Sender: TObject);

var n,i:longint;

begin

assignfile(rf,'rf');reset(rf);seek(rf,fileSize(rf));

n:=strtoint(edit1.Text);

for i:=1 to n do begin

x.NMG:=stringgrid1.Cells[0,i];

x.KS:=strtoint(stringgrid1.Cells[1,i]);

x.NMR_SPEC:=strtoint(stringgrid1.Cells[2,i]);

x.Klv_ch_v_gp:=strtoint(stringgrid1.Cells[3,i]);

x.Klv_sdav_5:=strtoint(stringgrid1.Cells[4,i]);

x.Klv_sdav_4_5:=strtoint(stringgrid1.Cells[5,i]);

x.Klv_sdav_3_4:=strtoint(stringgrid1.Cells[6,i]);

x.Klv_sdav_3:=strtoint(stringgrid1.Cells[7,i]);

x.Sr_gp:=strtofloat(stringgrid1.Cells[8,i]);

x.Pc_chv:=strtofloat(stringgrid1.Cells[9,i]);

x.Pc_usp:=strtofloat(stringgrid1.Cells[10,i]);

x.Klv_dol:=strtoint(stringgrid1.Cells[11,i]);

x.Fam:=stringgrid1.Cells[12,i];

x.Name:=stringgrid1.Cells[13,i];

x.Oth:=stringgrid1.Cells[14,i];

x.Pr_zadolg:=stringgrid1.Cells[15,i];

write(rf,x);

end;closefile(rf);

end;

procedure TForm2.Button4Click(Sender: TObject);

var s:integer;

n:integer;

begin

assignfile(rf,'rf');

assignfile(rf1,'rf1');

reset(rf);rewrite(rf1);

n:=strtoint(edit1.Text);s:=0;

while not eof(rf)do begin

s:=s+1;

if n=s then read(rf,x)

else begin read (rf,x);

write(rf1,x);

end;end;

closefile(rf);closefile(rf1);

reset(rf1);rewrite(rf);

while not eof(rf1)do begin

read(rf1,x);write(rf,x);

end;

closefile(rf);closefile(rf1);

end;

procedure TForm2.Button5Click(Sender: TObject);

var zp:array[1..50]of z1;

v:z1;j,k,n,i:integer;

begin

assignfile(rf,'rf');reset(rf);i:=1;

WHILE NOT EOF(rf)do begin read(rf,zp[i]);i:=i+1;

end;CLOSEFILE(rf);n:=i-1;

for i:=1 to n do begin k:=i;

for j:=i+1 to n do

if zp[j].nmg<zp[k].nmg then k:=j;

v:=zp[i];zp[i]:=zp[k];zp[k]:=v;

end;

rewrite(rf);

for i:=1 to n do write(rf,zp[i]);

closefile(rf);

end;

procedure TForm2.Button7Click(Sender: TObject);

var n,i:longint;

begin

assignfile(rf,'rf');reset(rf);

n:=strtoint(edit1.Text);

seek(rf,n-1);

x.NMG:=stringgrid1.Cells[0,n];

x.KS:=strtoint(stringgrid1.Cells[1,n]);

x.NMR_SPEC:=strtoint(stringgrid1.Cells[2,n]);

x.Klv_ch_v_gp:=strtoint(stringgrid1.Cells[3,n]);

x.Klv_sdav_5:=strtoint(stringgrid1.Cells[4,n]);

x.Klv_sdav_4_5:=strtoint(stringgrid1.Cells[5,n]);

x.Klv_sdav_3_4:=strtoint(stringgrid1.Cells[6,n]);

x.Klv_sdav_3:=strtoint(stringgrid1.Cells[7,n]);

x.Sr_gp:=strtofloat(stringgrid1.Cells[8,n]);

x.Pc_chv:=strtofloat(stringgrid1.Cells[9,n]);

x.Pc_usp:=strtofloat(stringgrid1.Cells[10,n]);

x.Klv_dol:=strtoint(stringgrid1.Cells[11,n]);

x.Fam:=stringgrid1.Cells[12,n];

x.Name:=stringgrid1.Cells[13,n];

x.Oth:=stringgrid1.Cells[14,n];

x.Pr_zadolg:=stringgrid1.Cells[15,n];

write(rf,x);

closefile(rf);

end;

procedure TForm2.FormActivate(Sender: TObject);

begin

stringgrid1.Cells[0,0]:='Номер группы';

stringgrid1.Cells[1,0]:='Курс';

stringgrid1.Cells[2,0]:='Номер специальности';

stringgrid1.Cells[3,0]:='Кол-во человек в группе';

stringgrid1.Cells[4,0]:='Кол-во сдавших на 5';

stringgrid1.Cells[5,0]:='Кол-во сдавших на 4 и 5';

stringgrid1.Cells[6,0]:='Кол-во на 3 и 4';

stringgrid1.Cells[7,0]:='Кол-во на 3';

stringgrid1.Cells[8,0]:='Средний балл по группе';

stringgrid1.Cells[9,0]:='Процент качества';

stringgrid1.Cells[10,0]:='Процент успеваймости';

stringgrid1.Cells[11,0]:='Количество задолжников';

stringgrid1.Cells[12,0]:='фамилия';

stringgrid1.Cells[13,0]:='Имя';

stringgrid1.Cells[14,0]:='Отчество';

stringgrid1.Cells[15,0]:='Предметы задолжности';

end;

procedure TForm2.Button8Click(Sender: TObject);

begin

Close;

end;

end.

Unit3

unit Unit3;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, StdCtrls;

type

TForm3 = class(TForm)

StringGrid1: TStringGrid;

Button1: TButton;

Button2: TButton;

Label1: TLabel;

procedure Button1Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

z1=record

NMG:string[6];

KS:integer;

NMR_SPEC:longint;

Klv_ch_v_gp:integer;

Klv_sdav_5:integer;

Klv_sdav_4_5:integer;

Klv_sdav_3_4:integer;

Klv_sdav_3:integer;

Sr_gp:real;

Pc_chv:real;

Pc_usp:real;

Klv_dol:integer;

Fam:string[15];

Name:string[15];

Oth:string[15];

Pr_zadolg:string[15];

end;

var

Form3: TForm3;

rf,rf1:file of z1;

x:z1;

i, n:integer;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);

begin

assignfile(rf,'rf');reset(rf);i:=1;

while not eof (rf) do begin

read(rf,x);

stringgrid1.Cells[0,i]:=(x.NMG);

stringgrid1.Cells[1,i]:=inttostr(x.NMR_SPEC);

stringgrid1.Cells[2,i]:=inttostr(x.Klv_dol);

stringgrid1.Cells[3,i]:=(x.Fam);

stringgrid1.Cells[4,i]:=(x.Name);

stringgrid1.Cells[5,i]:=(x.Oth);

stringgrid1.Cells[6,i]:=(x.Pr_zadolg);

i:=i+1;

end;closefile(rf);

end;

procedure TForm3.FormActivate(Sender: TObject);

begin

stringgrid1.Cells[0,0]:='Номер группы';

stringgrid1.Cells[1,0]:='Номер специальности';

stringgrid1.Cells[2,0]:='Количество задолжников';

stringgrid1.Cells[3,0]:='фамилия';

stringgrid1.Cells[4,0]:='Имя';

stringgrid1.Cells[5,0]:='Отчество';

stringgrid1.Cells[6,0]:='Предметы задолжности';

end;

procedure TForm3.Button2Click(Sender: TObject);

begin

Close;

end;

end.

Unit4

unit Unit4;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Grids;

type

TForm4 = class(TForm)

StringGrid1: TStringGrid;

Button1: TButton;

Button2: TButton;

Label1: TLabel;

procedure Button2Exit(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

z1=record

NMG:string[6];

KS:integer;

NMR_SPEC:longint;

Klv_ch_v_gp:integer;

Klv_sdav_5:integer;

Klv_sdav_4_5:integer;

Klv_sdav_3_4:integer;

Klv_sdav_3:integer;

Sr_gp:real;

Pc_chv:real;

Pc_usp:real;

Klv_dol:integer;

Fam:string[15];

Name:string[15];

Oth:string[15];

Pr_zadolg:string[15];

end;

var

Form4: TForm4;

rf,rf1:file of z1;

x:z1;

i, n:integer;

implementation

{$R *.dfm}

procedure TForm4.Button2Exit(Sender: TObject);

begin

close;

end;

procedure TForm4.Button2Click(Sender: TObject);

begin

Close;

end;

procedure TForm4.Button1Click(Sender: TObject);

begin

assignfile(rf,'rf');reset(rf);i:=1;

while not eof (rf) do begin

read(rf,x);

stringgrid1.Cells[0,i]:=inttostr(x.NMR_SPEC);

stringgrid1.Cells[1,i]:=(x.NMG);

stringgrid1.Cells[2,i]:=FLOATTOSTR(x.Sr_gp);

stringgrid1.Cells[3,i]:=FLOATTOSTR(x.Pc_chv);

stringgrid1.Cells[4,i]:=FLOATTOSTR(x.Pc_usp);

i:=i+1;

end;closefile(rf);

end;

procedure TForm4.FormActivate(Sender: TObject);

begin

stringgrid1.Cells[0,0]:='Номер специальности';

stringgrid1.Cells[1,0]:='Номер группы';

stringgrid1.Cells[2,0]:='Средний балл';

stringgrid1.Cells[3,0]:='Процент качества';

stringgrid1.Cells[4,0]:='Процент успеваймости';

end;

end.

Unit5

unit Unit5;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, StdCtrls;

type

TForm5 = class(TForm)

Button1: TButton;

Button2: TButton;

StringGrid1: TStringGrid;

Label1: TLabel;

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

z1=record

NMG:string[6];

KS:integer;

NMR_SPEC:longint;

Klv_ch_v_gp:integer;

Klv_sdav_5:integer;

Klv_sdav_4_5:integer;

Klv_sdav_3_4:integer;

Klv_sdav_3:integer;

Sr_gp:real;

Pc_chv:real;

Pc_usp:real;

Klv_dol:integer;

Fam:string[15];

Name:string[15];

Oth:string[15];

Pr_zadolg:string[15];

end;

var

Form5: TForm5;

rf,rf1:file of z1;

x:z1;

i, n:integer;

implementation

{$R *.dfm}

procedure TForm5.Button2Click(Sender: TObject);

begin

Close;

end;

procedure TForm5.Button1Click(Sender: TObject);

begin

assignfile(rf,'rf');reset(rf);i:=1;

while not eof (rf) do begin

read(rf,x);

stringgrid1.Cells[0,i]:=inttostr(x.NMR_SPEC);

stringgrid1.Cells[1,i]:=FLOATTOSTR(x.KS);

stringgrid1.Cells[2,i]:=(x.NMG);

stringgrid1.Cells[3,i]:=FLOATTOSTR(x.Sr_gp);

stringgrid1.Cells[4,i]:=FLOATTOSTR(x.Pc_chv);

stringgrid1.Cells[5,i]:=FLOATTOSTR(x.Pc_usp);

i:=i+1;

end;closefile(rf);

end;

procedure TForm5.FormActivate(Sender: TObject);

begin

stringgrid1.Cells[0,0]:='Номер специальности';

stringgrid1.Cells[1,0]:='Курс';

stringgrid1.Cells[2,0]:='Номер группы';

stringgrid1.Cells[3,0]:='Средний балл';

stringgrid1.Cells[4,0]:='Процент качества';

stringgrid1.Cells[5,0]:='Процент успеваймости';

end;

end.

Формы:

Список рекомендуемой литературы:

1. Орлов С.А.Технологии разработки программного обеспечения.- СПб.: Питер.2003.- 650 с.:ил.

2. Рудаков А.В. Технология разработки программных продуктов: учеб.

Пособие для студ. Сред.проф. образования / А.В. Рудаков. – М. :

Издательский центр «Академия», 2006. – 208 с.

3. Фаронов В.В. Delphi – программирование на языке высокого

уровня. :Учебник для вузов/ В.В.Фаронов. – СПб.: Питер. 2003.- 640с.:ил.

Рецензия