Attribute VB_Name = "Module1"
Public wrkJet As Workspace 'Espace de travail
Public wrkJet2 As Workspace 'Espace de travail
Public dbs As Database 'Base de donnée
Public dbs2 As Database 'Base de donnée
Public ImpressionEnPDF As Boolean
Public DossierPDF As String

Public zz As Integer
Public rst0, rst1, rst As recordset 'Enregistrement
Public recordset As recordset 'Enregistrement
Public path_base As String 'Chemin de la base MMC
Public RemiseBoulangerie As Byte
Public RemisePatisserie As Byte
Public modif, EditionParametre, ApercuFactureRapide, BaseCorrompu, ModifClient As Boolean
Public BottomMargin, LeftMargin, RightMargin, TopMargin, sel As Byte
Public IDClient
Public CheminFacture As String
Public Resolution_EcranX
Public Resolution_EcranY
Public ImprimanteExiste As Boolean
Public FileSplashScreen As String
Public RemiseBoulangerie1 As Integer
Public RemisePatisserie1 As Integer
Public RemiseBoulangerie2 As Integer
Public RemisePatisserie2 As Integer
Public RemiseBoulangerie3 As Integer
Public RemisePatisserie3 As Integer
Public RemiseBoulangerie4 As Integer
Public RemisePatisserie4 As Integer
Public Font_Name As String
Public Font_Size As String
Public Font_Color As String
Public Font_Style As String

Public CurrentSetFontesName As String
Public CurrentZoneName As String
Public CurrentSetFontesSize As String
Public CurrentSetFontesColor As String
Public Current_Font_Format As String

