unit Unit21;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, sComboBox, Buttons, sBitBtn, acPNG,
  ExtCtrls, acImage, sLabel, sPanel;
type
  TForm21=class(TForm)
    sPanel1: TsPanel;
    sLabelFX1: TsLabelFX;
    sLabelFX2: TsLabelFX;
    sImage1: TsImage;
    sPanel2: TsPanel;
    sBitBtn5: TsBitBtn;
    sBitBtn6: TsBitBtn;
    sComboBox1: TsComboBox;
    sComboBox2: TsComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    sLabelFX3: TsLabelFX;
    sImage2: TsImage;
    procedure sBitBtn6Click(Sender : TObject);
    procedure sBitBtn5Click(Sender : TObject);
    procedure FormShow(Sender : TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form21: TForm21;

{This file is generated by DelphiDecompiler version 1.1 Copyright (c) 1997-2009 BitMaker}

implementation
         uses Unit2, DB;
{$R *.DFM}

procedure TForm21.sBitBtn6Click(Sender : TObject);
var
  test:Boolean; //[ebp-0C]
  s:string;
  i:Integer;
  procedure CalculRend;
  begin
   with Data do begin
        {
        ciapp.Append;
        ciappNum_emp.AsInteger:= empNum_empl.AsInteger; //i; //gvar_006B3574
        if(empIst_po_su.AsInteger = 0)then
        ciappIst_r.AsString := empIstidlali.AsString+'+'+empIs_daraja.AsString
        else
          if(empIs_daraja.AsInteger = 0) then
            ciappIst_r.AsString := empIstidlali.AsString+'+'+empIst_po_su.AsString
          else
            ciappIst_r.AsString := empIstidlali.AsString+'+'+empIst_po_su.AsString+'+'+empIs_daraja.AsString;
        rond.Last;
        rondRond.AsInteger;
        ciappPercent.AsString:=rondRond.AsString+'%';
        ciappNom_prnom.AsString :=empNom_prenom.AsString;
        ciappRotba.AsString:=empRotba.AsString;
        ciappN_compt.AsString:=empN_compt.AsString;
        ciappIs_daraj.AsString:=empIs_daraja.AsString;
        ciappSINF.AsString := empSinf.AsString;
        ciappBank.AsString := empWakala_cb.AsString;
        ciappMejmou_kham.AsFloat:=rondRond.AsInteger/100*(empIs_daraja.AsInteger+empIstidlali.AsInteger)*3*45;
        //ShowMessage(empIs_daraja.AsString + ':'+empIstidlali.AsString +':'+ciappMejmou_kham.AsString);
        ciappRond.AsFloat := ciappMejmou_kham.AsFloat;
        ciappDamane.AsFloat:=ciappMejmou_kham.AsFloat*0.09;
        ciappDariba.AsFloat:= (ciappMejmou_kham.AsFloat-ciappDamane.AsFloat)*0.1;
        ciappNet.AsFloat:= ciappMejmou_kham.AsFloat-ciappDamane.AsFloat-ciappDariba.AsFloat;
        ciapp.Post;
        ttrnd.Edit;
        ttrndIapp_cc.Value:=ciappMejmou_kham.Value;
        ttrndIapp_cc2375.Value:=ttrndIapp_cc2375.Value+ciappMejmou_kham.Value*0.2375;
        ttrndIapp_cc1.Value:=ttrndIapp_cc1.Value+ciappMejmou_kham.Value*0.01;
        ttrndIapp_cc0025.Value:=ttrndIapp_cc0025.Value+ciappMejmou_kham.Value*0.0025;
        ttrndIapp_cc25.Value:=ttrndIapp_cc25.Value+ciappMejmou_kham.Value*0.25;
        ttrndDariba.Value:=ttrndDariba.Value+ciappDariba.Value;
        ttrndTt_9.Value:=ttrndTt_9.Value+ciappDamane.Value;
        ttrnd.Post;
   end;
  end;
  procedure init_ttrnd;
  begin
    with Data do begin
      ttrnd.Append;
      ttrndAnne.AsString:=sComboBox1.Text;
      ttrndSem.AsString:=sComboBox2.Text;
      ttrndAnne_sem.AsString:=s;
      ttrndIapp_cc.AsFloat := 0;
      ttrndIapp_p.AsFloat := 0;
      ttrndIapg.AsFloat := 0;
      ttrndIapp_cc25.AsFloat := 0;
      ttrndIapp_cc2375.AsFloat := 0;
      ttrndIapp_cc0025.AsFloat := 0;
      ttrndIapp_p25.AsFloat := 0;
      ttrndIapp_p2375.AsFloat := 0;
      ttrndIapp_p1.AsFloat := 0;
      ttrndIapp_p0025.AsFloat := 0;
      ttrndIapg_25.AsFloat := 0;
      ttrndIapg_2375.AsFloat := 0;
      ttrndIapg_1.AsFloat := 0;
      ttrndIapg_0025.AsFloat := 0;
      ttrndDariba.AsFloat := 0;
      ttrndTt_9.AsFloat := 0;
      ttrndTt_per.AsFloat := 0;
      ttrndIapp_cc1.AsFloat := 0;
      ttrnd.Post;}
    end;
  end;

  procedure RecherchBank(text:String);
  var
    Recherche : Boolean;
  begin
    Recherche := False;
     with Data do begin
      {  iapb.First;
        while(not iapb.Eof)do begin
          if(iapbTyp_rnd.AsString = text)then begin
            Recherche := True;
            Break;
          end;
          iapb.Next;
        end;
        if(not Recherche)then begin
          iapb.append;
          iapbBank.AsString := empWakala_cb.AsString+' '+text;
          iapbTyp_rnd.AsString :=text;
          iapbDamane.Value:=0;
          iapbDariba.Value:=0;
          iapbNet.Value:=0;
          iapbMejmou_kham.Value:=0;
          iapbRond.Value:=0;
          iapbIk.Value:=0;
          iapb.Post;
        end; }
     end;
  end;
  procedure ReCalcul;
  begin
    // iapp.Filter:='Bank='''+bankBank.AsString+'*''';
    with Data do begin
        //iapb
       { iapb.Edit;
        iapbDamane.Value := iapbDamane.Value+ iappgDamane.Value;
        iapbDariba.Value:= iapbDariba.Value+ iappgDariba.Value;
        iapbNet.Value:= iapbNet.Value+ iappgNet.Value;
        iapbMejmou_kham.Value := iapbMejmou_kham.Value + iappgMejmou_kham.Value;
        iapbRond.Value:= iapbRond.Value+ iappgRond.Value;
        iapbIk.Value:= iapbIk.Value+ iappgDariba.Value+iappgDamane.Value;
        iapb.Post;
        //ttrnd :
       (* ttrnd.Edit;
        ttrndTt_iap.asfloat:= ttrndIapp_p.asfloat+ttrndIapp_cc.asfloat+ttrndIapg.asfloat;
        ttrndTt_2375.Value:=ttrndIapp_cc2375.Value+ttrndIapg_2375.Value;
        ttrndTt_1.Value:=ttrndIapp_p1.Value+ttrndIapp_cc1.Value+ttrndIapg_1.Value;
        ttrndTt_0025.Value:=ttrndIapp_p0025.Value+ttrndIapp_cc0025.Value+ttrndIapg_0025.Value;
        ttrndTt_25.Value:=ttrndIapp_p25.Value+ttrndIapp_cc25.Value+ttrndIapg_25.Value;
        ttrndD_9.Value:=ttrndTt_9.Value;
        ttrndS_9.Value:=ttrndTt_9.Value;
        ttrndS_9.Value:=ttrndS_9.Value;
        ttrndD_25.Value:=int(ttrndS_9.Value);
        ttrndS_28.Value:=Frac(ttrndTt_25.Value);
        ttrndTt_ik.Value:=ttrndDariba.Value+ttrndTt_9.Value;
        ttrndTt_per.Value:=ciapp.RecordCount;
        ttrnd.Post;*) }
    end;
  end;
begin
  //0065D084
  s:=sComboBox2.Text+' '+sComboBox1.Text;
  with data do begin
   { Test:=False;
    ttrnd.First;
    while (not ttrnd.Eof ) do begin
       if(ttrndAnne_sem.AsString = s)then  Test:=True;
       ttrnd.Next;
    end;
    if(Test) then begin
      sLabelFX3.Visible :=True;
      sImage2.Visible := True;
    end
    else begin
      sLabelFX3.Visible :=False;
      sImage2.Visible := False;
      init_ttrnd;
      i:=0;  //gvar_006B3574
      emp.First;
      while(not emp.Eof) do begin
        rond.Last;
        if(not ((rondAnne.AsString = ttrndAnne.AsString)and
          (rondSem_rand.AsString = ttrndSem.AsString))) then begin
            ShowMessage('‰ﬁ«ÿ «·⁄„«· €Ì— „œŒ·…');
            Exit;
          end;
        CalculRend;
        if(empSilk.AsString = '«· ﬂÊÌ‰ Ê«· ⁄·Ì„ «·„Â‰Ì' ) then begin
          if(empCho3ba.AsString <> '«·„ﬁ ’œÌ…' ) then begin
            RecherchBank(' Õ”Ì‰ «·√œ«¡ «·»Ìœ«€ÊÃÌ');
              iappf.append;
              for I := 1 to ciapp.FieldCount - 1 do  begin
                if(iappf.Fields[I].FieldName <> 'F_iapb')then
                iappf.Fields[I].Value:=ciapp.Fields[I].Value;
              end;
              iappf.Post;
          end
          else
          begin
            RecherchBank(' Õ”Ì‰ «·√œ«¡ ›Ì «· ”ÌÌ—');
              iappg.append;
              for I := 1 to ciapp.FieldCount - 1 do  begin
                if(iappg.Fields[I].FieldName <> 'F_iapb')then
                iappg.Fields[I].Value:=ciapp.Fields[I].Value;
              end;
              iappg.Post;

          end;
        end //0065DA46
        else if(empSilk.AsString = '«·⁄„«· „Â‰‹ Ê”«∆ﬁÌ ” Ê«·ÕÃ«»' ) then begin //0065E817
            RecherchBank('«·„—œÊœÌ…');
              iappc.append;
              for I := 1 to ciapp.FieldCount - 1 do  begin
                if(iappc.Fields[I].FieldName <> 'F_iapb')then
                iappc.Fields[I].Value:=ciapp.Fields[I].Value;
              end;
              iappc.Post;

        end
        else if(empSilk.AsString = '«·√”·«ﬂ «·„‘ —ﬂ…') then begin //0065EF1C
           RecherchBank('«·„—œÊœÌ…');
              iappc.append;
              for I := 1 to ciapp.FieldCount - 1 do  begin
                if(iappg.Fields[I].FieldName <> 'F_iapb')then
                iappg.Fields[I].Value:=ciapp.Fields[I].Value;
              end;
              iappc.Post;

        end;
       ReCalcul;
       emp.Next;
      end;
      ciapp.First;
      while (not ciapp.Eof) do begin
        if(ciappMejmou_kham.AsFloat = 0 ) then
          ciapp.Delete
        else
        ciapp.Next;
      end; //00661BD1
      if(ttrndDariba.AsFloat = 0)then ttrnd.Delete
    end;}
  end;
 Close;
end;

procedure TForm21.sBitBtn5Click(Sender : TObject);
begin
  Close;
end;

procedure TForm21.FormShow(Sender : TObject);
var
  Annee:Integer;
  Trimestre : string;
  function ordre(Trim : String):Integer;
  begin
    if(Trim= '«·√Ê·') then Result :=1;
    if(Trim= '«·À«‰Ì') then Result :=2;
    if(Trim= '«·À«·À') then Result :=3;
    if(Trim= '«·—«»⁄') then Result :=4;
  end;
begin
  //00662108
  Annee:=0;
  //recherche derniere annee et Trimestre :
  with Data do begin
    {ABSemp.First;
     while (not emp.Eof) do begin
       rond.Last;
       if(Annee<rondAnne.AsInteger) then begin
          Annee:=rondAnne.AsInteger;
          Trimestre:=rondSem_rand.AsString;
       end
       else if(Annee=rondAnne.AsInteger) then begin
          if(ordre(Trimestre)<ordre(rondSem_rand.AsString)) then
           Trimestre := rondSem_rand.AsString;
       emp.next;
     end;
    end; }
    ShowMessage('derniere Traitement :'+inttostr(Annee)+' '+Trimestre);
  end;

end;
end.