Problèmes SQLite - "Values et colomns"

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
PCPixMusic
Messages : 106
Inscription : ven. 06/janv./2017 9:50

Problèmes SQLite - "Values et colomns"

Message par PCPixMusic »

Bonjour,

Je suis débutant et mon projet en cours et la création d'un base de données SQLite, dans le but de facilité la gestion de la clientèle
de Photographe et modèles, avec gestions des séances contrats photos et factures. C'est encore loin d'être fini. J'ai voulu ajouter
une deuxième image BLOB dans ma base de données, pour avoir une signature imprimer sur les documents, malheureusement,
je m'y suis mal pris.

Je me suis servis de la page suivante pour écrire mon code :

Source : http://f-lefevre.developpez.com/tutorie ... ncontacts/

La Procedure DB_InsertContact() me renvoie l'erreur suivante au moment de l'action du #Button_1 "Ajouter une fiche" :

51 Values for 52 columns

Pourtant, je compte bien 52 Values dans cette procedure, cela fait deux jours que je cherche sans réponses.

Voilà plusieurs jours que je ne trouve pas les erreurs. Merci beaucoup d'avance pour votre aide.

Code : Tout sélectionner


Enumeration
  #Window_0
  #Listview_0
  #Button_0
  #Button_1
  #Button_2
  #Button_3
  #Button_4
  #Button_5
  #Button_6
  #Button_7
  #Button_8
  #Button_9
  #Button_10
  #Button_11
  #Button_12
  #Button_13
  #Button_14
  #Button_15
  
  #BoutonAgenda
  #Agenda
  
  #Image_0
  #Image_1  
  #Text_0
  #Text_1
  #Text_2
  #Text_3
  #Text_4
  #Text_5
  #Text_6
  #Text_7
  #Text_8
  #Text_9
  #Text_10
  #Text_11
  #Text_12
  #Text_13
  #Text_14
  #Text_15
  #Text_16
  #Text_17
  #Text_18
  #Text_19
  #Text_20
  #Text_21
  #Text_22
  #Text_23
  #Text_24
  #Text_25
  #Text_26
  #Text_27
  #Text_28
  #Text_29
  #Text_30
  #Text_31
  #Text_32
  #Text_33
  #Text_34
  #Text_35
  #Text_36
  #Text_37
  #Text_38
  #Text_39
  #Text_40
  #Text_41
  #Text_42
  #Text_43
  #Text_44
  #Text_45
  #Text_46
  #Text_47
  #Text_48
  #Text_49
  #Text_50
  
  #String_0
  #String_1
  #String_2
  #String_3
  #String_4
  #String_5
  #String_6
  #String_7
  #String_8
  #String_9
  #String_10
  #String_11
  #String_12
  #String_13
  #String_14
  #String_15
  #String_16
  #String_17
  #String_18
  #String_19
  #String_20
  #String_21
  #String_22
  #String_23
  #String_24
  #String_25
  #String_26
  #String_27
  #String_28
  #String_29
  #String_30
  #String_31
  #String_32
  #String_33
  #String_34
  #String_35
  #String_36
  #String_37
  #String_38
  #String_39
  #String_40
  #String_41
  #String_42
  #String_43
  #String_44
  #String_45
  #String_46
  #String_47
  #String_48
  #String_49
  #String_50
  #CheckBox_0
  #CheckBox_1
  #CheckBox_2
  #CheckBox_3
  #CheckBox_4
  #CheckBox_5
  #CheckBox_6
  #CheckBox_7
  #CheckBox_8
  #CheckBox_9
  #CheckBox_10        
  #CheckBox_11
  #CheckBox_12
  #CheckBox_13
  #CheckBox_14
  #CheckBox_15  
    
  #Cadre_1
  
  #FenetreAgenda
  #TextAgenda
  
  #Fond_Dessin
  #Font
  
  #Win0
  #Text0
  
        
  EndEnumeration
  
Global glDBSQLite.l
Global glListviewItemSelected.l = -1
Global glImageMemory.l

Global glImageMemory2.l

Define Etat_CheckBox_0.D
Define Etat_CheckBox_1.D
Define Etat_CheckBox_2.D
Define Etat_CheckBox_3.D
Define Etat_CheckBox_4.D
Define Etat_CheckBox_5.D
Define Etat_CheckBox_6.D
Define Etat_CheckBox_7.D
Define Etat_CheckBox_8.D
Define Etat_CheckBox_9.D
Define Etat_CheckBox_10.D
Define Etat_CheckBox_11.D
Define Etat_CheckBox_12.D
Define Etat_CheckBox_13.D
Define Etat_CheckBox_14.D
Define Etat_CheckBox_15.D


UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()


Procedure DrawSelection(X, Y, x1, y1, Couleur, Eppaisseur, Type)
  For vx = X To x1 Step 4
    Box(vx, y, Eppaisseur, Eppaisseur, Couleur)
    Box(vx, y1, Eppaisseur, Eppaisseur, Couleur)
  Next               
 
  For vy = Y To y1 Step 4
    Box(x, vy, Eppaisseur, Eppaisseur, Couleur)
    Box(x1, vy, Eppaisseur, Eppaisseur, Couleur)
  Next               
EndProcedure

Procedure Cadre(X1, Y1, X2, Y2, Couleur1,Couleur2)
   LineXY(X1, Y1, X2, Y1,Couleur1)
   LineXY(X1, Y1, X1, Y2,Couleur1)
   LineXY(X2, Y1, X2, Y2,Couleur2)
   LineXY(X1, Y2, X2, Y2,Couleur2)
 EndProcedure
 
 Procedure GraphMenu()
         If GlEvent = PB_Event_Repaint
           StartDrawing(WindowOutput(0))  
                    
         ;Box(388,10, 461, 283, RGB(255, 255, 233))
       Cadre(388,10, 850, 293, RGB(0,0,0),RGB(0,0,0))
       
         ;Box(860, 10,  496, 283, RGB(255, 255, 233))
       Cadre(860, 10, 1355, 293, RGB(0,0,0),RGB(0,0,0))
       
         ;Box(860, 300,  496, 408, RGB(255, 255, 233))
       Cadre(860, 300, 1355, 709, RGB(0,0,0),RGB(0,0,0))
       
        ;Box(388, 300,  496, 408, RGB(255, 255, 233))
       Cadre(388, 300, 850, 709, RGB(0,0,0),RGB(0,0,0))
             
         ;BackColor(RGB(255,255,233))
         BackColor(RGB(240,240,240))
         FrontColor(RGB(0,0,0))
         
         DrawText(400,20,"Edition de la Facture Client")
         DrawText(872,20,"Edition du Contrat Modèle")
         DrawText(872,310,"Déroulement de la séance photo")
         DrawText(400,310,"Édition fiche contact")
         
         DrawText(872,100,"Autorisation modes de diffusion")
         
         DrawText(872,200,"Conditions financières")
        
        StopDrawing()
      
    EndIf 
  EndProcedure
  
  Procedure MouseMove(n)
  Repeat
    GetCursorPos_(CursorPos.POINT)
    MouseX = CursorPos\x
    MouseY = CursorPos\y
    If Not MouseX=Mx And MouseY =My
      GraphMenu()
    
    EndIf
    Mx=MouseX
    My=MouseY
    ForEver
 
EndProcedure
                  