'Pour envoyer des données a la listview
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
   (ByVal hWnd As Long, _
    ByVal Msg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long

Public Type Color
    NomEntreprise As String
    adresse1 As String
    CP1 As String
    Tel1 As String
    DetailNomEntreprise As String
    adresse2 As String
    CP2 As String
    Tel2 As String
    Fax As String
    RCS As String
    TVA As String
    LigneMediane As String
    Signature As String
    Facture As String
    DateFacture As String
    Client As String
    LigneBoulangerie As String
    LignePatisserie As String
    TotalTTC As String
    Designation As String
End Type

Public Type Police
    NomEntreprise As String
    adresse1 As String
    CP1 As String
    Tel1 As String
    DetailNomEntreprise As String
    adresse2 As String
    CP2 As String
    Tel2 As String
    Fax As String
    RCS As String
    TVA As String
    LigneMediane As String
    Signature As String
    Facture As String
    DateFacture As String
    Client As String
    LigneBoulangerie As String
    LignePatisserie As String
    TotalTTC As String
    Designation As String
End Type

Public Type Size
    NomEntreprise As String
    adresse1 As String
    CP1 As String
    Tel1 As String
    DetailNomEntreprise As String
    adresse2 As String
    CP2 As String
    Tel2 As String
    Fax As String
    RCS As String
    TVA As String
    LigneMediane As String
    Signature As String
    Facture As String
    DateFacture As String
    Client As String
    LigneBoulangerie As String
    LignePatisserie As String
    TotalTTC As String
    Designation As String
End Type

Public Type Style
    NomEntreprise As String
    adresse1 As String
    CP1 As String
    Tel1 As String
    DetailNomEntreprise As String
    adresse2 As String
    CP2 As String
    Tel2 As String
    Fax As String
    RCS As String
    TVA As String
    LigneMediane As String
    Signature As String
    Facture As String
    DateFacture As String
    Client As String
    LigneBoulangerie As String
    LignePatisserie As String
    TotalTTC As String
    Designation As String
End Type

Public Enum ListDataType
    ldtString = 0
    ldtNumber = 1
    ldtDateTime = 2
End Enum
'***********Constante d'affichage pour la listview**********
Public Const LVM_FIRST = &H1000
Public Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
Public Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
Public Const LVS_EX_FULLROWSELECT = &H20

Public Type Info
  nb_enregistrement As Long
  Taille_Base As Long
End Type

Public Type T_Record
  T_TotalTTC As String
  T_RemiseBoulangerie As String
  T_TotalBoulangerie As String
  T_PercRemiseBoulangerie As String
  T_ST_Boulangerie As String
  T_RemisePatisserie As String
  T_TotalPatisserie As String
  T_PercRemisePatisserie As String
  T_ST_Patisserie As String
  T_DontTVA As String
  T_TotalHT As String
  T_Date As String
  T_CommentaireBoulangerie As String
  T_CommentairePatisserie As String
  T_Clients As String
  T_AdresseClients As String
  T_AdresseClients2 As String
End Type
Public Type T_RaisonSocial
  T_NomEntreprise As String
  T_Adresse1 As String
  T_CP1 As String
  T_Tel1 As String
  T_Adresse2 As String
  T_CP2 As String
  T_Tel2 As String
  T_RCS As String
  T_TVA As String
  T_LigneMediane As String
  T_Fax As String
  T_DetailNomEntreprise As String
  T_Logo As String
  T_Signature As String
End Type

Public Type Fontes
  Name As String
  Size As String
  Color As String
End Type

'----------------Pour la capture de la facture en JPG------------------------------------------------------------
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
' Déclaration des Api
Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

' Enumération des dossiers spéciaux
Public Enum SpecialFoldersConstants
    CSIDL_ADMINTOOLS = &H30
    CSIDL_ALTSTARTUP = &H1D
    CSIDL_APPDATA = &H1A
    CSIDL_BITBUCKET = &HA
    CSIDL_COMMON_ADMINTOOLS = &H2F
    CSIDL_COMMON_ALTSTARTUP = &H1E
    CSIDL_COMMON_APPDATA = &H23
    CSIDL_COMMON_DESKTOPDIRECTORY = &H19
    CSIDL_COMMON_DOCUMENTS = &H2E
    CSIDL_COMMON_FAVORITES = &H1F
    CSIDL_COMMON_PROGRAMS = &H17
    CSIDL_COMMON_STARTMENU = &H16
    CSIDL_COMMON_STARTUP = &H18
    CSIDL_COMMON_TEMPLATES = &H2D
    CSIDL_CONTROLS = &H3
    CSIDL_COOKIES = &H21
    CSIDL_DESKTOP = &H0
    CSIDL_DESKTOPDIRECTORY = &H10
    CSIDL_DRIVES = &H11
    CSIDL_FAVORITES = &H6
    CSIDL_FLAG_CREATE = &H8000
    CSIDL_FLAG_DONT_VERIFY = &H4000
    CSIDL_FLAG_MASK = &HFF00
    CSIDL_FONTS = &H14
    CSIDL_HISTORY = &H22
    CSIDL_INTERNET = &H1
    CSIDL_INTERNET_CACHE = &H20
    CSIDL_LOCAL_APPDATA = &H1C
    CSIDL_MYPICTURES = &H27
    CSIDL_NETHOOD = &H13
    CSIDL_NETWORK = &H12
    CSIDL_PERSONAL = &H5
    CSIDL_PRINTERS = &H4
    CSIDL_PRINTHOOD = &H1B
    CSIDL_PROFILE = &H28
    CSIDL_PROGRAM_FILES = &H26
    CSIDL_PROGRAM_FILES_COMMON = &H2B
    CSIDL_PROGRAM_FILES_COMMONX86 = &H2C
    CSIDL_PROGRAM_FILESX86 = &H2A
    CSIDL_PROGRAMS = &H2
    CSIDL_RECENT = &H8
    CSIDL_SENDTO = &H9
    CSIDL_STARTMENU = &HB
    CSIDL_STARTUP = &H7
    CSIDL_SYSTEM = &H25
    CSIDL_SYSTEMX86 = &H29
    CSIDL_TEMPLATES = &H15
    CSIDL_WINDOWS = &H24
End Enum

' Type
Private Type SHITEMID
    cb As Long
    abID As Byte
End Type
Private Type ITEMIDLIST
    mkid As SHITEMID
End Type

' Constantes
Public Const MAX_PATH = 260

Public Function GetSpecialFolder(SpecialFolder As SpecialFoldersConstants) As String

    ' Les variables
    Dim RC As Long
    Dim IDL As ITEMIDLIST
    Dim sPath As String

    ' Récupère le dossier spécial
    RC = SHGetSpecialFolderLocation(100, SpecialFolder, IDL)
    If RC = 0 Then
        ' Crée un tampon
        sPath = Space$(MAX_PATH)
        ' Récupère le path à partir de l'IDList
        SHGetPathFromIDList ByVal IDL.mkid.cb, ByVal sPath
        ' Supprime les chr$(0) inutiles
        sPath = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
        If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
    Else
        sPath = ""
    End If
    GetSpecialFolder = sPath

End Function


Public Function NbOc(Chaine As String, ch As String, Optional RC As Boolean = False) As Long
        If RC Then
           NbOc = (Len(Chaine) - Len(Replace(Chaine, ch, "", , , 0))) / Len(ch)
        Else
           NbOc = (Len(Chaine) - Len(Replace(Chaine, ch, "", , , 1))) / Len(ch)
        End If
End Function
Public Sub SetFontes(NomFonte, SizeFonte, ColorFonte, StyleFonte, NomZone)
Font_Name = NomFonte
Font_Size = SizeFonte
Font_Style = StyleFonte
Font_Color = ColorFonte
If Font_Color = "" Then Font_Color = "255"
If Font_Style = "" Then Font_Style = "BI"

ColorNomEntreprise = Font_Color
End Sub
Public Sub CenterForm(form_name As Form)

    ' Centre la fenêtre au milieu de l'ecran
    Screen.MousePointer = 11
    form_name.Top = (Screen.Height - form_name.Height) / 2
    form_name.Left = (Screen.Width - form_name.Width) / 2
    Screen.MousePointer = 0



End Sub
'
Public Sub ResolutionEcran()
Dim X As Long, Y As Long
X = Screen.Width / Screen.TwipsPerPixelX    'résolution horizontale
Y = Screen.Height / Screen.TwipsPerPixelY   'verticale
Resolution_EcranX = X
Resolution_EcranY = Y
End Sub
Public Sub ValeurImpressionDefaut()
On Error GoTo err

'Sauve les valeurs d'impression par defaut dans la base
Set recordset = dbs.OpenRecordset("T_Option", dbOpenDynaset)
        recordset.AddNew
        recordset![BottomMargin] = 30
        recordset![LeftMargin] = 15
        recordset![RightMargin] = 5
        recordset![TopMargin] = 30
        recordset![Lieu] = "Defaut"
        recordset.Update
        

    
   
Set rst = dbs.OpenRecordset("Select * from [T_Option]")
    rst.MoveLast
      
Set recordset = dbs.OpenRecordset("T_Option2", dbOpenDynaset)
        recordset.AddNew
        recordset![NumFacture] = 1
        recordset![DefautImpression] = rst.Fields(0)
        recordset.Update
        
Exit Sub
 
err:
If err.Number = 3021 Then Resume Next
End Sub
Public Sub CreerBase()
   On Error GoTo err 'Si erreur alors va a ERR:
   Dim Sgbd As Workspace 'Definition de l'objet Workspace
   Dim SgbdNEW As Database 'Definition de la base de donnée
   Dim Table As TableDef, Champs(97) As Field, Maindex As Index
   Dim rep
   Dim r As Integer
   ' Obtient l'objet Workspace par défaut.
   Set Sgbd = DBEngine.Workspaces(0)

   ' Crée une nouvelle base de données cryptée avec
   ' l'ordre de classement précisé.
   Set SgbdNEW = Sgbd.CreateDatabase(path_base, _
      dbLangGeneral, dbEncrypt)
      
      ' Crée un objet TableDef
   Set Table = SgbdNEW.CreateTableDef("T_Record")
    
   'Définitions des differents champs de Record
   Set Champs(0) = Table.CreateField("T_NumFacture", dbLong, 10)
   Set Champs(1) = Table.CreateField("T_RaisonSocial1", dbText, 50)
   Set Champs(2) = Table.CreateField("T_RaisonSocial2", dbText, 50)
   Set Champs(3) = Table.CreateField("T_Clients", dbText, 50)
   Set Champs(4) = Table.CreateField("T_AdresseClients", dbText, 50)
   Set Champs(5) = Table.CreateField("T_AdresseClients2", dbText, 50)
   Set Champs(6) = Table.CreateField("T_Commentaires_Boulangerie", dbText, 100)
   Set Champs(7) = Table.CreateField("T_Commentaires_Patisserie", dbText, 100)
   Set Champs(8) = Table.CreateField("T_ST_Boulangerie", dbText, 50)
   Set Champs(9) = Table.CreateField("T_RemiseBoulangerie", dbText, 50)
   Set Champs(10) = Table.CreateField("T_TotalBoulangerie", dbText, 50)
   Set Champs(11) = Table.CreateField("T_PercRemiseBoulangerie", dbText, 50)
   Set Champs(12) = Table.CreateField("T_ST_Patisserie", dbText, 50)
   Set Champs(13) = Table.CreateField("T_RemisePatisserie", dbText, 50)
   Set Champs(14) = Table.CreateField("T_TotalPatisserie", dbText, 50)
   Set Champs(15) = Table.CreateField("T_PercRemisePatisserie", dbText, 50)
   Set Champs(16) = Table.CreateField("T_TotalTTC", dbText, 50)
   Set Champs(17) = Table.CreateField("T_TotalHT", dbText, 50)
   Set Champs(18) = Table.CreateField("T_DontTVA", dbText, 50)
   Set Champs(19) = Table.CreateField("T_DateCreation", dbText, 50)
   Set Champs(20) = Table.CreateField("T_HeureCreation", dbText, 50)
   Set Champs(21) = Table.CreateField("T_Index", dbLong)
   Set Champs(22) = Table.CreateField("T_AnneeIndex", dbText, 50)
   
   
   'On Ajoute les champs dans la base de donnée
   For a = 0 To 22
    Table.Fields.Append Champs(a)
   Next a
   Table.Fields(21).Attributes = dbAutoIncrField
         
   SgbdNEW.TableDefs.Append Table
    
   Set Table = SgbdNEW.CreateTableDef("T_RaisonSocial")
    
   'Définitions des differents champs
   Set Champs(0) = Table.CreateField("N°", dbLong)
   Set Champs(1) = Table.CreateField("NomEntreprise", dbText, 100)
   Set Champs(2) = Table.CreateField("Adresse1", dbText, 100)
   Set Champs(3) = Table.CreateField("CP1", dbText, 50)
   Set Champs(4) = Table.CreateField("Tel1", dbText, 50)
   Set Champs(5) = Table.CreateField("Adresse2", dbText, 50)
   Set Champs(6) = Table.CreateField("CP2", dbText, 50)
   Set Champs(7) = Table.CreateField("Tel2", dbText, 50)
   Set Champs(8) = Table.CreateField("RCS", dbText, 50)
   Set Champs(9) = Table.CreateField("TVA", dbText, 50)
   Set Champs(10) = Table.CreateField("Ligne_Mediane", dbText, 100)
   Set Champs(11) = Table.CreateField("Fax", dbText, 50)
   Set Champs(12) = Table.CreateField("DetailNomEntreprise", dbText, 100)
   Set Champs(13) = Table.CreateField("Logo", dbText, 50)
   Set Champs(14) = Table.CreateField("SplashScreen", dbBoolean)
   Set Champs(15) = Table.CreateField("Signature", dbText, 50)
   Set Champs(16) = Table.CreateField("FileSplashScreen", dbText, 50)
   Set Champs(17) = Table.CreateField("FontNomEntreprise", dbText, 50)
   Set Champs(18) = Table.CreateField("SizeNomEntreprise", dbText, 50)
   Set Champs(19) = Table.CreateField("ColorNomEntreprise", dbText, 50)
   Set Champs(20) = Table.CreateField("StyleNomEntreprise", dbText, 50)
   Set Champs(21) = Table.CreateField("FontAdresse1", dbText, 50)
   Set Champs(22) = Table.CreateField("SizeAdresse1", dbText, 50)
   Set Champs(23) = Table.CreateField("ColorAdresse1", dbText, 50)
   Set Champs(24) = Table.CreateField("StyleAdresse1", dbText, 50)
   Set Champs(25) = Table.CreateField("FontCP1", dbText, 50)
   Set Champs(26) = Table.CreateField("SizeCP1", dbText, 50)
   Set Champs(27) = Table.CreateField("ColorCP1", dbText, 50)
   Set Champs(28) = Table.CreateField("StyleCP1", dbText, 50)
   Set Champs(29) = Table.CreateField("FontTel1", dbText, 50)
   Set Champs(30) = Table.CreateField("SizeTel1", dbText, 50)
   Set Champs(31) = Table.CreateField("ColorTel1", dbText, 50)
   Set Champs(32) = Table.CreateField("StyleTel1", dbText, 50)
   Set Champs(33) = Table.CreateField("FontDetailNomEntreprise", dbText, 50)
   Set Champs(34) = Table.CreateField("SizeDetailNomEntreprise", dbText, 50)
   Set Champs(35) = Table.CreateField("ColorDetailNomEntreprise", dbText, 50)
   Set Champs(36) = Table.CreateField("StyleDetailNomEntreprise", dbText, 50)
   Set Champs(37) = Table.CreateField("FontAdresse2", dbText, 50)
   Set Champs(38) = Table.CreateField("SizeAdresse2", dbText, 50)
   Set Champs(39) = Table.CreateField("ColorAdresse2", dbText, 50)
   Set Champs(40) = Table.CreateField("StyleAdresse2", dbText, 50)
   Set Champs(41) = Table.CreateField("FontCP2", dbText, 50)
   Set Champs(42) = Table.CreateField("SizeCP2", dbText, 50)
   Set Champs(43) = Table.CreateField("ColorCP2", dbText, 50)
   Set Champs(44) = Table.CreateField("StyleCP2", dbText, 50)
   Set Champs(45) = Table.CreateField("FontTel2", dbText, 50)
   Set Champs(46) = Table.CreateField("SizeTel2", dbText, 50)
   Set Champs(47) = Table.CreateField("ColorTel2", dbText, 50)
   Set Champs(48) = Table.CreateField("StyleTel2", dbText, 50)
   Set Champs(49) = Table.CreateField("FontFAX", dbText, 50)
   Set Champs(50) = Table.CreateField("SizeFAX", dbText, 50)
   Set Champs(51) = Table.CreateField("ColorFAX", dbText, 50)
   Set Champs(52) = Table.CreateField("StyleFAX", dbText, 50)
   Set Champs(53) = Table.CreateField("FontRCS", dbText, 50)
   Set Champs(54) = Table.CreateField("SizeRCS", dbText, 50)
   Set Champs(55) = Table.CreateField("ColorRCS", dbText, 50)
   Set Champs(56) = Table.CreateField("StyleRCS", dbText, 50)
   Set Champs(57) = Table.CreateField("FontTVA", dbText, 50)
   Set Champs(58) = Table.CreateField("SizeTVA", dbText, 50)
   Set Champs(59) = Table.CreateField("ColorTVA", dbText, 50)
   Set Champs(60) = Table.CreateField("StyleTVA", dbText, 50)
   Set Champs(61) = Table.CreateField("FontLigneMediane", dbText, 50)
   Set Champs(62) = Table.CreateField("SizeLigneMediane", dbText, 50)
   Set Champs(63) = Table.CreateField("ColorLigneMediane", dbText, 50)
   Set Champs(64) = Table.CreateField("StyleLigneMediane", dbText, 50)
   Set Champs(65) = Table.CreateField("FontSignature", dbText, 50)
   Set Champs(66) = Table.CreateField("SizeSignature", dbText, 50)
   Set Champs(67) = Table.CreateField("ColorSignature", dbText, 50)
   Set Champs(68) = Table.CreateField("StyleSignature", dbText, 50)
   Set Champs(69) = Table.CreateField("FontFacture", dbText, 50)
   Set Champs(70) = Table.CreateField("SizeFacture", dbText, 50)
   Set Champs(71) = Table.CreateField("ColorFacture", dbText, 50)
   Set Champs(72) = Table.CreateField("StyleFacture", dbText, 50)
   Set Champs(73) = Table.CreateField("FontDate", dbText, 50)
   Set Champs(74) = Table.CreateField("SizeDate", dbText, 50)
   Set Champs(75) = Table.CreateField("ColorDate", dbText, 50)
   Set Champs(76) = Table.CreateField("StyleDate", dbText, 50)
   Set Champs(77) = Table.CreateField("FontClient", dbText, 50)
   Set Champs(78) = Table.CreateField("SizeClient", dbText, 50)
   Set Champs(79) = Table.CreateField("ColorClient", dbText, 50)
   Set Champs(80) = Table.CreateField("StyleClient", dbText, 50)
   Set Champs(81) = Table.CreateField("FontLigneBoulangerie", dbText, 50)
   Set Champs(82) = Table.CreateField("SizeLigneBoulangerie", dbText, 50)
   Set Champs(83) = Table.CreateField("ColorLigneBoulangerie", dbText, 50)
   Set Champs(84) = Table.CreateField("StyleLigneBoulangerie", dbText, 50)
   Set Champs(85) = Table.CreateField("FontLignePatisserie", dbText, 50)
   Set Champs(86) = Table.CreateField("SizeLignePatisserie", dbText, 50)
   Set Champs(87) = Table.CreateField("ColorLignePatisserie", dbText, 50)
   Set Champs(88) = Table.CreateField("StyleLignePatisserie", dbText, 50)
   Set Champs(89) = Table.CreateField("FontTOTALTTC", dbText, 50)
   Set Champs(90) = Table.CreateField("SizeTOTALTTC", dbText, 50)
   Set Champs(91) = Table.CreateField("ColorTOTALTTC", dbText, 50)
   Set Champs(92) = Table.CreateField("StyleTOTALTTC", dbText, 50)
   Set Champs(93) = Table.CreateField("FontDesignation", dbText, 50)
   Set Champs(94) = Table.CreateField("SizeDesignation", dbText, 50)
   Set Champs(95) = Table.CreateField("ColorDesignation", dbText, 50)
   Set Champs(96) = Table.CreateField("StyleDesignation", dbText, 50)
   
   
   
   
   'On Ajoute les champs dans la base de donnée
   For a = 0 To 96
    Table.Fields.Append Champs(a)
   Next a
   
   Table.Fields(0).Attributes = dbAutoIncrField
   Table.Fields(16).AllowZeroLength = True
   Table.Fields(20).AllowZeroLength = True
   Table.Fields(24).AllowZeroLength = True
   Table.Fields(28).AllowZeroLength = True
   Table.Fields(32).AllowZeroLength = True
   Table.Fields(36).AllowZeroLength = True
   Table.Fields(40).AllowZeroLength = True
   Table.Fields(44).AllowZeroLength = True
   Table.Fields(48).AllowZeroLength = True
   Table.Fields(52).AllowZeroLength = True
   Table.Fields(56).AllowZeroLength = True
   Table.Fields(60).AllowZeroLength = True
   Table.Fields(64).AllowZeroLength = True
   Table.Fields(68).AllowZeroLength = True
   Table.Fields(72).AllowZeroLength = True
   Table.Fields(76).AllowZeroLength = True
   Table.Fields(80).AllowZeroLength = True
   Table.Fields(84).AllowZeroLength = True
   Table.Fields(88).AllowZeroLength = True
   Table.Fields(92).AllowZeroLength = True
   Table.Fields(96).AllowZeroLength = True
   
   
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   Set Table = SgbdNEW.CreateTableDef("T_Produit_Patisserie")
    
   'Définitions des differents champs
   Set Champs(0) = Table.CreateField("T_Designation", dbText, 50)
   Set Champs(1) = Table.CreateField("T_Prix", dbText, 50)
   Set Champs(2) = Table.CreateField("T_Index", dbLong)
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields(2).Attributes = dbAutoIncrField
      
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
    Set Table = SgbdNEW.CreateTableDef("T_Produit_Boulangerie")
    
   'Définitions des differents champs
   Set Champs(0) = Table.CreateField("T_Designation", dbText, 50)
   Set Champs(1) = Table.CreateField("T_Prix", dbText, 50)
   Set Champs(2) = Table.CreateField("T_Index", dbLong)
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields(2).Attributes = dbAutoIncrField
      
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
      
      
      Set Table = SgbdNEW.CreateTableDef("T_Facture_Patisserie")
    
   'Définitions des differents champs de RECORD MATERIEL
   Set Champs(0) = Table.CreateField("T_NumFacture", dbText, 10)
   Set Champs(1) = Table.CreateField("T_Produit", dbText, 50)
   Set Champs(2) = Table.CreateField("T_Prix", dbText, 10)
   Set Champs(3) = Table.CreateField("T_PrixTTC", dbText, 50)
   Set Champs(4) = Table.CreateField("T_TotalHT", dbText, 50)
   Set Champs(5) = Table.CreateField("T_TotalTTC", dbText, 50)
   Set Champs(6) = Table.CreateField("T_Quantite", dbText, 10)
   Set Champs(7) = Table.CreateField("T_TVA", dbText, 10)
   Set Champs(8) = Table.CreateField("T_Index", dbLong)
   Set Champs(9) = Table.CreateField("T_AnneeIndex", dbText, 50)
   
   'On Ajoute les champs dans la base de donnée
   For a = 0 To 9
    Table.Fields.Append Champs(a)
   Next a
   Table.Fields(8).Attributes = dbAutoIncrField
      
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   Set Table = SgbdNEW.CreateTableDef("T_Facture_Boulangerie")
    
   Set Champs(0) = Table.CreateField("T_NumFacture", dbText, 10)
   Set Champs(1) = Table.CreateField("T_Produit", dbText, 50)
   Set Champs(2) = Table.CreateField("T_Prix", dbText, 10)
   Set Champs(3) = Table.CreateField("T_PrixTTC", dbText, 50)
   Set Champs(4) = Table.CreateField("T_TotalHT", dbText, 50)
   Set Champs(5) = Table.CreateField("T_TotalTTC", dbText, 50)
   Set Champs(6) = Table.CreateField("T_Quantite", dbText, 10)
   Set Champs(7) = Table.CreateField("T_TVA", dbText, 10)
   Set Champs(8) = Table.CreateField("T_Index", dbLong)
   Set Champs(9) = Table.CreateField("T_AnneeIndex", dbText, 50)
   
   'On Ajoute les champs dans la base de donnée
   For a = 0 To 9
    Table.Fields.Append Champs(a)
   Next a
   Table.Fields(8).Attributes = dbAutoIncrField
   
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   
   
   Set Table = SgbdNEW.CreateTableDef("T_Clients")
    
   Set Champs(0) = Table.CreateField("NomClient", dbText, 50)
   Set Champs(1) = Table.CreateField("Adresse", dbText, 50)
   Set Champs(2) = Table.CreateField("Adresse2", dbText, 50)
   Set Champs(3) = Table.CreateField("Index", dbLong)
   
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields.Append Champs(3)
   Table.Fields(3).Attributes = dbAutoIncrField
   
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   
   Set Table = SgbdNEW.CreateTableDef("T_Option")
    
   Set Champs(0) = Table.CreateField("N°", dbLong)
   Set Champs(1) = Table.CreateField("BottomMargin", dbText, 50)
   Set Champs(2) = Table.CreateField("LeftMargin", dbText, 50)
   Set Champs(3) = Table.CreateField("RightMargin", dbText, 50)
   Set Champs(4) = Table.CreateField("TopMargin", dbText, 50)
   Set Champs(5) = Table.CreateField("Lieu", dbText, 50)
      
   
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields.Append Champs(3)
   Table.Fields.Append Champs(4)
   Table.Fields.Append Champs(5)
   Table.Fields(0).Attributes = dbAutoIncrField
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   
   Set Table = SgbdNEW.CreateTableDef("T_Option2")
    
   Set Champs(0) = Table.CreateField("N°", dbLong)
   Set Champs(1) = Table.CreateField("NumFacture", dbText, 50)
   Set Champs(2) = Table.CreateField("DefautImpression", dbText, 50)
   
   
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields(0).Attributes = dbAutoIncrField
   
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   Set Table = SgbdNEW.CreateTableDef("T_Remise")
    
   Set Champs(0) = Table.CreateField("N°", dbLong)
   Set Champs(1) = Table.CreateField("Affichage_Remise1", dbText, 25)
   Set Champs(2) = Table.CreateField("RemiseBoulangerie1", dbText, 3)
   Set Champs(3) = Table.CreateField("RemisePatisserie1", dbText, 3)
   Set Champs(4) = Table.CreateField("Affichage_Remise2", dbText, 25)
   Set Champs(5) = Table.CreateField("RemiseBoulangerie2", dbText, 3)
   Set Champs(6) = Table.CreateField("RemisePatisserie2", dbText, 3)
   Set Champs(7) = Table.CreateField("Affichage_Remise3", dbText, 25)
   Set Champs(8) = Table.CreateField("RemiseBoulangerie3", dbText, 3)
   Set Champs(9) = Table.CreateField("RemisePatisserie3", dbText, 3)
   Set Champs(10) = Table.CreateField("Affichage_Remise4", dbText, 25)
   Set Champs(11) = Table.CreateField("RemiseBoulangerie4", dbText, 3)
   Set Champs(12) = Table.CreateField("RemisePatisserie4", dbText, 3)
   
   
   
   'On Ajoute les champs dans la base de donnée
   Table.Fields.Append Champs(0)
   Table.Fields.Append Champs(1)
   Table.Fields.Append Champs(2)
   Table.Fields.Append Champs(3)
   Table.Fields.Append Champs(4)
   Table.Fields.Append Champs(5)
   Table.Fields.Append Champs(6)
   Table.Fields.Append Champs(7)
   Table.Fields.Append Champs(8)
   Table.Fields.Append Champs(9)
   Table.Fields.Append Champs(10)
   Table.Fields.Append Champs(11)
   Table.Fields.Append Champs(12)
   Table.Fields(0).Attributes = dbAutoIncrField
   
   'Sauvegarde des tables dans la base
   SgbdNEW.TableDefs.Append Table
   
   'Fermeture de la base
   SgbdNEW.Close
   
   
   r = MsgBox("La Base Boulangerie à été Creer", vbOKOnly, "Boulangerie")
   Exit Sub
    
err:
If err.Number = 13 Then
Resume Next
End If

Resume Next
End Sub

Public Function InfoBase() As Info
'Information sur la base
On Error GoTo err
InfoBase.Taille_Base = (FileLen(path_base) / 1024)
Set rst = dbs.OpenRecordset("SELECT * FROM [T_Record]")
rst.MoveLast
rst.MoveFirst
InfoBase.nb_enregistrement = rst.RecordCount
Exit Function

err:
If err.Number = 3420 Then
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set dbs = wrkJet.OpenDatabase(path_base, True, False, ";pwd=" & pwd)
    Resume
End If

If err.Number = 3021 Then Resume Next
End Function
Public Sub ApercuAvtImpression(NumFacture As Integer, Rapide As Boolean, RemiseBoulangerie As Boolean, RemisePatisserie As Boolean, NewParametre As Boolean, ImpressionDirecte As Boolean)
On Error GoTo err
Dim temp As Byte
Dim i As Long, j As Long, k As Single
Dim t As clsTables, c As clsColumns
Dim ta As clsTableAttributes, ca As clsColumnAttributes, la As clsLabelAttributes, ia As clsImageAttributes, linea As clsLineAttributes, ra As clsRectangleAttributes, laex As clsLabelExAttributes, pa As clsPointAttributes
Dim ary() As String, str As String, aryPatisserie() As String
Dim db As Database, rs As recordset
Dim sngAry() As Single

If Rapide = True Then
Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rs = dbs.OpenRecordset("Select * from [T_Facture_Boulangerie] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
    rs.MoveLast
    rs.MoveFirst
End If

    
NewReport
If ImpressionDirecte = False Then
    DoEvents
    Frm_Message.Show 0, Frm_Main
    DoEvents
End If

If Rapide = True Then
    If Frm_Main.ListView3.ListItems.Count >= 20 Then
        b = 1
    Else
        b = 20 - Frm_Main.ListView3.ListItems.Count
    End If
    ReDim ary(1 To 5, 1 To Frm_Main.ListView3.ListItems.Count + b)
Else
    If rs.RecordCount >= 20 Then
        b = 1
    Else
        b = 20 - rs.RecordCount
    End If
    ReDim ary(1 To 5, 1 To rs.RecordCount + b)
End If

ary(1, 1) = "Désignation BOULANGERIE"
ary(2, 1) = "Quantité"
ary(3, 1) = "Prix Unitaire TTC"
ary(4, 1) = "Montant TTC"
ary(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
    For j = 2 To Frm_Main.ListView3.ListItems.Count + 1
        ary(1, j) = Frm_Main.ListView3.ListItems.Item(j - 1).Text & vbNullString
        ary(2, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(1) & vbNullString
        ary(3, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(2) & vbNullString
        ary(4, j) = Format(Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
    Next j
Else
    For j = 2 To rs.RecordCount + b
        ary(1, j) = rs.Fields(1) & vbNullString
        ary(2, j) = rs.Fields(6) & vbNullString
        ary(3, j) = rs.Fields(2) & vbNullString
        ary(4, j) = Format(rs.Fields(5), "0.00") & vbNullString
        rs.MoveNext
    Next j
End If

If Rapide = True Then
Else
    Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
    Set rst = dbs.OpenRecordset("Select * from [T_Facture_Patisserie] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
        rst.MoveLast
        rst.MoveFirst
End If

If Rapide = True Then
    If Frm_Main.ListView4.ListItems.Count >= 8 Then
        b = 1
    Else
        b = 8 - Frm_Main.ListView4.ListItems.Count
    End If
    
    If Frm_Main.ListView4.ListItems.Count = 0 Then
        ReDim aryPatisserie(1 To 5, 1 To b)
    Else
        ReDim aryPatisserie(1 To 5, 1 To Frm_Main.ListView4.ListItems.Count + b)
    End If
Else
    If rst.RecordCount >= 8 Then
        b = 1
    Else
        b = 8 - rst.RecordCount
    End If
    ReDim aryPatisserie(1 To 5, 1 To rst.RecordCount + b)
End If


aryPatisserie(1, 1) = "Désignation PATISSERIE"
aryPatisserie(2, 1) = "Quantité"
aryPatisserie(3, 1) = "Prix Unitaire TTC"
aryPatisserie(4, 1) = "Montant TTC"
aryPatisserie(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
    For j = 2 To Frm_Main.ListView4.ListItems.Count + 1
        aryPatisserie(1, j) = Frm_Main.ListView4.ListItems.Item(j - 1).Text & vbNullString
        aryPatisserie(2, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(1) & vbNullString
        aryPatisserie(3, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(2) & vbNullString
        aryPatisserie(4, j) = Format(Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
    Next j
Else
    For j = 2 To rst.RecordCount + 1
        aryPatisserie(1, j) = rst.Fields(1) & vbNullString
        aryPatisserie(2, j) = rst.Fields(6) & vbNullString
        aryPatisserie(3, j) = rst.Fields(2) & vbNullString
        aryPatisserie(4, j) = Format(rst.Fields(5), "0.00") & vbNullString
        rst.MoveNext
    Next j
End If

With PrinterEx
    .Orientation = OPortrait
    .PageSize = sizeA4
    If NewParametre = False Then
    .BottomMargin = BottomMargin
    .LeftMargin = LeftMargin
    .RightMargin = RightMargin
    .TopMargin = TopMargin
    Else
    .BottomMargin = Frm_New_Parametre.Txt_MargeBas
    .LeftMargin = Frm_New_Parametre.Txt_MargeGauche
    .RightMargin = Frm_New_Parametre.Txt_Margedroite
    .TopMargin = Frm_New_Parametre.txt_MargeHaut
    End If
    
    With .Repeats
             .AddLabel "- &[Page] -", 170, 0, 185, 15, , DT_CENTER
    End With
    
    Set ia = .Images.Add(LoadPicture(App.Path & "\" & InfoRaisonSocial.T_Logo), 0, -30)
    
    Set la = .Labels.Add(InfoRaisonSocial.T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = False
    la.Align = DT_CENTER
    la.ForeColor = Color.NomEntreprise
    la.FontName = Police.NomEntreprise
    la.FontSize = 20
   
    
     Set la = .Labels.Add(InfoRaisonSocial.T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_CENTER
     la.ForeColor = Color.DetailNomEntreprise
     la.FontName = Police.DetailNomEntreprise
     la.FontSize = 18
    
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP1, 0, 12, 40, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP1
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
    If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Tel1
    la.FontName = Police.Tel1
    la.FontSize = 9
    la.FontBold = True
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Fax, 8, 20.5, 41, 25, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Fax
    la.FontName = Police.Fax
    la.FontSize = 9
    la.FontBold = True
    'la.BorderWidth = 1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse2
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse2
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP2, 151, 11, 184, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP2
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP2
    
     'Affichage du Sigle telephone marigné
    If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
        Set la = .Labels.Add("(", 150, 16, 158, 20, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings"
        la.FontSize = 12
    End If
    
    
   
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel2, 153, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel2
    la.FontName = Police.Tel2
    la.FontSize = 9
    la.FontBold = True
    
    
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Facture
    la.FontName = Police.Facture
    la.FontSize = 12
    la.FontBold = True
        
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(InfoRecord2(NumFacture).T_Date, 15.5, 39.8, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.DateFacture
    la.FontName = Police.DateFacture
    la.FontSize = 12
    la.FontBold = True
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_Clients, 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_AdresseClients, 117, 32, 180, 38, True)
    End If
    
      
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_AdresseClients2, 117, 39, 180, 45, True)
    End If
    
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
     
    Set ta = .Tables.Add(ary, 1, 10, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Color.LigneBoulangerie
        .BodyFontName = Police.LigneBoulangerie
        .TitleHeight = 6
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        .CellSpacing = 0.5
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemiseBoulangerie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Boulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
          Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemiseBoulangerie, 126, 0, 156, 5, False)
     Else
          Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Boulangerie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
            Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemiseBoulangerie, 156, -5, 181, 0, False)
    Else
            Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemiseBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
   End If
   Set la = .Labels.Add("Total Boulangerie", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalBoulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Boulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
    
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentaireBoulangerie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Frm_Main.txt_commentaire_boulangerie.Text, 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbRed
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 233, 156, 238, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTTC3.Caption, "0.00"), 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = Color.TotalTTC
        la.FontName = Police.TotalTTC
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 233, 181, 238, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTVA.Caption, "0.00"), 156, 233, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 238, 181, 243, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.lbl_TotalHT.Caption, "0.00"), 156, 238, 181, 243, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial.T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.LigneMediane
    la.FontName = Police.LigneMediane
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial.T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Color.RCS
    la.FontName = Police.RCS
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial.T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Color.TVA
    la.FontName = Police.TVA
    
    .PageBreaks.Add
    Set ia = .Images.Add(LoadPicture(App.Path & "\" & InfoRaisonSocial.T_Logo), 0, -30)
    
     'Set la = .Labels.Add(InfoRaisonSocial.T_NomEntreprise, 50, -30, 410, 10, True)
     Set la = .Labels.Add(InfoRaisonSocial.T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = False
    la.Align = DT_CENTER
    la.ForeColor = Color.NomEntreprise
    la.FontName = Police.NomEntreprise
    la.FontSize = 20
    
     'Set la = .Labels.Add(InfoRaisonSocial.T_DetailNomEntreprise, 65, -22, 410, 10, True)
     Set la = .Labels.Add(InfoRaisonSocial.T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_CENTER
     la.ForeColor = Color.DetailNomEntreprise
     la.FontName = Police.DetailNomEntreprise
     la.FontSize = 18
   
    
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
   
   Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP1, 0, 12, 40, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP1
    
    'Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1 & " " & InfoRaisonSocial.T_CP1, 0, 8, 40, 15, True)
    'la.WordWrap = True
    'la.Align = DT_CENTER
    'la.ForeColor = Color.CP1
    'la.FontName = Police.CP1
    'la.FontSize = 9
    'la.FontBold = True
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
   
    If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel1
    la.FontName = Police.Tel1
    la.FontSize = 9
    la.FontBold = True
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Fax, 8, 20.5, 41, 25, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Fax
    la.FontName = Police.Fax
    la.FontSize = 9
    la.FontBold = True
    'la.BorderWidth = 1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse2
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse2
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP2, 151, 11, 184, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP2
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP2
    
    'Set la = .Labels.Add(InfoRaisonSocial.T_Adresse2 & " " & InfoRaisonSocial.T_CP2, 151, 7, 184, 15, True)
    'la.WordWrap = True
    'la.Align = DT_CENTER
    'la.ForeColor = Color.CP2
    'la.FontName = Police.CP2
    'la.FontSize = 9
    'la.FontBold = True
    
    If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
     'Affichage du Sigle telephone marigné
    Set la = .Labels.Add("(", 153, 16, 158, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    End If
    
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel2, 160, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel2
    la.FontName = Police.Tel2
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Facture
    la.FontName = Police.Facture
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(InfoRecord2(NumFacture).T_Date, 15.5, 39.8, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.DateFacture
    la.FontName = Police.DateFacture
    la.FontSize = 12
    la.FontBold = True
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(3), 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(4), 117, 32, 180, 38, True)
    End If
    
      
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(5), 117, 39, 180, 45, True)
    End If
    
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    Set ta = .Tables.Add(aryPatisserie, 1, 10, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Color.LignePatisserie
        .BodyFontName = Police.LignePatisserie
        .TitleHeight = 6
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemisePatisserie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Patisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalPatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemisePatisserie, 126, 0, 156, 5, False)
     Else
        Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Patisserie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemisePatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemisePatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    End If
    Set la = .Labels.Add("Total Patisserie", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalPatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Patisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentairePatisserie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.txt_commentaire_patisserie.Text, "0.00"), 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbRed
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 233, 156, 238, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTTC3.Caption, "0.00"), 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = Color.TotalTTC
        la.FontName = Police.TotalTTC
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 233, 181, 238, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTVA.Caption, "0.00"), 156, 233, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 238, 181, 243, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.lbl_TotalHT.Caption, "0.00"), 156, 238, 181, 243, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial.T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.LigneMediane
    la.FontName = Police.LigneMediane
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial.T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Color.RCS
    la.FontName = Police.RCS
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial.T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Color.TVA
    la.FontName = Police.TVA
End With

If Rapide = False Then
 rs.Close
 Set rs = Nothing
 db.Close
 Set db = Nothing
End If

If ImpressionDirecte = True Then
PrinterEx.PrintDoc frmTest.hWnd
Else
frmTest.Command8.Value = True
Frm_Message.Hide
End If
Exit Sub


err:
If err.Number = 13 Then Resume Next
If err.Number = 3021 Then
Resume Next
End If
End Sub
Public Sub ApercuRaisonSocial(NumFacture, Rapide As Boolean, RemiseBoulangerie As Boolean, RemisePatisserie As Boolean, NewParametre As Boolean, ImpressionDirecte As Boolean)
On Error GoTo err
Dim temp As Byte
Dim i As Long, j As Long, k As Single
Dim t As clsTables, c As clsColumns
Dim ta As clsTableAttributes, ca As clsColumnAttributes, la As clsLabelAttributes, ia As clsImageAttributes, linea As clsLineAttributes, ra As clsRectangleAttributes, laex As clsLabelExAttributes, pa As clsPointAttributes
Dim ary() As String, str As String, aryPatisserie() As String
Dim db As Database, rs As recordset
Dim sngAry() As Single

If FontNomEntreprise = "" Then FontNomEntreprise = "Arial"
If SizeNomEntreprise = "" Then SizeNomEntreprise = "20"
If ColorNomEntreprise = "" Then ColorNomEntreprise = "vbblue"

InfoRaisonSocial_T_Adresse1 = Frm_Config.txt_adresse1.Text
InfoRaisonSocial_T_Adresse2 = Frm_Config.txt_adresse2.Text
InfoRaisonSocial_T_CP1 = Frm_Config.Txt_CP1.Text
InfoRaisonSocial_T_CP2 = Frm_Config.Txt_CP2.Text
InfoRaisonSocial_T_DetailNomEntreprise = Frm_Config.txt_DetailNomEntreprise.Text
InfoRaisonSocial_T_Fax = Frm_Config.Txt_Fax.Text
InfoRaisonSocial_T_LigneMediane = Frm_Config.Txt_LigneMediane.Text
'InfoRaisonSocial_T_Logo = ""
InfoRaisonSocial_T_NomEntreprise = Frm_Config.Txt_Nom_Entreprise.Text
InfoRaisonSocial_T_RCS = Frm_Config.Txt_Num_RCS.Text
InfoRaisonSocial_T_Tel1 = Frm_Config.Txt_Tel1.Text
InfoRaisonSocial_T_Tel2 = Frm_Config.Txt_Tel2.Text
InfoRaisonSocial_T_TVA = Frm_Config.Txt_NumTVA.Text
If Frm_Config.lbl_NomLogo.Caption = "" Then
   InfoRaisonSocial_T_Logo = App.Path & "\epi.jpg"
Else
   InfoRaisonSocial_T_Logo = App.Path & "\" & Frm_Config.lbl_NomLogo
End If
InfoRaisonSocial_T_Signature = Frm_Config.Txt_Signature.Text


If Rapide = True Then
Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rs = dbs.OpenRecordset("Select * from [T_Facture_Boulangerie] where [T_NumFacture]like '" & CInt(NumFacture) & "'")
    rs.MoveLast
    rs.MoveFirst
End If

    
NewReport
If ImpressionDirecte = False Then
    DoEvents
    Frm_Message.Show 0, Frm_Main
    DoEvents
End If
If Rapide = True Then
If Frm_Main.ListView3.ListItems.Count >= 20 Then
b = 1
Else
b = 20 - Frm_Main.ListView3.ListItems.Count
End If
ReDim ary(1 To 5, 1 To Frm_Main.ListView3.ListItems.Count + b)
Else
If rs.RecordCount >= 20 Then
 b = 1
Else
 b = 20 - rs.RecordCount
End If
ReDim ary(1 To 5, 1 To rs.RecordCount + b)
End If

ary(1, 1) = "Désignation BOULANGERIE"
ary(2, 1) = "Quantité"
ary(3, 1) = "Prix Unitaire TTC"
ary(4, 1) = "Montant TTC"
ary(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
For j = 2 To Frm_Main.ListView3.ListItems.Count + 1
        ary(1, j) = Frm_Main.ListView3.ListItems.Item(j - 1).Text & vbNullString
        ary(2, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(1) & vbNullString
        ary(3, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(2) & vbNullString
        ary(4, j) = Format(Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
Next j
Else
For j = 2 To rs.RecordCount + b
        ary(1, j) = rs.Fields(1) & vbNullString
        ary(2, j) = rs.Fields(6) & vbNullString
        ary(3, j) = rs.Fields(2) & vbNullString
        ary(4, j) = Format(rs.Fields(5), "0.00") & vbNullString
        rs.MoveNext
Next j
End If
If Rapide = True Then
Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rst = dbs.OpenRecordset("Select * from [T_Facture_Patisserie] where [T_NumFacture]like '" & CInt(NumFacture) & "'")
    rst.MoveLast
    rst.MoveFirst
End If

If Rapide = True Then
If Frm_Main.ListView4.ListItems.Count >= 8 Then
b = 1
Else
b = 8 - Frm_Main.ListView4.ListItems.Count
End If
If Frm_Main.ListView4.ListItems.Count = 0 Then
    ReDim aryPatisserie(1 To 5, 1 To b)
Else
    ReDim aryPatisserie(1 To 5, 1 To Frm_Main.ListView4.ListItems.Count + b)
End If
Else
If rst.RecordCount >= 8 Then
b = 1
Else
b = 8 - rst.RecordCount
End If
ReDim aryPatisserie(1 To 5, 1 To rst.RecordCount + b)
End If


aryPatisserie(1, 1) = "Désignation PATISSERIE"
aryPatisserie(2, 1) = "Quantité"
aryPatisserie(3, 1) = "Prix Unitaire TTC"
aryPatisserie(4, 1) = "Montant TTC"
aryPatisserie(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
For j = 2 To Frm_Main.ListView4.ListItems.Count + 1
        aryPatisserie(1, j) = Frm_Main.ListView4.ListItems.Item(j - 1).Text & vbNullString
        aryPatisserie(2, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(1) & vbNullString
        aryPatisserie(3, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(2) & vbNullString
        aryPatisserie(4, j) = Format(Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
Next j
Else
For j = 2 To rst.RecordCount + 1
        aryPatisserie(1, j) = rst.Fields(1) & vbNullString
        aryPatisserie(2, j) = rst.Fields(6) & vbNullString
        aryPatisserie(3, j) = rst.Fields(2) & vbNullString
        aryPatisserie(4, j) = Format(rst.Fields(5), "0.00") & vbNullString
        rst.MoveNext
Next j
End If

With PrinterEx
    .Orientation = OPortrait
    .PageSize = sizeA4
    If NewParametre = False Then
    .BottomMargin = BottomMargin
    .LeftMargin = LeftMargin
    .RightMargin = RightMargin
    .TopMargin = TopMargin
    Else
    .BottomMargin = Frm_New_Parametre.Txt_MargeBas
    .LeftMargin = Frm_New_Parametre.Txt_MargeGauche
    .RightMargin = Frm_New_Parametre.Txt_Margedroite
    .TopMargin = Frm_New_Parametre.txt_MargeHaut
    End If
    
    With .Repeats
             .AddLabel "- &[Page] -", 170, 0, 185, 15, , DT_CENTER
    End With
    
    Set ia = .Images.Add(LoadPicture(InfoRaisonSocial_T_Logo), 0, -30)
    
    Set la = .Labels.Add(InfoRaisonSocial_T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_Nom_Entreprise.SelColor
    la.FontName = Frm_Config.Txt_Nom_Entreprise.SelFontName
    la.FontSize = "20"
      
    
     Set la = .Labels.Add(InfoRaisonSocial_T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_CENTER
     la.ForeColor = Frm_Config.txt_DetailNomEntreprise.SelColor
     la.FontName = Frm_Config.txt_DetailNomEntreprise.SelFontName
     la.FontSize = 18
    
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.txt_adresse1.SelColor
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Frm_Config.txt_adresse1.SelFontName
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP1, 0, 12, 40, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_CP1.SelColor
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Frm_Config.Txt_CP1.SelFontName
    
    'Set la = .Labels.Add(InfoRaisonSocial_T_Adresse1 & " " & InfoRaisonSocial_T_CP1, 0, 8, 40, 15, True)
    'la.WordWrap = True
    'la.Align = DT_CENTER
    'la.ForeColor = Frm_Config.Txt_CP1.SelColor
    'la.FontName = Frm_Config.Txt_CP1.SelFontName
    'la.FontSize = 9
    'la.FontBold = True
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
     If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_Tel1.SelColor
    la.FontName = Frm_Config.Txt_Tel1.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Fax, 8, 20.5, 41, 25, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.Txt_Fax.SelColor
    la.FontName = Frm_Config.Txt_Fax.SelFontName
    la.FontSize = 9
    la.FontBold = True
    'la.BorderWidth = 1
    
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Adresse2 & " " & InfoRaisonSocial_T_Tel2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.txt_adresse2.SelColor
    la.FontName = Frm_Config.txt_adresse2.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
     'Affichage du Sigle telephone marigné
    If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
    Set la = .Labels.Add("(", 153, 16, 158, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    End If
    Set la = .Labels.Add(InfoRaisonSocial_T_Tel2, 160, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_Tel2.SelColor
    la.FontName = Frm_Config.Txt_Tel2.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_NumFacture.SelColor
    la.FontName = Frm_Config.RTB_NumFacture.SelFontName
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(InfoRecord2(NumFacture).T_Date, 15, 40, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_DateFacture.SelColor
    la.FontName = Frm_Config.RTB_DateFacture.SelFontName
    la.FontSize = 12
    la.FontBold = True
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(3), 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(4), 117, 32, 180, 38, True)
    End If
    
      
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(5), 117, 39, 180, 45, True)
    End If
    
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    
     
    Set ta = .Tables.Add(ary, 1, 10, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Frm_Config.RTB_Boulangerie.SelColor
        .BodyFontName = Frm_Config.RTB_Boulangerie.SelFontName
        .TitleHeight = 6
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        .CellSpacing = 0.5
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemiseBoulangerie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Boulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
          Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemiseBoulangerie, 126, 0, 156, 5, False)
     Else
          Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Boulangerie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
            Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemiseBoulangerie, 156, -5, 181, 0, False)
    Else
            Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemiseBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
   End If
   Set la = .Labels.Add("Total Boulangerie", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalBoulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Boulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
    
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentaireBoulangerie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Frm_Main.txt_commentaire_boulangerie.Text, 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbRed
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 233, 156, 238, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTTC3.Caption, "0.00"), 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = Frm_Config.RTB_TotalTTC.SelColor
        la.FontName = Frm_Config.RTB_TotalTTC.SelFontName
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 233, 181, 238, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTVA.Caption, "0.00"), 156, 233, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 238, 181, 243, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.lbl_TotalHT.Caption, "0.00"), 156, 238, 181, 243, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial_T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.Txt_LigneMediane.SelColor
    la.FontName = Frm_Config.Txt_LigneMediane.SelFontName
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial_T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Frm_Config.Txt_Num_RCS.SelColor
    la.FontName = Frm_Config.Txt_Num_RCS.SelFontName
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial_T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Frm_Config.Txt_NumTVA.SelColor
    la.FontName = Frm_Config.Txt_NumTVA.SelFontName
    
    .PageBreaks.Add
    Set ia = .Images.Add(LoadPicture(InfoRaisonSocial_T_Logo), 0, -30)
    
     Set la = .Labels.Add(InfoRaisonSocial_T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.Txt_Nom_Entreprise.SelColor
    la.FontName = Frm_Config.Txt_Nom_Entreprise.SelFontName
    la.FontSize = 20
    
     Set la = .Labels.Add(InfoRaisonSocial_T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_LEFT
     la.ForeColor = Frm_Config.txt_DetailNomEntreprise.SelColor
     la.FontName = Frm_Config.txt_DetailNomEntreprise.SelFontName
     la.FontSize = 18
   
    
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Adresse1 & " " & InfoRaisonSocial_T_CP1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_CP1.SelColor
    la.FontName = Frm_Config.Txt_CP1.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
     If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_Tel1.SelColor
    la.FontName = Frm_Config.Txt_Tel1.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Adresse2 & " " & InfoRaisonSocial_T_CP2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_CP2.SelColor
    la.FontName = Frm_Config.Txt_CP2.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
     'Affichage du Sigle telephone marigné
    If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
    Set la = .Labels.Add("(", 153, 16, 158, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial_T_Tel2, 160, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Frm_Config.Txt_Tel2.SelColor
    la.FontName = Frm_Config.Txt_Tel2.SelFontName
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_NumFacture.SelColor
    la.FontName = Frm_Config.RTB_NumFacture.SelFontName
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(Date, 15, 40, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_DateFacture.SelColor
    la.FontName = Frm_Config.RTB_DateFacture.SelFontName
    la.FontSize = 12
    la.FontBold = True
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(3), 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(4), 117, 32, 180, 38, True)
    End If
    
      
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(5), 117, 39, 180, 45, True)
    End If
    
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.RTB_Client.SelColor
    la.FontName = Frm_Config.RTB_Client.SelFontName
    la.FontSize = 12
    la.FontItalic = True
    Set ta = .Tables.Add(aryPatisserie, 1, 10, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Frm_Config.RTB_Patisserie.SelColor
        .BodyFontName = Frm_Config.RTB_Patisserie.SelFontName
        .TitleHeight = 6
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemisePatisserie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Patisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalPatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemisePatisserie, 126, 0, 156, 5, False)
     Else
        Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Patisserie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemisePatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemisePatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    End If
    Set la = .Labels.Add("Total Patisserie", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalPatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Patisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentairePatisserie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.txt_commentaire_patisserie.Text, "0.00"), 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbRed
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 233, 156, 238, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTTC3.Caption, "0.00"), 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = Frm_Config.RTB_TotalTTC.SelColor
        la.FontName = Frm_Config.RTB_TotalTTC.SelFontName
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 233, 181, 238, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTVA.Caption, "0.00"), 156, 233, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 238, 181, 243, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.lbl_TotalHT.Caption, "0.00"), 156, 238, 181, 243, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    
    Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial_T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Frm_Config.Txt_LigneMediane.SelColor
    la.FontName = Frm_Config.Txt_LigneMediane.SelFontName
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial_T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Frm_Config.Txt_Num_RCS.SelColor
    la.FontName = Frm_Config.Txt_Num_RCS.SelFontName
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial_T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Frm_Config.Txt_NumTVA.SelColor
    la.FontName = Frm_Config.Txt_NumTVA.SelFontName
End With

If Rapide = False Then
 rs.Close
 Set rs = Nothing
 db.Close
 Set db = Nothing
End If

If ImpressionDirecte = True Then
PrinterEx.PrintDoc frmTest.hWnd
Else
frmTest.Command8.Value = True
Frm_Message.Hide
End If
Exit Sub


err:
If err.Number = 13 Then Resume Next
If err.Number = 3021 Then
Resume Next
End If
End Sub

Private Function Color() As Color
        Set rst = dbs.OpenRecordset("Select * from [T_RaisonSocial]")
        rst.MoveLast
        rst.MoveFirst
        Color.DetailNomEntreprise = rst.Fields(35)
        Color.adresse1 = rst.Fields(23)
        Color.adresse2 = rst.Fields(39)
        Color.Client = rst.Fields(79)
        Color.CP1 = rst.Fields(27)
        Color.CP2 = rst.Fields(43)
        Color.DateFacture = rst.Fields(75)
        Color.Designation = rst.Fields(95)
        Color.Facture = rst.Fields(71)
        Color.Fax = rst.Fields(51)
        Color.LigneBoulangerie = rst.Fields(83)
        Color.LigneMediane = rst.Fields(63)
        Color.LignePatisserie = rst.Fields(87)
        Color.NomEntreprise = rst.Fields(19)
        Color.RCS = rst.Fields(55)
        Color.Signature = rst.Fields(67)
        Color.Tel1 = rst.Fields(31)
        Color.Tel2 = rst.Fields(47)
        Color.TotalTTC = rst.Fields(91)
        Color.TVA = rst.Fields(59)
End Function

Public Sub ApercuAvtImpression3(NumFacture, Rapide As Boolean, RemiseBoulangerie As Boolean, RemisePatisserie As Boolean, NewParametre As Boolean, ImpressionDirecte As Boolean)
On Error GoTo err
Dim temp As Byte
Dim i As Long, j As Long, k As Single
Dim t As clsTables, c As clsColumns
Dim ta As clsTableAttributes, ca As clsColumnAttributes, la As clsLabelAttributes, ia As clsImageAttributes, linea As clsLineAttributes, ra As clsRectangleAttributes, laex As clsLabelExAttributes, pa As clsPointAttributes
Dim ary() As String, str As String, aryPatisserie() As String
Dim db As Database, rs As recordset
Dim sngAry() As Single



If Rapide = True Then

Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rs = dbs.OpenRecordset("Select * from [T_Facture_Boulangerie] where [T_NumFacture]like  '" & CInt(NumFacture) & "'")
    rs.MoveLast
    rs.MoveFirst
End If

    
NewReport

If ImpressionDirecte = False Then
    DoEvents
    Frm_Message.Show 0, Frm_Main
    DoEvents
End If

If Rapide = True Then
    frmPreview.tbToolBar.Buttons(12).Visible = False
    If Frm_Main.ListView3.ListItems.Count >= 13 Then
        b = 1
    Else
        b = 13 - Frm_Main.ListView3.ListItems.Count
    End If
    ReDim ary(1 To 5, 1 To Frm_Main.ListView3.ListItems.Count + b)
Else
    If rs.RecordCount >= 13 Then
        b = 1
    Else
        b = 13 - rs.RecordCount
    End If
    ReDim ary(1 To 5, 1 To rs.RecordCount + b)
End If

ary(1, 1) = "Désignation BOULANGERIE"
ary(2, 1) = "Quantité"
ary(3, 1) = "Prix Unitaire TTC"
ary(4, 1) = "Montant TTC"
ary(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
    For j = 2 To Frm_Main.ListView3.ListItems.Count + 1
        ary(1, j) = Frm_Main.ListView3.ListItems.Item(j - 1).Text & vbNullString
        ary(2, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(1) & vbNullString
        ary(3, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(2) & vbNullString
        ary(4, j) = Format(Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
    Next j
Else
    For j = 2 To rs.RecordCount + b
        ary(1, j) = rs.Fields(1) & vbNullString
        ary(2, j) = rs.Fields(6) & vbNullString
        ary(3, j) = rs.Fields(2) & vbNullString
        ary(4, j) = Format(rs.Fields(5), "0.00") & vbNullString
        rs.MoveNext
    Next j
End If

If Rapide = True Then
Else
    Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
    Set rst = dbs.OpenRecordset("Select * from [T_Facture_Patisserie] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
    rst.MoveLast
    rst.MoveFirst
End If

If Rapide = True Then
    If Frm_Main.ListView4.ListItems.Count >= 8 Then
        b = 1
    Else
        b = 8 - Frm_Main.ListView4.ListItems.Count
    End If
    
    If Frm_Main.ListView4.ListItems.Count = 0 Then
        ReDim aryPatisserie(1 To 5, 1 To b)
    Else
        ReDim aryPatisserie(1 To 5, 1 To Frm_Main.ListView4.ListItems.Count + b)
    End If
Else
    If rst.RecordCount >= 8 Then
        b = 1
    Else
        b = 8 - rst.RecordCount
    End If
    ReDim aryPatisserie(1 To 5, 1 To rst.RecordCount + b)
End If


aryPatisserie(1, 1) = "Désignation PATISSERIE"
aryPatisserie(2, 1) = "Quantité"
aryPatisserie(3, 1) = "Prix Unitaire TTC"
aryPatisserie(4, 1) = "Montant TTC"
aryPatisserie(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
    For j = 2 To Frm_Main.ListView4.ListItems.Count + 1
        aryPatisserie(1, j) = Frm_Main.ListView4.ListItems.Item(j - 1).Text & vbNullString
        aryPatisserie(2, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(1) & vbNullString
        aryPatisserie(3, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(2) & vbNullString
        aryPatisserie(4, j) = Format(Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
    Next j
Else
    For j = 2 To rst.RecordCount + 1
        aryPatisserie(1, j) = rst.Fields(1) & vbNullString
        aryPatisserie(2, j) = rst.Fields(6) & vbNullString
        aryPatisserie(3, j) = rst.Fields(2) & vbNullString
        aryPatisserie(4, j) = Format(rst.Fields(5), "0.00") & vbNullString
        rst.MoveNext
    Next j
End If

With PrinterEx
    .Orientation = OPortrait
    .PageSize = sizeA4
    If NewParametre = False Then
    .BottomMargin = BottomMargin
    .LeftMargin = LeftMargin
    .RightMargin = RightMargin
    .TopMargin = TopMargin
    Else
    .BottomMargin = Frm_New_Parametre.Txt_MargeBas
    .LeftMargin = Frm_New_Parametre.Txt_MargeGauche
    .RightMargin = Frm_New_Parametre.Txt_Margedroite
    .TopMargin = Frm_New_Parametre.txt_MargeHaut
    End If
    With .Repeats
             .AddLabel "- &[Page] -", 170, 0, 185, 15, , DT_CENTER
    End With
    
    Set ia = .Images.Add(LoadPicture(App.Path & "\" & InfoRaisonSocial.T_Logo), 0, -30)
    
     
    Set la = .Labels.Add(InfoRaisonSocial.T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = False
    la.Align = DT_CENTER
    la.ForeColor = Color.NomEntreprise
    la.FontName = Police.NomEntreprise
    la.FontSize = 20
   
    
     Set la = .Labels.Add(InfoRaisonSocial.T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_CENTER
     la.ForeColor = Color.DetailNomEntreprise
     la.FontName = Police.DetailNomEntreprise
     la.FontSize = 18
     
        
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    
    'Set la = .Labels.Add("30, Rue Dominique Godivier 53200 DAON", 0, 8, 40, 15, True)
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse1
    'la.BorderColor = vbRed
    'la.BorderWidth = 5
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP1, 0, 12, 40, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP1
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
     If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel1
    la.FontName = Police.Tel1
    la.FontSize = 9
    la.FontBold = True
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Fax, 8, 20.5, 41, 25, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Fax
    la.FontName = Police.Fax
    la.FontSize = 9
    la.FontBold = True
    'la.BorderWidth = 1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse2
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse2
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP2, 151, 11, 184, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP2
    la.FontSize = 9
    la.FontBold = True
    
     'Affichage du Sigle telephone marigné
     If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
        Set la = .Labels.Add("(", 150, 16, 158, 20, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings"
        la.FontSize = 12
    End If
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel2, 153, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel2
    la.FontName = Police.Tel2
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Facture
    la.FontName = Police.Facture
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(InfoRecord2(NumFacture).T_Date, 15.5, 39.8, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.DateFacture
    la.FontName = Police.DateFacture
    la.FontSize = 12
    la.FontBold = True
    
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_Clients, 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_AdresseClients, 117, 32, 180, 38, True)
    End If
    
    'If lbl_Adresse1ClientEnCours.Caption = "" Then
   '     Set la = .Labels.Add("", 117, 32, 180, 38, True)
    'Else
    '    Set la = .Labels.Add(lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
    'End If
    
   
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_AdresseClients2, 117, 39, 180, 45, True)
    End If
    
    'If lbl_Adresse2ClientEnCours.Caption = "" Then
    '    Set la = .Labels.Add("", 117, 39, 180, 45, True)
    'Else
    '    Set la = .Labels.Add(lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
    'End If
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 12
    la.FontItalic = True
    
    
        
    'If Rapide = False Then
    '    Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentaireBoulangerie, 56, -5, 181, 0, False)
    'Else
    '    Set la = .Labels.Add(Frm_Main.txt_commentaire_boulangerie.Text, 56, -5, 181, 0, False)
    'End If
    '    la.BorderWidth = 2
    '    la.BorderColor = vbBlack
    '    la.WordWrap = True
    '    la.Align = DT_RIGHT + DT_VCENTER
    '    la.ForeColor = vbBlack
    '    la.FontName = "Arial"
    '    la.FontSize = 10
    '    la.FontItalic = True
    '    la.CellSpacing = 0.9
   
   
    Set ta = .Tables.Add(ary, 1, 15, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Color.LigneBoulangerie
        .BodyFontName = Police.LigneBoulangerie
        .TitleHeight = 7
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        .CellSpacing = 0.5
        .BodyFontName = Police.LigneBoulangerie
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemiseBoulangerie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Boulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
          Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemiseBoulangerie, 126, 0, 156, 5, False)
     Else
          Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Boulangerie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
            Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemiseBoulangerie, 156, -5, 181, 0, False)
    Else
            Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemiseBoulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
   End If
   Set la = .Labels.Add("Total Boulangerie", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalBoulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Boulangerie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
    
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentaireBoulangerie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Frm_Main.txt_commentaire_boulangerie.Text, 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
    Set ta = .Tables.Add(aryPatisserie, 1, 8, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = Color.LignePatisserie
        .BodyFontName = Police.LignePatisserie
        .TitleHeight = 7
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemisePatisserie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Patisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_SousTotalPatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemisePatisserie, 126, 0, 156, 5, False)
     Else
        Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Patisserie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemisePatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_MontantRemisePatisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    End If
    Set la = .Labels.Add("Total Patisserie", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalPatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TTC_Patisserie.Caption, "0.00"), 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_CommentairePatisserie, 1, -5, 126, 1, False)
    Else
        Set la = .Labels.Add(Frm_Main.txt_commentaire_patisserie.Text, 1, -5, 126, 1, False)
    End If
        'la.BorderWidth = 2
        'la.BorderColor = vbRed
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = Color.TotalTTC
        la.FontName = Police.TotalTTC
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 233, 156, 238, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTTC3.Caption, "0.00"), 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = Color.TotalTTC
        la.FontName = Police.TotalTTC
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
      
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 233, 181, 238, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.Lbl_TotalTVA.Caption, "0.00"), 156, 233, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 238, 181, 243, True)
     Else
        Set la = .Labels.Add(Format(Frm_Main.lbl_TotalHT.Caption, "0.00"), 156, 238, 181, 243, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    
    Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial.T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.LigneMediane
    la.FontName = Police.LigneMediane
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial.T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Color.RCS
    la.FontName = Police.RCS
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial.T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Color.TVA
    la.FontName = Police.TVA
End With

If Rapide = False Then
 rs.Close
 Set rs = Nothing
 db.Close
 Set db = Nothing
End If

If ImpressionDirecte = True Then
PrinterEx.PrintDoc frmTest.hWnd
Else
frmTest.Command8.Value = True
Frm_Message.Hide
End If

Exit Sub


err:
If err.Number = 13 Then Resume Next
If err.Number = 3021 Then
Resume Next
End If

End Sub


Public Sub Impression(NumFacture, Rapide As Boolean, RemiseBoulangerie As Boolean, RemisePatisserie As Boolean, NewParametre As Boolean)
On Error GoTo err
Dim temp As Byte
Dim i As Long, j As Long, k As Single
Dim t As clsTables, c As clsColumns
Dim ta As clsTableAttributes, ca As clsColumnAttributes, la As clsLabelAttributes, ia As clsImageAttributes, linea As clsLineAttributes, ra As clsRectangleAttributes, laex As clsLabelExAttributes, pa As clsPointAttributes
Dim ary() As String, str As String, aryPatisserie() As String
Dim db As Database, rs As recordset
Dim sngAry() As Single

If Rapide = True Then
Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rs = dbs.OpenRecordset("Select * from [T_Facture_Boulangerie] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
    rs.MoveLast
    rs.MoveFirst
End If

    
NewReport

If Rapide = True Then
If Frm_Main.ListView3.ListItems.Count > 11 Then
b = 1
Else
b = 11 - Frm_Main.ListView3.ListItems.Count
End If
ReDim ary(1 To 5, 1 To Frm_Main.ListView3.ListItems.Count + b)
Else
If rs.RecordCount > 13 Then
 b = 1
Else
 b = 13 - rs.RecordCount
End If
ReDim ary(1 To 5, 1 To rs.RecordCount + b)
End If

ary(1, 1) = "Désignation BOULANGERIE"
ary(2, 1) = "Quantité"
ary(3, 1) = "Prix Unitaire TTC"
ary(4, 1) = "Montant TTC"
ary(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
For j = 2 To Frm_Main.ListView3.ListItems.Count + 1
        ary(1, j) = Frm_Main.ListView3.ListItems.Item(j - 1).Text & vbNullString
        ary(2, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(1) & vbNullString
        ary(3, j) = Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(2) & vbNullString
        ary(4, j) = Format(Frm_Main.ListView3.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
Next j
Else
For j = 2 To rs.RecordCount + b
        ary(1, j) = rs.Fields(1) & vbNullString
        ary(2, j) = rs.Fields(6) & vbNullString
        ary(3, j) = rs.Fields(2) & vbNullString
        ary(4, j) = Format(rs.Fields(5), "0.00") & vbNullString
        rs.MoveNext
Next j
End If
If Rapide = True Then
Else
Set db = OpenDatabase(App.Path & "\boulangerie.mdb")
Set rst = dbs.OpenRecordset("Select * from [T_Facture_Patisserie] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
    rst.MoveLast
    rst.MoveFirst
End If

If Rapide = True Then
If Frm_Main.ListView4.ListItems.Count > 8 Then
b = 1
Else
b = 8 - Frm_Main.ListView4.ListItems.Count
End If
If Frm_Main.ListView4.ListItems.Count = 0 Then
    ReDim aryPatisserie(1 To 5, 1 To b)
Else
    ReDim aryPatisserie(1 To 5, 1 To Frm_Main.ListView4.ListItems.Count + b)
End If
Else
If rst.RecordCount > 8 Then
b = 1
Else
b = 8 - rst.RecordCount
End If
ReDim aryPatisserie(1 To 5, 1 To rst.RecordCount + b)
End If


aryPatisserie(1, 1) = "Désignation PATISSERIE"
aryPatisserie(2, 1) = "Quantité"
aryPatisserie(3, 1) = "Prix Unitaire TTC"
aryPatisserie(4, 1) = "Montant TTC"
aryPatisserie(5, 1) = "1,0," & RGB(251, 201, 201) & "," & vbBlack & ",2,0," & RGB(251, 201, 201) & "," & vbBlack & ",3,0," & RGB(251, 201, 201) & "," & vbBlack & ",4,0," & RGB(251, 201, 201) & "," & vbBlack


If Rapide = True Then
For j = 2 To Frm_Main.ListView4.ListItems.Count + 1
        aryPatisserie(1, j) = Frm_Main.ListView4.ListItems.Item(j - 1).Text & vbNullString
        aryPatisserie(2, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(1) & vbNullString
        aryPatisserie(3, j) = Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(2) & vbNullString
        aryPatisserie(4, j) = Format(Frm_Main.ListView4.ListItems.Item(j - 1).SubItems(3), "0.00") & vbNullString
Next j
Else
For j = 2 To rst.RecordCount + 1
        aryPatisserie(1, j) = rst.Fields(1) & vbNullString
        aryPatisserie(2, j) = rst.Fields(6) & vbNullString
        aryPatisserie(3, j) = rst.Fields(2) & vbNullString
        aryPatisserie(4, j) = Format(rst.Fields(5), "0.00") & vbNullString
        rst.MoveNext
Next j
End If

With PrinterEx
    .Orientation = OPortrait
    .PageSize = sizeA4
    If NewParametre = False Then
    .BottomMargin = BottomMargin
    .LeftMargin = LeftMargin
    .RightMargin = RightMargin
    .TopMargin = TopMargin
    Else
    .BottomMargin = Frm_New_Parametre.Txt_MargeBas
    .LeftMargin = Frm_New_Parametre.Txt_MargeGauche
    .RightMargin = Frm_New_Parametre.Txt_Margedroite
    .TopMargin = Frm_New_Parametre.txt_MargeHaut
    End If
    
    Set ia = .Images.Add(LoadPicture(App.Path & "\epi.jpg"), 0, -30)
    
     Set la = .Labels.Add("BOULANGERIE FERTRE", 50, -30, 410, 10, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlue
    la.FontName = "comic sans ms"
    la.FontSize = 20
    
     Set la = .Labels.Add("Stéphanie et Eric", 65, -22, 410, 10, True)
     la.WordWrap = False
     la.Align = DT_LEFT
     la.ForeColor = vbRed
     la.FontName = "comic sans ms"
     la.FontSize = 18
   
    
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    
    Set la = .Labels.Add("30, Rue Dominique Godivier 53200 DAON", 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = vbBlack
    la.FontSize = 9
    la.FontBold = True
    
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
    Set la = .Labels.Add("02.43.06.92.75", 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("27, Rue Max Richard 49330 Marigné", 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = vbBlack
    la.FontSize = 9
    la.FontBold = True
    
     'Affichage du Sigle telephone marigné
    Set la = .Labels.Add("(", 153, 16, 158, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
    Set la = .Labels.Add("02.41.93.10.04", 160, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 9
    la.FontBold = True
    
    
    Set la = .Labels.Add("Facture N°" & NumFacture, 0, 30, 50, 35, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbRed
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("Fait Le", 0, 40, 110, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    Set la = .Labels.Add("", 115, 25, 181, 46, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(InfoRecord2(NumFacture).T_Date, 15, 40, 75, 45, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontBold = True
    
    If Rapide = True Then
        If Frm_Main.lbl_ClientsEnCours.Caption = "Aucun Client de sélectionné" Then
            Set la = .Labels.Add("", 117, 26, 180, 31, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_ClientsEnCours.Caption, 117, 26, 180, 31, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(3), 117, 26, 180, 31, True)
    End If
    
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse1ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 32, 180, 38, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(4), 117, 32, 180, 38, True)
    End If
    
    'If lbl_Adresse1ClientEnCours.Caption = "" Then
   '     Set la = .Labels.Add("", 117, 32, 180, 38, True)
    'Else
    '    Set la = .Labels.Add(lbl_Adresse1ClientEnCours.Caption, 117, 32, 180, 38, True)
    'End If
    
   
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontItalic = True
    
    If Rapide = True Then
        If Frm_Main.lbl_Adresse2ClientEnCours.Caption = "" Then
            Set la = .Labels.Add("", 117, 39, 180, 45, True)
        Else
            Set la = .Labels.Add(Frm_Main.lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
        End If
    Else
        Set la = .Labels.Add(rst.Fields(5), 117, 39, 180, 45, True)
    End If
    
    'If lbl_Adresse2ClientEnCours.Caption = "" Then
    '    Set la = .Labels.Add("", 117, 39, 180, 45, True)
    'Else
    '    Set la = .Labels.Add(lbl_Adresse2ClientEnCours.Caption, 117, 39, 180, 45, True)
    'End If
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "Arial"
    la.FontSize = 12
    la.FontItalic = True
    
   
    Set ta = .Tables.Add(ary, 1, 15, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = vbBlue
        .TitleHeight = 7
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        .CellSpacing = 0.5
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemiseBoulangerie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Boulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Frm_Main.Lbl_SousTotalBoulangerie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
          Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemiseBoulangerie, 126, 0, 156, 5, False)
     Else
          Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Boulangerie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
            Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemiseBoulangerie, 156, -5, 181, 0, False)
    Else
            Set la = .Labels.Add(Frm_Main.Lbl_MontantRemiseBoulangerie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
   End If
   Set la = .Labels.Add("Total Boulangerie", 126, 0, 156, 5, False)
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalBoulangerie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Frm_Main.Lbl_TTC_Boulangerie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 2
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    
    
    Set ta = .Tables.Add(aryPatisserie, 1, 8, 2, 1)
    With ta
        .TitleFontBold = True
        .BodyForeColor = vbBlue
        .TitleHeight = 7
        .TitleWordWrap = True
        .FirstRowIsTitle = True
        .BodyWordWrap = True
        .ColumnSpacing = 10
        .TotalColumns = 1
        .BorderColor = vbBlack
        .BodyFontSize = 9
        .BodyFontBold = True
        Set ca = .Columns.Add(105, DT_CENTER, DT_LEFT)
        Set ca = .Columns.Add(20, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(30, DT_CENTER, DT_CENTER)
        Set ca = .Columns.Add(25, DT_CENTER, DT_RIGHT)
        Set ca = .Columns.Add
    End With
    If RemisePatisserie = True Then
    Set la = .Labels.Add("Sous total", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_ST_Patisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Frm_Main.Lbl_SousTotalPatisserie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add("Remise " & InfoRecord2(NumFacture).T_PercRemisePatisserie, 126, 0, 156, 5, False)
     Else
        Set la = .Labels.Add("Remise " & Frm_Main.Lbl_Perc_Patisserie.Caption, 126, 0, 156, 5, False)
     End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_RemisePatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Frm_Main.Lbl_MontantRemisePatisserie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    End If
    Set la = .Labels.Add("Total Patisserie", 126, 0, 156, 5, False)
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
    If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalPatisserie, 156, -5, 181, 0, False)
    Else
        Set la = .Labels.Add(Frm_Main.Lbl_TTC_Patisserie.Caption, 156, -5, 181, 0, False)
    End If
        la.BorderWidth = 1
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
        
    Set la = .Labels.Add("TOTAL TTC", 126, 228, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
      Set la = .Labels.Add("Dont TVA 5.5%", 126, 238, 156, 233, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
     Set la = .Labels.Add("Total HT", 126, 238, 156, 243, True)
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
        Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalTTC, 156, 228, 181, 233, True)
     Else
        Set la = .Labels.Add(Frm_Main.Lbl_TotalTTC3.Caption, 156, 228, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_RIGHT + DT_VCENTER
        la.ForeColor = vbRed
        la.FontName = "Arial"
        la.FontSize = 10
        'la.FontItalic = True
        la.CellSpacing = 0.9
        la.FontBold = True
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_DontTVA, 156, 238, 181, 233, True)
     Else
        Set la = .Labels.Add(Frm_Main.Lbl_TotalTVA.Caption, 156, 238, 181, 233, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
     If Rapide = False Then
         Set la = .Labels.Add(InfoRecord2(NumFacture).T_TotalHT, 156, 243, 181, 238, True)
     Else
        Set la = .Labels.Add(Frm_Main.lbl_TotalHT.Caption, 156, 243, 181, 238, True)
     End If
        la.BorderWidth = 5
        la.BorderColor = vbBlack
        la.WordWrap = True
        la.Align = DT_LEFT + DT_VCENTER
        la.ForeColor = vbBlack
        la.FontName = "Arial"
        la.FontSize = 10
        la.FontItalic = True
        la.CellSpacing = 0.9
        
    
    Set linea = .Lines.Add(0, 248, 181, 248, True)
    linea.Size = 3
    
     Set la = .Labels.Add("Boulangerie Fertré 53200 DAON", 5, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    
     Set la = .Labels.Add("RCS : 423 781 954", 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = vbBlack
    
     Set la = .Labels.Add("N° de TVA : FR48423781954", 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = vbBlack
End With

If Rapide = False Then
 rs.Close
 Set rs = Nothing
 db.Close
 Set db = Nothing
End If
'frmTest.Command8.Value = True
'PrinterEx.PreviewDoc frmPreview.hWnd, True

Exit Sub


err:
If err.Number = 13 Then Resume Next
If err.Number = 3021 Then
Resume Next
End If
End Sub

Public Sub ApercuImpaye(Nom As String, adresse1 As String, adresse2 As String, Somme As String, DateFac As String, NumFacture As String)
On Error GoTo err
Dim temp As Byte
Dim i As Long, j As Long, k As Single
Dim t As clsTables, c As clsColumns
Dim ta As clsTableAttributes, ca As clsColumnAttributes, la As clsLabelAttributes, ia As clsImageAttributes, linea As clsLineAttributes, ra As clsRectangleAttributes, laex As clsLabelExAttributes, pa As clsPointAttributes
Dim ary() As String, str As String, aryPatisserie() As String
Dim db As Database, rs As recordset
Dim sngAry() As Single

NewReport
DoEvents
Frm_Message.Show 0, Frm_Main
DoEvents

With PrinterEx
    .Orientation = OPortrait
    .PageSize = sizeA4
    .BottomMargin = BottomMargin
    .LeftMargin = LeftMargin
    .RightMargin = RightMargin
    .TopMargin = TopMargin
    
     Set ia = .Images.Add(LoadPicture(App.Path & "\" & InfoRaisonSocial.T_Logo), 0, -30)
    
     Set la = .Labels.Add(InfoRaisonSocial.T_NomEntreprise, 0, -30, 179, -20, True)
    la.WordWrap = False
    la.Align = DT_CENTER
    la.ForeColor = Color.NomEntreprise
    la.FontName = Police.NomEntreprise
    la.FontSize = 20
   
    
     Set la = .Labels.Add(InfoRaisonSocial.T_DetailNomEntreprise, 0, -22, 179, -10, True)
     la.WordWrap = False
     la.Align = DT_CENTER
     la.ForeColor = Color.DetailNomEntreprise
     la.FontName = Police.DetailNomEntreprise
     la.FontSize = 18
     
    
      
    Set linea = .Lines.Add(0, 4, 181, 4, True)
    linea.Size = 3
   
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse1, 0, 8, 40, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.adresse1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.adresse1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_CP1, 0, 12, 40, 19, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP1
    la.FontSize = 9
    la.FontBold = True
    la.FontName = Police.CP1
    
       
    
    'Affichage du Sigle telephone
    Set la = .Labels.Add("(", 2, 16, 7, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    
     If Trim(InfoRaisonSocial.T_Fax) = "" Then
    Else
        Set la = .Labels.Add("7", 2, 20.5, 6, 25, True)
        la.WordWrap = True
        la.Align = DT_LEFT
        la.ForeColor = vbBlack
        la.FontName = "WingDings 2"
        la.FontSize = 12
        'la.BorderWidth = 1
    End If
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel1, 8, 16, 31, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel1
    la.FontName = Police.Tel1
    la.FontSize = 9
    la.FontBold = True
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Fax, 8, 20.5, 41, 25, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = Color.Fax
    la.FontName = Police.Fax
    la.FontSize = 9
    la.FontBold = True
    'la.BorderWidth = 1
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Adresse2 & " " & InfoRaisonSocial.T_CP2, 151, 7, 184, 15, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.CP2
    la.FontName = Police.CP2
    la.FontSize = 9
    la.FontBold = True
    
     'Affichage du Sigle telephone marigné
    If Trim(InfoRaisonSocial.T_Tel2) = "" Then
    Else
    Set la = .Labels.Add("(", 153, 16, 158, 20, True)
    la.WordWrap = True
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "WingDings"
    la.FontSize = 12
    End If
    
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Tel2, 160, 16, 182, 20, True)
    la.WordWrap = True
    la.Align = DT_CENTER
    la.ForeColor = Color.Tel2
    la.FontName = Police.Tel2
    la.FontSize = 9
    la.FontBold = True
    
    'Set ia = .Images.Add(LoadPicture(App.Path & "\epi.jpg"), 0, -30)
    Set la = .Labels.Add("", 115, 35, 181, 56, True)
    la.BorderWidth = 5
    la.BorderColor = vbBlack
    
    Set la = .Labels.Add(Nom, 117, 36, 180, 43, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 11
    Set la = .Labels.Add(adresse1, 117, 42, 180, 48, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 11
    Set la = .Labels.Add(adresse2, 117, 49, 180, 54, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.Client
    la.FontName = Police.Client
    la.FontSize = 11
    
    Set la = .Labels.Add(Format(Date, "DDDD DD MMMM YYYY"), 117, 60, 180, 70, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("Madame, Monsieur,", 0, 80, 70, 90, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("Après vérification de votre compte, nous avons constaté que le règlement de la facture N°" & NumFacture, 0, 99, 175, 105, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("du " & DateFac & " n'a pas été effectué à ce jour.", 0, 105, 150, 111, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("Nous pensons qu'il s'agit d'un simple oubli et nous vous remercions de bien vouloir nous ", 0, 124, 175, 131, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("adresser le règlement de " & Format(Somme, "0.00") & " euros par le moyen de votre choix.", 0, 130, 175, 136, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("Dans cette attente, nous vous prions d'agréer, Madame, Monsieur, l'expression de nos ", 0, 149, 175, 155, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    Set la = .Labels.Add("salutations distinguées.", 0, 155, 150, 161, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = vbBlack
    la.FontName = "comic sans ms"
    la.FontSize = 11
    
    
    Set la = .Labels.Add(InfoRaisonSocial.T_Signature, 110, 190, 160, 196, True)
    'la.BorderColor = vbRed
    'la.BorderWidth = 2
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.Signature
    la.FontName = Police.Signature
    la.FontSize = 11
    
    
 Set linea = .Lines.Add(181, 245, 0, 245, True)
    linea.Size = 3
    
     Set la = .Labels.Add(InfoRaisonSocial.T_LigneMediane, 0, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_LEFT
    la.ForeColor = Color.LigneMediane
    la.FontName = Police.LigneMediane
    
     Set la = .Labels.Add("RCS : " & InfoRaisonSocial.T_RCS, 85, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_VCENTER
    la.ForeColor = Color.RCS
    la.FontName = Police.RCS
    
     Set la = .Labels.Add("N° de TVA : " & InfoRaisonSocial.T_TVA, 95, 249, 181, 253, True)
    la.WordWrap = False
    la.Align = DT_RIGHT
    la.ForeColor = Color.TVA
    la.FontName = Police.TVA
End With

frmTest.Command8.Value = True
Frm_Message.Hide
Exit Sub


err:
If err.Number = 13 Then Resume Next
If err.Number = 3021 Then
Resume Next
End If
End Sub

Public Function InfoRecord() As T_Record
'Information sur la base
On Error GoTo err
Set rst = dbs.OpenRecordset("SELECT * FROM [T_Record] where [T_NumFacture]like '" & CInt(Frm_Main.Lbl_NumFactureAvant.Caption) & "'")
rst.MoveLast
rst.MoveFirst

InfoRecord.T_TotalTTC = Format(rst.Fields(16), "0.00")
InfoRecord.T_PercRemiseBoulangerie = rst.Fields(11)
InfoRecord.T_PercRemisePatisserie = rst.Fields(15)
InfoRecord.T_RemiseBoulangerie = Format(rst.Fields(9), "0.00")
InfoRecord.T_RemisePatisserie = Format(rst.Fields(13), "0.00")
InfoRecord.T_ST_Boulangerie = Format(rst.Fields(8), "0.00")
InfoRecord.T_ST_Patisserie = Format(rst.Fields(12), "0.00")
InfoRecord.T_TotalBoulangerie = Format(rst.Fields(10), "0.00")
InfoRecord.T_TotalPatisserie = Format(rst.Fields(14), "0.00")
InfoRecord.T_TotalHT = Format(rst.Fields(17), "0.00")
InfoRecord.T_DontTVA = Format(rst.Fields(18), "0.00")
InfoRecord.T_Date = rst.Fields(19)
Exit Function

err:
If err.Number = 3420 Then
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set dbs = wrkJet.OpenDatabase(path_base, True, False, ";pwd=" & pwd)
    Resume
End If

If err.Number = 3021 Then Resume Next
End Function
Public Function InfoRecord2(NumFacture) As T_Record
'Information sur la base
On Error GoTo err
Set rst = dbs.OpenRecordset("SELECT * FROM [T_Record] where [T_NumFacture] like '" & CInt(NumFacture) & "'")
rst.MoveLast
rst.MoveFirst

InfoRecord2.T_TotalTTC = Format(rst.Fields(16), "0.00")
InfoRecord2.T_PercRemiseBoulangerie = rst.Fields(11)
InfoRecord2.T_PercRemisePatisserie = rst.Fields(15)
InfoRecord2.T_RemiseBoulangerie = Format(rst.Fields(9), "0.00")
InfoRecord2.T_RemisePatisserie = Format(rst.Fields(13), "0.00")
InfoRecord2.T_ST_Boulangerie = Format(rst.Fields(8), "0.00")
InfoRecord2.T_ST_Patisserie = Format(rst.Fields(12), "0.00")
InfoRecord2.T_TotalBoulangerie = Format(rst.Fields(10), "0.00")
InfoRecord2.T_TotalPatisserie = Format(rst.Fields(14), "0.00")
InfoRecord2.T_TotalHT = Format(rst.Fields(17), "0.00")
InfoRecord2.T_DontTVA = Format(rst.Fields(18), "0.00")
InfoRecord2.T_Date = rst.Fields(19)
InfoRecord2.T_CommentaireBoulangerie = rst.Fields(6)
InfoRecord2.T_CommentairePatisserie = rst.Fields(7)
InfoRecord2.T_AdresseClients = rst.Fields(4)
InfoRecord2.T_AdresseClients2 = rst.Fields(5)
InfoRecord2.T_Clients = rst.Fields(3)


Exit Function

err:
If err.Number = 3420 Then
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set dbs = wrkJet.OpenDatabase(path_base, True, False, ";pwd=" & pwd)
    Resume
End If

If err.Number = 3021 Then Resume Next
End Function
Public Function InfoRaisonSocial() As T_RaisonSocial
'Information sur la base
On Error GoTo err
Set rst = dbs.OpenRecordset("SELECT * FROM [T_RaisonSocial]")
rst.MoveLast
rst.MoveFirst

InfoRaisonSocial.T_Adresse1 = rst.Fields(2)
InfoRaisonSocial.T_Adresse2 = rst.Fields(5)
InfoRaisonSocial.T_CP1 = rst.Fields(3)
InfoRaisonSocial.T_CP2 = rst.Fields(6)
InfoRaisonSocial.T_DetailNomEntreprise = rst.Fields(12)
InfoRaisonSocial.T_Fax = rst.Fields(11)
InfoRaisonSocial.T_LigneMediane = rst.Fields(10)
InfoRaisonSocial.T_Logo = rst.Fields(13)
InfoRaisonSocial.T_NomEntreprise = rst.Fields(1)
InfoRaisonSocial.T_RCS = rst.Fields(8)
InfoRaisonSocial.T_Tel1 = rst.Fields(4)
InfoRaisonSocial.T_Tel2 = rst.Fields(7)
InfoRaisonSocial.T_TVA = rst.Fields(9)
InfoRaisonSocial.T_Signature = rst.Fields(15)
Exit Function

err:
If err.Number = 3420 Then
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set dbs = wrkJet.OpenDatabase(path_base, True, False, ";pwd=" & pwd)
    Resume
End If

If err.Number = 3021 Then Resume Next
End Function

Private Function InvNumber(ByVal Number As String) As String
    Static i As Integer
    For i = 1 To Len(Number)
        Select Case Mid$(Number, i, 1)
        Case "-": Mid$(Number, i, 1) = " "
        Case "0": Mid$(Number, i, 1) = "9"
        Case "1": Mid$(Number, i, 1) = "8"
        Case "2": Mid$(Number, i, 1) = "7"
        Case "3": Mid$(Number, i, 1) = "6"
        Case "4": Mid$(Number, i, 1) = "5"
        Case "5": Mid$(Number, i, 1) = "4"
        Case "6": Mid$(Number, i, 1) = "3"
        Case "7": Mid$(Number, i, 1) = "2"
        Case "8": Mid$(Number, i, 1) = "1"
        Case "9": Mid$(Number, i, 1) = "0"
        End Select
    Next
    InvNumber = Number
End Function

Public Sub SortListView(ListView As ListView, ByVal Index As Integer, _
                ByVal DataType As ListDataType, ByVal Ascending As Boolean)

    On Error Resume Next
    Dim i As Integer
    Dim L As Long
    Dim strFormat As String
    
    ' Display the hourglass cursor whilst sorting
    
    Dim lngCursor As Long
    lngCursor = Form2.ListView1.MousePointer
    ListView.MousePointer = vbHourglass
    
    ' Prevent the ListView control from updating on screen - this is to hide
    ' the changes being made to the listitems, and also to speed up the sort
    
    LockWindowUpdate ListView.hWnd
    
    Dim blnRestoreFromTag As Boolean
    
    Select Case DataType
    Case ldtString
        
        ' Sort alphabetically. This is the only sort provided by the
        ' MS ListView control (at this time), and as such we don't really
        ' need to do much here
    
        blnRestoreFromTag = False
        
    Case ldtNumber
    
        ' Sort Numerically
    
        strFormat = String$(20, "0") & "." & String$(10, "0")
        
        ' Loop through the values in this column. Re-format the values so
        ' as they can be sorted alphabetically, having already stored their
        ' text values in the tag, along with the tag's original value
    
        With ListView.ListItems
            If (Index = 1) Then
                For L = 1 To .Count
                    With .Item(L)
                        .Tag = .Text & Chr$(0) & .Tag
                        If IsNumeric(.Text) Then
                            If CDbl(.Text) >= 0 Then
                                .Text = Format(CDbl(.Text), strFormat)
                            Else
                                .Text = "&" & InvNumber(Format(0 - CDbl(.Text), strFormat))
                            End If
                        Else
                            .Text = ""
                        End If
                    End With
                Next L
            Else
                For L = 1 To .Count
                    With .Item(L).ListSubItems(Index - 1)
                        .Tag = .Text & Chr$(0) & .Tag
                        If IsNumeric(.Text) Then
                            If CDbl(.Text) >= 0 Then
                                .Text = Format(CDbl(.Text), strFormat)
                            Else
                                .Text = "&" & InvNumber(Format(0 - CDbl(.Text), strFormat))
                            End If
                        Else
                            .Text = ""
                        End If
                    End With
                Next L
            End If
        End With
        
        blnRestoreFromTag = True
    
    Case ldtDateTime
    
        ' Sort by date.
        
        strFormat = "YYYYMMDDHhNnSs"
        
        Dim dte As Date
    
        ' Loop through the values in this column. Re-format the dates so as they
        ' can be sorted alphabetically, having already stored their visible
        ' values in the tag, along with the tag's original value
    
        With ListView.ListItems
            If (Index = 1) Then
                For L = 1 To .Count
                    With .Item(L)
                        .Tag = .Text & Chr$(0) & .Tag
                        dte = CDate(.Text)
                        .Text = Format$(dte, strFormat)
                    End With
                Next L
            Else
                For L = 1 To .Count
                    With .Item(L).ListSubItems(Index - 1)
                        .Tag = .Text & Chr$(0) & .Tag
                        dte = CDate(.Text)
                        .Text = Format$(dte, strFormat)
                    End With
                Next L
            End If
        End With
        
        blnRestoreFromTag = True
        
    End Select
    
    ' Sort the ListView Alphabetically
    
   ListView.SortOrder = IIf(Ascending, lvwAscending, lvwDescending)
   ListView.SortKey = Index - 1
   ListView.Sorted = True
    
    ' Restore the Text Values if required
    
    If blnRestoreFromTag Then
        
        ' Restore the previous values to the 'cells' in this column of the list
        ' from the tags, and also restore the tags to their original values
        
        With ListView.ListItems
            If (Index = 1) Then
                For L = 1 To .Count
                    With .Item(L)
                        i = InStr(.Tag, Chr$(0))
                        .Text = Left$(.Tag, i - 1)
                        .Tag = Mid$(.Tag, i + 1)
                    End With
                Next L
            Else
                For L = 1 To .Count
                    With .Item(L).ListSubItems(Index - 1)
                        i = InStr(.Tag, Chr$(0))
                        .Text = Left$(.Tag, i - 1)
                        .Tag = Mid$(.Tag, i + 1)
                    End With
                Next L
            End If
        End With
    End If
    
    ' Unlock the list window so that the OCX can update it
    
    LockWindowUpdate 0&
    
    ' Restore the previous cursor
    
   ListView.MousePointer = lngCursor
    

End Sub

Public Sub EffaceTout()
Frm_Main.lbl_ClientsEnCours.Caption = ""
Frm_Main.lbl_ClientsEnCoursArriere.Caption = ""
Frm_Main.lbl_Adresse1ClientEnCours.Caption = ""
Frm_Main.lbl_Adresse1ClientEnCoursArriere.Caption = ""
Frm_Main.lbl_Adresse2ClientEnCours.Caption = ""
Frm_Main.lbl_Adresse2ClientEnCoursArriere.Caption = ""
Frm_Main.Txt_NumFacture.Text = ""
Frm_Main.Lbl_NumFactureArriere.Caption = ""
Frm_Main.Lbl_NumFactureAvant.Caption = ""
Frm_Main.txt_commentaire_boulangerie.Text = ""
Frm_Main.txt_commentaire_patisserie.Text = ""
Frm_Main.Lbl_SousTotalBoulangerie.Caption = "0"
Frm_Main.Lbl_MontantRemiseBoulangerie.Caption = "0"
Frm_Main.Lbl_TTC_Boulangerie.Caption = "0"
Frm_Main.Lbl_Perc_Boulangerie.Caption = "0"
Frm_Main.Lbl_SousTotalPatisserie.Caption = "0"
Frm_Main.Lbl_MontantRemisePatisserie.Caption = "0"
Frm_Main.Lbl_TTC_Patisserie.Caption = "0"
Frm_Main.Lbl_Perc_Patisserie.Caption = "0"
Frm_Main.Lbl_TotalTTC.Caption = "0"
Frm_Main.lbl_TotalHT.Caption = "0"
Frm_Main.Lbl_TotalTVA.Caption = "0"
Frm_Main.ListView1.ListItems.Clear
Frm_Main.ListView2.ListItems.Clear
Frm_Main.ListView3.ListItems.Clear
Frm_Main.ListView4.ListItems.Clear
Frm_Main.Lbl_NB_Boulangerie.Caption = "0 Produit"
Frm_Main.Lbl_NB_Patisserie.Caption = "0 Produit"
Frm_Main.lbl_nbproduitBoulangerie.Caption = ""
Frm_Main.lbl_nbproduitPatisserie.Caption = ""
Frm_Main.MAJ_Calcul_Boulangerie
Frm_Main.MAJ_Calcul_Patisserie
End Sub

Private Function Police() As Police
        Set rst = dbs.OpenRecordset("Select * from [T_RaisonSocial]")
        rst.MoveLast
        rst.MoveFirst
        Police.DetailNomEntreprise = rst.Fields(33)
        Police.adresse1 = rst.Fields(21)
        Police.adresse2 = rst.Fields(37)
        Police.Client = rst.Fields(77)
        Police.CP1 = rst.Fields(25)
        Police.CP2 = rst.Fields(41)
        Police.DateFacture = rst.Fields(73)
        Police.Designation = rst.Fields(93)
        Police.Facture = rst.Fields(69)
        Police.Fax = rst.Fields(49)
        Police.LigneBoulangerie = rst.Fields(81)
        Police.LigneMediane = rst.Fields(61)
        Police.LignePatisserie = rst.Fields(85)
        Police.NomEntreprise = rst.Fields(17)
        Police.RCS = rst.Fields(53)
        Police.Signature = rst.Fields(65)
        Police.Tel1 = rst.Fields(29)
        Police.Tel2 = rst.Fields(45)
        Police.TotalTTC = rst.Fields(89)
        Police.TVA = rst.Fields(57)
End Function

Private Function Style() As Style
        Set rst = dbs.OpenRecordset("Select * from [T_RaisonSocial]")
        rst.MoveLast
        rst.MoveFirst
        Style.DetailNomEntreprise = rst.Fields(35)
        Style.adresse1 = rst.Fields(23)
        Style.adresse2 = rst.Fields(39)
        Style.Client = rst.Fields(79)
        Style.CP1 = rst.Fields(27)
        Style.CP2 = rst.Fields(43)
        Style.DateFacture = rst.Fields(75)
        Style.Designation = rst.Fields(95)
        Style.Facture = rst.Fields(71)
        Style.Fax = rst.Fields(51)
        Style.LigneBoulangerie = rst.Fields(83)
        Style.LigneMediane = rst.Fields(63)
        Style.LignePatisserie = rst.Fields(87)
        Style.NomEntreprise = rst.Fields(19)
        Style.RCS = rst.Fields(55)
        Style.Signature = rst.Fields(67)
        Style.Tel1 = rst.Fields(31)
        Style.Tel2 = rst.Fields(47)
        Style.TotalTTC = rst.Fields(91)
        Style.TVA = rst.Fields(59)
End Function

Private Function Size() As Size
        Set rst = dbs.OpenRecordset("Select * from [T_RaisonSocial]")
        rst.MoveLast
        rst.MoveFirst
        Size.DetailNomEntreprise = rst.Fields(35)
        Size.adresse1 = rst.Fields(23)
        Size.adresse2 = rst.Fields(39)
        Size.Client = rst.Fields(79)
        Size.CP1 = rst.Fields(27)
        Size.CP2 = rst.Fields(43)
        Size.DateFacture = rst.Fields(75)
        Size.Designation = rst.Fields(95)
        Size.Facture = rst.Fields(71)
        Size.Fax = rst.Fields(51)
        Size.LigneBoulangerie = rst.Fields(83)
        Size.LigneMediane = rst.Fields(63)
        Size.LignePatisserie = rst.Fields(87)
        Size.NomEntreprise = rst.Fields(19)
        Size.RCS = rst.Fields(55)
        Size.Signature = rst.Fields(67)
        Size.Tel1 = rst.Fields(31)
        Size.Tel2 = rst.Fields(47)
        Size.TotalTTC = rst.Fields(91)
        Size.TVA = rst.Fields(59)
End Function

