unit Uparamsociete;

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
  Tfrmparamsociete = class(TForm)
    Panel1: TPanel;
    GroupBox2: TGroupBox;
    Dsetatterritorial: TDataSource;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Panel2: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label7: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label8: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    DBEcode: TDBEdit;
    DBraisonsociale: TDBEdit;
    DBEdit7: TDBEdit;
    DBComboBox1: TDBComboBox;
    DBComboBox2: TDBComboBox;
    DBComboBox3: TDBComboBox;
    DBDateEdit1: TDBDateEdit;
    DBDateEdit2: TDBDateEdit;
    DBComboBox4: TDBComboBox;
    DBComboBox5: TDBComboBox;
    DBComboBox6: TDBComboBox;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    Label21: TLabel;
    DBComboBox7: TDBComboBox;
    Label22: TLabel;
    DBEdit8: TDBEdit;
    Label23: TLabel;
    DBMemo1: TDBMemo;
    Label24: TLabel;
    DBComboBox8: TDBComboBox;
    DBMemo2: TDBMemo;
    Label26: TLabel;
    Label27: TLabel;
    Dscapitalliee: TDataSource;
    DBEdit9: TDBEdit;
    Label28: TLabel;
    Label29: TLabel;
    DBEdit10: TDBEdit;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    DBEdit11: TDBEdit;
    DBGrid1: TDBGrid;
    Label35: TLabel;
    DBComboBox9: TDBComboBox;
    Label36: TLabel;
    DBEdit12: TDBEdit;
    Label33: TLabel;
    DBEdit13: TDBEdit;
    Label34: TLabel;
    DBEdit14: TDBEdit;
    dxButton28: TdxButton;
    Panel3: TPanel;
    Bitnok: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    dxButton1: TdxButton;
    dxButton2: TdxButton;
    dxButton3: TdxButton;
    TabSheet3: TTabSheet;
    DBGrid2: TDBGrid;
    dxButton4: TdxButton;
    dxButton5: TdxButton;
    dxButton6: TdxButton;
    dxButton7: TdxButton;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    DBEdit15: TDBEdit;
    DBEdit16: TDBEdit;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    DBEdit17: TDBEdit;
    Label44: TLabel;
    DBComboBox10: TDBComboBox;
    Label45: TLabel;
    DBEdit18: TDBEdit;
    Label46: TLabel;
    DBEdit19: TDBEdit;
    Label47: TLabel;
    DBEdit20: TDBEdit;
    Dsdeclarante: TDataSource;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    Label48: TLabel;
    DBComboBox11: TDBComboBox;
    DBMemo4: TDBMemo;
    Label49: TLabel;
    Label50: TLabel;
    TabSheet4: TTabSheet;
    Label25: TLabel;
    Label51: TLabel;
    DBMemo5: TDBMemo;
    DBMemo3: TDBMemo;
    Label52: TLabel;
    DBComboBox12: TDBComboBox;
    Label53: TLabel;
    Label54: TLabel;
    DBComboBox13: TDBComboBox;
    DBComboBox14: TDBComboBox;
    DBEdit21: TDBEdit;
    DBEdit22: TDBEdit;
    DBEdit23: TDBEdit;
    BitBtn5: TBitBtn;
    dxButton8: TdxButton;
    dxButton9: TdxButton;
    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 dxButton1Click(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 DBLookupComboBox3Exit(Sender: TObject);
    procedure DBEdit21DblClick(Sender: TObject);
    procedure DBEdit22Click(Sender: TObject);
    procedure DBEdit23DblClick(Sender: TObject);
    procedure DBEdit22DblClick(Sender: TObject);
    procedure dxButton8Click(Sender: TObject);
    procedure dxButton9Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);

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

var
  frmparamsociete: Tfrmparamsociete;

implementation

uses usocietes, Umain,udataprix, UterritoireSELECT;

{$R *.dfm}

procedure Tfrmparamsociete.BitBtn2Click(Sender: TObject);
begin
dataprix.Societe.Cancel;
frmparamsociete.close;
end;

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

procedure Tfrmparamsociete.PassageChampSuiv();
begin
FindNextControl(frmparamsociete.ActiveControl, true, true, false).SetFocus;
end;

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

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

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

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

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

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

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

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

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

procedure Tfrmparamsociete.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 action:=caFree;
end;

procedure Tfrmparamsociete.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);
    if not(Dataprix.societe.State  in [dsedit]) then Dataprix.societe.edit;
    Dataprix.societeMFISCAL.Value:=copy('0000000',1,l1-l2)+matricule;
end;
                                          
procedure Tfrmparamsociete.DBLookupComboBox1Exit(Sender: TObject);
begin
 Dataprix.Etatterritorial.LocateNext('code',Dataprix.societeNATIONALITE.Value,[locaseinsensitive]);
 label5.Caption:=Dataprix.EtatterritorialPAYS.Value;