Procedure Main_WindowOpen()
  If OpenWindow(#Window_0, 0,0,1360,710, "Notysoft Ordinem - Gestion de Contacts",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_BorderLess | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget )
    
    ListViewGadget(#Listview_0, 10, 300, 374,410)
     
    ButtonGadget(#Button_0, 10, 10, 120,26,"Effacer la fiche")
    ButtonGadget(#Button_1, 10, 36, 120,26,"Ajouter une fiche")
    ButtonGadget(#Button_2, 10, 62, 120,26,"Mettre à jour la base")
    ButtonGadget(#Button_3, 10, 88, 120,26,"Supprimer une fiche")
    ButtonGadget(#Button_4, 10, 114, 120,26,"Ajouter une photo")
    ButtonGadget(#Button_5, 10, 140,120,26,"Séance photo")
    ButtonGadget(#Button_6, 10, 166,120,26,"Contrat photo")
    ButtonGadget(#Button_7, 10, 192,120,26,"Facture client")
    ButtonGadget(#Button_8, 10, 218,120,26,"Agenda")
    ButtonGadget(#Button_9, 10, 244,120,26,"Calculatrice")
    ButtonGadget(#Button_10, 10,270,120,26,"A Propos")
    ButtonGadget(#Button_11, 1220,200,120,26,"Ajouter une signature")
    
    ImageGadget(#Image_0, 140, 10, 244, 284, 00, #PB_Image_Border)
    ImageGadget(#Image_1, 1220,230,119,  59, 00, #PB_Image_Border)
    
    ;CalendarGadget(0,10, 497, 374, 195)  
    
    TextGadget(#Text_0    ,  400, 50, 100, 20, "N°Client    ")
    TextGadget(#Text_1    ,  625, 50, 70, 20, "N°Facture   ")    
    TextGadget(#Text_25, 400,105,200,20, "Désignation prestation(s) ")
    TextGadget(#Text_26, 400,160,50, 20, "Quantité")
    TextGadget(#Text_27, 400, 215, 200, 20, "Commentaire(s) & Recommandation(s)")
    ;TextGadget(#Text_28, 400, 270, 200, 20, "Recommandation(s)")
    TextGadget(#Text_29  , 460,160,80, 20, "Prix unitaire HT")
    TextGadget(#Text_30  , 550,160,100, 20, "Date de règlement")    
    TextGadget(#Text_31 ,660,160,80,50, "Date exécution")
    TextGadget(#Text_32, 740,160,120, 20, "Conditions escompte")
    
   TextGadget(#Text_3,  400, 358, 110, 20, "Prénom      ")
   TextGadget(#Text_4,  400, 388, 110, 20, "Nom         ")
   TextGadget(#Text_5,  400, 418, 110, 20, "Profession  ")
   TextGadget(#Text_6,  400, 448, 110, 20, "Société     ")
   TextGadget(#Text_7,  400, 478, 110, 20, "Adresse 1   ")
   TextGadget(#Text_8,  400, 508, 110, 20, "Adresse 2   ")
   TextGadget(#Text_9,  400, 538, 110, 20, "Adresse 3   ")
   TextGadget(#Text_10, 400, 568, 110, 20, "Code Postal ")
   TextGadget(#Text_11, 400, 598, 110, 20, "Ville       ")
   TextGadget(#Text_12, 400, 628, 110, 20, "Pays        ")
   TextGadget(#Text_13, 400, 658, 110, 20, "Téléphone   ")
   
   TextGadget(#Text_14, 630, 358,110, 20, "Fax         ")
   TextGadget(#Text_15, 630, 388,110, 20, "Mail        ")
   TextGadget(#Text_16, 630, 418,110, 20, "Naissance   ")
   TextGadget(#Text_17, 630, 448,110, 20, "Sexe        ")
   TextGadget(#Text_18, 630, 478,110, 20, "Cheveux     ")
   TextGadget(#Text_19, 630, 508, 110, 20, "Yeux        ")
   TextGadget(#Text_20, 630, 538, 110, 20, "Peau        ")
   TextGadget(#Text_21, 630, 568, 110, 20, "Taille      ")
   TextGadget(#Text_22, 630, 598, 110, 20, "Poids      ")
   TextGadget(#Text_23, 630, 628, 110, 20, "Hanches")
   TextGadget(#Text_24, 630, 658, 110, 20, "Loisir(s)")   
         
   ;TextGadget(#Text_12, 620, 20, 110, 20, "Photo :")
   
   TextGadget(#Text_2,     872,50,100,20,"N°Contrat")
   TextGadget(#Text_34,    982,50,100,20," Date du shooting")
   TextGadget(#Text_35,    1092,50,150,20,"Durée de l'autorisation")
   TextGadget(#Text_33,     1140,170,100,20,"Autre (Préciser)")
   TextGadget(#Text_36,    1252,50,100,20,"Fin de validité")
   
    StringGadget(#String_0,  400, 70, 215, 20, "")           
    StringGadget(#String_1,  625, 70, 215, 20, "")
    StringGadget(#String_25, 400,125,440,20, "")   
    StringGadget(#String_26, 400,180,50, 20, "")
    StringGadget(#String_29, 460,180,80, 20, "")
    StringGadget(#String_30,550,180,100, 20, "")
      
    StringGadget(#String_31,658,180,76,20, "")
    
    StringGadget(#String_32,740,180,100, 20, "")     
    StringGadget(#String_27, 400, 235, 440, 20, "")        
    StringGadget(#String_28, 400, 260, 440, 20, "")
    StringGadget(#String_3,  460, 355, 150, 20, "")    
    StringGadget(#String_4,  460, 385, 150, 20, "")
    StringGadget(#String_5,  460, 415, 150, 20, "")
    StringGadget(#String_6,  460, 445, 150, 20, "")
    StringGadget(#String_7,  460, 475, 150, 20, "")
    StringGadget(#String_8,  460, 505, 150, 20, "")
    StringGadget(#String_9,  460, 535, 150, 20, "")
    StringGadget(#String_10, 460, 565, 150, 20, "")
    StringGadget(#String_11, 460, 595, 150, 20, "")
    StringGadget(#String_12, 460, 625, 150, 20, "")
    StringGadget(#String_13, 460, 655, 150, 20, "")
    StringGadget(#String_14, 690, 355, 150, 20, "")
    StringGadget(#String_15, 690, 385, 150, 20, "")
    StringGadget(#String_16, 690, 415, 150, 20, "")
    StringGadget(#String_17, 690, 445, 150, 20, "")
    StringGadget(#String_18, 690, 475, 150, 20, "")
    StringGadget(#String_19, 690, 505, 150, 20, "")
    StringGadget(#String_20, 690, 535, 150, 20, "")
    StringGadget(#String_21, 690, 565, 150, 20, "")
    StringGadget(#String_22, 690, 595, 150, 20, "")
    StringGadget(#String_23, 690, 625, 150, 20, "")
    StringGadget(#String_24, 690, 655, 150, 20, "")        
    StringGadget(#String_2, 872,70,100,20, "")
    StringGadget(#String_34,982,70,100,20, "")
    StringGadget(#String_35,1092,70,150,20, "")      
    StringGadget(#String_36,1252,70,90,20, "")       
                    
   
    CheckBoxGadget(#CheckBox_0, 876,130,100, 15, "Presse"):SetGadgetState(#CheckBox_0,Etat_CheckBox_0)                 
    CheckBoxGadget(#CheckBox_1, 876,150,100, 15, "Livre"):SetGadgetState(#CheckBox_1,Etat_CheckBox_1)
    CheckBoxGadget(#CheckBox_2, 876,170,100, 15, "Exposition"):SetGadgetState(#CheckBox_2,Etat_CheckBox_2)
        
                
    CheckBoxGadget(#CheckBox_5, 1060,130,100, 15, "Carte postale"):SetGadgetState(#CheckBox_5,Etat_CheckBox_5)
    CheckBoxGadget(#CheckBox_6, 1060,150,120, 15, "Projection publique"):SetGadgetState(#CheckBox_6,Etat_CheckBox_6)
    CheckBoxGadget(#CheckBox_7, 1060,170,60, 15, "Publicité"):SetGadgetState(#CheckBox_7,Etat_CheckBox_7) 
        
    CheckBoxGadget(#CheckBox_4, 1220,130,130, 15, "Objets de décoration"):SetGadgetState(#CheckBox_4,Etat_CheckBox_4)
    CheckBoxGadget(#CheckBox_3, 1220,150,130, 15, "Publication électronique"):SetGadgetState(#CheckBox_3,Etat_CheckBox_3)
        
    StringGadget(#String_33,1220,170,100,20, "")
    
    CheckBoxGadget(#CheckBox_8,  876,230,300, 15, "Autorisation à titre gratuit"):SetGadgetState(#CheckBox_8,Etat_CheckBox_8)
    CheckBoxGadget(#CheckBox_9,  876,250,300, 15, "Autorisation contre tirage : Pourcentage sur les recettes : %"):SetGadgetState(#CheckBox_9,Etat_CheckBox_9)
     CheckBoxGadget(#CheckBox_10, 876,270,200, 15, "Exposition"):SetGadgetState(#CheckBox_10,Etat_CheckBox_10)        
            
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
  EndIf                      
EndProcedure

Procedure DB_Init()
  Protected plFile.l
  Protected psSQLRequest.s
  UseSQLiteDatabase()
  If FileSize(#PB_Compiler_FilePath+"Ordinem.sqlite") < 0
    plFile = CreateFile(#PB_Any, #PB_Compiler_FilePath+"Ordinem.sqlite")
    If plFile
      CloseFile(plFile)
    EndIf
  EndIf
 
  glDBSQLite = OpenDatabase(#PB_Any, #PB_Compiler_FilePath+"Ordinem.sqlite", "", "", #PB_Database_SQLite)
  If glDBSQLite = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts", DatabaseError())
    End
  ElseIf plFile
    psSQLRequest = "CREATE TABLE IF NOT EXISTS contacts ("
    psSQLRequest + "id_contact INTEGER PRIMARY KEY AUTOINCREMENT Not NULL, "
    psSQLRequest + "contact_Numero_Client TEXT, "
    psSQLRequest + "contact_Numero_Facture TEXT, "
    psSQLRequest + "contact_Numero_Contrat TEXT, "
    psSQLRequest + "contact_prenom TEXT Not NULL, "
    psSQLRequest + "contact_nom TEXT Not NULL, "
    psSQLRequest + "contact_job TEXT, "
    psSQLRequest + "contact_company TEXT, "
    psSQLRequest + "contact_address_1 TEXT, "
    psSQLRequest + "contact_address_2 TEXT, "
    psSQLRequest + "contact_address_3 TEXT, "
    psSQLRequest + "contact_postalcode TEXT, "
    psSQLRequest + "contact_city TEXT, "
    psSQLRequest + "contact_country TEXT, "
    psSQLRequest + "contact_phone TEXT, "
    psSQLRequest + "contact_fax TEXT, "
    psSQLRequest + "contact_mail TEXT, "
    psSQLRequest + "contact_date_de_naissance TEXT, "
    psSQLRequest + "contact_sexe TEXT, "
    psSQLRequest + "contact_cheveux TEXT, "
    psSQLRequest + "contact_yeux TEXT, "
    psSQLRequest + "contact_peau TEXT, "
    psSQLRequest + "contact_taille TEXT, "
    psSQLRequest + "contact_poids TEXT, "
    psSQLRequest + "contact_hanches TEXT, "
    psSQLRequest + "contact_loisir TEXT, "
    psSQLRequest + "contact_prestation TEXT, "
    psSQLRequest + "facture_quantite TEXT, "
    psSQLRequest + "facture_commentaires TEXT,"
    psSQLRequest + "facture_recommandations TEXT, "
    psSQLRequest + "facture_prix_uht TEXT, "
    psSQLRequest + "facture_date_reglement TEXT, "
    psSQLRequest + "facture_date_exécution TEXT, "
    psSQLRequest + "facture_conditions_escompte TEXT, " 
    psSQLRequest + "contrat_shooting TEXT, "
    psSQLRequest + "contrat_autorisation TEXT, "   
    psSQLRequest + "contrat_fin_validite TEXT, " 
    psSQLRequest + "contrat_autres TEXT, "
    psSQLRequest + "Etat_CheckBox_0 TEXT, "
    psSQLRequest + "Etat_CheckBox_1 TEXT, "
    psSQLRequest + "Etat_CheckBox_2 TEXT, "
    psSQLRequest + "Etat_CheckBox_3 TEXT, "
    psSQLRequest + "Etat_CheckBox_4 TEXT, "
    psSQLRequest + "Etat_CheckBox_5 TEXT, "
    psSQLRequest + "Etat_CheckBox_6 TEXT, "
    psSQLRequest + "Etat_CheckBox_7 TEXT, "
    psSQLRequest + "Etat_CheckBox_8 TEXT, "
    psSQLRequest + "Etat_CheckBox_9 TEXT, "
    psSQLRequest + "Etat_CheckBox_10 TEXT, "
    psSQLRequest + "contact_photo BLOB, "
    psSQLRequest + "contact_photo_s BLOB, "
    psSQLRequest + "contact_photo_size INTEGER,"
    psSQLRequest + "contact_photo_s_size INTEGER"
    psSQLRequest + ")"
    ; Debug psSQLRequest
    If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
      MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_Init()", DatabaseError())
    EndIf
  EndIf
 
  If DatabaseQuery(glDBSQLite, "SELECT * FROM contacts") <> 0
    While NextDatabaseRow(glDBSQLite)    
    AddGadgetItem(#Listview_0, CountGadgetItems(#Listview_0), "Facture N°" +GetDatabaseString(glDBSQLite, 2) + " " +GetDatabaseString(glDBSQLite, 4) + " " + GetDatabaseString(glDBSQLite, 5) + " " + GetDatabaseString(glDBSQLite, 6))
    SetGadgetItemData(#Listview_0, CountGadgetItems(#Listview_0)-1, GetDatabaseLong(glDBSQLite, 0))
    Wend
    FinishDatabaseQuery(glDBSQLite)
  EndIf
EndProcedure

Procedure DB_InsertContact()
  Protected psSQLRequest.s
  psSQLRequest = "INSERT INTO contacts"
  psSQLRequest + "(contact_Numero_Client,contact_Numero_Facture,contact_Numero_Contrat,contact_prenom, contact_nom, contact_job, contact_company, contact_address_1,contact_address_2,contact_address_3,"
  psSQLRequest + "contact_postalcode, contact_city, contact_country, contact_phone, contact_fax, contact_mail, contact_date_de_naissance,contact_sexe, contact_cheveux,contact_yeux,contact_peau,"
  psSQLRequest + "contact_taille,contact_poids,contact_hanches,contact_loisir,contact_prestation,facture_quantite,facture_commentaires,facture_recommandations,facture_prix_uht,"
  psSQLRequest + "facture_date_reglement,facture_date_exécution,facture_conditions_escompte,contrat_shooting,contrat_autorisation,contrat_fin_validite,contrat_autres,Etat_CheckBox_0,"
  psSQLRequest + "Etat_CheckBox_1,Etat_CheckBox_2,Etat_CheckBox_3,Etat_CheckBox_4,Etat_CheckBox_5,Etat_CheckBox_6,Etat_CheckBox_7,Etat_CheckBox_8,Etat_CheckBox_9,Etat_CheckBox_10,"
  psSQLRequest + "contact_photo,contact_photo_s,contact_photo_size,contact_photo_s_size)"
  psSQLRequest + "VALUES ("
  psSQLRequest + "'"+GetGadgetText(#String_0)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_1)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_2)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_3)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_4)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_5)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_6)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_7)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_8)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_9)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_10)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_11)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_12)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_13)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_14)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_15)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_16)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_17)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_18)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_19)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_20)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_21)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_22)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_23)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_24)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_25)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_26)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_27)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_28)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_29)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_30)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_31)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_32)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_33)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_34)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_35)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_36)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_0)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_1)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_2)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_3)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_4)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_5)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_6)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_7)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_8)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_9)+"',"
  psSQLRequest + "'"+GetGadgetText(#CheckBox_10)+"',"
  psSQLRequest + "?,"
  psSQLRequest + "?,"
  
  If glImageMemory
    psSQLRequest + Str(MemorySize(glImageMemory))
  Else
    psSQLRequest + "0"
  EndIf
  
  If glImageMemory2
    psSQLRequest + Str(MemorySize(glImageMemory2))
  Else
    psSQLRequest + "1"
  EndIf
  
  psSQLRequest + ")"
  
  ;Debug psSQLRequest
  
  If glImageMemory
    SetDatabaseBlob(glDBSQLite, 0, glImageMemory, MemorySize(glImageMemory))  
  Else
    ReplaceString(psSQLRequest, "?", "'0'")  
  EndIf  
  
  If glImageMemory2    
    SetDatabaseBlob(glDBSQLite, 1, glImageMemory2, MemorySize(glImageMemory2))
  Else  
    ReplaceString(psSQLRequest, "?", "'1'")
  EndIf  
  
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_InsertContact()", DatabaseError())
  EndIf
   
  ; Ajoute le dernier element ajouté à la base
  If DatabaseQuery(glDBSQLite, "SELECT max(id_contact), contact_prenom, contact_nom FROM contacts") <> 0
    While NextDatabaseRow(glDBSQLite)
      AddGadgetItem(#Listview_0, CountGadgetItems(#Listview_0), GetDatabaseString(glDBSQLite, 1) + " " + GetDatabaseString(glDBSQLite, 2))
      SetGadgetItemData(#Listview_0, CountGadgetItems(#Listview_0)-1, GetDatabaseLong(glDBSQLite, 0))
    Wend
    FinishDatabaseQuery(glDBSQLite)
  Else
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_InsertContact", DatabaseError())
  EndIf
EndProcedure

Procedure DB_SelectContact(GadgetItem.l)
  Protected psSQLRequest.s
  Protected plFileImageSize.l
  Protected plFileImage.l
  
  Protected plFileImageSize2.l
  Protected plFileImage2.l
    
  psSQLRequest = "SELECT * FROM contacts WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  If DatabaseQuery(glDBSQLite, psSQLRequest) <> 0
    While NextDatabaseRow(glDBSQLite)
      SetGadgetText(#String_0, GetDatabaseString(glDBSQLite, 1))
      SetGadgetText(#String_1, GetDatabaseString(glDBSQLite, 2))
      SetGadgetText(#String_2, GetDatabaseString(glDBSQLite, 3))
      SetGadgetText(#String_3, GetDatabaseString(glDBSQLite, 4))
      SetGadgetText(#String_4, GetDatabaseString(glDBSQLite, 5))
      SetGadgetText(#String_5, GetDatabaseString(glDBSQLite, 6))
      SetGadgetText(#String_6, GetDatabaseString(glDBSQLite, 7))
      SetGadgetText(#String_7, GetDatabaseString(glDBSQLite, 8))
      SetGadgetText(#String_8, GetDatabaseString(glDBSQLite, 9))
      SetGadgetText(#String_9, GetDatabaseString(glDBSQLite, 10))
      SetGadgetText(#String_10,GetDatabaseString(glDBSQLite, 11))
      SetGadgetText(#String_11,GetDatabaseString(glDBSQLite, 12))
      SetGadgetText(#String_12,GetDatabaseString(glDBSQLite, 13))
      SetGadgetText(#String_13,GetDatabaseString(glDBSQLite, 14))
      SetGadgetText(#String_14,GetDatabaseString(glDBSQLite, 15))
      SetGadgetText(#String_15,GetDatabaseString(glDBSQLite, 16))
      SetGadgetText(#String_16,GetDatabaseString(glDBSQLite, 17))
      SetGadgetText(#String_17,GetDatabaseString(glDBSQLite, 18))
      SetGadgetText(#String_18,GetDatabaseString(glDBSQLite, 19))
      SetGadgetText(#String_19,GetDatabaseString(glDBSQLite, 20))
      SetGadgetText(#String_20,GetDatabaseString(glDBSQLite, 21))   
      SetGadgetText(#String_21,GetDatabaseString(glDBSQLite, 22))   
      SetGadgetText(#String_22,GetDatabaseString(glDBSQLite, 23))   
      SetGadgetText(#String_23,GetDatabaseString(glDBSQLite, 24))   
      SetGadgetText(#String_24,GetDatabaseString(glDBSQLite, 25))   
      SetGadgetText(#String_25,GetDatabaseString(glDBSQLite, 26))   
      SetGadgetText(#String_26,GetDatabaseString(glDBSQLite, 27))   
      SetGadgetText(#String_27,GetDatabaseString(glDBSQLite, 28))   
      SetGadgetText(#String_28,GetDatabaseString(glDBSQLite, 29))   
      SetGadgetText(#String_29,GetDatabaseString(glDBSQLite, 30))   
      SetGadgetText(#String_30,GetDatabaseString(glDBSQLite, 31))   
      SetGadgetText(#String_31,GetDatabaseString(glDBSQLite, 32))  
      SetGadgetText(#String_32,GetDatabaseString(glDBSQLite, 33))  
      SetGadgetText(#String_33,GetDatabaseString(glDBSQLite, 34))   
      SetGadgetText(#String_34,GetDatabaseString(glDBSQLite, 35))   
      SetGadgetText(#String_35,GetDatabaseString(glDBSQLite, 36))  
      SetGadgetText(#String_36,GetDatabaseString(glDBSQLite, 37))  
      SetGadgetText(#CheckBox_0,GetDatabaseString(glDBSQLite, 38))
      SetGadgetText(#CheckBox_1,GetDatabaseString(glDBSQLite, 39))
      SetGadgetText(#CheckBox_2,GetDatabaseString(glDBSQLite, 40))      
      SetGadgetText(#CheckBox_3,GetDatabaseString(glDBSQLite, 41))
      SetGadgetText(#CheckBox_4,GetDatabaseString(glDBSQLite, 42))
      SetGadgetText(#CheckBox_5,GetDatabaseString(glDBSQLite, 43))
      SetGadgetText(#CheckBox_6,GetDatabaseString(glDBSQLite, 44))
      SetGadgetText(#CheckBox_7,GetDatabaseString(glDBSQLite, 45))
      SetGadgetText(#CheckBox_8,GetDatabaseString(glDBSQLite, 46))
      SetGadgetText(#CheckBox_9,GetDatabaseString(glDBSQLite, 47))
      SetGadgetText(#CheckBox_10,GetDatabaseString(glDBSQLite,48))
      plFileImageSize = GetDatabaseLong(glDBSQLite, 51)
      If plFileImageSize > 0
        glImageMemory = AllocateMemory(plFileImageSize)
        GetDatabaseBlob(glDBSQLite, 49, glImageMemory, plFileImageSize)
        plFileImage = CatchImage(#PB_Any, glImageMemory, plFileImageSize)
        If plFileImage
          ResizeImage(plFileImage, 240, 283)
          SetGadgetState(#Image_0, ImageID(plFileImage))
          FreeImage(plFileImage)
        EndIf
      Else
        SetGadgetState(#Image_0, 0)
      EndIf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      plFileImageSize2 = GetDatabaseLong(glDBSQLite, 52)
      If plFileImageSize2 > 0
        glImageMemory2 = AllocateMemory(plFileImageSize2)
        GetDatabaseBlob(glDBSQLite, 50, glImageMemory2, plFileImageSize2)
        plFileImage2 = CatchImage(#PB_Any, glImageMemory2, plFileImageSize2)
        If plFileImage2
          ResizeImage(plFileImage2, 240, 283)
          SetGadgetState(#Image_1, ImageID(plFileImage2))
          FreeImage(plFileImage2)
        EndIf
      Else
        SetGadgetState(#Image_1, 0)
      EndIf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    Wend
    FinishDatabaseQuery(glDBSQLite)
  Else
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_SelectContact", DatabaseError())
  EndIf
EndProcedure

Procedure DB_UpdateContact(GadgetItem.l)
  Protected psSQLRequest.s
  psSQLRequest = "UPDATE contacts SET "
  psSQLRequest + "contact_Numero_Client='"    +GetGadgetText(#String_0)+"', "
  psSQLRequest + "contact_Numero_Facture='"   +GetGadgetText(#String_1)+"', "
  psSQLRequest + "contact_Numero_Contrat='"   +GetGadgetText(#String_2)+"', "
  psSQLRequest + "contact_prenom='"           +GetGadgetText(#String_3)+"', "
  psSQLRequest + "contact_nom='"              +GetGadgetText(#String_4)+"', "
  psSQLRequest + "contact_job='"              +GetGadgetText(#String_5)+"', "
  psSQLRequest + "contact_company='"          +GetGadgetText(#String_6)+"', "
  psSQLRequest + "contact_address_1='"        +GetGadgetText(#String_7)+"', "
  psSQLRequest + "contact_address_2='"        +GetGadgetText(#String_8)+"', "
  psSQLRequest + "contact_address_3='"        +GetGadgetText(#String_9)+"', "
  psSQLRequest + "contact_postalcode='"       +GetGadgetText(#String_10)+"', "
  psSQLRequest + "contact_city='"             +GetGadgetText(#String_11)+"', "
  psSQLRequest + "contact_country='"          +GetGadgetText(#String_12)+"', "
  psSQLRequest + "contact_phone='"            +GetGadgetText(#String_13)+"', "
  psSQLRequest + "contact_fax='"              +GetGadgetText(#String_14)+"', "
  psSQLRequest + "contact_mail='"             +GetGadgetText(#String_15)+"', "
  psSQLRequest + "contact_date_de_naissance='"+GetGadgetText(#String_16)+"', "
  psSQLRequest + "contact_sexe='"             +GetGadgetText(#String_17)+"', "
  psSQLRequest + "contact_cheveux='"          +GetGadgetText(#String_18)+"',"
  psSQLRequest + "contact_yeux='"             +GetGadgetText(#String_19)+"',"
  psSQLRequest + "contact_peau='"             +GetGadgetText(#String_20)+"',"
  psSQLRequest + "contact_taille='"           +GetGadgetText(#String_21)+"',"
  psSQLRequest + "contact_poids='"            +GetGadgetText(#String_22)+"',"
  psSQLRequest + "contact_hanches='"          +GetGadgetText(#String_23)+"',"
  psSQLRequest + "contact_loisir='"           +GetGadgetText(#String_24)+"',"
  psSQLRequest + "contact_prestation='"       +GetGadgetText(#String_25)+"',"
  psSQLRequest + "facture_quantite='"         +GetGadgetText(#String_26)+"',"
  psSQLRequest + "facture_commentaires='"     +GetGadgetText(#String_27)+"',"
  psSQLRequest + "facture_recommandations='"  +GetGadgetText(#String_28)+"',"
  psSQLRequest + "facture_prix_uht='"         +GetGadgetText(#String_29)+"',"
  psSQLRequest + "facture_date_reglement='"   +GetGadgetText(#String_30)+"',"
  psSQLRequest + "facture_date_exécution='"   +GetGadgetText(#String_31)+"',"
  psSQLRequest + "facture_conditions_escompte='" +GetGadgetText(#String_32)+"'," 
  psSQLRequest + "contrat_shooting='"         +GetGadgetText(#String_33)+"'," 
  psSQLRequest + "contrat_autorisation='" +GetGadgetText(#String_34)+"'," 
  psSQLRequest + "contrat_fin_validite='" +GetGadgetText(#String_35)+"'," 
  psSQLRequest + "contrat_autres='"  +GetGadgetText(#String_36)+"'," 
  psSQLRequest + "Etat_CheckBox_0='" +GetGadgetText(#CheckBox_0)+"'," 
  psSQLRequest + "Etat_CheckBox_1='" +GetGadgetText(#CheckBox_1)+"'," 
  psSQLRequest + "Etat_CheckBox_2='" +GetGadgetText(#CheckBox_2)+"'," 
  psSQLRequest + "Etat_CheckBox_3='" +GetGadgetText(#CheckBox_3)+"'," 
  psSQLRequest + "Etat_CheckBox_4='" +GetGadgetText(#CheckBox_4)+"'," 
  psSQLRequest + "Etat_CheckBox_5='" +GetGadgetText(#CheckBox_5)+"'," 
  psSQLRequest + "Etat_CheckBox_6='" +GetGadgetText(#CheckBox_6)+"',"   
  psSQLRequest + "Etat_CheckBox_7='" +GetGadgetText(#CheckBox_7)+"',"   
  psSQLRequest + "Etat_CheckBox_8='" +GetGadgetText(#CheckBox_8)+"'," 
  psSQLRequest + "Etat_CheckBox_9='" +GetGadgetText(#CheckBox_9)+"',"   
  psSQLRequest + "Etat_CheckBox_10='" +GetGadgetText(#CheckBox_10)+"',"   
  psSQLRequest + "contact_photo = ?," 
  psSQLRequest + "contact_photo_s = ?," 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   If glImageMemory
    psSQLRequest + "contact_photo_size = " + Str(MemorySize(glImageMemory))
  Else
    psSQLRequest + "contact_photo_size = 0"
  EndIf
  
   If glImageMemory2
    psSQLRequest + "contact_photo_s_size = " + Str(MemorySize(glImageMemory2))
  Else
    psSQLRequest + "contact_photo_s_size = 1"
  EndIf
  
  psSQLRequest + " WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  
  If glImageMemory
    SetDatabaseBlob(glDBSQLite, 0, glImageMemory, MemorySize(glImageMemory))
  Else
    ReplaceString(psSQLRequest, "?", "'0'")
  EndIf
  
  If glImageMemory2
    SetDatabaseBlob(glDBSQLite, 1, glImageMemory2, MemorySize(glImageMemory2))
  Else
    ReplaceString(psSQLRequest, "?", "'1'")
  EndIf 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0 Or 1
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_UpdateContact()", DatabaseError())
  Else
    SetGadgetItemText(#Listview_0, GadgetItem, GetGadgetText(#String_0)+" "+GetGadgetText(#String_1))
  EndIf
EndProcedure

Procedure DB_DeleteContact(GadgetItem.l)
  Protected psSQLRequest.s
  psSQLRequest = "DELETE FROM contacts WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_DeleteContact()", DatabaseError())
  Else
    RemoveGadgetItem(#Listview_0, GadgetItem)
  EndIf
EndProcedure

Procedure ExecCalc()
  ;Compilateur = RunProgram(#PB_Compiler_Home+"/Compilers/pbcompiler", "/?", "", #PB_Program_Open | #PB_Program_Read)
  LanceCalc = RunProgram("C:\Windows\System32\calc.exe","", "", #PB_Program_Open | #PB_Program_Read)
  Sortie$ = ""
  If LanceCalc 
    While ProgramRunning(LanceCalc)
      If AvailableProgramOutput(LanceCalc)
        Sortie$ + ReadProgramString(LanceCalc) + Chr(13)
      EndIf
    Wend
    Sortie$ + Chr(13) + Chr(13)
    Sortie$ + "Code de retour : " + Str(ProgramExitCode(LanceCalc))
    
    CloseProgram(LanceCalc) ; Ferme la connection vers le programme
  EndIf
  ;MessageRequester("Sortie", Sortie$)
  
EndProcedure

  Procedure OpenAgenda()
    If OpenWindow(#FenetreAgenda,153,50,220,220, "Agenda", #PB_Window_BorderLess, WindowID(#Window_0))
         CalendarGadget(#Agenda,0,0,220, 190)
         ButtonGadget(#BoutonAgenda,0,192,220,26, "Ok")
      EndIf
    EndProcedure
    
Main_WindowOpen()
DB_Init()

;CreateGadgetList(WindowID(0))
;GraphMenu()
CreateThread(@MouseMove(),0)

Repeat
     
  glEvent = WaitWindowEvent()
  glGadget= EventGadget()
  glType = EventType() 
  
  
 ;*****************************
    
    Etat_CheckBox_0 = GetGadgetState(#CheckBox_0)
    Etat_CheckBox_1 = GetGadgetState(#CheckBox_1)
    tat_CheckBox_2 =  GetGadgetState(#CheckBox_2)
    Etat_CheckBox_3 = GetGadgetState(#CheckBox_3)
    Etat_CheckBox_4 = GetGadgetState(#CheckBox_4)
    Etat_CheckBox_5 = GetGadgetState(#CheckBox_5)
    Etat_CheckBox_6 = GetGadgetState(#CheckBox_6)
    Etat_CheckBox_7 = GetGadgetState(#CheckBox_7)   
    Etat_CheckBox_8 = GetGadgetState(#CheckBox_8)
    Etat_CheckBox_9 = GetGadgetState(#CheckBox_9)
    Etat_CheckBox_10 = GetGadgetState(#CheckBox_10)
    
    ;Debug Etat_CheckBox_0
    ;Debug Etat_CheckBox_1
    ;Debug Etat_CheckBox_2
    ;Debug Etat_CheckBox_3
    ;Debug Etat_CheckBox_4
    ;Debug Etat_CheckBox_5
    ;Debug Etat_CheckBox_6
    ;Debug Etat_CheckBox_7
    ;Debug Etat_CheckBox_8
    ;Debug Etat_CheckBox_9
    ;Debug Etat_CheckBox_10
    
    ;Debug "WindowID: " + Str(EventWindowID())
    ;GadgetID = EventGadgetID()
    
    ;*****************************

    If glEvent = #PB_Event_Gadget
    Select glGadget  
        
    Case #CheckBox_0 
      If #CheckBox_0 = 1 
      Etat_CheckBox_0 = #CheckBox_0
       Else 
      Etat_CheckBox_0 = 0
     EndIf
    
    Case #CheckBox_1 
      If #CheckBox_1 = 1 
      Etat_CheckBox_1 = #CheckBox_1
      Else 
      Etat_CheckBox_1 = 0
     EndIf
     
    Case #CheckBox_2 
      If #CheckBox_2 = 1 
      Etat_CheckBox_2 = #CheckBox_2
       Else 
     Etat_CheckBox_2 = 0
     EndIf
    
    Case #CheckBox_3 
      If #CheckBox_3 = 1 
      Etat_CheckBox_3 = #CheckBox_3
       Else 
      Etat_CheckBox_3 = 0
    EndIf
    
    Case #CheckBox_4 
      If #CheckBox_4 = 1 
      Etat_CheckBox_4 = #CheckBox_4
       Else 
      Etat_CheckBox_4 = 0
     EndIf
    
    Case #CheckBox_5 
      If #CheckBox_5 = 1 
      Etat_CheckBox_5 = #CheckBox_5
       Else 
      Etat_CheckBox_5 = 0
    EndIf
    
    Case #CheckBox_6 
    If #CheckBox_6 = 1 
    Etat_CheckBox_6 = #CheckBox_6
    Else 
    Etat_CheckBox_6 = 0
   EndIf
    
    Case #CheckBox_7 
     If #CheckBox_7 = #CheckBox_7
     Etat_CheckBox_7 = 1
      Else 
     Etat_CheckBox_7 = 0
    EndIf
     
   Case #Listview_0 ;{
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)
          If GetGadgetState(#Listview_0) <> glListviewItemSelected
            glListviewItemSelected = GetGadgetState(#Listview_0)
            DB_SelectContact(GetGadgetState(#Listview_0))
          EndIf
        EndIf
      ;}
      Case #Button_0 ;{ Reset
        If glType = #PB_EventType_LeftClick
          Define.l dlInc
          For dlInc = #String_0 To #String_37
            SetGadgetText(dlInc, "")
          Next
          SetGadgetState(#Image_0, 0)
          If glImageMemory
            FreeMemory(glImageMemory)
            glImageMemory = 0
          EndIf
          glListviewItemSelected = -1
        EndIf
      ;}
      Case #Button_1 ;{ Ajouter
       ;If GetGadgetText(#String_0) <> "" And GetGadgetText(#String_1) <> ""
       If GetGadgetText(#String_2) <> "" And GetGadgetText(#String_3) <> "" And GetGadgetText(#String_4) <> "" And GetGadgetText(#String_5) <> ""
          If glType = #PB_EventType_LeftClick
            DB_InsertContact()
          EndIf
        EndIf
      ;}
      Case #Button_2 ;{ Mettre à jour
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
          If glType = #PB_EventType_LeftClick
            DB_UpdateContact(GetGadgetState(#Listview_0))
            Main_WindowOpen()
            DB_Init()
            MessageRequester("Notysoft Ordinem - Gestion de Contacts - ","Vos contacts sont à jour ! :D",64)
            EndIf
        EndIf
      ;}
      Case #Button_3 ;{ Supprimer
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
          If glType = #PB_EventType_LeftClick
            If MessageRequester("Notysoft Ordinem - Gestion de Contacts", "Voulez vous vraiment supprimer le contact courant "+Chr(34)+GetGadgetItemText(#Listview_0, GetGadgetState(#Listview_0))+Chr(34)+" ?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
              DB_DeleteContact(GetGadgetState(#Listview_0))
            EndIf
          EndIf
        EndIf
      ;}
      Case #Button_4 ;{ Parcourir
        Define.s psFileImage
        Define.l plFileImage
        ; Ouvre une boîte de dialogue standard pour choisir une image
        psFileImage = OpenFileRequester("Choisissez une image à charger", "", "Fichiers Images|*.png;*.bmp;*.jpg;*.jpeg|Tous les fichiers (*.*)|*.*", 0)
        If psFileImage
          ; Charge une image
          plFileImage = LoadImage(#PB_Any, psFileImage)
          If plFileImage
            ; Redimensionne l'image à la taille de l'ImageGadget
            ResizeImage(plFileImage, 240, 283)
            ; Change l'image affichée par l' ImageGadget
            SetGadgetState(#Image_0, ImageID(plFileImage))
            ; Libère l'image
            FreeImage(plFileImage)
            ; Charge l'image dans la zone mémoire globale dédiée 'glImageMemory'
            plFileImage = OpenFile(#PB_Any, psFileImage)
            If plFileImage
              glImageMemory = AllocateMemory(Lof(plFileImage))
              If glImageMemory
                ReadData(plFileImage, glImageMemory, Lof(plFileImage))
              EndIf
              CloseFile(plFileImage)
            EndIf
          EndIf
        EndIf
        ;}
        
    Case #Button_8 ;{ Lance l'Agenda
           OpenAgenda()
     
                           
    Case #Button_9 ;{ Lance la calculatrice
    ExecCalc()    
                
      Case #Button_10 ;{ A_Propos
        MessageRequester("A Propos","Notysoft Ordinem - 2016 - 2017                                                                  Créer simplement sa base de données modèles et photographes.",64)
        
        Case #Button_11 ;{ Parcourir Signiature
        Define.s psFileImage2
        Define.l plFileImage2
        ;Ouvre une boîte de dialogue standard pour choisir une image
        psFileImage2 = OpenFileRequester("Choisissez une image à charger", "", "Fichiers Images|*.png;*.bmp;*.jpg;*.jpeg|Tous les fichiers (*.*)|*.*", 0)
        If psFileImage2
          ;Charge une image
          plFileImage2 = LoadImage(#PB_Any, psFileImage2)
          If plFileImage2
            ;Redimensionne l'image à la taille de l'ImageGadget
            ResizeImage(plFileImage2, 116, 55)
            ;Change l'image affichée par l' ImageGadget
            SetGadgetState(#Image_1 , ImageID(plFileImage2))
            ;Libère l'image
            FreeImage(plFileImage2)
           ;Charge l'image dans la zone mémoire globale dédiée 'glImageMemory'
            plFileImage2 = OpenFile(#PB_Any, psFileImage2)
            If plFileImage2
              glImageMemory2 = AllocateMemory(Lof(plFileImage2))
              If glImageMemory2
               ReadData(plFileImage2, glImageMemory2, Lof(plFileImage2))
              EndIf
              CloseFile(plFileImage2)
            EndIf
          EndIf
        EndIf
        ;}
        
      Case #BoutonAgenda
        ;SetGadgetText(#Text, "Vous avez fermé la fenêtre 1")
       CloseWindow(#FenetreAgenda)
   
EndSelect
EndIf

Until glEvent = #PB_Event_CloseWindow

End
Avatar de l’utilisateur
Micoute
Messages : 2584
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: Problèmes SQLite - "Values et colomns"

Message par Micoute »

Bonjour PCPixMusic, j'ai testé ton programme et je n'ai trouvé aucune erreur.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 6.20 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
PCPixMusic
Messages : 106
Inscription : ven. 06/janv./2017 9:50

Re: Problèmes SQLite - "Values et colomns"

Message par PCPixMusic »

Bonjour Micoute,

J'ai rempli n'importe quoi dans les champs, mais c'est juste pour afficher le résultat du bouton Ajouter une fiche, qu'importe, même avec une fiche remplie normalement ça fonctionne, de toute façon une chaîne est une chaîne. ^^

Voici une capture : (cliquez sur le lien pour agrandir ^^)

Image
Avatar de l’utilisateur
Micoute
Messages : 2584
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: Problèmes SQLite - "Values et colomns"

Message par Micoute »

J'ai retenté la démarche à nouveau en faisant n'importe quoi aussi et toujours pas de défaut, il faudra trouver un autre testeur.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 6.20 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

Whaouuu long à décrypter.

:!: Dans un enregistrement chaque variable doit être séparer par une "," ce qui n'est pas le cas pour tes deux dernières variables (contact_photo_size et contact_photo_s_size).

Donc je pense que l'erreur est ici en ligne 536

Code : Tout sélectionner

If glImageMemory
    psSQLRequest + Str(MemorySize(glImageMemory))
  Else
    psSQLRequest + "0"
  EndIf
  
  If glImageMemory2
    psSQLRequest + Str(MemorySize(glImageMemory2))
  Else
    psSQLRequest + "1"
  EndIf
:idea: Remplace

Code : Tout sélectionner

If glImageMemory
    psSQLRequest + Str(MemorySize(glImageMemory))
  Else
    psSQLRequest + "0"
  EndIf
par

Code : Tout sélectionner

  If glImageMemory
    psSQLRequest + Str(MemorySize(glImageMemory)) + ","
  Else
    psSQLRequest + "0" + ","
  EndIf
Bienvenue à toi et bon code.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

Quelques bugs:

■ Le bouton effacer crash le code.
[19:23:18] [ERROR] test.pb (Line: 254)
[19:23:18] [ERROR] The specified #Gadget is Not initialised.
[19:23:18] The Program execution has finished.

■ La modification d'une fiche génère une erreur SQL surement du à un souci de séparateur de colonne.
Ton appli est insolente et informe quand même que la modification a bien était effective ^^
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
PCPixMusic
Messages : 106
Inscription : ven. 06/janv./2017 9:50

Re: Problèmes SQLite - "Values et colomns"

Message par PCPixMusic »

@ Micoute : Merci beaucoup d'avoir pris du temps pour tester ce programme.

@ Falsam : Merci beaucoup, c'est exactement ça ! ça Marche ! :D
Il me reste à trouvé pourquoi DB_InsertContact() n'affiche pas le nom de la fiche
directement Numéro de la facture, nom et prénom.

Dans :

Code : Tout sélectionner

 If DatabaseQuery(glDBSQLite, "SELECT max(id_contact), contact_prenom, contact_nom FROM contacts") <> 0
    While NextDatabaseRow(glDBSQLite)
      AddGadgetItem(#Listview_0, CountGadgetItems(#Listview_0), GetDatabaseString(glDBSQLite, 1) + " " + GetDatabaseString(glDBSQLite, 2))
      SetGadgetItemData(#Listview_0, CountGadgetItems(#Listview_0)-1, GetDatabaseLong(glDBSQLite, 0))
    Wend
    FinishDatabaseQuery(glDBSQLite)
  Else
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_InsertContact", DatabaseError())
  EndIf
Maintenant, DB_Update_Contact me renvoie : unrecognized token: "87890contact_photo_s_size"

J'ai mis :

Code : Tout sélectionner

psSQLRequest + "contact_photo_size = " + Str(MemorySize(glImageMemory)) + ","
Au lieu de :

Code : Tout sélectionner

psSQLRequest + "contact_photo_size = " + Str(MemorySize(glImageMemory))
ET

Code : Tout sélectionner

contact_photo_size = 0" + ","
Au lieu de :

Code : Tout sélectionner

contact_photo_size = 0"
Donc maintenant il y a :

Code : Tout sélectionner

   If glImageMemory
    psSQLRequest + "contact_photo_size = " + Str(MemorySize(glImageMemory)) + ","
  Else
    psSQLRequest + "contact_photo_size = 0" + ","
  EndIf
  
Mais pas de changement.:/

Pour Le bouton effacer qui crash le code. je ne voie pas non plus :

Code : Tout sélectionner

Procedure DB_DeleteContact(GadgetItem.l)
  Protected psSQLRequest.s
  psSQLRequest = "DELETE FROM contacts WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_DeleteContact()", DatabaseError())
  Else
    RemoveGadgetItem(#Listview_0, GadgetItem)
  EndIf
EndProcedure
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

Les modification que tu as effectué sont bonnes. J'ai pu modifier puis supprimer un enregistrement.

Ne cherche pas à modifier ou supprimer celui que tu viens de créer. Sélectionne l’enregistrement dans la liste que tu affiches puis effectue une modification. Tu verras que ça fonctionne et tu comprendras en meme temps pourquoi tu as eu cette erreur.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

Petit exercice avec moins de données avant d'aller trop loin dans ton code
- Crée un dossier
- Enregistre ce code de création de base de donneés. http://www.purebasic.fr/french/viewtopi ... 83#p160383
- Exécute le pour créer la base.

- Enregistre ensuite ce code de manipulation de données (Création, Modification, Suppression) http://www.purebasic.fr/french/viewtopi ... 91#p160391
- Exécute le et regarde le fonctionnement.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
PCPixMusic
Messages : 106
Inscription : ven. 06/janv./2017 9:50

Re: Problèmes SQLite - "Values et colomns"

Message par PCPixMusic »

J'ai remplacé :

Code : Tout sélectionner

If DatabaseQuery(glDBSQLite, "SELECT max(id_contact), contact_prenom, contact_nom FROM contacts") <> 0
Par :

Code : Tout sélectionner

If DatabaseQuery(glDBSQLite, "SELECT * FROM contacts") <> 0
Es cela ?

Pour le moment, cela semble fonctionné.

Le bouton "Effacer la fiche" crash toujours le code, j'ai supprimé ce bouton et décaler les autres, car au final supprimer la fiche suffit.

J'ai corriger l'affichage de la listeview, il n'y avait pas les bons enregistrement dedans.

Merci pour ton code d'exemple, les explications sont bien détaillées, même s'il n'est pas du tout fait de la même façon.

Mais en fait, j'avais fait mon code dans un premier temps à partir de la source que j'ai cité dans mon premier post,
c'est à partir du moment où j'ai voulu ajouter la deuxième image BLOB que ça n'avais plus fonctionné. :roll:

Merci beaucoup, j'ai fait pas mal de nettoyage.

Une fois sûr du débogage, j'ai encore le problème de la récupération d'état des CheckBoxGadget()
et de l'enregistrement de leurs états dans la base SQlite, qui ne fonctionne pas.
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

PCPixMusic a écrit :j'ai encore le problème de la récupération d'état des CheckBoxGadget()
Il suffit d'enregistrer la valeur (0 ou 1) de chaque CheckBoxGadget() dans la base de données.

Un code pour t'aider.

On va créer une base de données qui sera en mémoire pour ce test contenant une table clients.
On souhaite savoir si le client est actif ou pas -> Pour chaque client on crée un CheckBoxGadget()

Code : Tout sélectionner

Enumeration Database
  #database
EndEnumeration

Enumeration Window
  #mf
EndEnumeration

Enumeration Gadgets
  #mfClientId
  #mfClients        ;Liste des clients
  #mfClientNom      ;Client Nom
  #MfClientActif    ;Client Actif Oui ou Non
EndEnumeration

Global ReqSql.s

;Declaration des procédures
Declare Init()          
Declare Start() 
Declare ListeClients()
Declare AfficheClient()
Declare Exit()

Init()

;Création d'une base de données test en mémoire
Procedure Init()
  Protected flag.s
  
  UseSQLiteDatabase()

  ;- Création de la base de données  en mémoire pour ce test
  OpenDatabase(#DataBase, ":memory:", "", "")

  ;Creation de la table client (trés simplifié)
  ReqSql = "CREATE TABLE clients ("
  ReqSql + "clientid INTEGER PRIMARY KEY," ;Identification automatique
  ReqSql + "nom TEXTE,"                    ;Nom du client
  ReqSql + "actif INTEGER"                 ;Actif Bool Oui (1) ou Non (0)
  ReqSql + ");"
  DatabaseUpdate(#DataBase, ReqSql)
  Flag = DatabaseError()
  
  ;Ajout de deux Clients 
  ReqSql = "INSERT INTO clients (nom, actif) values ("
  ReqSql + Chr(34) + "John Dow" + Chr(34)+Chr(44)     ;Nom du client 
  ReqSql + Chr(34) + 1 + Chr(34)+")"                  ;Actif
  DatabaseUpdate(#Database, ReqSql)

  ReqSql = "INSERT INTO clients (nom, actif) values ("
  ReqSql + Chr(34) + "Laura Leach" + Chr(34)+Chr(44)  ;Nom du produit 
  ReqSql + Chr(34) + 0 + Chr(34)+")"                 ;Actif 
  DatabaseUpdate(#Database, ReqSql)
  Flag = DatabaseError()
  
  If flag = ""
    Start()
  Else
    MessageRequester("Info","Erreur durant la création de la base de données" + #CRLF$ + flag)
    Exit()
  EndIf
  
EndProcedure

;Affichage de la fenetre
Procedure Start()
  OpenWindow(#mf, 0, 0, 800, 600, "Liste des clients", #PB_Window_SystemMenu |#PB_Window_ScreenCentered)
  
  ListViewGadget(#mfClients, 10, 10, 350, 580)
 
  TextGadget(#PB_Any, 375, 23, 100, 20, "Numéro client")
  StringGadget(#mfClientId, 485, 20, 50, 22, "", #PB_String_ReadOnly)
  
  TextGadget(#PB_Any, 375, 53, 100, 20, "Nom")
  StringGadget(#mfClientNom, 485, 50, 200, 22, "")
  
  CheckBoxGadget(#MfClientActif, 485, 80, 100, 24, "Actif")
  
  ;Affichage de la liste des clients
  ListeClients()
 
  ;Déclencheurs
  BindEvent(#PB_Event_CloseWindow, @Exit())
  BindGadgetEvent(#mfClients, @AfficheClient())
  
  Repeat : WaitWindowEvent() : ForEver  
EndProcedure

;Liste des clients
Procedure ListeClients()
  ReqSql = "SELECT clientid, nom, actif FROM clients"
  
  DatabaseQuery(#Database, ReqSql) 
  
  While NextDatabaseRow(#Database)
    ;Affichage du nom du client
    AddGadgetItem(#mfClients, -1, GetDatabaseString(#database, 1))
    
    ;Pour chaque item du ListView on ajoute le ClientID
    SetGadgetItemData(#mfClients, CountGadgetItems(#mfClients) - 1, GetDatabaseLong(#database, 0)) 
  Wend
  
  ;Positionner le curseur sur le premier item
  SetGadgetState(#mfClients, 0)
  
  ;Et afficher le premier client
  AfficheClient()
EndProcedure

;Affichage d'un client sélectionné dans la liste des clients 
Procedure AfficheClient()
  Protected ClientID = GetGadgetItemData(#mfClients, GetGadgetState(#mfClients)) 
    
  ReqSql = "SELECT clientid, nom, actif FROM clients WHERE clientid = " + ClientId
  
  DatabaseQuery(#Database, ReqSql) 
  
  NextDatabaseRow(#Database)
  SetGadgetText(#mfClientId, Str(GetDatabaseLong(#database, 0)))
  SetGadgetText(#mfClientNom, GetDatabaseString(#database, 1))
  SetGadgetState(#MfClientActif, GetDatabaseLong(#database, 2))
EndProcedure

Procedure Exit()
  CloseDatabase(#database)
  End
EndProcedure
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
PCPixMusic
Messages : 106
Inscription : ven. 06/janv./2017 9:50

Re: Problèmes SQLite - "Values et colomns"

Message par PCPixMusic »

Merci beaucoup. C'est qu'il me semble que j'ai fait, mais le résultat ne s'affiche jamais à la lecture d'un enregistrement. :?

J'ai mis dans la boucle en plus par exemple :

Code : Tout sélectionner

    Etat_CheckBox_0 = GetGadgetState(#CheckBox_0)
    Etat_CheckBox_1 = GetGadgetState(#CheckBox_1)
    tat_CheckBox_2 =  GetGadgetState(#CheckBox_2)
    Etat_CheckBox_3 = GetGadgetState(#CheckBox_3)
    Etat_CheckBox_4 = GetGadgetState(#CheckBox_4)
    Etat_CheckBox_5 = GetGadgetState(#CheckBox_5)
    Etat_CheckBox_6 = GetGadgetState(#CheckBox_6)
    Etat_CheckBox_7 = GetGadgetState(#CheckBox_7)   
    Etat_CheckBox_8 = GetGadgetState(#CheckBox_8)
    Etat_CheckBox_9 = GetGadgetState(#CheckBox_9)
    Etat_CheckBox_10 = GetGadgetState(#CheckBox_10)
    Case #CheckBox_0 
      If #CheckBox_0 = 1 
      Etat_CheckBox_0 = #CheckBox_0
       Else 
      Etat_CheckBox_0 = 0
     EndIf
Mais rien de plus . C'est l'occasion de mette le nouveau code, qui en dehors des CheckBoxGadget et GetGadgetState, fonctionne.

Code : Tout sélectionner

Enumeration
  #Window_0
  #Listview_0
  #Button_0
  #Button_1
  #Button_2
  #Button_3
  #Button_4
  #Button_5
  #Button_6
  #Button_7
  #Button_8
  #Button_9
  #Button_10
  #Button_11
  #Button_12
  #Button_13
  #Button_14
  #Button_15
  
  #BoutonAgenda
  #Agenda
  
  #Image_0
  #Image_1  
  #Text_0
  #Text_1
  #Text_2
  #Text_3
  #Text_4
  #Text_5
  #Text_6
  #Text_7
  #Text_8
  #Text_9
  #Text_10
  #Text_11
  #Text_12
  #Text_13
  #Text_14
  #Text_15
  #Text_16
  #Text_17
  #Text_18
  #Text_19
  #Text_20
  #Text_21
  #Text_22
  #Text_23
  #Text_24
  #Text_25
  #Text_26
  #Text_27
  #Text_28
  #Text_29
  #Text_30
  #Text_31
  #Text_32
  #Text_33
  #Text_34
  #Text_35
  #Text_36
  #Text_37
  #Text_38
  #Text_39
  #Text_40
  #Text_41
  #Text_42
  #Text_43
  #Text_44
  #Text_45
  #Text_46
  #Text_47
  #Text_48
  #Text_49
  #Text_50
  
  #String_0
  #String_1
  #String_2
  #String_3
  #String_4
  #String_5
  #String_6
  #String_7
  #String_8
  #String_9
  #String_10
  #String_11
  #String_12
  #String_13
  #String_14
  #String_15
  #String_16
  #String_17
  #String_18
  #String_19
  #String_20
  #String_21
  #String_22
  #String_23
  #String_24
  #String_25
  #String_26
  #String_27
  #String_28
  #String_29
  #String_30
  #String_31
  #String_32
  #String_33
  #String_34
  #String_35
  #String_36
  #String_37
  #String_38
  #String_39
  #String_40
  #String_41
  #String_42
  #String_43
  #String_44
  #String_45
  #String_46
  #String_47
  #String_48
  #String_49
  #String_50
  
  #CheckBox_0
  #CheckBox_1
  #CheckBox_2
  #CheckBox_3
  #CheckBox_4
  #CheckBox_5
  #CheckBox_6
  #CheckBox_7
  #CheckBox_8
  #CheckBox_9
  #CheckBox_10        
  #CheckBox_11
  #CheckBox_12
  #CheckBox_13
  #CheckBox_14
  #CheckBox_15  
  
  #Element_CheckBox_0
  #Element_CheckBox_1
  #Element_CheckBox_2
  #Element_CheckBox_3
  #Element_CheckBox_4
  #Element_CheckBox_5
  #Element_CheckBox_6
  #Element_CheckBox_7
  #Element_CheckBox_8
  #Element_CheckBox_9
  #Element_CheckBox_10        
  #Element_CheckBox_11
  #Element_CheckBox_12
  #Element_CheckBox_13
  #Element_CheckBox_14
  #Element_CheckBox_15  
  
  #Cadre_1
  
  #FenetreAgenda
  #TextAgenda
  
  #Fond_Dessin
  #Font
  
  #Win0
  #Text0
  
        
  EndEnumeration
  
Global glDBSQLite.l
Global glListviewItemSelected.l = -1
Global glImageMemory.l

Global glImageMemory2.l

Define Etat_CheckBox_0.D
Define Etat_CheckBox_1.D
Define Etat_CheckBox_2.D
Define Etat_CheckBox_3.D
Define Etat_CheckBox_4.D
Define Etat_CheckBox_5.D
Define Etat_CheckBox_6.D
Define Etat_CheckBox_7.D
Define Etat_CheckBox_8.D
Define Etat_CheckBox_9.D
Define Etat_CheckBox_10.D
Define Etat_CheckBox_11.D
Define Etat_CheckBox_12.D
Define Etat_CheckBox_13.D
Define Etat_CheckBox_14.D
Define Etat_CheckBox_15.D


UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()


Procedure DrawSelection(X, Y, x1, y1, Couleur, Eppaisseur, Type)
  For vx = X To x1 Step 4
    Box(vx, y, Eppaisseur, Eppaisseur, Couleur)
    Box(vx, y1, Eppaisseur, Eppaisseur, Couleur)
  Next               
 
  For vy = Y To y1 Step 4
    Box(x, vy, Eppaisseur, Eppaisseur, Couleur)
    Box(x1, vy, Eppaisseur, Eppaisseur, Couleur)
  Next               
EndProcedure

Procedure Cadre(X1, Y1, X2, Y2, Couleur1,Couleur2)
   LineXY(X1, Y1, X2, Y1,Couleur1)
   LineXY(X1, Y1, X1, Y2,Couleur1)
   LineXY(X2, Y1, X2, Y2,Couleur2)
   LineXY(X1, Y2, X2, Y2,Couleur2)
 EndProcedure
 
  Procedure GraphMenu()
         If GlEvent = PB_Event_Repaint
           StartDrawing(WindowOutput(0))  
                    
         ;Box(388,10, 461, 283, RGB(255, 255, 233))
       Cadre(388,10, 850, 293, RGB(0,0,0),RGB(0,0,0))
       
         ;Box(860, 10,  496, 283, RGB(255, 255, 233))
       Cadre(860, 10, 1355, 293, RGB(0,0,0),RGB(0,0,0))
       
         ;Box(860, 300,  496, 408, RGB(255, 255, 233))
       Cadre(860, 300, 1355, 709, RGB(0,0,0),RGB(0,0,0))
       
        ;Box(388, 300,  496, 408, RGB(255, 255, 233))
       Cadre(388, 300, 850, 709, RGB(0,0,0),RGB(0,0,0))
             
         ;BackColor(RGB(255,255,233))
         BackColor(RGB(240,240,240))
         FrontColor(RGB(0,0,0))
         
         DrawText(400,20,"Edition de la Facture Client")
         DrawText(872,20,"Edition du Contrat Modèle")
         DrawText(872,310,"Déroulement de la séance photo")
         DrawText(400,310,"Édition fiche contact")
         
         DrawText(872,100,"Autorisation modes de diffusion")
         
         DrawText(872,200,"Conditions financières")
        
        StopDrawing()
      
    EndIf 
  EndProcedure
 
 Procedure MouseMove(n)
  Repeat
    GetCursorPos_(CursorPos.POINT)
    MouseX = CursorPos\x
    MouseY = CursorPos\y
    If Not MouseX=Mx And MouseY =My
      GraphMenu()
    
    EndIf
    Mx=MouseX
    My=MouseY
    ForEver
 
EndProcedure
                  
Procedure Main_WindowOpen()
  If OpenWindow(#Window_0, 0,0,1360,710, "Notysoft Ordinem - Gestion de Contacts",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_BorderLess | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget )
    
    ListViewGadget(#Listview_0, 10, 300, 374,410)
    
    ButtonGadget(#Button_0, 10,  10, 120,26,"Nouveau")
    ButtonGadget(#Button_1, 10,  36, 120,26,"Enregistrer")
    ButtonGadget(#Button_2, 10,  62, 120,26,"Mettre à jour la base")
    ButtonGadget(#Button_3, 10,  88,120,26,"Supprimer une fiche")
    ButtonGadget(#Button_4, 10,  114,120,26,"Ajouter une photo")
    ButtonGadget(#Button_5, 10,  140,120,26,"Séance photo")
    ButtonGadget(#Button_6, 10,  166,120,26,"Contrat photo")
    ButtonGadget(#Button_7, 10,  192,120,26,"Facture client")
    ButtonGadget(#Button_8, 10,  218,120,26,"Agenda")
    ButtonGadget(#Button_9, 10,  244,120,26,"Calculatrice")
    ButtonGadget(#Button_10,10,  270,120,26,"A Propos")
    
    
    ButtonGadget(#Button_11, 1220,200,120,26,"Ajouter une signature")
    
    ImageGadget(#Image_0, 140, 10, 244, 284, 00, #PB_Image_Border)
    ImageGadget(#Image_1, 1220,230,119,  59, 00, #PB_Image_Border)
    
    ;CalendarGadget(0,10, 497, 374, 195)  
    
    TextGadget(#Text_0 , 400, 50, 100, 20, "N°Client    ")
    TextGadget(#Text_1 , 625, 50, 70, 20, "N°Facture   ")    
    TextGadget(#Text_25, 400,105,200,20, "Désignation prestation(s) ")
    TextGadget(#Text_26, 400,160,50, 20, "Quantité")
    TextGadget(#Text_27, 400, 215, 200, 20, "Commentaire(s) & Recommandation(s)")
    ;TextGadget(#Text_28, 400, 270, 200, 20, "Recommandation(s)")
    TextGadget(#Text_29  , 460,160,80, 20, "Prix unitaire HT")
    TextGadget(#Text_30  , 550,160,100, 20, "Date de règlement")    
    TextGadget(#Text_31  ,660,160,80,50, "Date exécution")
    TextGadget(#Text_32, 740,160,120, 20, "Conditions escompte")
    
   TextGadget(#Text_3,  400, 358, 110, 20, "Prénom      ")
   TextGadget(#Text_4,  400, 388, 110, 20, "Nom         ")
   TextGadget(#Text_5,  400, 418, 110, 20, "Profession  ")
   TextGadget(#Text_6,  400, 448, 110, 20, "Société     ")
   TextGadget(#Text_7,  400, 478, 110, 20, "Adresse 1   ")
   TextGadget(#Text_8,  400, 508, 110, 20, "Adresse 2   ")
   TextGadget(#Text_9,  400, 538, 110, 20, "Adresse 3   ")
   TextGadget(#Text_10, 400, 568, 110, 20, "Code Postal ")
   TextGadget(#Text_11, 400, 598, 110, 20, "Ville       ")
   TextGadget(#Text_12, 400, 628, 110, 20, "Pays        ")
   TextGadget(#Text_13, 400, 658, 110, 20, "Téléphone   ")
   
   TextGadget(#Text_14, 630, 358,110, 20, "Fax         ")
   TextGadget(#Text_15, 630, 388,110, 20, "Mail        ")
   TextGadget(#Text_16, 630, 418,110, 20, "Naissance   ")
   TextGadget(#Text_17, 630, 448,110, 20, "Sexe        ")
   TextGadget(#Text_18, 630, 478,110, 20, "Cheveux     ")
   TextGadget(#Text_19, 630, 508, 110, 20, "Yeux        ")
   TextGadget(#Text_20, 630, 538, 110, 20, "Peau        ")
   TextGadget(#Text_21, 630, 568, 110, 20, "Taille      ")
   TextGadget(#Text_22, 630, 598, 110, 20, "Poids      ")
   TextGadget(#Text_23, 630, 628, 110, 20, "Hanches")
   TextGadget(#Text_24, 630, 658, 110, 20, "Loisir(s)")   
         
   ;TextGadget(#Text_12, 620, 20, 110, 20, "Photo :")
   
   TextGadget(#Text_2,     872,50,100,20,"N°Contrat")
   TextGadget(#Text_34,    982,50,100,20," Date du shooting")
   TextGadget(#Text_35,    1092,50,150,20,"Durée de l'autorisation")
   TextGadget(#Text_33,     1140,170,100,20,"Autre (Préciser)")
   TextGadget(#Text_36,    1252,50,100,20,"Fin de validité")
    StringGadget(#String_0,  400, 70, 215, 20, "")           
    StringGadget(#String_1,  625, 70, 215, 20, "")
    StringGadget(#String_25, 400,125,440,20, "")   
    StringGadget(#String_26, 400,180,50, 20, "")
    StringGadget(#String_29, 460,180,80, 20, "")
    StringGadget(#String_30,550,180,100, 20, "")
    StringGadget(#String_31,658,180,76,20, "")
    StringGadget(#String_32,740,180,100, 20, "")     
    StringGadget(#String_27, 400, 235, 440, 20, "")        
    StringGadget(#String_28, 400, 260, 440, 20, "")
    StringGadget(#String_3,  460, 355, 150, 20, "")    
    StringGadget(#String_4,  460, 385, 150, 20, "")
    StringGadget(#String_5,  460, 415, 150, 20, "")
    StringGadget(#String_6,  460, 445, 150, 20, "")
    StringGadget(#String_7,  460, 475, 150, 20, "")
    StringGadget(#String_8,  460, 505, 150, 20, "")
    StringGadget(#String_9,  460, 535, 150, 20, "")
    StringGadget(#String_10, 460, 565, 150, 20, "")
    StringGadget(#String_11, 460, 595, 150, 20, "")
    StringGadget(#String_12, 460, 625, 150, 20, "")
    StringGadget(#String_13, 460, 655, 150, 20, "")
    StringGadget(#String_14, 690, 355, 150, 20, "")
    StringGadget(#String_15, 690, 385, 150, 20, "")
    StringGadget(#String_16, 690, 415, 150, 20, "")
    StringGadget(#String_17, 690, 445, 150, 20, "")
    StringGadget(#String_18, 690, 475, 150, 20, "")
    StringGadget(#String_19, 690, 505, 150, 20, "")
    StringGadget(#String_20, 690, 535, 150, 20, "")
    StringGadget(#String_21, 690, 565, 150, 20, "")
    StringGadget(#String_22, 690, 595, 150, 20, "")
    StringGadget(#String_23, 690, 625, 150, 20, "")
    StringGadget(#String_24, 690, 655, 150, 20, "")        
    StringGadget(#String_2, 872,70,100,20, "")
    StringGadget(#String_34,982,70,100,20, "")
    StringGadget(#String_35,1092,70,150,20, "")      
    StringGadget(#String_36,1252,70,90,20, "")       
                    
   
    CheckBoxGadget(#Element_CheckBox_0, 876,130,100, 15, "Presse"):SetGadgetState(#Element_CheckBox_0,#CheckBox_0)                 
    CheckBoxGadget(#Element_CheckBox_1, 876,150,100, 15, "Livre"):SetGadgetState(#Element_CheckBox_1,#CheckBox_1)
    CheckBoxGadget(#Element_CheckBox_2, 876,170,100, 15, "Exposition"):SetGadgetState(#Element_CheckBox_2,#CheckBox_2)
        
    CheckBoxGadget(#Element_CheckBox_5, 1060,130,100, 15, "Carte postale"):SetGadgetState(#Element_CheckBox_5,#CheckBox_5)
    CheckBoxGadget(#Element_CheckBox_6, 1060,150,120, 15, "Projection publique"):SetGadgetState(#Element_CheckBox_6,#CheckBox_6)
    CheckBoxGadget(#Element_CheckBox_7, 1060,170,60, 15, "Publicité"):SetGadgetState(#Element_CheckBox_7,#CheckBox_7) 
        
    CheckBoxGadget(#Element_CheckBox_4, 1220,130,130, 15, "Objets de décoration"):SetGadgetState(#Element_CheckBox_4,#CheckBox_4)
    CheckBoxGadget(#Element_CheckBox_3, 1220,150,130, 15, "Publication électronique"):SetGadgetState(#Element_CheckBox_3,#CheckBox_3)
        
    StringGadget(#String_33,1220,170,100,20, "")
    
    CheckBoxGadget(#Element_CheckBox_8,  876,230,300, 15, "Autorisation à titre gratuit"):SetGadgetState(#Element_CheckBox_8,#CheckBox_8)
    CheckBoxGadget(#Element_CheckBox_9,  876,250,290, 15, "Autorisation contre tirage : Pourcentage sur les recettes :"):SetGadgetState(#Element_CheckBox_9,#CheckBox_9)
    
    ;TextGadget(#Text_37  ,1194,251,20,20,"%")
    StringGadget(#String_37,1165,248,24,20,"")
          
      CheckBoxGadget(#Element_CheckBox_10, 876,270,200, 15, "Exposition"):SetGadgetState(#Element_CheckBox_10,#CheckBox_10)   
      
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
  EndIf                      
EndProcedure
Procedure DB_Init()
  Protected plFile.l
  Protected psSQLRequest.s
  UseSQLiteDatabase()
  If FileSize(#PB_Compiler_FilePath+"Ordinem.sqlite") < 0
    plFile = CreateFile(#PB_Any, #PB_Compiler_FilePath+"Ordinem.sqlite")
    If plFile
      CloseFile(plFile)
    EndIf
  EndIf
 
  glDBSQLite = OpenDatabase(#PB_Any, #PB_Compiler_FilePath+"Ordinem.sqlite", "", "", #PB_Database_SQLite)
  If glDBSQLite = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts", DatabaseError())
    End
  ElseIf plFile
    psSQLRequest = "CREATE TABLE IF NOT EXISTS contacts ("
    psSQLRequest + "id_contact INTEGER PRIMARY KEY AUTOINCREMENT Not NULL, "
    psSQLRequest + "contact_Numero_Client TEXT, "
    psSQLRequest + "contact_Numero_Facture TEXT, "
    psSQLRequest + "contact_Numero_Contrat TEXT, "
    psSQLRequest + "contact_prenom TEXT Not NULL, "
    psSQLRequest + "contact_nom TEXT Not NULL, "
    psSQLRequest + "contact_job TEXT, "
    psSQLRequest + "contact_company TEXT, "
    psSQLRequest + "contact_address_1 TEXT, "
    psSQLRequest + "contact_address_2 TEXT, "
    psSQLRequest + "contact_address_3 TEXT, "
    psSQLRequest + "contact_postalcode TEXT, "
    psSQLRequest + "contact_city TEXT, "
    psSQLRequest + "contact_country TEXT, "
    psSQLRequest + "contact_phone TEXT, "
    psSQLRequest + "contact_fax TEXT, "
    psSQLRequest + "contact_mail TEXT, "
    psSQLRequest + "contact_date_de_naissance TEXT, "
    psSQLRequest + "contact_sexe TEXT, "
    psSQLRequest + "contact_cheveux TEXT, "
    psSQLRequest + "contact_yeux TEXT, "
    psSQLRequest + "contact_peau TEXT, "
    psSQLRequest + "contact_taille TEXT, "
    psSQLRequest + "contact_poids TEXT, "
    psSQLRequest + "contact_hanches TEXT, "
    psSQLRequest + "contact_loisir TEXT, "
    psSQLRequest + "contact_prestation TEXT, "
    psSQLRequest + "facture_quantite TEXT, "
    psSQLRequest + "facture_commentaires TEXT,"
    psSQLRequest + "facture_recommandations TEXT, "
    psSQLRequest + "facture_prix_uht TEXT, "
    psSQLRequest + "facture_date_reglement TEXT, "
    psSQLRequest + "facture_date_exécution TEXT, "
    psSQLRequest + "facture_conditions_escompte TEXT, " 
    psSQLRequest + "contrat_shooting TEXT, "
    psSQLRequest + "contrat_autorisation TEXT, "   
    psSQLRequest + "contrat_fin_validite TEXT, " 
    psSQLRequest + "contrat_autres TEXT, "
    psSQLRequest + "Etat_CheckBox_0 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_1 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_2 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_3 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_4 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_5 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_6 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_7 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_8 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_9 BOOLEAN, "
    psSQLRequest + "Etat_CheckBox_10 BOOLEAN, "
    psSQLRequest + "contact_photo BLOB, "
    psSQLRequest + "contact_photo_s BLOB, "
    psSQLRequest + "contact_photo_size INTEGER,"
    psSQLRequest + "contact_photo_s_size INTEGER"
    psSQLRequest + ")"
    ; Debug psSQLRequest
    If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
      MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_Init()", DatabaseError())
    EndIf
  EndIf
 
  If DatabaseQuery(glDBSQLite, "SELECT * FROM contacts") <> 0
    While NextDatabaseRow(glDBSQLite)    
    AddGadgetItem(#Listview_0, CountGadgetItems(#Listview_0), "Facture N°" +GetDatabaseString(glDBSQLite, 2) + " " +GetDatabaseString(glDBSQLite, 4) + " " + GetDatabaseString(glDBSQLite, 5) + " " + GetDatabaseString(glDBSQLite, 6))
    SetGadgetItemData(#Listview_0, CountGadgetItems(#Listview_0)-1, GetDatabaseLong(glDBSQLite, 0))
    Wend
    FinishDatabaseQuery(glDBSQLite)
  EndIf
EndProcedure

Procedure DB_InsertContact()
  Protected psSQLRequest.s
  psSQLRequest = "INSERT INTO contacts"
  psSQLRequest + "(contact_Numero_Client,contact_Numero_Facture,contact_Numero_Contrat,contact_prenom, contact_nom, contact_job, contact_company, contact_address_1,contact_address_2,contact_address_3,"
  psSQLRequest + "contact_postalcode, contact_city, contact_country, contact_phone, contact_fax, contact_mail, contact_date_de_naissance,contact_sexe, contact_cheveux,contact_yeux,contact_peau,"
  psSQLRequest + "contact_taille,contact_poids,contact_hanches,contact_loisir,contact_prestation,facture_quantite,facture_commentaires,facture_recommandations,facture_prix_uht,"
  psSQLRequest + "facture_date_reglement,facture_date_exécution,facture_conditions_escompte,contrat_shooting,contrat_autorisation,contrat_fin_validite,contrat_autres,Etat_CheckBox_0,"
  psSQLRequest + "Etat_CheckBox_1,Etat_CheckBox_2,Etat_CheckBox_3,Etat_CheckBox_4,Etat_CheckBox_5,Etat_CheckBox_6,Etat_CheckBox_7,Etat_CheckBox_8,Etat_CheckBox_9,Etat_CheckBox_10,"
  psSQLRequest + "contact_photo,contact_photo_s,contact_photo_size,contact_photo_s_size)"
  psSQLRequest + "VALUES ("
  psSQLRequest + "'"+GetGadgetText(#String_0)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_1)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_2)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_3)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_4)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_5)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_6)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_7)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_8)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_9)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_10)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_11)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_12)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_13)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_14)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_15)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_16)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_17)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_18)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_19)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_20)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_21)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_22)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_23)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_24)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_25)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_26)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_27)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_28)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_29)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_30)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_31)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_32)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_33)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_34)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_35)+"',"
  psSQLRequest + "'"+GetGadgetText(#String_36)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_0)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_1)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_2)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_3)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_4)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_5)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_6)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_7)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_8)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_9)+"',"
  psSQLRequest + "'"+GetGadgetState(#CheckBox_10)+"',"
  psSQLRequest + "?,"
  psSQLRequest + "?,"
  
   If glImageMemory
    psSQLRequest + Str(MemorySize(glImageMemory)) + ","
  Else
    psSQLRequest + "0" + ","
  EndIf
  
  If glImageMemory2
    psSQLRequest + Str(MemorySize(glImageMemory2))
  Else
    psSQLRequest + "1"
  EndIf
    
  psSQLRequest + ")"
  
  ;Debug psSQLRequest
  
  If glImageMemory
    SetDatabaseBlob(glDBSQLite, 0, glImageMemory, MemorySize(glImageMemory))  
  Else
    ReplaceString(psSQLRequest, "?", "'0'")  
  EndIf  
  
  If glImageMemory2    
    SetDatabaseBlob(glDBSQLite, 1, glImageMemory2, MemorySize(glImageMemory2))
  Else  
    ReplaceString(psSQLRequest, "?", "'1'")
  EndIf  
  
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_InsertContact()", DatabaseError())
  EndIf
   
  ; Ajoute le dernier element ajouté à la base
  If DatabaseQuery(glDBSQLite, "SELECT max(id_contact), contact_Numero_Facture,contact_prenom, contact_nom,contact_job FROM contacts") <> 0    
    While NextDatabaseRow(glDBSQLite)
      
      AddGadgetItem(#Listview_0, CountGadgetItems(#Listview_0), "Facture N°" +GetDatabaseString(glDBSQLite, 2) + " " +GetDatabaseString(glDBSQLite, 4) + " " + GetDatabaseString(glDBSQLite, 5) + " " + GetDatabaseString(glDBSQLite, 6))
      SetGadgetItemData(#Listview_0, CountGadgetItems(#Listview_0)-1, GetDatabaseLong(glDBSQLite, 0))
    Wend
    FinishDatabaseQuery(glDBSQLite)
  Else
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_InsertContact", DatabaseError())
  EndIf
EndProcedure

Procedure DB_SelectContact(GadgetItem.l)
  Protected psSQLRequest.s
  Protected plFileImageSize.l
  Protected plFileImage.l
  
  Protected plFileImageSize2.l
  Protected plFileImage2.l
    
  psSQLRequest = "SELECT * FROM contacts WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  If DatabaseQuery(glDBSQLite, psSQLRequest) <> 0
    While NextDatabaseRow(glDBSQLite)
      SetGadgetText(#String_0, GetDatabaseString(glDBSQLite, 1))
      SetGadgetText(#String_1, GetDatabaseString(glDBSQLite, 2))
      SetGadgetText(#String_2, GetDatabaseString(glDBSQLite, 3))
      SetGadgetText(#String_3, GetDatabaseString(glDBSQLite, 4))
      SetGadgetText(#String_4, GetDatabaseString(glDBSQLite, 5))
      SetGadgetText(#String_5, GetDatabaseString(glDBSQLite, 6))
      SetGadgetText(#String_6, GetDatabaseString(glDBSQLite, 7))
      SetGadgetText(#String_7, GetDatabaseString(glDBSQLite, 8))
      SetGadgetText(#String_8, GetDatabaseString(glDBSQLite, 9))
      SetGadgetText(#String_9, GetDatabaseString(glDBSQLite, 10))
      SetGadgetText(#String_10,GetDatabaseString(glDBSQLite, 11))
      SetGadgetText(#String_11,GetDatabaseString(glDBSQLite, 12))
      SetGadgetText(#String_12,GetDatabaseString(glDBSQLite, 13))
      SetGadgetText(#String_13,GetDatabaseString(glDBSQLite, 14))
      SetGadgetText(#String_14,GetDatabaseString(glDBSQLite, 15))
      SetGadgetText(#String_15,GetDatabaseString(glDBSQLite, 16))
      SetGadgetText(#String_16,GetDatabaseString(glDBSQLite, 17))
      SetGadgetText(#String_17,GetDatabaseString(glDBSQLite, 18))
      SetGadgetText(#String_18,GetDatabaseString(glDBSQLite, 19))
      SetGadgetText(#String_19,GetDatabaseString(glDBSQLite, 20))
      SetGadgetText(#String_20,GetDatabaseString(glDBSQLite, 21))   
      SetGadgetText(#String_21,GetDatabaseString(glDBSQLite, 22))   
      SetGadgetText(#String_22,GetDatabaseString(glDBSQLite, 23))   
      SetGadgetText(#String_23,GetDatabaseString(glDBSQLite, 24))   
      SetGadgetText(#String_24,GetDatabaseString(glDBSQLite, 25))   
      SetGadgetText(#String_25,GetDatabaseString(glDBSQLite, 26))   
      SetGadgetText(#String_26,GetDatabaseString(glDBSQLite, 27))   
      SetGadgetText(#String_27,GetDatabaseString(glDBSQLite, 28))   
      SetGadgetText(#String_28,GetDatabaseString(glDBSQLite, 29))   
      SetGadgetText(#String_29,GetDatabaseString(glDBSQLite, 30))   
      SetGadgetText(#String_30,GetDatabaseString(glDBSQLite, 31))   
      SetGadgetText(#String_31,GetDatabaseString(glDBSQLite, 32))  
      SetGadgetText(#String_32,GetDatabaseString(glDBSQLite, 33))  
      SetGadgetText(#String_33,GetDatabaseString(glDBSQLite, 34))   
      SetGadgetText(#String_34,GetDatabaseString(glDBSQLite, 35))   
      SetGadgetText(#String_35,GetDatabaseString(glDBSQLite, 36))  
      SetGadgetText(#String_36,GetDatabaseString(glDBSQLite, 37))  
      
    CheckBoxGadget(#Element_CheckBox_0, 876,130,100, 15, "Presse"):SetGadgetState(#Element_CheckBox_0,GetDatabaseFloat(glDBSQLite, 38))                 
    CheckBoxGadget(#Element_CheckBox_1, 876,150,100, 15, "Livre"):SetGadgetState(#Element_CheckBox_1,GetDatabaseFloat(glDBSQLite, 39))
    CheckBoxGadget(#Element_CheckBox_2, 876,170,100, 15, "Exposition"):SetGadgetState(#Element_CheckBox_2,GetDatabaseFloat(glDBSQLite, 40))
    CheckBoxGadget(#Element_CheckBox_3, 1060,130,100, 15, "Carte postale"):SetGadgetState(#Element_CheckBox_3, GetDatabaseFloat(glDBSQLite, 41))
    CheckBoxGadget(#Element_CheckBox_4, 1060,150,120, 15, "Projection publique"):SetGadgetState(#Element_CheckBox_4,GetDatabaseFloat(glDBSQLite, 42))
    CheckBoxGadget(#Element_CheckBox_5, 1060,170,60, 15, "Publicité"):SetGadgetState(#Element_CheckBox_5,GetDatabaseFloat(glDBSQLite, 43)) 
    CheckBoxGadget(#Element_CheckBox_6, 1220,130,130, 15, "Objets de décoration"):SetGadgetState(#Element_CheckBox_6,GetDatabaseFloat(glDBSQLite, 44))
    CheckBoxGadget(#Element_CheckBox_7, 1220,150,130, 15, "Publication électronique"):SetGadgetState(#Element_CheckBox_7,GetDatabaseFloat(glDBSQLite, 45))
    CheckBoxGadget(#Element_CheckBox_8,  876,230,300, 15, "Autorisation à titre gratuit"):SetGadgetState(#Element_CheckBox_8,GetDatabaseFloat(glDBSQLite, 46))
    CheckBoxGadget(#Element_CheckBox_9,  876,250,290, 15, "Autorisation contre tirage : Pourcentage sur les recettes :"):SetGadgetState(#Element_CheckBox_9,GetDatabaseFloat(glDBSQLite, 47))
    CheckBoxGadget(#Element_CheckBox_10, 876,270,200, 15, "Exposition"):SetGadgetState(#Element_CheckBox_10,GetDatabaseFloat(glDBSQLite,48))   
      
      plFileImageSize = GetDatabaseLong(glDBSQLite, 51)
      If plFileImageSize > 0
        glImageMemory = AllocateMemory(plFileImageSize)
        GetDatabaseBlob(glDBSQLite, 49, glImageMemory, plFileImageSize)
        plFileImage = CatchImage(#PB_Any, glImageMemory, plFileImageSize)
        If plFileImage
          ResizeImage(plFileImage, 240, 283)
          SetGadgetState(#Image_0, ImageID(plFileImage))
          FreeImage(plFileImage)
        EndIf
      Else
        SetGadgetState(#Image_0, 0)
      EndIf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      plFileImageSize2 = GetDatabaseLong(glDBSQLite, 52)
      If plFileImageSize2 > 0
        glImageMemory2 = AllocateMemory(plFileImageSize2)
        GetDatabaseBlob(glDBSQLite, 50, glImageMemory2, plFileImageSize2)
        plFileImage2 = CatchImage(#PB_Any, glImageMemory2, plFileImageSize2)
        If plFileImage2
          ResizeImage(plFileImage2, 116, 55)          
          SetGadgetState(#Image_1, ImageID(plFileImage2))
          FreeImage(plFileImage2)
        EndIf
      Else
        SetGadgetState(#Image_1, 0)
      EndIf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    Wend
    FinishDatabaseQuery(glDBSQLite)
  Else
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_SelectContact", DatabaseError())
  EndIf
EndProcedure

Procedure DB_UpdateContact(GadgetItem.l)
  Protected psSQLRequest.s
  psSQLRequest = "UPDATE contacts SET "
  psSQLRequest + "contact_Numero_Client='"       +GetGadgetText(#String_0)+"', "
  psSQLRequest + "contact_Numero_Facture='"      +GetGadgetText(#String_1)+"', "
  psSQLRequest + "contact_Numero_Contrat='"      +GetGadgetText(#String_2)+"', "
  psSQLRequest + "contact_prenom='"              +GetGadgetText(#String_3)+"', "
  psSQLRequest + "contact_nom='"                 +GetGadgetText(#String_4)+"', "
  psSQLRequest + "contact_job='"                 +GetGadgetText(#String_5)+"', "
  psSQLRequest + "contact_company='"             +GetGadgetText(#String_6)+"', "
  psSQLRequest + "contact_address_1='"           +GetGadgetText(#String_7)+"', "
  psSQLRequest + "contact_address_2='"           +GetGadgetText(#String_8)+"', "
  psSQLRequest + "contact_address_3='"           +GetGadgetText(#String_9)+"', "
  psSQLRequest + "contact_postalcode='"          +GetGadgetText(#String_10)+"', "
  psSQLRequest + "contact_city='"                +GetGadgetText(#String_11)+"', "
  psSQLRequest + "contact_country='"             +GetGadgetText(#String_12)+"', "
  psSQLRequest + "contact_phone='"               +GetGadgetText(#String_13)+"', "
  psSQLRequest + "contact_fax='"                 +GetGadgetText(#String_14)+"', "
  psSQLRequest + "contact_mail='"                +GetGadgetText(#String_15)+"', "
  psSQLRequest + "contact_date_de_naissance='"   +GetGadgetText(#String_16)+"', "
  psSQLRequest + "contact_sexe='"                +GetGadgetText(#String_17)+"', "
  psSQLRequest + "contact_cheveux='"             +GetGadgetText(#String_18)+"',"
  psSQLRequest + "contact_yeux='"                +GetGadgetText(#String_19)+"',"
  psSQLRequest + "contact_peau='"                +GetGadgetText(#String_20)+"',"
  psSQLRequest + "contact_taille='"              +GetGadgetText(#String_21)+"',"
  psSQLRequest + "contact_poids='"               +GetGadgetText(#String_22)+"',"
  psSQLRequest + "contact_hanches='"             +GetGadgetText(#String_23)+"',"
  psSQLRequest + "contact_loisir='"              +GetGadgetText(#String_24)+"',"
  psSQLRequest + "contact_prestation='"          +GetGadgetText(#String_25)+"',"
  psSQLRequest + "facture_quantite='"            +GetGadgetText(#String_26)+"',"
  psSQLRequest + "facture_commentaires='"        +GetGadgetText(#String_27)+"',"
  psSQLRequest + "facture_recommandations='"     +GetGadgetText(#String_28)+"',"
  psSQLRequest + "facture_prix_uht='"            +GetGadgetText(#String_29)+"',"
  psSQLRequest + "facture_date_reglement='"      +GetGadgetText(#String_30)+"',"
  psSQLRequest + "facture_date_exécution='"      +GetGadgetText(#String_31)+"',"
  psSQLRequest + "facture_conditions_escompte='" +GetGadgetText(#String_32)+"'," 
  psSQLRequest + "contrat_shooting='"            +GetGadgetText(#String_33)+"'," 
  psSQLRequest + "contrat_autorisation='"        +GetGadgetText(#String_34)+"'," 
  psSQLRequest + "contrat_fin_validite='"        +GetGadgetText(#String_35)+"'," 
  psSQLRequest + "contrat_autres='"              +GetGadgetText(#String_36)+"'," 
  psSQLRequest + "Etat_CheckBox_0='"             +GetGadgetState(#CheckBox_0)+"'," 
  psSQLRequest + "Etat_CheckBox_1='"             +GetGadgetState(#CheckBox_1)+"'," 
  psSQLRequest + "Etat_CheckBox_2='"             +GetGadgetState(#CheckBox_2)+"'," 
  psSQLRequest + "Etat_CheckBox_3='"             +GetGadgetState(#CheckBox_3)+"'," 
  psSQLRequest + "Etat_CheckBox_4='"             +GetGadgetState(#CheckBox_4)+"'," 
  psSQLRequest + "Etat_CheckBox_5='"             +GetGadgetState(#CheckBox_5)+"'," 
  psSQLRequest + "Etat_CheckBox_6='"             +GetGadgetState(#CheckBox_6)+"',"   
  psSQLRequest + "Etat_CheckBox_7='"             +GetGadgetState(#CheckBox_7)+"',"   
  psSQLRequest + "Etat_CheckBox_8='"             +GetGadgetState(#CheckBox_8)+"'," 
  psSQLRequest + "Etat_CheckBox_9='"             +GetGadgetState(#CheckBox_9)+"',"   
  psSQLRequest + "Etat_CheckBox_10='"            +GetGadgetState(#CheckBox_10)+"',"   
  psSQLRequest + "contact_photo = ?," 
  psSQLRequest + "contact_photo_s = ?," 
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    CheckBoxGadget(#Element_CheckBox_0, 876,130,100, 15, "Presse"):SetGadgetState(#Element_CheckBox_0,GetDatabaseFloat(glDBSQLite, 38))                 
    CheckBoxGadget(#Element_CheckBox_1, 876,150,100, 15, "Livre"):SetGadgetState(#Element_CheckBox_1,GetDatabaseFloat(glDBSQLite, 39))
    CheckBoxGadget(#Element_CheckBox_2, 876,170,100, 15, "Exposition"):SetGadgetState(#Element_CheckBox_2,GetDatabaseFloat(glDBSQLite, 40))
    CheckBoxGadget(#Element_CheckBox_3, 1060,130,100, 15, "Carte postale"):SetGadgetState(#Element_CheckBox_3, GetDatabaseFloat(glDBSQLite, 41))
    CheckBoxGadget(#Element_CheckBox_4, 1060,150,120, 15, "Projection publique"):SetGadgetState(#Element_CheckBox_4,GetDatabaseFloat(glDBSQLite, 42))
    CheckBoxGadget(#Element_CheckBox_5, 1060,170,60, 15, "Publicité"):SetGadgetState(#Element_CheckBox_5,GetDatabaseFloat(glDBSQLite, 43)) 
    CheckBoxGadget(#Element_CheckBox_6, 1220,130,130, 15, "Objets de décoration"):SetGadgetState(#Element_CheckBox_6,GetDatabaseFloat(glDBSQLite, 44))
    CheckBoxGadget(#Element_CheckBox_7, 1220,150,130, 15, "Publication électronique"):SetGadgetState(#Element_CheckBox_7,GetDatabaseFloat(glDBSQLite, 45))
    CheckBoxGadget(#Element_CheckBox_8,  876,230,300, 15, "Autorisation à titre gratuit"):SetGadgetState(#Element_CheckBox_8,GetDatabaseFloat(glDBSQLite, 46))
    CheckBoxGadget(#Element_CheckBox_9,  876,250,290, 15, "Autorisation contre tirage : Pourcentage sur les recettes :"):SetGadgetState(#Element_CheckBox_9,GetDatabaseFloat(glDBSQLite, 47))
    CheckBoxGadget(#Element_CheckBox_10, 876,270,200, 15, "Exposition"):SetGadgetState(#Element_CheckBox_10,GetDatabaseFloat(glDBSQLite,48))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   If glImageMemory
    psSQLRequest + "contact_photo_size = " + Str(MemorySize(glImageMemory)) + ","
  Else
    psSQLRequest + "contact_photo_size = 0" + ","
  EndIf
  
   If glImageMemory2
    psSQLRequest + "contact_photo_s_size = " + Str(MemorySize(glImageMemory2))
  Else
    psSQLRequest + "contact_photo_s_size = 1"
  EndIf
  
  psSQLRequest + " WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  
  If glImageMemory
    SetDatabaseBlob(glDBSQLite, 0, glImageMemory, MemorySize(glImageMemory))
  Else
    ReplaceString(psSQLRequest, "?", "'0'")
  EndIf
  
  If glImageMemory2
    SetDatabaseBlob(glDBSQLite, 1, glImageMemory2, MemorySize(glImageMemory2))
  Else
    ReplaceString(psSQLRequest, "?", "'1'")
  EndIf 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_UpdateContact()", DatabaseError())
  Else
    SetGadgetItemText(#Listview_0, GadgetItem, "Facture N°"+" "+GetGadgetText(#String_2)+" "+GetGadgetText(#String_3)+" "+GetGadgetText(#String_4)+" "+GetGadgetText(#String_5))    
    EndIf
EndProcedure                                          

Procedure DB_DeleteContact(GadgetItem.l)
  Protected psSQLRequest.s
  psSQLRequest = "DELETE FROM contacts WHERE id_contact="+Str(GetGadgetItemData(#Listview_0, GadgetItem))
  ;Debug psSQLRequest
  If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
    MessageRequester("Notysoft Ordinem - Gestion de Contacts - DB_DeleteContact()", DatabaseError())
  Else
    RemoveGadgetItem(#Listview_0, GadgetItem)
  EndIf
EndProcedure

Procedure ExecCalc()
  ;Compilateur = RunProgram(#PB_Compiler_Home+"/Compilers/pbcompiler", "/?", "", #PB_Program_Open | #PB_Program_Read)
  LanceCalc = RunProgram("C:\Windows\System32\calc.exe","", "", #PB_Program_Open | #PB_Program_Read)
  Sortie$ = ""
  If LanceCalc 
    While ProgramRunning(LanceCalc)
      If AvailableProgramOutput(LanceCalc)
        Sortie$ + ReadProgramString(LanceCalc) + Chr(13)
      EndIf
    Wend
    Sortie$ + Chr(13) + Chr(13)
    Sortie$ + "Code de retour : " + Str(ProgramExitCode(LanceCalc))
    
    CloseProgram(LanceCalc) ; Ferme la connection vers le programme
  EndIf
  ;MessageRequester("Sortie", Sortie$)
  
EndProcedure

  Procedure OpenAgenda()
    If OpenWindow(#FenetreAgenda,153,50,220,220, "Agenda", #PB_Window_BorderLess, WindowID(#Window_0))
         CalendarGadget(#Agenda,0,0,220, 190)
         ButtonGadget(#BoutonAgenda,0,192,220,26, "Ok")
      EndIf
    EndProcedure
    
Main_WindowOpen()
DB_Init()

;CreateGadgetList(WindowID(0))
;GraphMenu()
CreateThread(@MouseMove(),0)

Repeat
     
  glEvent = WaitWindowEvent()
  glGadget= EventGadget()
  glType = EventType() 
  
  
 ;*****************************
    
    Etat_CheckBox_0 = GetGadgetState(#CheckBox_0)
    Etat_CheckBox_1 = GetGadgetState(#CheckBox_1)
    tat_CheckBox_2 =  GetGadgetState(#CheckBox_2)
    Etat_CheckBox_3 = GetGadgetState(#CheckBox_3)
    Etat_CheckBox_4 = GetGadgetState(#CheckBox_4)
    Etat_CheckBox_5 = GetGadgetState(#CheckBox_5)
    Etat_CheckBox_6 = GetGadgetState(#CheckBox_6)
    Etat_CheckBox_7 = GetGadgetState(#CheckBox_7)   
    Etat_CheckBox_8 = GetGadgetState(#CheckBox_8)
    Etat_CheckBox_9 = GetGadgetState(#CheckBox_9)
    Etat_CheckBox_10 = GetGadgetState(#CheckBox_10)
    
     ;*****************************

    If glEvent = #PB_Event_Gadget
    Select glGadget  
        
    Case #CheckBox_0 
      If #CheckBox_0 = 1 
      Etat_CheckBox_0 = #CheckBox_0
       Else 
      Etat_CheckBox_0 = 0
     EndIf
    
    Case #CheckBox_1 
      If #CheckBox_1 = 1 
      Etat_CheckBox_1 = #CheckBox_1
      Else 
      Etat_CheckBox_1 = 0
     EndIf
     
    Case #CheckBox_2 
      If #CheckBox_2 = 1 
      Etat_CheckBox_2 = #CheckBox_2
       Else 
     Etat_CheckBox_2 = 0
     EndIf
    
    Case #CheckBox_3 
      If #CheckBox_3 = 1 
      Etat_CheckBox_3 = #CheckBox_3
       Else 
      Etat_CheckBox_3 = 0
    EndIf
    
    Case #CheckBox_4 
      If #CheckBox_4 = 1 
      Etat_CheckBox_4 = #CheckBox_4
       Else 
      Etat_CheckBox_4 = 0
     EndIf
    
    Case #CheckBox_5 
      If #CheckBox_5 = 1 
      Etat_CheckBox_5 = #CheckBox_5
       Else 
     Etat_CheckBox_5 = 0
    EndIf
    
    Case #CheckBox_6 
    If #CheckBox_6 = 1 
    Etat_CheckBox_6 = #CheckBox_6
    Else 
    Etat_CheckBox_6 = 0
   EndIf
    
    Case #CheckBox_7 
     If #CheckBox_7 = #CheckBox_7
     Etat_CheckBox_7 = 1
      Else 
     Etat_CheckBox_7 = 0
    EndIf
     
   Case #Listview_0 ;{
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)
          If GetGadgetState(#Listview_0) <> glListviewItemSelected
            glListviewItemSelected = GetGadgetState(#Listview_0)
            DB_SelectContact(GetGadgetState(#Listview_0))
          EndIf
        EndIf
      ;}
        
      Case #Button_0 ;{ Nouveau
        If glType = #PB_EventType_LeftClick
          Define.l dlInc                     
            
          For dlInc = #String_0 To #CheckBox_10
            SetGadgetText(dlInc,"")
          Next
          SetGadgetState(#Image_0, 0)
          If glImageMemory
            FreeMemory(glImageMemory)
            glImageMemory = 0
          EndIf
          SetGadgetState(#Image_1, 0)
          If glImageMemory2
            FreeMemory(glImageMemory2)
            glImageMemory2 = 0
          EndIf
          glListviewItemSelected = -1
          EndIf          
          ;}

      Case #Button_1 ;{Enregistrer
       ;If GetGadgetText(#String_0) <> "" And GetGadgetText(#String_1) <> ""
       If GetGadgetText(#String_2) <> "" And GetGadgetText(#String_3) <> "" And GetGadgetText(#String_4) <> "" And GetGadgetText(#String_5) <> ""
          ;If glType = #PB_EventType_LeftClick
            DB_InsertContact()
          EndIf
        ;EndIf
      ;}
      Case #Button_2 ;{ Mettre à jour
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
          If glType = #PB_EventType_LeftClick
            DB_UpdateContact(GetGadgetState(#Listview_0))
            ;Main_WindowOpen()
            ;DB_Init()
            MessageRequester("Notysoft Ordinem - Gestion de Contacts - ","Vos contacts sont à jour !",64)
            EndIf
        EndIf
      ;}
      Case #Button_3 ;{ Supprimer
        If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
          If glType = #PB_EventType_LeftClick
            If MessageRequester("Notysoft Ordinem - Gestion de Contacts", "Voulez vous vraiment supprimer le contact courant "+Chr(34)+GetGadgetItemText(#Listview_0, GetGadgetState(#Listview_0))+Chr(34)+" ?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
              DB_DeleteContact(GetGadgetState(#Listview_0))
            EndIf
          EndIf
        EndIf
      ;}
      Case #Button_4 ;{ Parcourir
        Define.s psFileImage
        Define.l plFileImage
        ; Ouvre une boîte de dialogue standard pour choisir une image
        psFileImage = OpenFileRequester("Choisissez une image à charger", "", "Fichiers Images|*.png;*.bmp;*.jpg;*.jpeg|Tous les fichiers (*.*)|*.*", 0)
        If psFileImage
          ; Charge une image
          plFileImage = LoadImage(#PB_Any, psFileImage)
          If plFileImage
            ; Redimensionne l'image à la taille de l'ImageGadget
            ResizeImage(plFileImage, 240, 283)
            ; Change l'image affichée par l' ImageGadget
            SetGadgetState(#Image_0, ImageID(plFileImage))
            ; Libère l'image
            FreeImage(plFileImage)
            ; Charge l'image dans la zone mémoire globale dédiée 'glImageMemory'
            plFileImage = OpenFile(#PB_Any, psFileImage)
            If plFileImage
              glImageMemory = AllocateMemory(Lof(plFileImage))
              If glImageMemory
                ReadData(plFileImage, glImageMemory, Lof(plFileImage))
              EndIf
              CloseFile(plFileImage)
            EndIf
          EndIf
        EndIf
        ;}
        
    Case #Button_8 ;{ Lance l'Agenda
           OpenAgenda()
     
                           
    Case #Button_9 ;{ Lance la calculatrice
    ExecCalc()    
                
      Case #Button_10 ;{ A_Propos
        MessageRequester("A Propos","Notysoft Ordinem - 2016 - 2017                                                                  Créer simplement sa base de données modèles et photographes.",64)
        
        Case #Button_11 ;{ Parcourir Signiature
        Define.s psFileImage2
        Define.l plFileImage2
        ;Ouvre une boîte de dialogue standard pour choisir une image
        psFileImage2 = OpenFileRequester("Choisissez une image à charger", "", "Fichiers Images|*.png;*.bmp;*.jpg;*.jpeg|Tous les fichiers (*.*)|*.*", 0)
        If psFileImage2
          ;Charge une image
          plFileImage2 = LoadImage(#PB_Any, psFileImage2)
          If plFileImage2
            ;Redimensionne l'image à la taille de l'ImageGadget
            ResizeImage(plFileImage2, 116, 55)
            ;Change l'image affichée par l' ImageGadget
            SetGadgetState(#Image_1 , ImageID(plFileImage2))
            ;Libère l'image
            FreeImage(plFileImage2)
           ;Charge l'image dans la zone mémoire globale dédiée 'glImageMemory'
            plFileImage2 = OpenFile(#PB_Any, psFileImage2)
            If plFileImage2
              glImageMemory2 = AllocateMemory(Lof(plFileImage2))
              If glImageMemory2
               ReadData(plFileImage2, glImageMemory2, Lof(plFileImage2))
              EndIf
              CloseFile(plFileImage2)
            EndIf
          EndIf
        EndIf
        ;}
        
      Case #BoutonAgenda
       CloseWindow(#FenetreAgenda)
   
EndSelect
EndIf

Until glEvent = #PB_Event_CloseWindow

End
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

PB 5.51 (x86)

Ton dernier code génère une erreur au lancement .
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

■ Chaque fois que tu insères ou met à jour un client tu affiches à nouveau les gadgets. Exemple avec ce code dans ta procedure DB_UpdateContact(GadgetItem.l)

Code : Tout sélectionner

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  CheckBoxGadget(#Element_CheckBox_0, 876,130,100, 15, "Presse"):SetGadgetState(#Element_CheckBox_0,GetDatabaseFloat(glDBSQLite, 38))                 
  CheckBoxGadget(#Element_CheckBox_1, 876,150,100, 15, "Livre"):SetGadgetState(#Element_CheckBox_1,GetDatabaseFloat(glDBSQLite, 39))
  CheckBoxGadget(#Element_CheckBox_2, 876,170,100, 15, "Exposition"):SetGadgetState(#Element_CheckBox_2,GetDatabaseFloat(glDBSQLite, 40))
  CheckBoxGadget(#Element_CheckBox_3, 1060,130,100, 15, "Carte postale"):SetGadgetState(#Element_CheckBox_3, GetDatabaseFloat(glDBSQLite, 41))
  CheckBoxGadget(#Element_CheckBox_4, 1060,150,120, 15, "Projection publique"):SetGadgetState(#Element_CheckBox_4,GetDatabaseFloat(glDBSQLite, 42))
  CheckBoxGadget(#Element_CheckBox_5, 1060,170,60, 15, "Publicité"):SetGadgetState(#Element_CheckBox_5,GetDatabaseFloat(glDBSQLite, 43)) 
  CheckBoxGadget(#Element_CheckBox_6, 1220,130,130, 15, "Objets de décoration"):SetGadgetState(#Element_CheckBox_6,GetDatabaseFloat(glDBSQLite, 44))
  CheckBoxGadget(#Element_CheckBox_7, 1220,150,130, 15, "Publication électronique"):SetGadgetState(#Element_CheckBox_7,GetDatabaseFloat(glDBSQLite, 45))
  CheckBoxGadget(#Element_CheckBox_8,  876,230,300, 15, "Autorisation à titre gratuit"):SetGadgetState(#Element_CheckBox_8,GetDatabaseFloat(glDBSQLite, 46))
  CheckBoxGadget(#Element_CheckBox_9,  876,250,290, 15, "Autorisation contre tirage : Pourcentage sur les recettes :"):SetGadgetState(#Element_CheckBox_9,GetDatabaseFloat(glDBSQLite, 47))
  CheckBoxGadget(#Element_CheckBox_10, 876,270,200, 15, "Exposition"):SetGadgetState(#Element_CheckBox_10,GetDatabaseFloat(glDBSQLite,48))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
Code que tu dupliques aussi dans ta procédure d'insertion.

Il est inutile d'afficher les gadgets et de remettre les valeurs que tu viens de sauvegarder dans ta base de données.

■ Le thread sert à quoi ?

■ Lors de la création de ta fenetre tu affiches tes 16 CheckBoxGadget() que tu assignes à une valeur de cette maniere

Code : Tout sélectionner

CheckBoxGadget(#Element_CheckBox_0, 876,130,100, 15, "Presse") : SetGadgetState(#Element_CheckBox_0,#CheckBox_0)
Le SetGadgetState ne sert à rien car chacune de tes valeurs #CheckBox_0 à #CheckBox_15 sont initialisés à 0.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Problèmes SQLite - "Values et colomns"

Message par falsam »

Aie ça cafouille dans ton code. Par exemple

Code : Tout sélectionner

For dlInc = #String_0 To #CheckBox_10
            SetGadgetText(dlInc,"")
          Next
Ne peut pas fonctionner les constantes #CheckBox_0 à #CheckBox_10 par exemple ne sont pas des gadgets.

Ce qui explique pourquoi le bouton Nouveau plante ton code.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre