Unit Unit1; interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls,
ComCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Table1: TTable;
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
RadioGroup1: TRadioGroup;
Button2: TButton;
RadioGroup2: TRadioGroup;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
ListBox3: TLstBox;
Button5: TButton;
btnWorkStart: TButton;
btnWorkBreak: TButton;
Button6: TButton;
Panel1: TPanel;
ProgressBar1: TProgressBar;
Label1: TLabel;
lblWorkPercent: TLabel;
lblSum: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnWorkStartClick(Sender: TObject);
procedure btnWorkBreakClick(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
WorkBreak:boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
btnWorkStart.Enabled:=true;
btnWorkBreak.Enabled:=false;
WorkBreak:=false;
end;
procedure TForm1.btnWorkStartClick(Sender: TObject);
label 10;
var s:real;
begin
btnWorkStart.Enabled:=false;
btnWorkBreak.Enabled:=true;
s:=0;
// Это будет работать только при числе записей, меньших 3276
ProgressBar1.Max:=Table1.RecordCount;
Table1.DisableControls;
Table1.First;
while not Table1.Eof do begin
s:=s+Table1.FieldByName ('Salary').AsFloat;
//Без этого вызова не будет обрабатываться нажатие копки btnWorkBreak
Application.ProcessMessages;
// Это будет работать только при числе записей, меньших 3276
ProgressBar1.Position:=Table1.RecNo;
lblWorkPercent.Caption:=
IntToStr(Round(ProgressBar1.Position/ProgressBar1.Max*100))+'%';
if WorkBreak then goto 10;
Table1.Next;
end;
lblSum.Caption:='Èòîãî' + FloatToStr(s);
10:
Table1.EnableControls;
ProgressBar1.Position:=0;
lblWorkPercent.Caption:='';
btnWorkStart.Enabled:=true;
btnWorkBreak.Enabled:=false;
WorkBreak:=false;
end;
procedure TForm1.btnWorkBreakClick(Sender: TObject);
begin
WorkBreak:=true;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
close;
end;
end.