Developers Jos Posted March 28, 2011 Developers Share Posted March 28, 2011 Looks like you might have left a password in the script. (line 26 of the main script)updated the posted code... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
misterDee Posted March 28, 2011 Author Share Posted March 28, 2011 Looks like you might have left a password in the script. (line 26 of the main script)i know, its a test password ! Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2011 Developers Share Posted March 28, 2011 Oh now i get what you mean, im sorry for the whole converstation!its very clear, thnx for all your support!Geen probleem .... gewoon vragen als je een zet in de goeie richting nodig hebt. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
misterDee Posted March 28, 2011 Author Share Posted March 28, 2011 Geen probleem .... gewoon vragen als je een zet in de goeie richting nodig hebt. Dank je wel, dat waardeer ik, soms is het zoeken en prutsen naar een oplossing Link to comment Share on other sites More sharing options...
misterDee Posted April 3, 2011 Author Share Posted April 3, 2011 (edited) Thought I already did ... but guess I haven't What you could do is make the GUI logic in beheerder.au3 a FUNC... something like: expandcollapse popup#include <misc.au3> #include <File.au3> #include <GuiComboBox.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <GuiListView.au3> #include <GuiTab.au3> ;Globalizeren Global $db_artikelcode Global $db_omschrijving Global $db_bestelnummer Global $db_inkoopprijs Global $db_aantal Global $db_opmerking Global $db_klant Global $db_aanmelder Global $db_status Global $aListView[3] Main() Func Main() ;DB connect $FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb" $dbpass = "1" $CONN = ObjCreate("ADODB.Connection") $CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass & ';') $RecordSet = ObjCreate("ADODB.Recordset") ; We use ESC to exit the temporary Combo Opt("GUICloseOnESC", 0) ; Set flag to indicate double click in ListView Global $fDblClk = False, $hListView = 0 ; Declare global variables Global $aLV_Click_Info, $hTmp_Combo = 0 ; Open DLL for _IsPressed $dll = DllOpen("user32.dll") ;Gui $GUI = GUICreate("BETA v0.99 - Ingelogd als: ", 790, 700, 134, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_MINIMIZEBOX, $WS_EX_RIGHT, $WS_EX_WINDOWEDGE)) GUICtrlCreatePic(@ScriptDir & "\images\main_bg_top.jpg", 0, 0, 790, 78) GUICtrlCreatePic(@ScriptDir & "\images\main_bg_bottom.jpg", 0, 666, 790, 35) GUISetBkColor(0xFFFFFF) $TAB = GUICtrlCreateTab(0, 76, 800, 700) GUICtrlCreateTabItem("Dashboard") ;Bodegraven GUICtrlCreateTabItem("Bestellingenlijst Bodegraven") $updatebtn_bg = GUICtrlCreateButton("Update statussen", 10, 640, 100, 20) $listview_bg = _GUICtrlListView_Create($GUI, "Artikelcode | Artikelomschrijving | Bestelnummer | Inkoopprijs | Aantal | Opmerking | Klantgegevens | Aanmelder | Status", 0, 110, 791, 527) _GUICtrlListView_SetExtendedListViewStyle($listview_bg, $LVS_EX_GRIDLINES) $bestellingen = $CONN.Execute("SELECT * FROM bestellingen_bodegraven") With $bestellingen While Not .EOF $db_artikelcode = .fields("artikelcode").value $db_omschrijving = .fields("artikelomschrijving").value $db_bestelnummer = .fields("bestelnummer").value $db_inkoopprijs = .fields("inkoopprijs").value $db_aantal = .fields("aantal").value $db_opmerking = .fields("opmerking").value $db_klant = .fields("klant").value $db_aanmelder = .fields("aanmelder").value $db_status = .fields("status").value Local $Name[9] $Name[0] = $db_artikelcode $Name[1] = $db_omschrijving $Name[2] = $db_bestelnummer $Name[3] = $db_inkoopprijs $Name[4] = $db_aantal $Name[5] = $db_opmerking $Name[6] = $db_klant $Name[7] = $db_aanmelder $Name[8] = $db_status $index = _GUICtrlListView_AddItem($listview_bg, $Name[0], 0) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[1], 1) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[2], 2) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[3], 3) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[4], 4) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[5], 5) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[6], 6) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[7], 7) _GUICtrlListView_AddSubItem($listview_bg, $index, $Name[8], 8) .Movenext WEnd EndWith ControlHide($GUI, "", $listview_bg) $aListView[0] = $listview_bg ; Put handles into an array ;Ter Aar GUICtrlCreateTabItem("Bestellingenlijst Ter Aar") $updatebtn_ta = GUICtrlCreateButton("Update statussen", 10, 640, 100, 20) $listview_ta = _GUICtrlListView_Create($GUI, "Artikelcode | Artikelomschrijving | Bestelnummer | Inkoopprijs | Aantal | Opmerking | Klantgegevens | Aanmelder | Status", 0, 110, 791, 527) _GUICtrlListView_SetExtendedListViewStyle($listview_ta, $LVS_EX_GRIDLINES) $bestellingen = $CONN.Execute("SELECT * FROM bestellingen_teraar") With $bestellingen While Not .EOF $db_artikelcode = .fields("artikelcode").value $db_omschrijving = .fields("artikelomschrijving").value $db_bestelnummer = .fields("bestelnummer").value $db_inkoopprijs = .fields("inkoopprijs").value $db_aantal = .fields("aantal").value $db_opmerking = .fields("opmerking").value $db_klant = .fields("klant").value $db_aanmelder = .fields("aanmelder").value $db_status = .fields("status").value Local $Name[9] $Name[0] = $db_artikelcode $Name[1] = $db_omschrijving $Name[2] = $db_bestelnummer $Name[3] = $db_inkoopprijs $Name[4] = $db_aantal $Name[5] = $db_opmerking $Name[6] = $db_klant $Name[7] = $db_aanmelder $Name[8] = $db_status $index = _GUICtrlListView_AddItem($listview_ta, $Name[0], 0) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[1], 1) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[2], 2) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[3], 3) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[4], 4) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[5], 5) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[6], 6) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[7], 7) _GUICtrlListView_AddSubItem($listview_ta, $index, $Name[8], 8) .Movenext WEnd EndWith ControlHide($GUI, "", $listview_ta) $aListView[1] = $listview_ta ; Put handles into an array GUICtrlCreateTabItem("Bestellingenlijst Leimuiden") $updatebtn_lm = GUICtrlCreateButton("Update statussen", 10, 640, 100, 20) $listview_lm = _GUICtrlListView_Create($GUI, "Artikelcode | Artikelomschrijving | Bestelnummer | Inkoopprijs | Aantal | Opmerking | Klantgegevens | Aanmelder | Status", 0, 110, 791, 527) _GUICtrlListView_SetExtendedListViewStyle($listview_lm, $LVS_EX_GRIDLINES) $bestellingen = $CONN.Execute("SELECT * FROM bestellingen_leimuiden") With $bestellingen While Not .EOF $db_artikelcode = .fields("artikelcode").value $db_omschrijving = .fields("artikelomschrijving").value $db_bestelnummer = .fields("bestelnummer").value $db_inkoopprijs = .fields("inkoopprijs").value $db_aantal = .fields("aantal").value $db_opmerking = .fields("opmerking").value $db_klant = .fields("klant").value $db_aanmelder = .fields("aanmelder").value $db_status = .fields("status").value Local $Name[9] $Name[0] = $db_artikelcode $Name[1] = $db_omschrijving $Name[2] = $db_bestelnummer $Name[3] = $db_inkoopprijs $Name[4] = $db_aantal $Name[5] = $db_opmerking $Name[6] = $db_klant $Name[7] = $db_aanmelder $Name[8] = $db_status $index = _GUICtrlListView_AddItem($listview_lm, $Name[0], 0) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[1], 1) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[2], 2) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[3], 3) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[4], 4) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[5], 5) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[6], 6) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[7], 7) _GUICtrlListView_AddSubItem($listview_lm, $index, $Name[8], 8) .Movenext WEnd EndWith ControlHide($GUI, "", $listview_lm) $aListView[2] = $listview_lm ; Put handles into an array GUICtrlCreateTabItem("Gebruikersoverzicht") $listview_go = GUICtrlCreateListView("Gebruikersnaam | Locatie | Gebruikersrechten", 0, 340, 791, 295, "", $LVS_EX_GRIDLINES) $admin_toevoegen = GUICtrlCreateButton("Account aanmaken", 325, 305, 120, 20) $admin_verwijderen = GUICtrlCreateButton("Account verwijderen", 10, 640, 120, 20) GUICtrlCreatePic(@ScriptDir & "\images\logo.jpg", 240, 135, 150, 150) $gebruikers = $CONN.Execute("SELECT * FROM gebruikers") With $gebruikers While Not .EOF $db_gebruikersnaam = .fields("gebruikersnaam").value $db_locatie = .fields("locatie").value $db_rechten = .fields("rechten").value GUICtrlCreateListViewItem($db_gebruikersnaam & "|" & $db_locatie & "|" & $db_rechten, $listview_go) .Movenext WEnd EndWith ;Gebruikersnaam GUICtrlCreateLabel("Gebruikersnaam:", 20, 125) $admin_gebruikersnaam = GUICtrlCreateInput("", 20, 145, 150, 20) ;Wachtwoord GUICtrlCreateLabel("Wachtwoord:", 20, 175) $admin_wachtwoord = GUICtrlCreateInput("", 20, 195, 150, 20) ;Locatie GUICtrlCreateLabel("Locatie:", 20, 225) $admin_locatie = GUICtrlCreateCombo("Bodegraven", 20, 245, 120, 20) GUICtrlSetData(-1, "Ter Aar" & "|" & "Leimuiden") ;Rechten GUICtrlCreateLabel("Gebruikersrechten:", 20, 275) $admin_rechten = GUICtrlCreateCombo("Gebruiker", 20, 295, 120, 20) GUICtrlSetData(-1, "Beheerder") GUICtrlCreateGroup("", 10, 110, 440, 220) GUICtrlCreateTabItem("") ; Look for double clicks GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $iLastTab = 0 GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE DllClose($dll) Exit Case $updatebtn_bg _updatestatus_bg() Case $updatebtn_ta _updatestatus_ta() Case $updatebtn_lm _updatestatus_lm() Case $admin_toevoegen _admin_toevoegen() Case $admin_verwijderen _admin_verwijderen() EndSwitch ; Check which Tab is active $iCurrTab = _GUICtrlTab_GetCurFocus($TAB) ; If the Tab has changed If $iCurrTab <> $iLastTab Then ; Store the value for future comparisons $iLastTab = $iCurrTab ; Show/Hide controls as required Switch $iCurrTab Case 0, 4 ControlHide($GUI, "", $listview_bg) ControlHide($GUI, "", $listview_ta) ControlHide($GUI, "", $listview_lm) Case 1 ControlHide($GUI, "", $listview_ta) ControlHide($GUI, "", $listview_lm) ControlShow($GUI, "", $listview_bg) Case 2 ControlHide($GUI, "", $listview_bg) ControlHide($GUI, "", $listview_lm) ControlShow($GUI, "", $listview_ta) Case 3 ControlHide($GUI, "", $listview_bg) ControlHide($GUI, "", $listview_ta) ControlShow($GUI, "", $listview_lm) EndSwitch EndIf ;#ce ; If a temporary combo exists If $hTmp_Combo <> 0 Then ; If ENTER pressed If _IsPressed("0D", $dll) Then ; Set label to edit content $sText = GUICtrlRead($hTmp_Combo) _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1]) ; Delete temporary combo GUICtrlDelete($hTmp_Combo) $hTmp_Combo = 0 GUICtrlSetState($hListView, $GUI_ENABLE) EndIf ; If ESC pressed If _IsPressed("1B", $dll) Then ; Delete temporary combo GUICtrlDelete($hTmp_Combo) $hTmp_Combo = 0 GUICtrlSetState($hListView, $GUI_ENABLE) EndIf EndIf ; If an item was double clicked If $fDblClk Then ; Set clicked listview handle as passed in $fDblClk $hListView = $fDblClk $fDblClk = False ; Delete an existing temporary combo GUICtrlDelete($hTmp_Combo) ; Get label position Switch $aLV_Click_Info[1] Case 0 ; On Item $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2) Case Else ; On SubItem $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) EndSwitch ; Create temporary combo $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 0, $aLV_Rect_Info[1] + 110, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1]) GUICtrlSetData($hTmp_Combo, "In behandeling|Afgehandeld|In backorder") GUICtrlSetState($hListView, $GUI_DISABLE) GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP)) EndIf WEnd EndFunc ;==>Main Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ; If a combo exists, return immediately If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) ; Check the listviews For $i = 0 To 2 If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $aListView[$i] Then If DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($aListView[$i]) ; As long as the click was on the ListView If $aLV_Click_Info[0] <> -1 Then ; Check it was in Col 2 If $aLV_Click_Info[1] = 8 Then $fDblClk = $aListView[$i] ; return the handle of the Listview that was doubleclicked EndIf EndIf EndIf Next Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _updatestatus_bg() $ItemsCount = _GUICtrlListView_GetItemCount($listview_bg) For $i = 0 To $ItemsCount Step 1 $update_artikelcode = _GUICtrlListView_GetItemText($listview_bg, $i, 0) $update_omschrijving = _GUICtrlListView_GetItemText($listview_bg, $i, 1) $update_aantal = _GUICtrlListView_GetItemText($listview_bg, $i, 4) $update_status = _GUICtrlListView_GetItemText($listview_bg, $i, 8) $CONN.Execute("UPDATE bestellingen_bodegraven SET Status = '" & $update_status & "' WHERE Artikelcode = '" & $update_artikelcode & "' AND Artikelomschrijving = '" & $update_omschrijving & "' AND Aantal = '" & $update_aantal & "'") Next EndFunc ;==>_updatestatus_bg Func _updatestatus_ta() $ItemsCount = _GUICtrlListView_GetItemCount($listview_ta) For $i = 0 To $ItemsCount Step 1 $update_artikelcode = _GUICtrlListView_GetItemText($listview_ta, $i, 0) $update_omschrijving = _GUICtrlListView_GetItemText($listview_ta, $i, 1) $update_aantal = _GUICtrlListView_GetItemText($listview_ta, $i, 4) $update_status = _GUICtrlListView_GetItemText($listview_ta, $i, 8) $CONN.Execute("UPDATE bestellingen_teraar SET Status = '" & $update_status & "' WHERE Artikelcode = '" & $update_artikelcode & "' AND Artikelomschrijving = '" & $update_omschrijving & "' AND Aantal = '" & $update_aantal & "'") Next EndFunc ;==>_updatestatus_ta Func _updatestatus_lm() $ItemsCount = _GUICtrlListView_GetItemCount($listview_lm) For $i = 0 To $ItemsCount Step 1 $update_artikelcode = _GUICtrlListView_GetItemText($listview_lm, $i, 0) $update_omschrijving = _GUICtrlListView_GetItemText($listview_lm, $i, 1) $update_aantal = _GUICtrlListView_GetItemText($listview_lm, $i, 4) $update_status = _GUICtrlListView_GetItemText($listview_lm, $i, 8) $CONN.Execute("UPDATE bestellingen_leimuiden SET Status = '" & $update_status & "' WHERE Artikelcode = '" & $update_artikelcode & "' AND Artikelomschrijving = '" & $update_omschrijving & "' AND Aantal = '" & $update_aantal & "'") Next EndFunc ;==>_updatestatus_lm Func _admin_toevoegen() $read_gebruikersnaam = GUICtrlRead($admin_gebruikersnaam) $read_wachtwoord = GUICtrlRead($admin_wachtwoord) $read_locatie = GUICtrlRead($admin_locatie) $read_rechten = GUICtrlRead($admin_rechten) GUICtrlCreateListViewItem($read_gebruikersnaam & "|" & $read_locatie & "|" & $read_rechten, $listview_go) $CONN.Execute("INSERT into gebruikers (Gebruikersnaam, Wachtwoord, Locatie, Rechten) values ('" & $read_gebruikersnaam & "', '" & $read_wachtwoord & "', '" & $read_locatie & "', '" & $read_rechten & "')") EndFunc ;==>_admin_toevoegen Func _admin_verwijderen() $read_gebruikersnaam = GUICtrlRead($admin_gebruikersnaam) $read_locatie = GUICtrlRead($admin_locatie) $read_rechten = GUICtrlRead($admin_rechten) If _GUICtrlListView_GetItemText($listview_go, 0, 0) = _GUICtrlListView_GetItemSelected($listview_go, 0) Then $CONN.Execute("DELETE FROM gebruikers WHERE Gebruikersnaam = '" & $read_gebruikersnaam & "' AND Locatie = '" & $read_locatie & "' AND Rechten = '" & $read_rechten & "'") EndIf EndFunc ;==>_admin_verwijderen ... and include that in your posted script like: expandcollapse popup; Techniektool gemaakt door Dennis ; in opdracht voor ; Versie 1.0 #include <GUIConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Variables $userlogin = "admin" $passlogin = "1" ; GUI $gui = GUICreate("Login ", 200, 180, 330, 200, -1, BitOR($WS_EX_RIGHT, $WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) GUISetBkColor(0xFFFFFF) GUICtrlCreatePic(@ScriptDir & "\images\logo.jpg", 90, 0, 100, 90) GUICtrlCreateLabel("Gebruikersnaam", 0, 65) $username = GUICtrlCreateInput("", 0, 80, 120, 20) GUICtrlCreateLabel("Wachtwoord", 0, 105) $password = GUICtrlCreateInput("", 0, 120, 120, 20, 0x0020) $loginbtn = GUICtrlCreateButton("Login", 70, 150, 50, 23) ;DB connect $FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb" $dbpass = "xyz" $CONN = ObjCreate("ADODB.Connection") $CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass & ';') $RecordSet = ObjCreate("ADODB.Recordset") ; Loop GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $loginbtn _userlogin() EndSwitch WEnd Func _userlogin() $readusername = GUICtrlRead($username) $readpassword = GUICtrlRead($password) $gebruikers = $CONN.Execute("SELECT * FROM gebruikers WHERE gebruikersnaam='" & $readusername & "';") With $gebruikers While Not .EOF $db_gebruikersnaam = .fields("gebruikersnaam").value $db_wachtwoord = .fields("wachtwoord").value $db_locatie = .fields("locatie").value $db_rechten = .fields("rechten").value .movenext If $readusername = $db_gebruikersnaam And $readpassword = $db_wachtwoord And $db_rechten = "Beheerder" Then GUIDelete($gui) main() Else GUICtrlCreateIcon("Shell32.dll", -132, 130, 123, 15, 15) MsgBox(16, "Fout!", "Foutief wachtwoord") GUICtrlSetData($password, "") EndIf WEnd EndWith EndFunc ;==>_userlogin Exit #include "beheerder.au3" All untested but might give you an idea Still gets errors when i put my script or parts of my script in func's how Jos it explained, can someone help me to get it fixed? Edited April 3, 2011 by misterDee Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now