دلفي تعليم
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

برنامج حساب الغاز والكهربة نسخة 3

اذهب الى الأسفل

برنامج حساب الغاز والكهربة نسخة 3 Empty برنامج حساب الغاز والكهربة نسخة 3

مُساهمة  ali 22/3/2018, 11:48 pm


برنامج حساب الغاز والكهربة نسخة 3


بسم الله الرحمن الرحيم

الصلاة والسلام على رسول الله وعلى آلـــــــــــــه صحبه أجمعين

الحمد لله رب العالمين الرحمن الرحيم

برنامج حساب الغاز والكهربة

برنامج حساب الغاز والكهربة هو محاولة بسيطة
ليستطيع أي مستهلك للغاز والكهربة معرفة ماذا أستهلك من الغاز والكهربة
حتي يأخذ الاحتياطات الازمة من أجل الاقتصاد في الاستهلاك والاستغناء على بعض
الاجهزة الغير ضرورية واطفاء بعض المصابيح

طريقة الاستعمال من أجل المستعمل للبرنامج

أولا:

يأخذ الرقم الموجود في عداد الكهربة وعداد الغاز كذلك
ويأخذ الرقم الموجود في آخر فاتورة للغاز والكهربة

وهو Index nouveau

يكتبهما في الأماكن المخصصة لهم في البرنامج

----------
طريقة البرمجة
ثانيا:

البرنامج موجه الى مبتدئ البرمجة دلفي

ضع فوق الفورم 2 TGroupBox
داخل ال GroupBox1 ضع 4 TEdit وهم
d1 و d2 و d5 و d6


وضع 2 TLabel وهم
Label18 و Label19

Label18 --> Caption = Index Nouveau
Label19 --> Caption = Index Ancien

داخل ال GroupBox2 ضع 6 TEdit وهم
d3 و d4 و d7 و d8
و ed1 و ed4

وضع 4 TLabel وهم
Label20 و Label21 و Label22 و Label23

Label20 --> Caption = Différance
Label21 --> Caption = COEF
Label22 --> Caption = (kwh/THERMIE)
Label23 --> Caption = CONSOMMATION

ضع على الفورم 3 TBitBtn وهم
btnCalc و BitBtn2 و EffacerClick

رتب الباقية حسب الفاتورة


حولت قدر المستطاع من خلاله توضيح فكرة البرمجة الموجهة بالكائنات oop


---------------------
الوحدة الاولى
---------------------

اسم الملف
untElecGaz.pas

الكود:

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, XPMan;

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;
    dtTotalElectricite: TEdit;
    dtTotalGaz: TEdit;
    Label24: TLabel;
    Label25: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    TotalDroitstaxes: TEdit;
    Label26: TLabel;
    XPManifest1: TXPManifest;
    Button4: TButton;
    procedure btnCalcClick(Sender: TObject);
    procedure chkbxChoiseClick(Sender: TObject);
    procedure d1Change(Sender: TObject);
    procedure d1KeyPress(Sender: TObject; var Key: Char);
    procedure EffacerClickClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    procedure TAUX_N;
    procedure TAUX_A;
  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) > 50)and(StrToInt(d7.Text) > 50)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 := FormatFloat('0.00',CalcTraElec(tc1^, tc2^,1));

  Edit3.Text := FormatFloat('0.00',CalcTraElec(tc3^, tc4^,2));

  Gaz(StrToFloat(ed4.Text), gc1^, gc2^, gc3^, gc4^);
  ed2.Text := FormatFloat('0.00',CalcTraGaz(gc1^,gc2^,1));
  ed3.Text := FormatFloat('0.00',CalcTraGaz(gc3^,gc4^,2));
 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^,1)+CalcTraElec(tc3^, 0,2));
  Edit3.Text := '0'; Edit4.Text := '0';
  Gaz(StrToFloat(ed4.Text), gc1^, gc2^, gc3^);
  ed2.Text := FormatFloat('0.00',StrToFloat(Edit5.Text)+
  CalcTraGaz(gc1^,gc2^,1)+CalcTraGaz(gc3^,0,2));
  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 10.2 . 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));
  // dtTotalElectricite.Text := StrToFloat(dtTotalElectricite.Text);

  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));

 ///////////////  2018
  with Memo2.Lines do begin
  dtTotalElectricite.Text := FormatFloat('0.00',StrToFloat(Strings[0])+StrToFloat(Strings[1])+StrToFloat(Strings[2]));
  dtTotalGaz.Text := FormatFloat('0.00',StrToFloat(Strings[3])+StrToFloat(Strings[4])+StrToFloat(Strings[5]));
  end; TotalDroitstaxes.Text := '200.00';
  //////////////  2018

  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'+{FormatSettings.}DecimalSeparator+'66';
 edit5.Text := '85'+{FormatSettings.}DecimalSeparator+'50';
 Edit7.Text := '150';
 Edit8.Text := '679'+{FormatSettings.}DecimalSeparator+'19';
 TAUX_N;
