unit uinfogroupe;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, StdCtrls, Mask, DBCtrls, ExtCtrls, Buttons, IBCustomDataSet,
  IBQuery,Ibtable, IBUpdateSQL, Grids, DBGrids, ComCtrls, ToolEdit,
  RXDBCtrl, dxCore, dxButton;

type
  Tfrminfogroupe = class(TForm)
    Panel1: TPanel;
    GroupBox2: TGroupBox;
    Dsetatterritorial: TDataSource;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label26: TLabel;
    Label27: TLabel;
    DBEdit9: TDBEdit;
    Label28: TLabel;
    Label29: TLabel;
    DBEdit10: TDBEdit;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    DBEdit11: TDBEdit;
    Label36: TLabel;
    DBEdit12: TDBEdit;
    Label33: TLabel;
    Dsinfogroupe: TDataSource;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    DBGrid1: TDBGrid;
    DBMemo1: TDBMemo;
    DBMemo2: TDBMemo;
    DBComboBox8: TDBComboBox;
    Label25: TLabel;
    Label24: TLabel;
    Label1: TLabel;
    DBMemo3: TDBMemo;
    dxButton4: TdxButton;
    dxButton5: TdxButton;
    dxButton6: TdxButton;
    dxButton7: TdxButton;
    Dsincorporel: TDataSource;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    DBEdit3: TDBEdit;
    Label8: TLabel;
    Label35: TLabel;
    DBComboBox9: TDBComboBox;
    Label9: TLabel;
    DBEdit4: TDBEdit;
    Label10: TLabel;
    DBComboBox1: TDBComboBox;
    Label11: TLabel;
    Label12: TLabel;
    DBEdit5: TDBEdit;
    DBComboBox2: TDBComboBox;
    Label13: TLabel;
    DBComboBox3: TDBComboBox;
    Label14: TLabel;
    DBEdit6: TDBEdit;
    DBGrid2: TDBGrid;
    Dscorporel: TDataSource;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label22: TLabel;
    DBEdit13: TDBEdit;
    Label23: TLabel;
    DBComboBox5: TDBComboBox;
    Label34: TLabel;
    DBEdit14: TDBEdit;
    Label37: TLabel;
    DBComboBox6: TDBComboBox;
    Label38: TLabel;
    DBEdit15: TDBEdit;
    Label39: TLabel;
    DBComboBox7: TDBComboBox;
    Label40: TLabel;
    DBEdit16: TDBEdit;
    dxButton8: TdxButton;
    dxButton9: TdxButton;
    dxButton10: TdxButton;
    dxButton11: TdxButton;
    Panel3: TPanel;
    Bitnok: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    DBEdit17: TDBEdit;
    DBEdit18: TDBEdit;
    DBEdit19: TDBEdit;
    dxButton1: TdxButton;
    dxButton2: TdxButton;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitnokClick(Sender: TObject);
    procedure PassageChampPrec();
    procedure PassageChampSuiv();
    procedure DBEcodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBraisonsocialeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEformejuridiqueKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEactiviteKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEadresseKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEtelephoneKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEmotdepasseKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEregistrecommerceKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBEcodetvaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DBEcodeExit(Sender: TObject);
    procedure DBLookupComboBox1Exit(Sender: TObject);
    procedure DBLookupComboBox2Exit(Sender: TObject);
    procedure dxButton28Click(Sender: TObject);
    procedure dxButton3Click(Sender: TObject);
    procedure dxButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure dxButton4Click(Sender: TObject);
    procedure dxButton5Click(Sender: TObject);
    procedure dxButton6Click(Sender: TObject);
    procedure dxButton7Click(Sender: TObject);
    procedure dxButton8Click(Sender: TObject);
    procedure dxButton9Click(Sender: TObject);
    procedure dxButton10Click(Sender: TObject);
    procedure dxButton11Click(Sender: TObject);
    procedure DBLookupComboBox3Exit(Sender: TObject);
    procedure DBEdit17DblClick(Sender: TObject);
    procedure DBEdit18DblClick(Sender: TObject);
    procedure DBEdit19DblClick(Sender: TObject);
    procedure DBEdit1DblClick(Sender: TObject);
    procedure DBEdit7DblClick(Sender: TObject);
    procedure dxButton1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frminfogroupe: Tfrminfogroupe;

implementation

