Code : Tout sélectionner
Declare Creation(NbBranche, NomBranche$)
Declare Lecture(NomBranche$)
Declare Matiere(Num, Nom.s)
Declare debut()
Enumeration
#Window_0
EndEnumeration
Enumeration
#MenuBar_0
EndEnumeration
Enumeration
#MENU_Ouvrir
#MENU_Quitter
#MENU_AddBranche
#MENU_AddInterro
#MENU_ModBranche
#MENU_ModInterro
#MENU_DelBranche
#MENU_DelInterro
#MENU_Apropos
EndEnumeration
;- Gadget Constants
;
Enumeration
#Panel_0
#Frame3D_0
#ListIcon_0
#Frame3D_1
#Text_0
#Text_1
#String_0
#String_1
#String_2
#String_3
#Text_2
#Text_3
#Text_4
#String_4
#String_5
#Text_5
#Text_6
#String_6
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 236, 147, 600, 400, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Laz'Calc")
If CreateMenu(#MenuBar_0, WindowID())
MenuTitle("Fichier")
MenuItem(#MENU_Ouvrir, "Options")
MenuBar()
MenuItem(#MENU_Quitter, "Quitter")
MenuTitle("Options")
OpenSubMenu("Ajouter")
MenuItem(#MENU_AddBranche, "Branche")
MenuItem(#MENU_AddInterro, "Interro")
CloseSubMenu()
OpenSubMenu("Modifier")
MenuItem(#MENU_ModBranche, "Branche")
MenuItem(#MENU_ModInterro, "Interro")
CloseSubMenu()
MenuBar()
OpenSubMenu("Supprimer")
MenuItem(#MENU_DelBranche, "Branche")
MenuItem(#MENU_DelInterro, "Interro")
CloseSubMenu()
MenuTitle("?")
MenuItem(#MENU_Apropos, "A propos")
EndIf
If CreateGadgetList(WindowID())
PanelGadget(0, 10, 10, 580, 360)
debut()
CloseGadgetList()
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID() ; To see which menu has been selected
Case 8 ; About
MessageRequester("About", "Cool Menu example", 0)
Case #MENU_Ouvrir
Nomdebranche$ = InputRequester("Nom de la Branche","Inserez le nom de la branche","")
Lecture(Nomdebranche$)
Default
MessageRequester("Info", "MenuItem: "+Str(EventMenuID()), 0)
EndSelect
Case #WM_CLOSE ; #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
EndProcedure
Procedure Creation(NbBranche, NomBranche$)
If CreatePreferences("calc.laz")
PreferenceGroup("Nb branche")
WritePreferenceLong("Nombre", NbBranche)
PreferenceGroup("Nom Branche")
Dim Branche(NbBranche)
For a=1 To NbBranche
WritePreferenceString("Branche("+Str(a)+")", NomBranche$)
CreatePreferences(NomBranche$+".laz")
WritePreferenceLong("Nb", 0)
PreferenceGroup(NomBranche$+" point")
PreferenceGroup(NomBranche$+" nom")
PreferenceGroup(NomBranche$+" date")
PreferenceGroup(NomBranche$+" com")
ClosePreferences()
Next
ClosePreferences()
EndIf
EndProcedure
Procedure debut()
ClearGadgetItemList(0)
OpenPreferences("calc.laz")
PreferenceGroup("Nb branche")
Nb = ReadPreferenceLong("Nombre", 0)
ClosePreferences()
Dim br.s(nb)
For a=1 To Nb
OpenPreferences("calc.laz")
PreferenceGroup("Nom Branche")
nomn$ = ReadPreferenceString("Branche("+Str(a)+")", "")
ClosePreferences()
If nomn$ = ""
nomn$ = NomBranche$
EndIf
br(a) = nomn$
Matiere(a, br(a))
Next
EndProcedure
Procedure nom(nb, NomBranche$)
Dim br.s(nb+1)
ClearGadgetItemList(#ListIcon_0)
ClearGadgetItemList(0)
For a=1 To Nb+1
OpenPreferences("calc.laz")
PreferenceGroup("Nom Branche")
nomn$ = ReadPreferenceString("Branche("+Str(a)+")", "")
ClosePreferences()
If nomn$ = ""
nomn$ = NomBranche$
EndIf
br(a) = nomn$
Matiere(a, br(a))
Next
CreatePreferences("calc.laz")
PreferenceGroup("Nb branche")
WritePreferenceLong("Nombre", Nb+1)
PreferenceGroup("Nom Branche")
For b=1 To Nb+1
WritePreferenceString("Branche("+Str(b)+")", br(b))
Next
For c=Nb+1 To Nb+1
If FileSize(br(c)+".laz")=-1
CreatePreferences(br(c)+".laz")
WritePreferenceLong("Nb", 0)
PreferenceGroup(br(c)+" point")
PreferenceGroup(br(c)+" nom")
PreferenceGroup(br(c)+" date")
PreferenceGroup(br(c)+" com")
ClosePreferences()
Else
MessageRequester("Erreur","Ce nom de branche a deja ete enregistré",0)
CreatePreferences("calc.laz")
PreferenceGroup("Nb branche")
WritePreferenceLong("Nombre", Nb)
PreferenceGroup("Nom Branche")
For b=1 To Nb
WritePreferenceString("Branche("+Str(b)+")", br(b))
Next
EndIf
Next
ClosePreferences()
EndProcedure
Procedure Lecture(NomBranche$)
If OpenPreferences("calc.laz") = 0
Creation(NbBranche+1,Nombranche$)
Else
OpenPreferences("calc.laz")
PreferenceGroup("Nb branche")
Nb = ReadPreferenceLong("Nombre", 0)
ClosePreferences()
nom(nb, NomBranche$)
ClosePreferences()
EndIf
EndProcedure
Procedure Matiere(Num, Nom.s)
Dim string.s(7)
For a=0 To 6
string(a) = Str(a)+Str(Num)
Debug Val(string(a))
Next
AddGadgetItem(0, Num, Nom)
Frame3DGadget(#Frame3D_0, 8, 8, 560, 230, "Rapport des interrogations")
ListIconGadget(1, 18, 28, 540, 200, "Nom", 100, #PB_ListIcon_GridLines|#PB_ListIcon_HeaderDragDrop )
AddGadgetColumn(1,2,"Date",100)
AddGadgetColumn(1,0,"N°",25)
AddGadgetColumn(1,3,"Point",40)
AddGadgetColumn(1,4,"Commentaire",270)
Frame3DGadget(#Frame3D_1, 8, 248, 560, 80, "Moyenne des resultats")
TextGadget(#Text_0, 18, 268, 160, 20, "Total des interrogations :")
TextGadget(#Text_1, 18, 298, 160, 20, "Total des interrogrations sur 100 :")
StringGadget(#String_0, 188, 268, 30, 20, "", #PB_String_ReadOnly | #PB_String_BorderLess)
StringGadget(#String_1, 188, 298, 30, 20, "", #PB_String_ReadOnly | #PB_String_BorderLess)
StringGadget(#String_2, 238, 268, 30, 20, "", #PB_String_ReadOnly | #PB_String_BorderLess)
StringGadget(#String_3, 238, 298, 30, 20, " 100", #PB_String_ReadOnly | #PB_String_BorderLess)
TextGadget(#Text_2, 218, 268, 20, 20, " /")
TextGadget(#Text_3, 218, 298, 20, 20, " /")
TextGadget(#Text_4, 288, 268, 160, 20, "Total des interrogations sur 20 :")
StringGadget(#String_4, 458, 268, 20, 20, "", #PB_String_ReadOnly | #PB_String_BorderLess)
StringGadget(#String_5, 498, 268, 20, 20, "20", #PB_String_ReadOnly | #PB_String_BorderLess)
TextGadget(#Text_5, 478, 268, 20, 20, " /")
TextGadget(#Text_6, 288, 298, 60, 20, "Mention :")
StringGadget(#String_6, 458, 298, 60, 20, "", #PB_String_ReadOnly | #PB_String_BorderLess)
EndProcedure
Open_Window_0()