home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 March
/
Chip_1999-03_cd.bin
/
zkuste
/
delphi
/
INFO
/
DI9901CJ.ZIP
/
EDITDEMU.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1998-10-23
|
4KB
|
169 lines
unit editdemu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Grids, DBGrids, DBCtrls, Db, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
DataSource1: TDataSource;
LabelStart1: TLabel;
LabelEnd1: TLabel;
LabelStart2: TLabel;
LabelEnd2: TLabel;
LabelTotal1: TLabel;
LabelTotal2: TLabel;
LabelStart3: TLabel;
LabelEnd3: TLabel;
LabelTotal3: TLabel;
LabelStart4: TLabel;
LabelEnd4: TLabel;
LabelTotal4: TLabel;
Table1OrderNo: TFloatField;
Table1CustNo: TFloatField;
Table1SaleDate: TDateTimeField;
Table1ShipDate: TDateTimeField;
Table1EmpNo: TIntegerField;
Table1ShipToContact: TStringField;
Table1ShipToAddr1: TStringField;
Table1ShipToAddr2: TStringField;
Table1ShipToCity: TStringField;
Table1ShipToState: TStringField;
Table1ShipToZip: TStringField;
Table1ShipToCountry: TStringField;
Table1ShipToPhone: TStringField;
Table1ShipVIA: TStringField;
Table1PO: TStringField;
Table1Terms: TStringField;
Table1PaymentMethod: TStringField;
Table1ItemsTotal: TCurrencyField;
Table1TaxRate: TFloatField;
Table1Freight: TCurrencyField;
Table1AmountPaid: TCurrencyField;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Enabled := False;
LabelStart1.Caption := IntToStr(GetTickCount);
Table1.First;
while not Table1.EOF do
begin
Table1.Next;
end;
LabelEnd1.Caption := IntToStr(GetTickCount);
LabelTotal1.Caption := 'Milliseconds: '+ IntToStr(StrToInt(LabelEnd1.Caption) - StrToInt(LabelStart1.Caption));
Button1.Enabled := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Enabled := False;
LabelStart2.Caption := IntToStr(GetTickCount);
Table1.DisableControls;
try
Table1.First;
while not Table1.EOF do
begin
Table1.Next;
end;
LabelEnd2.Caption := IntToStr(GetTickCount);
LabelTotal2.Caption := 'Milliseconds: '+ IntToStr(StrToInt(LabelEnd2.Caption) - StrToInt(LabelStart2.Caption));
finally
Table1.EnableControls;
Button2.Enabled := True;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
SumofSales: Currency;
begin
SumOfSales := 0;
Button3.Enabled := False;
LabelStart3.Caption := IntToStr(GetTickCount);
Table1.DisableControls;
try
Table1.First;
while not Table1.EOF do
begin
SumOfSales := SumOfSales + Table1.FieldByName('ItemsTotal').AsCurrency;
Table1.Next;
end;
LabelEnd3.Caption := IntToStr(GetTickCount);
LabelTotal3.Caption := 'Milliseconds: '+ IntToStr(StrToInt(LabelEnd3.Caption) - StrToInt(LabelStart3.Caption));
finally
Table1.EnableControls;
Button3.Enabled := True;
ShowMessage(FormatCurr('$ #,###.##',SumOfSales));
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
Undo: Boolean;
begin
Table1.First;
if Table1.FieldByName('ShipToState').AsString = '' then
Undo := False
else
Undo := True;
Button4.Enabled := False;
LabelStart4.Caption := IntToStr(GetTickCount);
Table1.DisableControls;
try
Table1.First;
while not Table1.EOF do
begin
try
Table1.Edit;
if Undo then
Table1.FieldByName('ShipToState').Value := ''
else
Table1.FieldByName('ShipToState').Value :=
Table1.FieldByName('PaymentMethod').Value +
' ' + Table1.FieldByName('OrderNo').AsString;
Table1.Post;
Table1.Next;
except
//Handle a failure to edit or post here.
//In this example, ignore records that
//cannot be edited or posted.
end; //try-except
end; //begin
LabelEnd4.Caption := IntToStr(GetTickCount);
LabelTotal4.Caption := 'Milliseconds: '+
IntToStr(StrToInt(LabelEnd4.Caption) - StrToInt(LabelStart4.Caption));
finally
Table1.EnableControls;
Button4.Enabled := True;
end; //try-finally
end;
end.