uses usocietes, Umain,udataprix, Uparamsociete, UterritoireSELECT,
  USOCIETESESELECT;

{$R *.dfm}

procedure Tfrminfogroupe.BitBtn1Click(Sender: TObject);
begin
dataprix.INFOGROUPE.Cancel;
close;
end;

procedure Tfrminfogroupe.BitBtn2Click(Sender: TObject);
begin
dataprix.INFOGROUPE.Cancel;
close;
end;

procedure Tfrminfogroupe.BitnokClick(Sender: TObject);
begin
if  NOT(dataprix.Societe.State in [dsInsert, dsEdit]) then dataprix.INFOGROUPE.EDIT;
dataprix.INFOGROUPE.Post;
end;

procedure Tfrminfogroupe.PassageChampSuiv();
begin
FindNextControl(frminfogroupe.ActiveControl, true, true, false).SetFocus;
end;

procedure Tfrminfogroupe.PassageChampPrec();
begin
FindNextControl(frminfogroupe.ActiveControl, false, true, false).SetFocus;
end;
procedure Tfrminfogroupe.DBEcodeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121: begin
       ModalResult := mrOk;
       dataprix.Societe.Post;
      frmparamsociete.close;
       end; //F10
    end;
end;

procedure Tfrminfogroupe.DBraisonsocialeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEformejuridiqueKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEactiviteKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEadresseKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEtelephoneKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEmotdepasseKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEregistrecommerceKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.DBEcodetvaKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case Key of
    13 :PassageChampSuiv();
    38 :PassageChampPrec();
    121:ModalResult := mrOk;  //F10
    end;
end;

procedure Tfrminfogroupe.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
dataprix.Societe.Edit;
if ModalResult=mrOk  then
dataprix.Societe.Post
else
dataprix.Societe.Cancel;
//frmsocietes.Close;
 action:=caFree;
 end;

procedure Tfrminfogroupe.DBEcodeExit(Sender: TObject);
  var l1,l2:integer; matricule:string;
begin
    l1:=Dataprix.societeMFISCAL.Size;
    l2:=length(trim(Dataprix.societeMFISCAL.Value));
    matricule:=trim(Dataprix.societeMFISCAL.Value);
    Dataprix.societeMFISCAL.Value:=copy('0000000',1,l1-l2)+matricule;
end;

procedure Tfrminfogroupe.DBLookupComboBox1Exit(Sender: TObject);
begin
 Dataprix.Etatterritorial.LocateNext('code',Dataprix.actifincorporelTERRITOIRE.Value,[locaseinsensitive]);
 label7.Caption:=Dataprix.EtatterritorialPAYS.Value;
end;

procedure Tfrminfogroupe.DBLookupComboBox2Exit(Sender: TObject);
begin
 Dataprix.Etatterritorial.LocateNext('code',Dataprix.INFOGROUPEETATTERRITORIAL.Value,[locaseinsensitive]);
 label31.Caption:=Dataprix.EtatterritorialPAYS.Value;
end;

procedure Tfrminfogroupe.dxButton28Click(Sender: TObject);
begin
if  NOT(dataprix.actifincorporel.State in [dsInsert, dsEdit]) then dataprix.actifincorporel.EDIT;
   Dataprix.actifincorporel.post;
   Dataprix.actifincorporel.edit;
end;

procedure Tfrminfogroupe.dxButton3Click(Sender: TObject);
begin
 Dataprix.actifincorporel.edit;
end;

procedure Tfrminfogroupe.dxButton2Click(Sender: TObject);
begin
if(Application.MessageBox('Voulez-vous supprimer toute la liste de l''actif corporel ?', 'Confirmation',MB_YESNO)= IDYES) then
 begin
  frmmain.ExecuterSql.Close;
  frmmain.ExecuterSql.SQL.Clear;
  frmmain.ExecuterSql.SQL.Add('delete from LISTEACTIFCORPOREL');
  frmmain.ExecuterSql.open;
 end;
end;