// Edit10.Text := '0'+{FormatSettings.}DecimalSeparator+'19';
// Edit13.Text := '0'+{FormatSettings.}DecimalSeparator+'19';
 end else
 begin
  chkbxChoise.Caption := 'Calcule Ancien';  //22
 edit4.Text := '131'+{FormatSettings.}DecimalSeparator+'10';
 edit5.Text := '85'+{FormatSettings.}DecimalSeparator+'50';
 Edit7.Text := '75';
 Edit8.Text := '600';
 TAUX_A;
// 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.Label18.Caption := 'Index Nouveau';
  Form1.Label19.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'+{FormatSettings.}DecimalSeparator+'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% -----------------//
  TAUX_N;
 //--------  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'+{FormatSettings.}DecimalSeparator+'66';  // Primes Fixes Elec
  form1.Edit5.Text := '85'+{FormatSettings.}DecimalSeparator+'50';  // Primes Fixes Gaz
  form1.Edit6.Text := '100';    // DRIOT FIXE
  form1.Edit7.Text := '150';    // TAXE HABITATION
  form1.Edit8.Text := '679'+{FormatSettings.}DecimalSeparator+'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;

procedure TForm1.TAUX_N;
begin
 //--------  TAUX% -----------------//
 Form1.Edit9.Text := '0'+{FormatSettings.}DecimalSeparator+'09';
 Form1.Edit10.Text := '0'+{FormatSettings.}DecimalSeparator+'19';
 Form1.Edit11.Text := '0'+{FormatSettings.}DecimalSeparator+'09';
 Form1.Edit12.Text := '0'+{FormatSettings.}DecimalSeparator+'09';
 Form1.Edit13.Text := '0'+{FormatSettings.}DecimalSeparator+'19';
 Form1.Edit14.Text := '0'+{FormatSettings.}DecimalSeparator+'09';
end;

procedure TForm1.TAUX_A;
begin
 //--------  TAUX% -----------------//
 Form1.Edit9.Text := '0'+{FormatSettings.}DecimalSeparator+'07';
 Form1.Edit10.Text := '0';
 Form1.Edit11.Text := '0'+{FormatSettings.}DecimalSeparator+'07';
 Form1.Edit12.Text := '0'+{FormatSettings.}DecimalSeparator+'07';
 Form1.Edit13.Text := '0';
 Form1.Edit14.Text := '0'+{FormatSettings.}DecimalSeparator+'07';
end;

end.



-----------------------
الوحدة الثانية
-----------------------

اسم الملف
untCalcGazElec.pas

الكود:

unit untCalcGazElec;

interface

uses
  untCalcGazElecs, SysUtils;

type
  TGazElecClassic = class
  procedure Elec(tc0: real; var tc1, tc2, tc3: real); overload;
  procedure Gaz(gcs: real; var gc1, gc2, gc3: real); overload;
  function CalcTraElec(tco, tco1: real; t1: word): real; virtual;
  function CalcTraGaz(gco, gco1: real; g1: word): real; virtual;
  end;

  TGazElec = class(TGazElecClassic)
  procedure Elec(tc0: real; var tc1, tc2, tc3, tc4: real); overload;
  procedure Gaz(gcs: real; var gc1, gc2, gc3, gc4: real); overload;
  function CalcTraElec(tco, tco1: real; t1: word): real; override;
  function CalcTraGaz(gco, gco1: real; g1: word): real; override;
  end;

  TCusGaEl = class(TGaEl)
  private
  fTAUX: Real;
  fMontant: Real;
  fTVA: Real;
  fVale: Real;
  protected
  procedure SetGazEle1(const Vale: Real); override;
  procedure SetGazEle2(const Vale: Real); override;
  procedure SetGazEle3(const Vale: Real); override;
  procedure SetGazEle4(const Vale: Real); override;
  function GetGazEle1: real; override;
  function GetGazEle2: real; override;
  function GetGazEle3: real; override;
  function GetGazEle4: real; override;
  public
  function TVA1: real; override;
  function Totg: Real; override;
  end;
  TCusGaElClass = class of TCusGaEl;
  function FonctionGazElecClass: TCusGaElClass;

  function SousGazElec(InNouveau, InAncien: Integer): string;
  function MulGazElecCoef(Difference, COEF: Real): real;
 
