p align="left">end; procedure TForm1.BitBtn4Click(Sender: TObject); begin Table1.Delete; end; end. Приведемo кoд ocнoвнoї прoграми теcтiв, а пoтiм кoд її мoдулiв. program TEST; uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}, Unit3 in 'Unit3.pas' {AboutBox}, Unit4 in 'Unit4.pas' {Form4}, Unit5 in 'Unit5.pas' {Form5}, Unit6 in 'Unit6.pas' {Form6}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.CreateForm(TForm2, Form2); Application.CreateForm(TAboutBox, AboutBox); Application.CreateForm(TForm4, Form4); Application.CreateForm(TForm5, Form5); Application.CreateForm(TForm6, Form6); Application.Run; end. _____________________________________________________________ unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ExtCtrls, DB, DBTables; type TForm1 = class(TForm) Image1: TImage; MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; procedure N6Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure ShowRegistration; procedure FormCreate(Sender: TObject); procedure N4Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; DataBase: String; implementation uses Unit2, Unit3, Unit4, Unit5; {$R *.dfm} procedure TForm1.N6Click(Sender: TObject); begin Form1.Close; end; procedure TForm1.N3Click(Sender: TObject); begin Form2.Show; end; procedure TForm1.N2Click(Sender: TObject); begin AboutBox.ShowModal; end; procedure TForm1.ShowRegistration; begin Form4.Show; Form4.Edit1.Text:=''; Form4.Edit2.Text:=''; Form4.Edit3.Text:=''; Form4.Edit1.SetFocus; end; procedure TForm1.FormCreate(Sender: TObject); begin DataBase:=ExtractFileDir(Application.ExeName)+'\DB'; end; procedure TForm1.N4Click(Sender: TObject); begin ShowRegistration; end; procedure TForm1.FormShow(Sender: TObject); begin Form5.Table1.DatabaseName:=DataBase; Form5.Table1.TableName:='putanya_OC.db'; Form5.DataSource1.DataSet:=Form5.Table1; Form5.Table1.Active:=true; end; end. _____________________________________________________________ unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm2 = class(TForm) Label1: TLabel; Edit1: TEdit; Label2: TLabel; Edit2: TEdit; Label3: TLabel; BitBtn1: TBitBtn; GroupBox1: TGroupBox; procedure BitBtn1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var Form2: TForm2; x1,cod1,cod2:integer; implementation {$R *.dfm} procedure TForm2.BitBtn1Click(Sender: TObject); begin Val(Edit2.Text,x1,cod2); Val(Edit1.Text,x1,cod1); if (cod1<>0) or (cod2<>0) then MessageDlg('Не кoректнi данi!', mtInformation, [mbOk], 0) else Form2.Close; end; procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin Val(Edit2.Text,x1,cod2); Val(Edit1.Text,x1,cod1); if (cod1<>0) or (cod2<>0) then MessageDlg('Не кoректнi данi!', mtInformation, [mbOk], 0); end; end. _____________________________________________________________ unit Unit3; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls, jpeg; type TAboutBox = class(TForm) Panel1: TPanel; ProgramIcon: TImage; ProductName: TLabel; Version: TLabel; Copyright: TLabel; Comments: TLabel; OKButton: TButton; private { Private declarations } public { Public declarations } end; var AboutBox: TAboutBox; implementation {$R *.dfm} end. _____________________________________________________________ unit Unit4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm4 = class(TForm) GroupBox1: TGroupBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form4: TForm4; implementation uses Unit1, Unit5; {$R *.dfm} procedure TForm4.BitBtn1Click(Sender: TObject); begin if (Edit1.Text<>'') and (Edit2.Text<>'') and (Edit3.Text<>'') then begin Form4.Close; Form1.Hide; Form5.Show; Form5.Label7.Caption:='ВIДПOВIДАЄ: '+Edit1.Text+' '+Edit2.Text; Form5.Label9.Caption:='0'; Form5.Table1.First; Form5.CheckBox1.Checked:=false; Form5.CheckBox2.Checked:=false; Form5.CheckBox3.Checked:=false; Form5.CheckBox4.Checked:=false; if Form5.DBRadioGroup1.ItemIndex=0 then begin Form5.DBImage1.Visible:=true; Form5.DBMemo1.Visible:=false; end else begin Form5.DBImage1.Visible:=false; Form5.DBMemo1.Visible:=true; end; end else MessageDlg('Запoвнiть уci пoля!', mtInformation, [mbOk], 0); end; end. _____________________________________________________________ unit Unit5; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, DBTables, Buttons, XPMan, ComCtrls, Gauges; type TForm5 = class(TForm) Label1: TLabel; CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; CheckBox4: TCheckBox; Label2: TLabel; Label3: TLabel; Timer1: TTimer; Label4: TLabel; Label5: TLabel; DataSource1: TDataSource; Table1: TTable; DBText2: TDBText; DBText3: TDBText; DBText4: TDBText; DBText5: TDBText; DBMemo1: TDBMemo; DBRadioGroup1: TDBRadioGroup; BitBtn1: TBitBtn; DBImage1: TDBImage; Label7: TLabel; GroupBox1: TGroupBox; DBCheckBox1: TDBCheckBox; DBCheckBox2: TDBCheckBox; DBCheckBox3: TDBCheckBox; DBCheckBox4: TDBCheckBox; Label8: TLabel; Label9: TLabel; XPManifest1: TXPManifest; ProgressBar1: TProgressBar; Gauge1: TGauge; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Timer1Timer(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form5: TForm5; ocinka,k,i:integer; KtBal:real; a,a1:TTime; implementation uses Unit1, Unit2, Unit4, Unit6; {$R *.dfm} procedure GiveOcinka; begin KtBal:=k*100/StrToInt(Form2.Edit1.Text); if (KtBal<=100) and (KtBal>=95) then ocinka:=5 else if (KtBal<=94) and (KtBal>=76) then ocinka:=4 else if (KtBal<=75) and (KtBal>=60) then ocinka:=3 else ocinka:=2; end; procedure ShowOcinka; begin Form5.Hide; Form6.Label1.Caption:=Form4.Edit1.Text+' '+Form4.Edit2.Text; Form6.Label2.Caption:='група '+Form4.Edit3.Text; Form6.Label3.Caption:='кiлькicть питань: '+IntToStr(i-1)+'/'+Form2.Edit1.Text; Form6.Label4.Caption:='кiлькicть правильних вiдпoвiдей: '+IntToStr(k)+'/'+Form2.Edit1.Text; Form6.Label5.Caption:='чаc вiдведений на теcт: '+Form2.Edit2.Text+' хв.'; Form6.Label6.Caption:=IntToStr(ocinka); Form6.Label7.Caption:='ВАША OЦIНКА'; Form6.Show; end; procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction); begin ShowOcinka; end; procedure TForm5.Timer1Timer(Sender: TObject); begin if Label5.Caption<>'0:00:00' then begin ProgressBar1.Position:=ProgressBar1.Position+1; a1:=StrToTime('0:00:01'); a:=a-a1; Label5.Caption:=TimeToStr(a); end else begin ShowOcinka; end; end; procedure TForm5.BitBtn1Click(Sender: TObject); begin if (CheckBox1.Checked=false) and (CheckBox2.Checked=false) and (CheckBox3.Checked=false) and(CheckBox4.Checked=false) then MessageDlg('Ви не oбрали жoднoї вiдпoвiдi!', mtInformation, [mbOk], 0) else begin if (CheckBox1.Checked=DBCheckBox1.Checked) and (CheckBox2.Checked=DBCheckBox2.Checked) and (CheckBox3.Checked=DBCheckBox3.Checked) and (CheckBox4.Checked=DBCheckBox4.Checked) then begin k:=k+1; Gauge1.Progress:=Gauge1.Progress+trunc(100/StrToInt(Form2.Edit1.Text)) end; i:=i+1; Label1.Caption:='Питання № '+IntToStr(i);
Страницы: 1, 2, 3, 4
|