procedure Tfrminfogroupe.FormCreate(Sender: TObject);
begin
   PageControl1.ActivePage:=TabSheet1;
   Dataprix.INFOGROUPE.close;
   Dataprix.INFOGROUPE.params[0].value:=Dataprix.societemfiscal.value+Dataprix.societecle.value;
   Dataprix.INFOGROUPE.params[1].value:=Dataprix.societeexercice.value;
   Dataprix.INFOGROUPE.open;

   Dataprix.actifincorporel.close;
   Dataprix.actifincorporel.params[0].value:=Dataprix.societemfiscal.value+Dataprix.societecle.value;
   Dataprix.actifincorporel.params[1].value:=Dataprix.societeexercice.value;
   Dataprix.actifincorporel.open;
   Dataprix.actifincorporel.first;
   Dataprix.actifcorporel.close;
   Dataprix.actifcorporel.params[0].value:=Dataprix.societemfiscal.value+Dataprix.societecle.value;
   Dataprix.actifcorporel.params[1].value:=Dataprix.societeexercice.value;
   Dataprix.actifcorporel.open;
   Dataprix.actifcorporel.First;
   Dataprix.devise.Close;
   Dataprix.devise.Open;
   Dataprix.Etatterritorial.Close;
   Dataprix.Etatterritorial.Open;
   Dataprix.Etatterritorial.Locate('code',Dataprix.INFOGROUPEETATTERRITORIAL.Value,[locaseinsensitive]);
   label31.Caption:=Dataprix.EtatterritorialPAYS.Value;
   if  not(Dataprix.actifincorporel.eof) then
     begin
      Dataprix.Etatterritorial.Locate('code',Dataprix.actifincorporelTERRITOIRE.Value,[locaseinsensitive]);
      label7.Caption:=Dataprix.EtatterritorialPAYS.Value;
     end;
   if  not(Dataprix.actifcorporel.eof) then
     begin
      Dataprix.Etatterritorial.Locate('code',Dataprix.ActifcorporelTERRITOIRE.Value,[locaseinsensitive]);
      label20.Caption:=Dataprix.EtatterritorialPAYS.Value;
     end;
end;

procedure Tfrminfogroupe.dxButton4Click(Sender: TObject);
begin
   Dataprix.Capitaldeclarante.post;
   Dataprix.Capitaldeclarante.edit;
end;

procedure Tfrminfogroupe.dxButton5Click(Sender: TObject);
begin
 Dataprix.Capitaldeclarante.Append;
 dbedit1.SetFocus;
end;

procedure Tfrminfogroupe.dxButton6Click(Sender: TObject);
begin
if(Application.MessageBox('Voulez-vous supprimer l''enregistrement en cours ?', 'Confirmation',MB_YESNO)= IDYES) then
  Dataprix.Capitaldeclarante.delete;
end;

procedure Tfrminfogroupe.dxButton7Click(Sender: TObject);
begin
  Dataprix.Capitaldeclarante.edit;
end;

procedure Tfrminfogroupe.dxButton8Click(Sender: TObject);
begin
 if NOT(dataprix.actifcorporel.State in [dsInsert, dsEdit]) then dataprix.actifcorporel.EDIT;
   Dataprix.actifcorporel.post;
   Dataprix.actifcorporel.edit;
end;

procedure Tfrminfogroupe.dxButton9Click(Sender: TObject);
begin
   Dataprix.actifcorporel.Append;
   dbedit7.SetFocus;
end;

procedure Tfrminfogroupe.dxButton10Click(Sender: TObject);
begin
  if(Application.MessageBox('Voulez-vous supprimer l''enregistrement en cours ?', 'Confirmation',MB_YESNO)= IDYES) then
  Dataprix.actifcorporel.delete;
end;

procedure Tfrminfogroupe.dxButton11Click(Sender: TObject);
begin
   Dataprix.actifcorporel.edit;
end;

procedure Tfrminfogroupe.DBLookupComboBox3Exit(Sender: TObject);
begin
 Dataprix.Etatterritorial.LocateNext('code',Dataprix.ActifcorporelTERRITOIRE.Value,[locaseinsensitive]);
 label20.Caption:=Dataprix.EtatterritorialPAYS.Value;
end;

procedure Tfrminfogroupe.DBEdit17DblClick(Sender: TObject);
begin
  frmmain.libelle:='';frmmain.libelle1:='';
  Application.CreateForm(TFrmterritoireSELECT,FrmterritoireSELECT);
  FrmterritoireSELECT.ShowModal;
  if FrmterritoireSELECT.ModalResult=mrOk  then
   begin
    Dataprix.INFOGROUPEETATTERRITORIAL.Value:=frmmain.libelle;
    label31.Caption:= frmmain.libelle1;
   end;