implementation

function SousGazElec(InNouveau, InAncien: Integer): string;
begin
 Result := IntToStr(InNouveau-InAncien);
end;

function MulGazElecCoef(Difference, COEF: Real): real;
begin
 Result := Difference*COEF;
end;

{ TGazElec }

function TGazElec.CalcTraElec(tco, tco1: real; t1: word): real;
const
  PremierTranchePrix = 1.7787;
  DeuxiemeTranchePrix = 4.1789;
  TroisiemeTranchePrix = 4.8120;
  QuatriemeTranchePrix = 5.4796;
begin
 if t1 = 2 then    //tco+tco1 > 250
  Result := tco*TroisiemeTranchePrix+tco1*QuatriemeTranchePrix
 else Result := tco*PremierTranchePrix+tco1*DeuxiemeTranchePrix;

end;

function TGazElec.CalcTraGaz(gco, gco1: real; g1: word): real;
const
  PremierTranchePrix = 0.1682;
  DeuxiemeTranchePrix = 0.3245;
  TroisiemeTranchePrix = 0.4025;
  QuatriemeTranchePrix = 0.4599;
begin
 if g1 = 1 then    //gco+gco1 <= 2500
  Result := gco*PremierTranchePrix+gco1*DeuxiemeTranchePrix
 else Result := gco*TroisiemeTranchePrix+gco1*QuatriemeTranchePrix
end;

procedure TGazElec.Elec(tc0: real; var tc1, tc2, tc3, tc4: real);
const
  tcom1 = 125; tcom3 = 750;
procedure test1;
begin
  tc1 := tcom1;
  tc2 := tc0 - tc1;
end;

procedure test2;
begin
  tc3 := tc2 - tc1;
  tc2 := tc1;
end;

procedure test3;
begin
  tc4 := tc3 - tcom3;
  tc3 := tcom3;
end;

begin
  tc1 := 0; tc2 := 0;
  tc3 := 0; tc4 := 0;
  if tc0 > tcom1 then
  begin
  test1;
  if tc2 > tc1 then
  begin
    test2;
    if tc3 > tcom3 then
    begin
    test3;
    end;
  end;
  end else tc1 := tc0;
end;

procedure TGazElec.Gaz(gcs: real; var gc1, gc2, gc3, gc4: real);
const
 gcom1 = 1125; gcom2 = 1375; gcom3 = 5000;
begin
  gc1 := 0; gc2 := 0;
  gc3 := 0; gc4 := 0;
  if gcs > gcom1 then
  begin
    gc1 := gcom1;
    gc2 := gcs - gc1;
    if gc2 > gcom2 then
    begin
      gc3 := gc2 - gcom2;
      gc2 := gcom2;
      if gc3 > gcom3 then
      begin
          gc4 := gc3 - gcom3;
          gc3 := gcom3;
      end;
    end;
  end else gc1 := gcs;
end;

{ TGazElecClassic }

function TGazElecClassic.CalcTraElec(tco, tco1: real; t1: word): real;
const
  PremierTranchePrix = 1.779;
  DeuxiemeTranchePrix = 4.179;
  TroisiemeTranchePrix = 4.8120;
begin
 if tco1 > 0 then
  Result := tco*PremierTranchePrix+tco1*DeuxiemeTranchePrix
 else Result := tco*DeuxiemeTranchePrix;
end;

function TGazElecClassic.CalcTraGaz(gco, gco1: real; g1: word): real;
const
  PremierTranchePrix = 0.168;
  DeuxiemeTranchePrix = 0.324;
  TroisiemeTranchePrix = 0.402;
