كود:
unit untElecGaz;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Dlk: TLabel;
btnCalc: TBitBtn;
Edit2: TEdit;
BitBtn2: TBitBtn;
Edit3: TEdit;
ed2: TEdit;
ed3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Memo1: TMemo;
Memo2: TMemo;
Edit16: TEdit;
Edit17: TEdit;
Edit18: TEdit;
Edit19: TEdit;
GroupBox1: TGroupBox;
Label18: TLabel;
Label19: TLabel;
d1: TEdit;
d2: TEdit;
d5: TEdit;
d6: TEdit;
GroupBox2: TGroupBox;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
d3: TEdit;
d4: TEdit;
ed1: TEdit;
ed4: TEdit;
d8: TEdit;
d7: TEdit;
edtJour: TEdit;
Edit1: TEdit;
Edit20: TEdit;
chkbxChoise: TCheckBox;
EffacerClick: TBitBtn;
procedure btnCalcClick(Sender: TObject);
procedure d1Change(Sender: TObject);
procedure d1KeyPress(Sender: TObject; var Key: Char);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure chkbxChoiseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure EffacerClickClick(Sender: TObject);
private public
end;
type
TPReel = ^Real;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
untCalcGazElec, untCalcGazElecs;
procedure Effacer;
begin
Form1.d1.Text := '';
Form1.d2.Text := '';
Form1.d5.Text := '';
Form1.d6.Text := '';
Form1.d1.SetFocus;
end;
procedure TForm1.btnCalcClick(Sender: TObject);
type
PTFonctionGazElec = ^TFonctionGazElec;
TFonctionGazElec = function: TCusGaElClass;
PTGazElecs = ^TGazElec;
PTGazElecClassic = ^TGazElecClassic;
PTGaEl = ^TGaEl;
var
tc1, tc2, tc3, tc4: TPReel;
gc1, gc2, gc3, gc4: TPReel;
i: Integer;
GazElecs: PTGazElecs;
GazElecClassic: PTGazElecClassic;
fonGE: PTFonctionGazElec;
GaEl: PTGaEl;
begin
d3.Text := SousGazElec(StrToInt(d1.Text),StrToInt(d2.Text));
d7.Text := SousGazElec(StrToInt(d5.Text),StrToInt(d6.Text));
if(StrToInt(d3.Text) > 0)and(StrToInt(d7.Text) > 0)then begin
ed1.Text := FormatFloat('0.00',MulGazElecCoef(StrToFloat(d3.Text),StrToFloat(d4.Text)));
ed4.Text := FormatFloat('0.00',MulGazElecCoef(StrToFloat(d7.Text),StrToFloat(d8.Text)));
new(tc1); new(tc2); new(tc3); new(tc4);
new(gc1); new(gc2); new(gc3); new(gc4);
if chkbxChoise.Checked then
begin
new(GazElecs);
GazElecs^ := TGazElec.Create;
try
with GazElecs^ do
begin
Elec(StrToFloat(ed1.Text), tc1^, tc2^, tc3^, tc4^);
Edit2.Text := FloatToStr(CalcTraElec(tc1^, tc2^));
Edit3.Text := FloatToStr(CalcTraElec(tc3^, tc4^));
Gaz(StrToFloat(ed4.Text), gc1^, gc2^, gc3^, gc4^);
ed2.Text := FloatToStr(CalcTraGaz(gc1^,gc2^));
ed3.Text := FloatToStr(CalcTraGaz(gc3^,gc4^));
end;
finally GazElecs^.Free; end;
dispose(GazElecs);
end else
begin
new(GazElecClassic);
GazElecClassic^ := TGazElecClassic.Create;
try
with GazElecClassic^ do
begin
Elec(StrToFloat(ed1.Text), tc1^, tc2^, tc3^);
Edit2.Text := FormatFloat('0.00',StrToFloat(Edit4.Text)+
CalcTraElec(tc1^, tc2^)+CalcTraElec(tc3^, 0));
Edit3.Text := '0'; Edit4.Text := '0';
Gaz(StrToFloat(ed4.Text), gc1^, gc2^, gc3^);
ed2.Text := FormatFloat('0.00',StrToFloat(Edit5.Text)+
CalcTraGaz(gc1^,gc2^)+CalcTraGaz(gc3^,0));
ed3.Text := '0'; Edit5.Text := '0';
end;
finally GazElecClassic^.Free; end;
dispose(GazElecClassic); end;
dispose(tc4); dispose(tc3); dispose(tc2); dispose(tc1);
dispose(gc4); dispose(gc3); dispose(gc2); dispose(gc1);
new(fonGE);
new(GaEl);
fonGE^ := FonctionGazElecClass;
GaEl^ := fonGE^.Create;
try
with GaEl^ do begin
with Memo1.Lines do begin
Clear;
//FormatFloat('0'+DecimalSeparator+'00',12);//Delphi7 . or , or
//FormatFloat('0'+FormatSettings.DecimalSeparator+'00',12);//Delphi xe . or , or
Montant := StrToFloat(Edit2.Text);
TAUX := StrToFloat(Edit9.Text);
Add(FormatFloat('0.00',TVA1));
Montant := StrToFloat(Edit3.Text);
TAUX := StrToFloat(Edit10.Text);
Add(FormatFloat('0.00',TVA1));
Montant := StrToFloat(Edit4.Text);
TAUX := StrToFloat(Edit11.Text);
Add(FormatFloat('0.00',TVA1));
Montant := StrToFloat(ed2.Text);
TAUX := StrToFloat(Edit12.Text);
Add(FormatFloat('0.00',TVA1));
Montant := StrToFloat(ed3.Text);
TAUX := StrToFloat(Edit13.Text);
Add(FormatFloat('0.00',TVA1));
Montant := StrToFloat(Edit5.Text);
TAUX := StrToFloat(Edit14.Text);
Add(FormatFloat('0.00',TVA1));
end;
with Memo2.Lines do
begin
Clear;
Montant := StrToFloat(Edit2.Text);
TVA := StrToFloat(Memo1.Lines.Strings[0]);
Add(FormatFloat('0.00',Totg));
Montant := StrToFloat(Edit3.Text);
TVA := StrToFloat(Memo1.Lines.Strings[1]);
Add(FormatFloat('0.00',Totg));
Montant := StrToFloat(Edit4.Text);
TVA := StrToFloat(Memo1.Lines.Strings[2]);
Add(FormatFloat('0.00',Totg));
Montant := StrToFloat(ed2.Text);
TVA := StrToFloat(Memo1.Lines.Strings[3]);
Add(FormatFloat('0.00',Totg));
Montant := StrToFloat(ed3.Text);
TVA := StrToFloat(Memo1.Lines.Strings[4]);
Add(FormatFloat('0.00',Totg));
Montant := StrToFloat(Edit5.Text);
TVA := StrToFloat(Memo1.Lines.Strings[5]);
Add(FormatFloat('0.00',Totg));
Add(Edit6.Text); Add(Edit7.Text); Add(Edit8.Text);
end;
Edit16.Text := '0'; Edit17.Text := '0';
with Memo1.Lines do for i := 0 to count-1 do
Value := Value+StrToFloat(Strings[i]);
Edit16.Text := FormatFloat('0.00',Value);
with Memo2.Lines do for i := 0 to count-1 do
Value := Value+StrToFloat(Strings[i]);
Edit17.Text := FormatFloat('0.00',Value); //('0,00',Value)
end;
finally GaEl^.Free; end;
dispose(GaEl); dispose(fonGE);
Edit15.Text := FormatFloat('0.00',StrToFloat(Edit2.Text)+StrToFloat(Edit3.Text)+
StrToFloat(Edit4.Text)+StrToFloat(ed2.Text)+StrToFloat(ed3.Text)+StrToFloat(Edit5.Text)+
StrToFloat(Edit6.Text)+StrToFloat(Edit7.Text)+StrToFloat(Edit8.Text));
Edit19.Text := FormatFloat('0.00',StrToFloat(Edit17.Text)+StrToFloat(Edit18.Text));
Label17.Caption := FormatFloat('0.00',StrToFloat(Edit19.Text)/StrToInt(edtJour.Text));
Edit20.Text := FormatFloat('0.00',StrToFloat(Edit17.Text)-StrToFloat(Edit1.Text));
if StrToFloat(edit15.Text)+StrToFloat(edit16.Text)<>StrToFloat(edit17.Text)
then ShowMessage('Error');
end else Effacer;
btncalc.Enabled := false;
end;
procedure TForm1.chkbxChoiseClick(Sender: TObject);
begin
if chkbxChoise.Checked then
begin
chkbxChoise.Caption := 'Calcule Nouveau';
edit4.Text := '78,66';
edit5.Text := '85,50';
Edit7.Text := '150';
Edit8.Text := '679,19';
Edit10.Text := '0,19';
Edit13.Text := '0,19';
end else
begin
chkbxChoise.Caption := 'Calcule Ancien';
edit4.Text := '131,10';
edit5.Text := '85,50';
Edit7.Text := '75';
Edit8.Text := '600';
Edit10.Text := '0';
Edit13.Text := '0';
end;
end;
procedure TForm1.d1Change(Sender: TObject);
begin
if(d1.Text <> '')and(d2.Text <> '')and(d5.Text <> '')and
(d6.Text <> '')then btnCalc.Enabled := true
else btnCalc.Enabled := false;
end;
procedure TForm1.d1KeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9',#8]) then key := #0;
end;
procedure TForm1.EffacerClickClick(Sender: TObject);
begin
Effacer;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//--- GroupBox1 -----------------------------------//
Form1.GroupBox1.Caption := 'RELEVE DE COMPTEUR';
Form1.Label8.Caption := 'Index Nouveau';
Form1.Label9.Caption := 'Index Ancien';
Form1.d1.Text := ''; // Index Nouveau Elec
Form1.d2.Text := ''; // Index Ancien Elec
Form1.d5.Text := ''; // Index Nouveau Gaz
Form1.d6.Text := ''; // Index Ancien Gaz
//--- GroupBox2 -----------------------------------//
Form1.GroupBox2.Caption := '';
Form1.Label20.Caption := 'Différance';
Form1.Label21.Caption := 'COEF';
Form1.Label22.Caption := '(kwh/THERMIE)';
Form1.Label23.Caption := 'CONSOMMATION';
// Index Nouveau - Index Ancien = Différance
Form1.d3.Text := ''; // Différance
Form1.d4.Text := '1'; // COEF Elec
Form1.ed1.Text := '';
Form1.d7.Text := ''; // Différance
Form1.d8.Text := '9,02'; // COEF Gaz
Form1.ed4.Text := '';
// 0.00 or 0,00
Form1.Label1.Caption := 'CONSOMMATION HORS TVA (DA)';
Form1.Label2.Caption := 'T.V.A';
Form1.Label3.Caption := 'ELEC 54 M';
//-------- TAUX% -----------------//
{ Form1.Edit9.Text := '0,09';
Form1.Edit10.Text := '0,19';
Form1.Edit11.Text := '0,09';
Form1.Edit12.Text := '0,09';
Form1.Edit13.Text := '0,19';
Form1.Edit14.Text := '0,09'; }
//-------- TAUX -----------------//
Form1.btnCalc.Caption := 'Calc';
Form1.EffacerClick.Caption := 'Effacer';
Form1.BitBtn2.Caption := '&Fermer';
form1.Edit1.Text := '0';
form1.Edit2.Text := '';
form1.Edit3.Text := '';
form1.Edit4.Text := '78,66'; // Primes Fixes Elec
form1.Edit5.Text := '85,50'; // Primes Fixes Gaz
form1.Edit6.Text := '100'; // DRIOT FIXE
form1.Edit7.Text := '150'; // TAXE HABITATION
form1.Edit8.Text := '679,19'; // Soutien Etat
form1.Edit18.Text := '162'; // Droit de timbre
form1.edtJour.Text := '90'; // Le montant de votre consommation moyenne d'énergie par jour :
form1.Edit15.Text := '';
form1.Edit16.Text := '';
form1.Edit17.Text := '';
form1.Edit19.Text := '';
form1.Edit20.Text := '';
end;
end.