end;

procedure Tfrminfogroupe.DBEdit18DblClick(Sender: TObject);
begin
   frmmain.libelle:='';frmmain.libelle1:='';
  Application.CreateForm(TFrmterritoireSELECT,FrmterritoireSELECT);
  FrmterritoireSELECT.ShowModal;
  if FrmterritoireSELECT.ModalResult=mrOk  then
   begin
    Dataprix.actifincorporelTERRITOIRE.Value:=frmmain.libelle;
    label7.Caption:= frmmain.libelle1;
   end;
end;

procedure Tfrminfogroupe.DBEdit19DblClick(Sender: TObject);
begin
  frmmain.libelle:='';frmmain.libelle1:='';
  Application.CreateForm(TFrmterritoireSELECT,FrmterritoireSELECT);
  FrmterritoireSELECT.ShowModal;
  if FrmterritoireSELECT.ModalResult=mrOk  then
   begin
    Dataprix.actifcorporelTERRITOIRE.Value:=frmmain.libelle;
    label20.Caption:= frmmain.libelle1;
   end;
end;

procedure Tfrminfogroupe.DBEdit1DblClick(Sender: TObject);
begin
 frmmain.indice:=0;
 Application.CreateForm(TfrmSOCIETESESELECT,frmSOCIETESESELECT);
 frmSOCIETESESELECT.ShowModal;
 if frmmain.indice=1  then
   begin
    if not(dataprix.actifincorporel.state in [dsedit,dsinsert])  then  dataprix.actifincorporel.Edit;
     dataprix.actifincorporelMATRICULEFISCAL.Value:=frmSOCIETESESELECT.societesMFISCALLIE.Value;
     dataprix.actifincorporelAUTREIDENTIFIANT.Value:=frmSOCIETESESELECT.societesAUTREIDENTIFIANT.Value;
     dataprix.actifincorporelTERRITOIRE.Value:=frmSOCIETESESELECT.societesETATTERRITOIRE.Value;
     dataprix.actifincorporelRAISONSOCIALE.Value:=frmSOCIETESESELECT.societesRAISONSOCIALE.Value;
     dataprix.actifincorporelQUALITE.Value:=frmSOCIETESESELECT.societesQUALITE.Value;
     dataprix.actifincorporelAUTREQUALITE.Value:=frmSOCIETESESELECT.societesAUTREQUALITE.Value;
   end;
end;

procedure Tfrminfogroupe.DBEdit7DblClick(Sender: TObject);
begin
  frmmain.indice:=0;
  Application.CreateForm(TfrmSOCIETESESELECT,frmSOCIETESESELECT);
  frmSOCIETESESELECT.ShowModal;
 if frmmain.indice=1  then
   begin
    if not(dataprix.actifcorporel.state in [dsedit,dsinsert])  then  dataprix.actifcorporel.Edit;
     dataprix.actifcorporelMATRICULEFISCAL.Value:=frmSOCIETESESELECT.societesMFISCALLIE.Value;
     dataprix.actifcorporelAUTREIDENTIFIANT.Value:=frmSOCIETESESELECT.societesAUTREIDENTIFIANT.Value;
     dataprix.actifcorporelTERRITOIRE.Value:=frmSOCIETESESELECT.societesETATTERRITOIRE.Value;
     dataprix.actifcorporelRAISONSOCIALE.Value:=frmSOCIETESESELECT.societesRAISONSOCIALE.Value;
     dataprix.actifcorporelQUALITE.Value:=frmSOCIETESESELECT.societesQUALITE.Value;
     dataprix.actifcorporelAUTREQUALITE.Value:=frmSOCIETESESELECT.societesAUTREQUALITE.Value;
   end;
end;

procedure Tfrminfogroupe.dxButton1Click(Sender: TObject);
begin
if(Application.MessageBox('Voulez-vous supprimer toute la liste de l''actif incorporel ?', 'Confirmation',MB_YESNO)= IDYES) then
 begin
  frmmain.ExecuterSql.Close;
  frmmain.ExecuterSql.SQL.Clear;
  frmmain.ExecuterSql.SQL.Add('delete from LISTEACTIFINCORPOREL');
  frmmain.ExecuterSql.open;
 end;
end;

end.
