Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.12.1
Author: BeCool
Script Function: Trombinoscope
Template AutoIt script.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#NoTrayIcon
Trombi()
Func Trombi()
$Trombi = GUICreate("Trombinoscope", 514, 480, 355, 256)
$Groupe_photo = GUICtrlCreateGroup(" Photo ", 8, 32, 161, 201)
$Photo = GUICtrlCreatePic("C:\Documents and Settings\renfort.info\Bureau\identite.jpg", 16, 48, 145, 178)
$Groupe_information = GUICtrlCreateGroup(" Information ", 176, 32, 329, 201)
$Nom = GUICtrlCreateLabel("Nom :", 192, 56, 32, 17)
$Prenom = GUICtrlCreateLabel("Prénom :", 192, 80, 46, 17)
$Service = GUICtrlCreateLabel("Service :", 192, 104, 46, 17)
$Fonction = GUICtrlCreateLabel("Fonction :", 192, 128, 51, 17)
$Num_externe = GUICtrlCreateLabel("Num de tel externe :", 192, 152, 99, 17)
$Num_interne = GUICtrlCreateLabel("Num de tel interne :", 192, 176, 96, 17)
$Mail = GUICtrlCreateLabel("Adresse @mail :", 192, 200, 80, 17)
$Nom_label_info = GUICtrlCreateLabel("", 304, 56, 196, 17)
$Prenom_label_info = GUICtrlCreateLabel("", 304, 80, 196, 17)
$Service_label_info = GUICtrlCreateLabel("", 304, 104, 196, 17)
$Fonction_label_info = GUICtrlCreateLabel("", 304, 128, 196, 17)
$Num_tel_ext_label_info = GUICtrlCreateLabel("", 304, 152, 196, 17)
$Num_tel_int_label_info = GUICtrlCreateLabel("", 304, 176, 196, 17)
$Mail_label_info = GUICtrlCreateLabel("", 304, 200, 196, 17)
$Groupe_recherche = GUICtrlCreateGroup(" Recherche ", 8, 240, 497, 201)
$Categorie = GUICtrlCreateList("", 16, 256, 153, 175)
$list_cat = GUICtrlSetData(-1, "A. Nom|B. Prénom|C. Service|D. Fonction|E. Num de tel interne|F. Num de tel externe|G. Adresse @mail")
$Recherche = GUICtrlCreateInput("", 176, 256, 209, 21)
$Groupe_resultat = GUICtrlCreateGroup(" Resultat ", 176, 280, 321, 153)
$Resultat = GUICtrlCreateList("", 184, 296, 305, 123)
$Rechercher = GUICtrlCreateButton("Rechercher", 392, 254, 105, 25, 0)
$Ajouter = GUICtrlCreateButton("Ajouter", 8, 448, 171, 25, 0)
$Quitter = GUICtrlCreateButton("Quitter", 336, 448, 171, 25, 0)
$Barre_de_progression = GUICtrlCreateProgress(184, 450, 148, 21)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Rechercher
Global Const $adoProvider = 'Microsoft.Jet.OLEDB.4.0'
Global Const $adSchemaTables = 20
Global $o_MyError = ObjEvent("AutoIt.Error", "_MY_AU3_ErrFunc"), $n_MyError = 0
Global $bdd = "C:\trombidb.mdb"
Global $oConn = _ADO_Open($bdd)
ConsoleWrite($oConn.ConnectionString & @LF)
Global $oRS = ObjCreate("ADODB.Recordset")
$oRS = $oConn.OpenSchema($adSchemaTables)
For $i = 0 To $oRS.Fields.Count - 1
ConsoleWrite($oRS.Fields($i).Name & @LF)
Next
While Not $oRS.EOF
If $oRS.Fields("TABLE_TYPE" ).Value = "TABLE" Then
ConsoleWrite("Table name: " & _
$oRS.Fields("TABLE_NAME" ).Value & _
" Table type: " & $oRS.Fields("TABLE_TYPE" ).Value & @LF)
EndIf
$oRS.MoveNext
WEnd
$oRS.Close
;=====================================
Global Const $adOpenStatic = 3
Global Const $adLockOptimistic = 3
Global $rec = GUICtrlRead($Recherche)
;Global $rec = InputBox("Recherche", "Rechercher un nom") ;save
Global $WHERE = " WHERE Nom like '" & $rec & "%'"
Global $SQL = " SELECT Nom, Prenom, Service, Fonction, NumTel1, NumTel2 " & _
"FROM (tb_Personnes INNER JOIN tb_Services ON tb_Personnes.Service_id=tb_Services.Service_id) " & _
"INNER JOIN tb_Fonctions ON tb_Personnes.Fonction_id=tb_Fonctions.Fonction_id"
$oRS = ObjCreate("ADODB.Recordset")
$oRS.Open($SQL & $WHERE, $oConn, $adOpenStatic, $adLockOptimistic)
$aaa = ""
If $oRS.EOF Then
$aaa &= "Aucun enregistrement dans la table" & @LF
Else
$aaa &= $oRS.RecordCount & "enregistrement dans la table" & @LF
For $Field In $oRS.Fields
$aaa &= $Field.Name & @TAB
Next
$aaa &= @LF
While Not $oRS.EOF
For $Field In $oRS.Fields
$aaa &= $Field.Value & @TAB
Next
$aaa &= @LF
$oRS.MoveNext
WEnd
EndIf
[color=#FF0000];========================================
GUICtrlSetData($Resultat, $aaa)
;========================================[/color]
; MsgBox(0, "Résultat", $aaa, 10); je mets une tempo de 10 s si des fois la msgbox dépasse de l'écran elle se fermera toute seule ;)
$oConn.Close
Case $Ajouter
GUISetState(@SW_HIDE)
Ajout_fiche_perso()
Case $Quitter
Exit
EndSwitch
WEnd
EndFunc ;==>Trombi
Exit
Func Ajout_fiche_perso()
$Trombi_ajout = GUICreate("Trombinoscope - Ajout d'un profil", 514, 271, 343, 326)
$Group_photo_ajout = GUICtrlCreateGroup(" Photo ", 8, 32, 161, 201)
$Photo_ajout = GUICtrlCreatePic("C:\Documents and Settings\renfort.info\Bureau\identite.jpg", 16, 48, 145, 178)
$Ajout_photo = GUICtrlCreateButton("Ajouter une photo", 8, 240, 161, 25, 0)
$Group_info_ajout = GUICtrlCreateGroup(" Information ", 176, 33, 329, 201)
$Nom_label = GUICtrlCreateLabel("Nom :", 184, 57, 32, 17)
$Prenom_label = GUICtrlCreateLabel("Prénom :", 184, 81, 46, 17)
$Service_label = GUICtrlCreateLabel("Service :", 184, 105, 46, 17)
$Fonction_label = GUICtrlCreateLabel("Fonction :", 184, 129, 51, 17)
$Num_tel_externe_label = GUICtrlCreateLabel("Num de tel externe :", 184, 153, 99, 17)
$Num_tel_interne_label = GUICtrlCreateLabel("Num de tel interne :", 184, 177, 96, 17)
$Mail_label = GUICtrlCreateLabel("Adresse @mail :", 184, 201, 80, 17)
$Nom_ajout = GUICtrlCreateInput("", 296, 53, 201, 21)
$Prenom_ajout = GUICtrlCreateInput("", 296, 77, 201, 21)
$Service_ajout = GUICtrlCreateInput("", 296, 101, 201, 21)
$Fonction_ajout = GUICtrlCreateInput("", 296, 125, 201, 21)
$Num_tel_externe_ajout = GUICtrlCreateInput("", 296, 149, 201, 21)
$Num_tel_interne_ajout = GUICtrlCreateInput("", 296, 173, 201, 21)
$Mail_ajout = GUICtrlCreateInput("", 296, 197, 141, 21)
$fin_mail = GUICtrlCreateLabel("@ville-vif.fr", 440, 201, 56, 17)
$Annuler = GUICtrlCreateButton("Annuler", 344, 240, 161, 25, 0)
$Valider = GUICtrlCreateButton("Valider", 176, 240, 161, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete()
Return
Case $Annuler
GUISetState(@SW_HIDE)
Trombi()
Case $Ajout_photo
Ajout_photo()
Case $Valider
If FileExists("_" & GUICtrlRead($Nom_ajout) & ".ini") Then
MsgBox(0, "Erreur", "La fiche existe déjà")
GUISetState(@SW_HIDE)
Ajout_fiche_perso()
ElseIf Not FileExists("_" & GUICtrlRead($Nom_ajout) & ".ini") Then
$recencement = FileOpen("recencement.txt", 1)
$file = FileOpen("_" & GUICtrlRead($Nom_ajout) & ".ini", 9)
If $file = -1 Then
MsgBox(0, "Erreur", "Impossible de créer la fiche.")
GUISetState(@SW_HIDE)
Ajout_fiche_perso()
EndIf
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "Information", "Nom", "" & GUICtrlRead($Nom_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Prenom", "" & GUICtrlRead($Prenom_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Service", "" & GUICtrlRead($Service_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Fonction", "" & GUICtrlRead($Fonction_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Numero de telephone externe", "" & GUICtrlRead($Num_tel_externe_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Numero de telephone interne", "" & GUICtrlRead($Num_tel_interne_ajout))
IniWrite("_" & GUICtrlRead($Nom_ajout) & ".ini", "", "Mail", "" & GUICtrlRead($Mail_ajout) & "@ville-vif.fr")
GUIDelete()
Trombi()
Return
EndIf
EndSwitch
WEnd
EndFunc ;==>Ajout_fiche_perso
Func Ajout_photo() ; A FAIRE
$image = FileOpenDialog("Selectionner une photo", @DocumentsCommonDir & "\", "Images (*.jpg;*.bmp)")
EndFunc ;==>Ajout_photo
Func _ADO_Open($base, $driver = "", $serveur = "", $user = "", $pwd = "")
Local $oConn = ObjCreate("ADODB.Connection")
With $oConn
Switch StringLower($driver)
Case "excel"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};Dbq=" & $base
.Open
Case "text"
.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & $base & ";Extensions=tab;Extended Properties=TEXT"
.Open
Case "mssql"
.ConnectionString = "driver={SQL Server};server=" & $serveur & ";db=" & $base & ";user id=" & $user & ";pwd=" & $pwd & ";option=16386"
.Open
Case Else
.Provider = $adoProvider
.Open($base, $user, $pwd)
EndSwitch
EndWith
Return $oConn
EndFunc ;==>_ADO_Open
Func _MY_AU3_ErrFunc()
Local $Msg
$Msg = MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $o_MyError.description & @CRLF & _
"err.windescription:" & @TAB & $o_MyError.windescription & @CRLF & _
"err.number is: " & @TAB & Hex($o_MyError.number, 8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $o_MyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $o_MyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $o_MyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $o_MyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $o_MyError.helpcontext _
)
Local $n = $o_MyError.number
If $n = 0 Then $n = -1
$n_MyError = $n
If $Msg <> 6 Then Exit
EndFunc ;==>_MY_AU3_ErrFunc