end;

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

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

procedure Tfrmparamsociete.dxButton1Click(Sender: TObject);
begin
 Dataprix.capitallie.Append;
 dbedit9.SetFocus;
end;

procedure Tfrmparamsociete.dxButton3Click(Sender: TObject);
begin
 Dataprix.capitallie.edit;
end;

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

procedure Tfrmparamsociete.FormCreate(Sender: TObject);
begin
   PageControl1.ActivePage:=TabSheet1;
   Dataprix.capitallie.close;
   Dataprix.capitallie.params[0].value:=Dataprix.societemfiscal.value+Dataprix.societecle.value;
   Dataprix.capitallie.params[1].value:=Dataprix.societeexercice.value;
   Dataprix.capitallie.open;
   Dataprix.capitallie.first;
   Dataprix.Capitaldeclarante.close;
   Dataprix.Capitaldeclarante.params[0].value:=Dataprix.societemfiscal.value+Dataprix.societecle.value;
   Dataprix.Capitaldeclarante.params[1].value:=Dataprix.societeexercice.value;
   Dataprix.Capitaldeclarante.open;
   Dataprix.Capitaldeclarante.first;
   Dataprix.devise.Close;
   Dataprix.devise.Open;
   Dataprix.Etatterritorial.Close;
   Dataprix.Etatterritorial.Open;
   Dataprix.Etatterritorial.Locate('code',Dataprix.societeNATIONALITE.Value,[locaseinsensitive]);
   label5.Caption:=Dataprix.EtatterritorialPAYS.Value;
   if  not(Dataprix.capitallie.eof) then
     begin
      Dataprix.Etatterritorial.Locate('code',Dataprix.capitallieETATTERRITOIRE.Value,[locaseinsensitive]);
      label31.Caption:=Dataprix.EtatterritorialPAYS.Value;
     end;
   if  not(Dataprix.Capitaldeclarante.eof) then
     begin
      Dataprix.Etatterritorial.Locate('code',Dataprix.CapitaldeclaranteETATTERRITOIRE.Value,[locaseinsensitive]);
      label42.Caption:=Dataprix.EtatterritorialPAYS.Value;
     end;
end;

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

procedure Tfrmparamsociete.dxButton5Click(Sender: TObject);
begin
 Dataprix.Capitaldeclarante.Append;
 dbedit15.SetFocus;
end;

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

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

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

procedure Tfrmparamsociete.DBEdit21DblClick(Sender: TObject);
begin
  frmmain.libelle:='';frmmain.libelle1:='';
  Application.CreateForm(TFrmterritoireSELECT,FrmterritoireSELECT);
  FrmterritoireSELECT.ShowModal;
  if FrmterritoireSELECT.ModalResult=mrOk  then
   begin
    Dataprix.societeNATIONALITE.Value:=frmmain.libelle;
    label5.Caption:= frmmain.libelle1;
   end;
end;

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

procedure Tfrmparamsociete.DBEdit23DblClick(Sender: TObject);
begin
  frmmain.libelle:='';frmmain.libelle1:='';
  Application.CreateForm(TFrmterritoireSELECT,FrmterritoireSELECT);
  FrmterritoireSELECT.ShowModal;
  if FrmterritoireSELECT.ModalResult=mrOk  then
   begin
    Dataprix.CapitaldeclaranteETATTERRITOIRE.Value:=frmmain.libelle;
    label42.Caption:= frmmain.libelle1;
   end;
end;

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

procedure Tfrmparamsociete.dxButton8Click(Sender: TObject);
begin
if(Application.MessageBox('Voulez-vous supprimer toutes les stés du capital lié ?', 'Confirmation',MB_YESNO)= IDYES) then
 begin
  frmmain.ExecuterSql.Close;
  frmmain.ExecuterSql.SQL.Clear;
  frmmain.ExecuterSql.SQL.Add('delete from capitalliee');
  frmmain.ExecuterSql.open;
 end;
end;

procedure Tfrmparamsociete.dxButton9Click(Sender: TObject);
begin
 if(Application.MessageBox('Voulez-vous supprimer toutes les stés du capital déclarante ?', 'Confirmation',MB_YESNO)= IDYES) then
 begin
  frmmain.ExecuterSql.Close;
  frmmain.ExecuterSql.SQL.Clear;
  frmmain.ExecuterSql.SQL.Add('delete from CAPITALDECLARANTE');
  frmmain.ExecuterSql.open;
 end;
end;

procedure Tfrmparamsociete.BitBtn1Click(Sender: TObject);
begin
  close;
end;

procedure Tfrmparamsociete.BitBtn3Click(Sender: TObject);
begin
  CLOSE;
end;

procedure Tfrmparamsociete.BitBtn4Click(Sender: TObject);
begin
  close;
end;

end.
