Enregistrer (Ajout si pas de fiche ou Mise à jour de la base si modification de fiche),
il paraît que c'est ainsi que doit être les commandes de bases. J'ai suivi vos instructions
au sujet de CheckBoxGadget, mais j'ai dû oublier quelque chose, car les états ne se remettent
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
Global Databasefile.s
Global ReqSQL.s
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")
CheckBoxGadget(#Element_CheckBox_1, 876,150,100, 15, "Livre")
CheckBoxGadget(#Element_CheckBox_2, 876,170,100, 15, "Exposition")
CheckBoxGadget(#Element_CheckBox_5, 1060,130,100, 15, "Carte postale")
CheckBoxGadget(#Element_CheckBox_6, 1060,150,120, 15, "Projection publique")
CheckBoxGadget(#Element_CheckBox_7, 1060,170,60, 15, "Publicité")
CheckBoxGadget(#Element_CheckBox_4, 1220,130,130, 15, "Objets de décoration")
CheckBoxGadget(#Element_CheckBox_3, 1220,150,130, 15, "Publication électronique")
StringGadget(#String_33,1220,170,100,20, "")
CheckBoxGadget(#Element_CheckBox_8, 876,230,300, 15, "Autorisation à titre gratuit")
CheckBoxGadget(#Element_CheckBox_9, 876,250,290, 15, "Autorisation contre tirage : Pourcentage sur les recettes :")
;TextGadget(#Text_37 ,1194,251,20,20,"%")
StringGadget(#String_37,1165,248,24,20,"")
CheckBoxGadget(#Element_CheckBox_10, 876,270,200, 15, "Exposition")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 INTEGER, "
psSQLRequest + "Etat_CheckBox_1 INTEGER, "
psSQLRequest + "Etat_CheckBox_2 INTEGER, "
psSQLRequest + "Etat_CheckBox_3 INTEGER, "
psSQLRequest + "Etat_CheckBox_4 INTEGER, "
psSQLRequest + "Etat_CheckBox_5 INTEGER, "
psSQLRequest + "Etat_CheckBox_6 INTEGER, "
psSQLRequest + "Etat_CheckBox_7 INTEGER, "
psSQLRequest + "Etat_CheckBox_8 INTEGER, "
psSQLRequest + "Etat_CheckBox_9 INTEGER, "
psSQLRequest + "Etat_CheckBox_10 INTEGER, "
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))
SetGadgetState(#Element_CheckBox_0,GetDatabaseLong(glDBSQLite, 38))
SetGadgetState(#Element_CheckBox_1,GetDatabaseLong(glDBSQLite, 39))
SetGadgetState(#Element_CheckBox_2,GetDatabaseLong(glDBSQLite, 40))
SetGadgetState(#Element_CheckBox_3, GetDatabaseLong(glDBSQLite, 41))
SetGadgetState(#Element_CheckBox_4,GetDatabaseLong(glDBSQLite, 42))
SetGadgetState(#Element_CheckBox_5,GetDatabaseLong(glDBSQLite, 43))
SetGadgetState(#Element_CheckBox_6,GetDatabaseLong(glDBSQLite, 44))
SetGadgetState(#Element_CheckBox_7,GetDatabaseLong(glDBSQLite, 45))
SetGadgetState(#Element_CheckBox_8,GetDatabaseLong(glDBSQLite, 46))
SetGadgetState(#Element_CheckBox_9,GetDatabaseLong(glDBSQLite, 47))
SetGadgetState(#Element_CheckBox_10,GetDatabaseLong(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 = ?,"
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)
Modification = 1
Repeat
glEvent = WaitWindowEvent()
glGadget= EventGadget()
glType = EventType()
If glEvent = #PB_Event_Gadget
Select glGadget
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
Modification = 0
Define.l dlInc
For dlInc = #String_0 To #String_37
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
;}
Case #Button_1 ;{Enregistrer
If GetGadgetText(#String_2) <> "" And GetGadgetText(#String_3) <> "" And GetGadgetText(#String_4) <> "" And GetGadgetText(#String_5) <> "" And Modification = 0
DB_InsertContact()
Modification = 1
Else
If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1 And Modification = 1
DB_UpdateContact(GetGadgetState(#Listview_0))
MessageRequester("Notysoft Ordinem - Gestion de Contacts - ","Contact enregistrer !",64)
EndIf
EndIf
;}
Case #Button_2 ;{ Mettre à jour
If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
DB_UpdateContact(GetGadgetState(#Listview_0))
MessageRequester("Notysoft Ordinem - Gestion de Contacts - ","Vos contacts sont à jour !",64)
EndIf
;}
Case #Button_3 ;{ Supprimer
If GetGadgetState(#Listview_0) >= 0 And GetGadgetState(#Listview_0) <= CountGadgetItems(#Listview_0)-1
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
;}
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