- •Введение
- •Теоретическая часть
- •Техническое задание на разработку программного продукта
- •Выбор и обоснование языка программирования
- •Выбор стиля, методов и средств программирования
- •Описание программы
- •Общие сведения
- •«Блокнот»
- •Приложение 1
- •Приложение 2
- •Список литературы
- •Костромской политехнический колледж
- •Приложение 3
- •Приложение 4
- •Приложение 5
- •Приложение 6
Приложение 6
КП-020699846.230105.13.20.12
Файл PhoneBook.exe
Листов 1
Выполнили:________ А. А. Тутаков
________ Н.А. Кустов
2013
Литера КП
ПРИЛОЖЕНИЕ 6
program Test_to_chemical; // Исходник проекта
uses
Forms,
Unit3 in 'Unit3.pas' {AvtFrm},
Unit7 in 'Unit7.pas' {MainFrm},
Unit4 in 'Unit4.pas' {AboutFrm},
Unit1 in 'Unit1.pas' {StatFrm};
{$R *.res}
begin
Application.Initialize;
Application.Title := 'Test_to_chemical';
Application.CreateForm(TAvtFrm, AvtFrm);
Application.CreateForm(TMainFrm, MainFrm);
Application.CreateForm(TAboutFrm, AboutFrm);
Application.CreateForm(TStatFrm, StatFrm);
Application.Run;
end.
unit Unit3;// Авторизация
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Mask, jpeg, ExtCtrls;
type
TAvtFrm = class(TForm)
ComboBox1: TComboBox;
MaskEdit1: TMaskEdit;
BitBtn1: TBitBtn;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
procedure BitBtn1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AvtFrm: TAvtFrm;
implementation
uses Unit4, Unit7;
{$R *.dfm}
procedure TAvtFrm.BitBtn1Click(Sender: TObject);// Процедура авторизации
begin
if ComboBox1.ItemIndex=-1 then
Application.MessageBox('Выберите пользователя','Ошибка',MB_OK);
If ComboBox1.ItemIndex=0 then
begin
MaskEdit1.Visible:=true;
Label2.Visible:=true;
If maskedit1.text<>'1' then
begin
maskedit1.clear;
ПРИЛОЖЕНИЕ 6 (Продолжение)
Application.MessageBox('Неверный пароль! Повторите попытку','Ошибка',MB_OK);
end
else
begin
AvtFrm.Hide;
MainFrm.Show;
MainFrm.Label4.Caption:='АДМИН';
MainFrm.BitBtn6.Visible:=true;
MainFrm.Memo1.Visible:=false;
MainFrm.RadioGroup1.Visible:=false;
MainFrm.BitBtn8.Visible:=false;
end;
end;
If ComboBox1.ItemIndex=1 then begin
Label2.Visible:=false;
MaskEdit1.Visible:=false;
If Edit1.Text='' then
Application.MessageBox('Введите ФИО','Ошибка',MB_OK)
else
begin
MainFrm.Memo1.Visible:=false;
MainFrm.RadioGroup1.Visible:=false;
MainFrm.BitBtn8.Visible:=false;
MainFrm.BitBtn6.Visible:=false;
AvtFrm.Hide;
MainFrm.Show;
MainFrm.Image2.visible:=false;
MainFrm.Label4.Caption:=AvtFrm.Edit1.Text;
end;
end;
end;
procedure TAvtFrm.ComboBox1Change(Sender: TObject);// Процедура выбора пользователя
begin
If ComboBox1.ItemIndex=0 then
begin
Label3.Visible:=false;
Edit1.Visible:=false;
MaskEdit1.Visible:=true;
Label2.Visible:=true
end
else
if ComboBox1.ItemIndex=1 then begin
Label2.Visible:=false;
MaskEdit1.Visible:=false;
Label3.Visible:=true;
Edit1.Visible:=true;
end;
end;
end.
unit Unit7;// Главное меню
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, Buttons, ExtCtrls, ComCtrls, jpeg;
type
TMainFrm = class(TForm)
Timer1: TTimer;
Image1: TImage;
Image2: TImage;
RadioGroup1: TRadioGroup;
ПРИЛОЖЕНИЕ 6 (Продолжение)
Memo1: TMemo;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn5: TBitBtn;
StatusBar1: TStatusBar;
Panel1: TPanel;
Image4: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure Image3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainFrm: TMainFrm;
balls : integer;
q_file : TextFile;
five, four, three,
ans1mark, ans2mark, ans3mark, ans4mark : integer;
question, answere1, answere2, answere3,
answere4, tmp_q, result : string;
flag_end, flag_write : boolean;
implementation
uses Unit3,Unit4, Unit1;
{$R *.dfm}
procedure TMainFrm.Timer1Timer(Sender: TObject);// Процедура установки времени
begin
StatusBar1.Panels[0].Text:=TimeToStr(Time);
end;
procedure check_ans;// Процедура проверки ответов
begin
if (MainFrm.RadioGroup1.ItemIndex=0)and(flag_end=false) then
balls:=balls+ans1mark;
if (MainFrm.RadioGroup1.ItemIndex=1)and(flag_end=false) then
balls:=balls+ans2mark;
if (MainFrm.RadioGroup1.ItemIndex=2)and(flag_end=false) then
balls:=balls+ans3mark;
if (MainFrm.RadioGroup1.ItemIndex=3)and(flag_end=false) then
ПРИЛОЖЕНИЕ 6 (Продолжение)
balls:=balls+ans4mark;
MainFrm.RadioGroup1.ItemIndex:=-1;
end;
procedure Read_next_q; // Процедура вывода оценки
begin
if EOF(q_file) then
begin
flag_end := true;
if balls>=15 then begin
result:='5' ;
MainFrm.Label5.Caption:=result;
end;
if (balls>=12)and(balls<five) then begin
result:='4';
MainFrm.Label5.Caption:=result;
end;
if (balls>=9)and(balls<four) then begin
result:='3';
MainFrm.Label5.Caption:=result;
end;
if (balls<7) then begin
result:='2';
MainFrm.Label5.Caption:=result;
end;
MainFrm.Memo1.Visible:=false;
MainFrm.RadioGroup1.Visible:=false;
MainFrm.BitBtn8.Visible:=false;
MainFrm.Panel1.Visible:=true;
end
else
begin
Readln(q_file,tmp_q);
question:=tmp_q+#13#10;
Readln(q_file,tmp_q);
question:=question+tmp_q+#13#10;
Readln(q_file,tmp_q);
question:=question+tmp_q+#13#10;
Readln(q_file,answere1);
Readln(q_file,ans1mark);
Readln(q_file,answere2);
Readln(q_file,ans2mark);
Readln(q_file,answere3);
Readln(q_file,ans3mark);
Readln(q_file,answere4);
Readln(q_file,ans4mark);
MainFrm.Memo1.Text:=question;
MainFrm.RadioGroup1.Items[0]:=answere1;
MainFrm.RadioGroup1.Items[1]:=answere2;
MainFrm.RadioGroup1.Items[2]:=answere3;
MainFrm.RadioGroup1.Items[3]:=answere4;
end;
end;
procedure TMainFrm.FormCreate(Sender: TObject); //Процедура установки даты
begin
StatusBar1.Panels[1].Text:=DateToStr(Date);
end;
procedure TMainFrm.BitBtn1Click(Sender: TObject); //Процедура выхода из программы
begin
if MessageDlg('Хотите выйти?',mtWarning,[mbOK,mbCancel],0)=mrOk then
Application.Terminate;
end;
procedure TMainFrm.BitBtn7Click(Sender: TObject); // Процедура запуска тестирования
begin
Memo1.Visible:=true;
RadioGroup1.Visible:=true;
ПРИЛОЖЕНИЕ 6 (Продолжение)
BitBtn8.Visible:=true;
flag_end:=false;
AssignFile(q_file, 'Тест.txt');
Reset(q_file);
Readln(q_file,five);
Readln(q_file,four);
Readln(q_file,three);
Read_next_q;
end;
procedure TMainFrm.BitBtn8Click(Sender: TObject); // Процедура считывания ответа
begin
if MainFrm.RadioGroup1.ItemIndex<>-1 then
begin;
check_ans;
Read_next_q;
end
else
Application.MessageBox('Выберите один из вариантов'+#13#10+'ответов!','Ошибка',MB_OK);
end;
procedure TMainFrm.BitBtn2Click(Sender: TObject); // Процедура смены пользователя
begin
if MessageDlg('Хотите сменить пользователя?',mtWarning,[mbOK,mbCancel],0)=mrOk then
begin
MainFrm.Close;
AvtFrm.Show;
AvtFrm.MaskEdit1.Clear;
AvtFrm.Edit1.Clear;
end;
end;
procedure TMainFrm.BitBtn5Click(Sender: TObject); // Процедура вызова справки
begin
AboutFrm.Show;
AboutFrm.Memo1.Lines.LoadFromFile('progr.txt')
end;
procedure TMainFrm.BitBtn3Click(Sender: TObject); // Процедура чтения статистики
var LF:textfile;
begin
Panel1.Visible:=false;
AssignFile(LF,'LogFile.txt');
Append(LF);
writeln(LF,Label4.Caption);
writeln(LF,Label5.Caption);
CloseFile(LF);
end;
procedure TMainFrm.BitBtn6Click(Sender: TObject); // Процедура вызова статистики
begin
StatFrm.show;
end;
procedure TMainFrm.Image3Click(Sender: TObject); // Процедура показа результата
begin
Memo1.Visible:=true;
RadioGroup1.Visible:=true;
BitBtn8.Visible:=true;
flag_end:=false;
AssignFile(q_file, 'Тест.txt');
Reset(q_file);
Readln(q_file,five);
Readln(q_file,four);
Readln(q_file,three);
Read_next_q;
end;
ПРИЛОЖЕНИЕ 6 (Продолжение)
procedure TMainFrm.BitBtn4Click(Sender: TObject); // Процедура ошибки при чтении статистики
begin
Application.MessageBox('Статистика доступна только пользователю с учетной записью "Преподаватель"!','Ошибка',MB_OK)
end;
end.
unit Unit1; // Статистика
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, Buttons, jpeg;
type
TStatFrm = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
StringGrid1: TStringGrid;
BitBtn1: TBitBtn;
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
StatFrm: TStatFrm;
implementation
uses Unit7;
{$R *.dfm}
procedure TStatFrm.FormShow(Sender: TObject); // Процедура показа окна статистики
var L:textfile;
S1,S2,lf:string;
i:byte;
begin
LF:='LogFile.txt';
AssignFile(L,lf);
reset(L);
stringgrid1.RowCount:=filesize(L)+1;
StringGrid1.Cells[0,0]:=' ФИО';
StringGrid1.Cells[1,0]:=' Оценка';
i:=0;
while not eof(L) do
begin
inc(i);
stringgrid1.rowcount:=stringgrid1.rowcount+1;
readln(L,s1);
stringgrid1.cells[0,i]:=s1;
readln(L,s2);
stringgrid1.cells[1,i]:=s2;
end;
end;
procedure TStatFrm.BitBtn1Click(Sender: TObject); // Процедура закрытия окна статистики
begin
StatFrm.Close
end;
end.
ПРИЛОЖЕНИЕ 6 (Продолжение)
unit Unit4; // Информация об авторах
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, jpeg;
type
TAboutFrm = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
BitBtn1: TBitBtn;
Image1: TImage;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutFrm: TAboutFrm;
implementation
uses Unit7;
{$R *.dfm}
procedure TAboutFrm.BitBtn1Click(Sender: TObject); // Процедура закрытия окна информации об авторах
begin
AboutFrm.Close;
end;
end
