Advertisement
Guest User

Untitled

a guest
May 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.26 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <ComboConstants.au3>
  3. #include <DateTimeConstants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <GuiToolbar.au3>
  7. #include <StaticConstants.au3>
  8. #include <TabConstants.au3>
  9. #include <ToolbarConstants.au3>
  10. #include <WindowsConstants.au3>
  11. #include <GuiComboBox.au3>
  12. #include "mysql.au3"
  13.  
  14. ; *. ini file  !
  15. $ini = "test.ini"
  16. ; Funktionen
  17.  
  18. ; ini file auslesen und füllen
  19. Func ReadSection ($isection)
  20.     Dim $section, $sectiong
  21.     $section = IniReadSection ($ini, $isection)
  22.     For $i=1 To $section[0][0]
  23.         $sectiong = $sectiong & $section[$i][1] & "|"
  24.     Next
  25.     Return $sectiong
  26. EndFunc
  27.  
  28.  
  29.  
  30. ; mysql connect
  31.  
  32. $UserName = "root"
  33. $Password = ""
  34. $Database = "auto"
  35. $MySQLServerName = "localhost"
  36. $table = "form"
  37.  
  38. $sql = _MySQLConnect($UserName,$Password,$Database,$MySQLServerName)
  39.  
  40.  
  41. ; Felder erstellen
  42. $ortr   = ReadSection("ort")
  43. $smt    = ReadSection("test2")
  44.  
  45. ; MYSQL Tabelleneinträge laden, wenn vorhanden
  46. Func DisplayTable()
  47.     $NameList = ""
  48.     $SQLCode = "SELECT * FROM form"
  49.     $TableContents = _Query ($sql, $SQLCode)
  50.     With $TableContents
  51.         While Not .EOF
  52.             ;$NameList &= .Fields ("form_id").value & "." & .Fields ("form_name").value & "|"
  53.             $NameList &= .Fields ("form_name").value & "|"
  54.             .MoveNext
  55.         WEnd
  56.     EndWith
  57.     Return $NameList
  58. EndFunc
  59.  
  60.  
  61.  
  62. $test = "Bitte Ort auswählen"
  63.  
  64. $lod = DisplayTable()
  65.  
  66.  
  67. #Region ### START Koda GUI section ### Form=
  68. $Form1 = GUICreate("test form", 635, 513, 188, 139)
  69. $Group1 = GUICtrlCreateGroup("Test Gruppe", 16, 136, 601, 345)
  70. $speichern = GUICtrlCreateButton("speichern", 232, 432, 121, 33, 0)
  71. $Label1 = GUICtrlCreateLabel("Name", 48, 176, 32, 17)
  72. $name = GUICtrlCreateInput("", 112, 176, 137, 21)
  73. $Ort_label = GUICtrlCreateLabel("Ort", 48, 208, 18, 17)
  74. $ort = GUICtrlCreateCombo($test, 112, 208, 145, 25)
  75. $ortset = GUICtrlSetData(-1,$ortr)
  76. $Label2 = GUICtrlCreateLabel("test2", 48, 240, 55, 17)
  77. $test2 = GUICtrlCreateCombo("Bitte test2 wählen", 112, 240, 145, 25)
  78. GUICtrlSetData(-1,$smt)
  79. $lli = GUICtrlCreateCombo("Eintrag laden", 120, 48, 145, 25)
  80. GUICtrlSetData(-1,$lod)
  81. $load = GUICtrlCreateButton("Button1", 272, 48, 75, 25, $WS_GROUP)
  82. GUISetState(@SW_SHOW)
  83. #EndRegion ### END Koda GUI section ###
  84. $msg = GUIGetMsg()
  85.  
  86.  
  87. ; Ausgewählten Eintrag laden
  88. Func LoadEntry()
  89.     $lentry = ""
  90.     $SQLCode = "SELECT * FROM form WHERE form_name = '"& GUICtrlRead($lli) &"'"
  91.     $TableContents = _Query ($sql, $SQLCode)
  92.     With $TableContents
  93.             $lentry &= .Fields ("form_id").value & "." & .Fields ("form_name").value
  94.     EndWith
  95.     MsgBox(0,"bla",$lentry)
  96. EndFunc
  97.  
  98.  
  99.  
  100.  While 1
  101.     $msg = GUIGetMsg()
  102.     Select
  103.         Case $msg = $GUI_EVENT_CLOSE
  104.             ExitLoop
  105.         Case $msg = $speichern
  106.             ; mysql felder
  107.             Dim $test[4]
  108.             $test[0] = "form_id"
  109.             $test[1] = "form_name"
  110.             $test[2] = "form_ort"
  111.             $test[3] = "form_test2"
  112.             ; form_id    form_name       form_ort    form_test2
  113.             ; form variablen
  114.             Dim $values[4]
  115.             $values[0] = ""
  116.             $values[1] = GUICtrlRead($name)
  117.             $values[2] = GUICtrlRead($ort)
  118.             $values[3] = GUICtrlRead($test2)
  119.  
  120.             _AddRecord($sql, $table, $test, $values)
  121.             MsgBox(0, 'Test', "Eintrag erfolgreich angelegt")
  122.         Case $msg = $load
  123.             LoadEntry()
  124.             GUICtrlSetData($name,"TEST")
  125.             GUICtrlSetData($ort,"bla",Default)
  126.  
  127.  
  128.  
  129.     EndSelect
  130. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement