unit udataprix;

interface

uses
  SysUtils, Classes, DB, IBCustomDataSet, IBUpdateSQL,Messages, IBQuery,IniFiles,  Dialogs,
  Forms, IBDatabase;

type
  TDataprix = class(TDataModule)
    idataprix: TIBDatabase;
    IBTransaction1: TIBTransaction;
    societe: TIBQuery;
    societeupd: TIBUpdateSQL;
    ctegorie: TIBQuery;
    categorieupd: TIBUpdateSQL;
    ctegorieCODE: TIBStringField;
    ctegorieLIBELLE: TIBStringField;
    devise: TIBQuery;
    deviseupd: TIBUpdateSQL;
    deviseDEVISE: TIBStringField;
    deviseLIBELLE: TIBStringField;
    Etatterritorial: TIBQuery;
    Etatterritorialupd: TIBUpdateSQL;
    EtatterritorialCODE: TIBStringField;
    EtatterritorialPAYS: TIBStringField;
    capitallie: TIBQuery;
    capitallieupd: TIBUpdateSQL;
    capitallieMFISCAL: TIBStringField;
    capitallieEXERCICE: TIntegerField;
    capitallieLG: TIntegerField;
    capitallieMFISCALLIE: TIBStringField;
    capitallieAUTREIDENTIFIANT: TIBStringField;
    capitallieETATTERRITOIRE: TIBStringField;
    capitallieRAISONSOCIALE: TIBStringField;
    capitallieQUALITE: TIBStringField;
    capitallieAUTREQUALITE: TIBStringField;
    capitalliePOURCENTCAPITAL: TIBBCDField;
    capitalliePOURVENVOTE: TIBBCDField;
    Capitaldeclarante: TIBQuery;
    Capitaldeclaranteupd: TIBUpdateSQL;
    CapitaldeclaranteMFISCAL: TIBStringField;
    CapitaldeclaranteEXERCICE: TIntegerField;
    CapitaldeclaranteLG: TIntegerField;
    CapitaldeclaranteMFISCALLIE: TIBStringField;
    CapitaldeclaranteAUTREIDENTIFIANT: TIBStringField;
    CapitaldeclaranteETATTERRITOIRE: TIBStringField;
    CapitaldeclaranteRAISONSOCIALE: TIBStringField;
    CapitaldeclaranteQUALITE: TIBStringField;
    CapitaldeclaranteAUTREQUALITE: TIBStringField;
    CapitaldeclarantePOURCENTCAPITAL: TIBBCDField;
    CapitaldeclarantePOURVENVOTE: TIBBCDField;
    QueryMaxNumero: TIBQuery;
    QueryMaxNumeroMAXNUMERO: TIntegerField;
    DSSOCIETE: TDataSource;
    INFOGROUPE: TIBQuery;
    INFOGROUPEUPD: TIBUpdateSQL;
    actifincorporel: TIBQuery;
    actifincorporelupd: TIBUpdateSQL;
    Actifcorporel: TIBQuery;
    Actifcorporelupd: TIBUpdateSQL;
    actifincorporelMFISCAL: TIBStringField;
    actifincorporelEXERCICE: TIntegerField;
    actifincorporelLG: TIntegerField;
    actifincorporelNATUREACTIF: TIBStringField;
    actifincorporelAUTRENATURE: TIBStringField;
    actifincorporelONEREUXGRATUIT: TIBStringField;
    actifincorporelMATRICULEFISCAL: TIBStringField;
    actifincorporelAUTREIDENTIFIANT: TIBStringField;
    actifincorporelTERRITOIRE: TIBStringField;
    actifincorporelRAISONSOCIALE: TIBStringField;
    actifincorporelQUALITE: TIBStringField;
    actifincorporelAUTREQUALITE: TIBStringField;
    actifincorporelNATURERELATION: TIBStringField;
    actifincorporelAUTRESNATURE: TIBStringField;
    ActifcorporelMFISCAL: TIBStringField;
    ActifcorporelEXERCICE: TIntegerField;
    ActifcorporelLG: TIntegerField;
    ActifcorporelNATUREACTIF: TIBStringField;
    ActifcorporelAUTRENATURE: TIBStringField;
    ActifcorporelMATRICULEFISCAL: TIBStringField;
    ActifcorporelAUTREIDENTIFIANT: TIBStringField;
    ActifcorporelTERRITOIRE: TIBStringField;
    ActifcorporelRAISONSOCIALE: TIBStringField;
    ActifcorporelQUALITE: TIBStringField;
    ActifcorporelAUTREQUALITE: TIBStringField;
    ActifcorporelNATURERELATION: TIBStringField;
    ActifcorporelAUTRESNATURE: TIBStringField;
    montanttransactions: TIBQuery;
    montanttransactionsupd: TIBUpdateSQL;
    Empruntsprets: TIBQuery;
    Empruntspretsupd: TIBUpdateSQL;
    operationssanscontre: TIBQuery;
    operationssanscontreupd: TIBUpdateSQL;
    operationssanscontreMFISCAL: TIBStringField;
    operationssanscontreEXERCICE: TIntegerField;
    operationssanscontreLG: TIntegerField;
    operationssanscontreMATRICULEFISCAL: TIBStringField;
    operationssanscontreAUTREIDENTIFIANT: TIBStringField;
    operationssanscontreETATTERRITORIAL: TIBStringField;
    operationssanscontreRAISONSOCIALE: TIBStringField;
    operationssanscontreQUALITE: TIBStringField;
    operationssanscontreAUTREQUALITE: TIBStringField;
    operationssanscontreNATURERELATION: TIBStringField;
    operationssanscontreAUTRENATURE: TIBStringField;
    operationssanscontreNATUREBIENSERVICE: TIBStringField;
    operationssanscontreNATURECONTREPARTIE: TIBStringField;
    operationsaccord: TIBQuery;
    operationsaccordupd: TIBUpdateSQL;
    montanttransactionsCONTROLE: TIBQuery;
    montanttransactionsCONTROLEMFISCAL: TIBStringField;
    montanttransactionsCONTROLEEXERCICE: TIntegerField;
    montanttransactionsCONTROLELG: TIntegerField;
    montanttransactionsCONTROLETYPEMONTANT: TIBStringField;
    montanttransactionsCONTROLENATUREOPERATIONS: TIBStringField;
    montanttransactionsCONTROLEAUTRESNATURESOPERATIONS: TIBStringField;
    montanttransactionsCONTROLEACHATS: TIBBCDField;
    montanttransactionsCONTROLEVENTES: TIBBCDField;
    montanttransactionsCONTROLEMATRICULEFISCAL: TIBStringField;
    montanttransactionsCONTROLEAUTREIDENTIFIANT: TIBStringField;
    montanttransactionsCONTROLEETATTERRITORIAL: TIBStringField;
    montanttransactionsCONTROLERAISONSOCIALE: TIBStringField;
    montanttransactionsCONTROLEQUALITE: TIBStringField;
    montanttransactionsCONTROLEAUTREQUALITE: TIBStringField;
    montanttransactionsCONTROLENATURRELATION: TIBStringField;
    montanttransactionsCONTROLEAUTRENATURERELATIONS: TIBStringField;
    montanttransactionsCONTROLEMETHODE: TIBStringField;
    montanttransactionsCONTROLEAUTREMETHODE: TBlobField;
    montanttransactionsCONTROLECHANGEMENTMETHODE: TIBStringField;
    montanttransactionsCONTROLECHANGEMENTAUTREMETRHODE: TIBStringField;
    EmpruntspretsMFISCAL: TIBStringField;
    EmpruntspretsEXERCICE: TIntegerField;
    EmpruntspretsLG: TIntegerField;
    EmpruntspretsTYPEPRETEMPRUNT: TIBStringField;
    EmpruntspretsMATRICULEFISCAL: TIBStringField;
    EmpruntspretsAUTREIDENTIFIANT: TIBStringField;
    EmpruntspretsETATTERRITORIAL: TIBStringField;
    EmpruntspretsRAISONSOCIALE: TIBStringField;
    EmpruntspretsQUALITE: TIBStringField;
    EmpruntspretsAUTREQUALITE: TIBStringField;
    EmpruntspretsNATURERELATION: TIBStringField;
    EmpruntspretsAUTRENATURE: TIBStringField;
    EmpruntspretsSOLDEOUVERTURE: TIBBCDField;
    EmpruntspretsDEVISE: TIBStringField;
    EmpruntspretsAUGMENTATIONS: TIBBCDField;
    EmpruntspretsDIMINUTIONS: TIBBCDField;
    EmpruntspretsSOLDECLOTURE: TIBBCDField;
    EmpruntspretsPRETINTERET: TIBStringField;
    EmpruntspretsTAUXINTERET: TIBBCDField;
    operationssanscontreAVECCONTREOUINON: TIBStringField;
    societeMFISCAL: TIBStringField;
    societeCLE: TIBStringField;
    societeEXERCICE: TIntegerField;
    societeTVA: TIBStringField;
    societeCATEGORIE: TIBStringField;
    societeRAISONSOCIALE: TIBStringField;
    societeFORMEJURIDIQUE: TIBStringField;
    societeNATIONALITE: TIBStringField;
    societeADRESSE: TIBStringField;
    societeCODEPOSTAL: TIntegerField;
    societeACTIVITEPRINCIPALE: TIBStringField;
    societeACTIVITESECONDAIRE: TIBStringField;
    societeDATEDEBUT: TDateField;
    societeDATEFIN: TDateField;
    societeCHIFFREAFFAIREANNUEL: TIBBCDField;
    societeQUALITE: TIBStringField;
    societeAUTRESQUALITE: TIBStringField;
    societeDESCRIPTIONACTIVITESPRINCIPALES: TBlobField;
    societeAFFIRMATION: TIBStringField;
    societeDESCRIPTION: TBlobField;
    societeCODEACTE: TIBStringField;
    societeTYPEDECLARATION: TIBStringField;
    societeNATUREDATEFIN: TIBStringField;
    societeAUTRESINFORMATIONS: TBlobField;
    societeAFFIRMATIONCHANGEMENTCAPITAL: TIBStringField;
    societeDESCRIPTIONCHANGCAPITAL: TBlobField;
    societeDESCRIPTIONREGIMEFISCAL: TBlobField;
    societeAFFIRMATIONBIENSERVICE: TIBStringField;
    societeAFFIRMATIONBIENSERVICEAVECCONTR: TIBStringField;
    societeAFFIRMATIONACCORDPREALABLE: TIBStringField;
    operationsaccordMFISCAL: TIBStringField;
    operationsaccordEXERCICE: TIntegerField;
    operationsaccordLG: TIntegerField;
    operationsaccordMATRICULEFISCAL: TIBStringField;
    operationsaccordAUTREIDENTIFIANT: TIBStringField;
    operationsaccordETATTERRITORIAL: TIBStringField;
    operationsaccordRAISONSOCIALE: TIBStringField;
    operationsaccordQUALITE: TIBStringField;
    operationsaccordAUTREQUALITE: TIBStringField;
    operationsaccordNATURERELATION: TIBStringField;
    operationsaccordAUTRENATURE: TIBStringField;
    operationsaccordNATUREOPERATION: TIBStringField;
    operationsaccordEXERCICEDEBUT: TIntegerField;
    operationsaccordEXERCICEFIN: TIntegerField;
    montanttransactionsMFISCAL: TIBStringField;
    montanttransactionsEXERCICE: TIntegerField;
    montanttransactionsLG: TIntegerField;
    montanttransactionsTYPEMONTANT: TIBStringField;
    montanttransactionsAUTRESNATURESOPERATIONS: TIBStringField;
    montanttransactionsACHATS: TIBBCDField;
    montanttransactionsVENTES: TIBBCDField;
    montanttransactionsMATRICULEFISCAL: TIBStringField;
    montanttransactionsAUTREIDENTIFIANT: TIBStringField;
    montanttransactionsETATTERRITORIAL: TIBStringField;
    montanttransactionsRAISONSOCIALE: TIBStringField;
    montanttransactionsQUALITE: TIBStringField;
    montanttransactionsAUTREQUALITE: TIBStringField;
    montanttransactionsNATURRELATION: TIBStringField;
    montanttransactionsAUTRENATURERELATIONS: TIBStringField;
    montanttransactionsMETHODE: TIBStringField;
    montanttransactionsAUTREMETHODE: TBlobField;
    montanttransactionsCHANGEMENTMETHODE: TIBStringField;
    montanttransactionsCHANGEMENTAUTREMETRHODE: TIBStringField;
    INFOGROUPEMFISCAL: TIBStringField;
    INFOGROUPEEXERCICE: TIntegerField;
    INFOGROUPEMFISCALMERE: TIBStringField;
    INFOGROUPEAUTREMFISCAL: TIBStringField;
    INFOGROUPEETATTERRITORIAL: TIBStringField;
    INFOGROUPERAISONSOCIALE: TIBStringField;
    INFOGROUPEADRESSE: TIBStringField;
    INFOGROUPEDESCRIPTIONACTIVITE: TBlobField;
    INFOGROUPEDESCRIPTIONPOLITIQUE: TBlobField;
    INFOGROUPEAFFIRMATOINRESTRUCTURATION: TIBStringField;
    INFOGROUPEDESCRIPTIONRESTRUCTURATION: TBlobField;
    montanttransactionsNATUREOPERATIONS: TIBStringField;
    procedure societeAfterPost(DataSet: TDataSet);
    procedure societeAfterDelete(DataSet: TDataSet);
    procedure ctegorieAfterDelete(DataSet: TDataSet);
    procedure ctegorieAfterPost(DataSet: TDataSet);
    procedure deviseAfterDelete(DataSet: TDataSet);
    procedure deviseAfterPost(DataSet: TDataSet);
    procedure EtatterritorialAfterDelete(DataSet: TDataSet);
    procedure EtatterritorialAfterPost(DataSet: TDataSet);
    procedure DataModuleCreate(Sender: TObject);
    procedure capitallieAfterInsert(DataSet: TDataSet);
    procedure capitallieBeforePost(DataSet: TDataSet);
    procedure capitallieAfterDelete(DataSet: TDataSet);
    procedure capitallieAfterPost(DataSet: TDataSet);
    procedure CapitaldeclaranteAfterDelete(DataSet: TDataSet);
    procedure CapitaldeclaranteAfterPost(DataSet: TDataSet);
    procedure CapitaldeclaranteAfterInsert(DataSet: TDataSet);
    procedure CapitaldeclaranteBeforePost(DataSet: TDataSet);
    procedure INFOGROUPEAfterDelete(DataSet: TDataSet);
    procedure INFOGROUPEAfterPost(DataSet: TDataSet);
    procedure INFOGROUPEBeforePost(DataSet: TDataSet);
    procedure actifincorporelAfterDelete(DataSet: TDataSet);
    procedure actifincorporelAfterPost(DataSet: TDataSet);
    procedure actifincorporelAfterInsert(DataSet: TDataSet);
    procedure actifincorporelBeforePost(DataSet: TDataSet);
    procedure ActifcorporelAfterDelete(DataSet: TDataSet);
    procedure ActifcorporelAfterPost(DataSet: TDataSet);
    procedure ActifcorporelAfterInsert(DataSet: TDataSet);
    procedure ActifcorporelBeforePost(DataSet: TDataSet);
    procedure montanttransactionsAfterDelete(DataSet: TDataSet);
    procedure montanttransactionsAfterPost(DataSet: TDataSet);
    procedure montanttransactionsAfterInsert(DataSet: TDataSet);
    procedure montanttransactionsBeforePost(DataSet: TDataSet);
    procedure EmpruntspretsAfterDelete(DataSet: TDataSet);
    procedure EmpruntspretsAfterPost(DataSet: TDataSet);
    procedure EmpruntspretsAfterInsert(DataSet: TDataSet);
    procedure EmpruntspretsBeforePost(DataSet: TDataSet);
    procedure operationssanscontreAfterDelete(DataSet: TDataSet);
    procedure operationssanscontreAfterPost(DataSet: TDataSet);
    procedure operationssanscontreAfterInsert(DataSet: TDataSet);
    procedure operationssanscontreBeforePost(DataSet: TDataSet);
    procedure operationsaccordAfterPost(DataSet: TDataSet);
    procedure operationsaccordAfterDelete(DataSet: TDataSet);
    procedure operationsaccordAfterInsert(DataSet: TDataSet);
    procedure operationsaccordBeforePost(DataSet: TDataSet);
     
    
  private
    { Private declarations }
  public
    { Public declarations }
    Codesociete,Repertoireexcel:String;
    verif:integer;
  end;

var
  Dataprix: TDataprix;

implementation

uses uvalidation;

{$R *.dfm}

procedure TDataprix.societeAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.societeAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.ctegorieAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.ctegorieAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.deviseAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.deviseAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.EtatterritorialAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.EtatterritorialAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.DataModuleCreate(Sender: TObject);
  VAR MyIniFile: TIniFile;
 asResulta :String; nBR:integer;
begin
  //showmessage('ddddfdf');
  MyIniFile := TIniFile.Create('..\CheminBase.ini');
  asResulta := MyIniFile.ReadString('CheminBase','Rep', 'Vérifier le chemin de la base!');
  Repertoireexcel:=MyIniFile.ReadString('CheminBase','Modelessexcel', 'Répertoire excel non défini!');
  MyIniFile.Free;
  idataprix.Connected := false;
  idataprix.DatabaseName := asResulta + '\ICONEPRIXTRANSFERT.gdb';
  idataprix.Connected := true;

  if (not FileExists('\WINDOWSPR.LOG') ) then
  BEGIN
  montanttransactionsCONTROLE.Close;
  montanttransactionsCONTROLE.Open;
  montanttransactionsCONTROLE.Last;
  nbr:=montanttransactionsCONTROLE.RecNo;

  if nbr>=10 then
     begin
      ShowMessage('Votre Logiciel est bloqué, veuillez acquérir une licence, vous ne pouvez pas accéder à vos données qu''aprés validation' );
      application.CreateForm(tfrmvalidation,frmvalidation);
      frmvalidation.ShowModal;
      //Application.Terminate;
    end;
  END;
end;

procedure TDataprix.capitallieAfterInsert(DataSet: TDataSet);
  var nMaxNumero:integer  ;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(capitalliee.lg) as MaxNumero from capitalliee Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   capitallielg.NewValue:= nMaxNumero;


   capitallieMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
   capitallieEXERCICE.Value:=societeEXERCICE.Value;

end;

procedure TDataprix.capitallieBeforePost(DataSet: TDataSet);
begin
   capitallieMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
   capitallieEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.capitallieAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.capitallieAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.CapitaldeclaranteAfterDelete(DataSet: TDataSet);
begin
 idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.CapitaldeclaranteAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.CapitaldeclaranteAfterInsert(DataSet: TDataSet);
 var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(capitaldeclarante.lg) as MaxNumero from capitaldeclarante Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   capitaldeclarantelg.NewValue:= nMaxNumero;


   capitaldeclaranteMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
   capitaldeclaranteEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.CapitaldeclaranteBeforePost(DataSet: TDataSet);
begin
   CapitaldeclaranteMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
   CapitaldeclaranteEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.INFOGROUPEAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.INFOGROUPEAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.INFOGROUPEBeforePost(DataSet: TDataSet);
begin
 if not(INFOGROUPE.State in [dsedit,dsinsert]) then INFOGROUPE.Edit;
   INFOGROUPEMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
   INFOGROUPEEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.actifincorporelAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.actifincorporelAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.actifincorporelAfterInsert(DataSet: TDataSet);
  var nMaxNumero:integer  ;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(LISTEACTIFINCORPOREL.lg) as MaxNumero from LISTEACTIFINCORPOREL Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   actifincorporellg.NewValue:= nMaxNumero;


 actifincorporelMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 actifincorporelEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.actifincorporelBeforePost(DataSet: TDataSet);
begin
 actifincorporelMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 actifincorporelEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.ActifcorporelAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.ActifcorporelAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.ActifcorporelAfterInsert(DataSet: TDataSet);
var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(LISTEACTIFCORPOREL.lg) as MaxNumero from LISTEACTIFCORPOREL Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   Actifcorporellg.NewValue:= nMaxNumero;

 ActifcorporelMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 ActifcorporelEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.ActifcorporelBeforePost(DataSet: TDataSet);
begin
 ActifcorporelMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 ActifcorporelEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.montanttransactionsAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.montanttransactionsAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.montanttransactionsAfterInsert(DataSet: TDataSet);
 var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(OPERATIONSMONTANTS.lg) as MaxNumero from OPERATIONSMONTANTS Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   montanttransactionslg.NewValue:= nMaxNumero;

 montanttransactionsMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 montanttransactionsEXERCICE.Value:=societeEXERCICE.Value;
  
end;

procedure TDataprix.montanttransactionsBeforePost(DataSet: TDataSet);
begin
 if montanttransactionsACHATS.IsNull  then montanttransactionsACHATS.Value:=0;
 if montanttransactionsVENTES.IsNull  then montanttransactionsVENTES.Value:=0;
 montanttransactionsMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 montanttransactionsEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.EmpruntspretsAfterDelete(DataSet: TDataSet);
begin
 idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.EmpruntspretsAfterPost(DataSet: TDataSet);
begin
 idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.EmpruntspretsAfterInsert(DataSet: TDataSet);
   var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(OPERATIONPRETEMPRUNT.lg) as MaxNumero from OPERATIONPRETEMPRUNT Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   Empruntspretslg.NewValue:= nMaxNumero;

 EmpruntspretsMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 EmpruntspretsEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.EmpruntspretsBeforePost(DataSet: TDataSet);
begin
 EmpruntspretsMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 EmpruntspretsEXERCICE.Value:=societeEXERCICE.Value;
 if EmpruntspretsSOLDEOUVERTURE.IsNull  then EmpruntspretsSOLDEOUVERTURE.Value:=0;
 if EmpruntspretsAUGMENTATIONS.IsNull  then EmpruntspretsAUGMENTATIONS.Value:=0;
 if EmpruntspretsDIMINUTIONS.IsNull  then EmpruntspretsDIMINUTIONS.Value:=0;
 if EmpruntspretsSOLDECLOTURE.IsNull  then EmpruntspretsSOLDECLOTURE.Value:=0;
end;

procedure TDataprix.operationssanscontreAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.operationssanscontreAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.operationssanscontreAfterInsert(DataSet: TDataSet);
   var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(OPERATIONSANSCONTRE.lg) as MaxNumero from OPERATIONSANSCONTRE Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   operationssanscontrelg.NewValue:= nMaxNumero;

 operationssanscontreMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 operationssanscontreEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.operationssanscontreBeforePost(DataSet: TDataSet);
begin
 operationssanscontreMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 operationssanscontreEXERCICE.Value:=societeEXERCICE.Value;
end;

procedure TDataprix.operationsaccordAfterPost(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.operationsaccordAfterDelete(DataSet: TDataSet);
begin
idataprix.Transactions[1].CommitRetaining;
end;

procedure TDataprix.operationsaccordAfterInsert(DataSet: TDataSet);
 var nMaxNumero:integer;
begin
 QueryMaxNumero.Close;
 QueryMaxNumero.SQL.Clear;
 QueryMaxNumero.SQL.Add('select max(OPERATIONRESCRITFISCAUX.lg) as MaxNumero from OPERATIONRESCRITFISCAUX Where mfiscal=:mfiscal and  exercice=:exercice');
 QueryMaxNumero.params[0].value:=societeMFISCAL.Value+societeCLE.Value;
 QueryMaxNumero.params[1].value:=societeEXERCICE.Value;
 QueryMaxNumero.Open;
 if(QueryMaxNumero.FieldByName('MaxNumero').AsString = '') then
    nMaxNumero := 1
 else
    nMaxNumero := QueryMaxNumero.FieldByName('MaxNumero').Value + 1;
   operationsaccordlg.NewValue:= nMaxNumero;

 operationsaccordMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 operationsaccordEXERCICE.Value:=societeEXERCICE.Value;

end;

procedure TDataprix.operationsaccordBeforePost(DataSet: TDataSet);
begin
 operationsaccordMFISCAL.Value:=societeMFISCAL.Value+societeCLE.Value;
 operationsaccordEXERCICE.Value:=societeEXERCICE.Value;
end;

end.
