#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Excel.au3>
#include <Array.au3>

;### Ecel Werte werden festgelegt ###
Local $oExcel = _Excel_Open(True, False, True, True, False) ;False 1=blendet Excel aus / False 2 unterdrückt alle Aufforderungs- und Fehlermeldungen von Excel
$sWorkbook = @ScriptDir & "\DB.xlsx" ;es wird der Pfad des Ordner in dem dieses Prgramm ausgeführt wird übergeben und dem Namen der .xlsx hinzugefügt
$oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, True, True, Default, Default, Default)
$oWorkbook.Sheets(4).Activate ;es wird die Tabelle 4 der Arbeitsmappe aktiv gesetzt
$aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("G:G"), 1, False) ;es werden aus der Tabelle Spalte F Werte ausgelesen
;### END Excel Werte ###

;_ArrayDisplay($aResult) ;gibt die Werte des Array in ein Popupfenster aus

#Region ### Formular Gestaltung ###
$Form1 = GUICreate("PDB", 537, 494, 288, 120)
$In_SV = GUICtrlCreateInput("", 111, 60, 138, 18)
$Combo_Suche = GUICtrlCreateCombo("", 111, 110, 138, 21)
$In_Titel = GUICtrlCreateInput("", 111, 135, 138, 21)
$Combo_Anrede = GUICtrlCreateCombo("", 111, 85, 138, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo_Anrede, "Frau|Herr", "Frau")
$In_Geb = GUICtrlCreateInput("", 111, 160, 138, 21)
$In_Adresse = GUICtrlCreateInput("", 111, 185, 138, 21)
$In_PLZ = GUICtrlCreateInput("", 111, 210, 138, 21)
$Combo_GKK = GUICtrlCreateCombo("", 376, 60, 138, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo_GKK, "ÖGKK|WGKK|NGKK|BGKK|STGKK|KGKK|SGKK|OGKK|TGKK|VGKK|BVA|SVB|SVA|VAEB", "ÖGKK")
$In_Nachname = GUICtrlCreateInput("", 376, 110, 138, 21)
$In_Titel_n = GUICtrlCreateInput("", 376, 135, 138, 21)
$In_Mail = GUICtrlCreateInput("", 376, 160, 138, 21)
$In_Tel = GUICtrlCreateInput("", 376, 185, 138, 21)
$In_Ort = GUICtrlCreateInput("", 376, 210, 138, 21)

$Label1 = GUICtrlCreateLabel("SV-Nummer:", 18, 60, 79, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label2 = GUICtrlCreateLabel("Anrede:", 18, 85, 50, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label3 = GUICtrlCreateLabel("Nachname:", 18, 110, 61, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label4 = GUICtrlCreateLabel("Titel:", 18, 135, 33, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label5 = GUICtrlCreateLabel("Geburtsdatum:", 18, 160, 90, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label6 = GUICtrlCreateLabel("Adresse:", 18, 185, 55, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label7 = GUICtrlCreateLabel("PLZ:", 18, 210, 30, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label8 = GUICtrlCreateLabel("Krankenkassen:", 270, 60, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label9 = GUICtrlCreateLabel("Vorname:", 270, 110, 69, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label10 = GUICtrlCreateLabel("Titel nachgestellt:", 270, 135, 105, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label11 = GUICtrlCreateLabel("E-Mail:", 270, 160, 43, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label12 = GUICtrlCreateLabel("Telefonnummer:", 270, 185, 99, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Label13 = GUICtrlCreateLabel("Ort:", 270, 210, 27, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Button_Speich = GUICtrlCreateButton("Speichern", 112, 432, 60, 42)

GUISetState(@SW_SHOW)
#EndRegion ### END Formular Gestaltung ###

GUICtrlSetData($Combo_Suche, _ArrayToString($aResult)) ;Array Werte werden der ComboBox übergeben

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Combo_Suche
			$sComboRead = GUICtrlRead($Combo_Suche) ;der Variablen wird der Wert aus der ComboBox ausgelesen und übergeben
			MsgBox(64, "ComboBox", "Nachname " & $sComboRead & " ausgewähl") ;der gewählte Wert wird in einer MsgBox ausgegeben
		Case $Button_Speich
			MsgBox(64, "Button", "Speicherbutton gedrückt")
	EndSwitch
WEnd