begin
  if gco1 > 0 then
  Result := gco*PremierTranchePrix+gco1*DeuxiemeTranchePrix
  else Result := gco*DeuxiemeTranchePrix;
end;

procedure TGazElecClassic.Elec(tc0: real; var tc1, tc2, tc3: real);
const
  tcom1 = 125; tcom = 875;
begin
  tc1 := 0; tc2 := 0;
  tc3 := 0;
  if tc0 > tcom1 then
  begin
  tc1 := tcom1;
  tc2 := tc0 - tc1;
  if tc2 > tcom then
  begin
    tc3 := tc2-tcom;
    tc2 := tc1+tcom;
  end; {}
  end else tc1 := tc0;
end;

procedure TGazElecClassic.Gaz(gcs: real; var gc1, gc2, gc3: real);
const
 gcom1 = 1125; gcom2 = 8875;
begin
  gc1 := 0; gc2 := 0;
  gc3 := 0;
  if gcs > gcom1 then
  begin
    gc1 := gcom1;
    gc2 := gcs - gc1;
    if gc2 > gcom2 then
    begin
        gc3 := gc2-gcom2;
        gc2 := gc1+gcom2;
    end;{}
  end else gc1 := gcs;
end;

{ TCusGaEl }

function TCusGaEl.GetGazEle1: real;
begin
  Result := fTAUX;
end;

function TCusGaEl.GetGazEle2: real;
begin
  Result := fMontant;
end;

function TCusGaEl.GetGazEle3: real;
begin
  Result := fTVA;
end;

function TCusGaEl.GetGazEle4: real;
begin
  Result := fVale;
end;

procedure TCusGaEl.SetGazEle1(const Vale: Real);
begin
  inherited;
  fTAUX := Vale;
end;

procedure TCusGaEl.SetGazEle2(const Vale: Real);
begin
  inherited;
  if Vale > 0 then
    fMontant := Vale
    else fMontant := 0;
end;

procedure TCusGaEl.SetGazEle3(const Vale: Real);
begin
  inherited;
  fTVA := Vale;
end;

procedure TCusGaEl.SetGazEle4(const Vale: Real);
begin
  inherited;
  fVale := Vale;
end;

function TCusGaEl.Totg: Real;
begin
  Result := fMontant+fTVA;  //fVale
end;

function TCusGaEl.TVA1: real;
begin
  Result := fMontant*fTAUX;
end;

function FonctionGazElecClass: TCusGaElClass;
begin
  Result := TCusGaEl;
end;


end.






----------------------
الوحدة الثاثة
----------------------

اسم الملف
untCalcGazElecs.pas

الكود:

unit untCalcGazElecs;

interface

type
 TGaEl = class
  protected
  procedure SetGazEle1(const Vale: Real); virtual; abstract;
  procedure SetGazEle2(const Vale: Real); virtual; abstract;
  procedure SetGazEle3(const Vale: Real); virtual; abstract;
  procedure SetGazEle4(const Vale: Real); virtual; abstract;
  function GetGazEle1: real; virtual; abstract;
  function GetGazEle2: real; virtual; abstract;
  function GetGazEle3: real; virtual; abstract;
  function GetGazEle4: real; virtual; abstract;
  public
  function TVA1: real; virtual; abstract;
  function Totg: Real; virtual; abstract;
  property TAUX: real read GetGazEle1 write SetGazEle1;
  property Montant: real read GetGazEle2 write SetGazEle2;
  property TVA: real read GetGazEle3 write SetGazEle3;
  property Value: real read GetGazEle4 write SetGazEle4;
 end;
 
implementation

end.


ali
مبرمج مجتهد

عدد المساهمات : 913
تاريخ التسجيل : 29/07/2013

الرجوع الى أعلى الصفحة اذهب الى الأسفل

برنامج حساب الغاز والكهربة نسخة 3 Empty رد: برنامج حساب الغاز والكهربة نسخة 3

مُساهمة  ali 19/5/2018, 3:25 pm

تحميل برنامج الكهربة والغاز
http://www.mediafire.com/file/oib0dxarypvd2ro/g_e.rar

ali
مبرمج مجتهد

عدد المساهمات : 913
تاريخ التسجيل : 29/07/2013

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

- مواضيع مماثلة

 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى