#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 360, 140, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Label1 = GUICtrlCreateLabel("服务器 IP", 8, 12, 55, 17)
$Label2 = GUICtrlCreateLabel("数据库 ID", 8, 44, 55, 17)
$Label3 = GUICtrlCreateLabel("数据库 PW", 8, 76, 55, 17)
$Label4 = GUICtrlCreateLabel("数据库 DA", 8, 108, 55, 17)
$Input1 = GUICtrlCreateInput("", 65, 8, 121, 21)
$Input2 = GUICtrlCreateInput("", 65, 40, 121, 21)
$Input3 = GUICtrlCreateInput("", 65, 72, 121, 21)
$Input4 = GUICtrlCreateInput("", 65, 104, 121, 21)
$Combo1 = GUICtrlCreateCombo("", 200, 8, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetState($Combo1, $GUI_DISABLE)
GUICtrlSetOnEvent($Combo1, "Combo1")
$Combo2 = GUICtrlCreateCombo("", 200, 40, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetState($Combo2, $GUI_DISABLE)
GUICtrlSetOnEvent($Combo2, "Combo2")
$Combo3 = GUICtrlCreateCombo("", 200, 72, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetState($Combo3, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("连接数据库", 200, 104, 145, 25)
GUICtrlSetOnEvent($Button1, "Button1")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Button1()
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("driver={SQL Server};server=" & GUICtrlRead($Input1) & ";uid=" & GUICtrlRead($Input2) & ";pwd=" & GUICtrlRead($Input3) & ";database=" & GUICtrlRead($Input4) & "")
$RS.ActiveConnection = $conn
Dim $hardware = "idcy_dept,idcy_user_info"
$RS.open("select * from " & $hardware & " where " & "idcy_dept.bmdm=idcy_user_info.bmdm")
Local $n = 0
While Not $RS.eof And Not $RS.bof
GUICtrlSetData($Combo1, $RS.Fields(2).value)
$n += 1
$RS.movenext
WEnd
$RS.close
GUICtrlSetState($Combo1, $GUI_ENABLE)
EndFunc ;==>Button1
Func Combo1()
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("driver={SQL Server};server=" & GUICtrlRead($Input1) & ";uid=" & GUICtrlRead($Input2) & ";pwd=" & GUICtrlRead($Input3) & ";database=" & GUICtrlRead($Input4) & "")
$RS.ActiveConnection = $conn
Dim $hardware = "idcy_dept,idcy_user_info"
$RS.open("select * from " & $hardware & " where " & "(idcy_dept.bmdm=idcy_user_info.bmdm) and (idcy_dept.name=" & "'" & GUICtrlRead($Combo1) & "'" & ")")
Local $n = 0
While Not $RS.eof And Not $RS.bof
GUICtrlSetData($Combo2, $RS.Fields(7).value)
$n += 1
$RS.movenext
WEnd
$RS.close
GUICtrlSetState($Combo2, $GUI_ENABLE)
EndFunc ;==>Combo1
Func Combo2()
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("driver={SQL Server};server=" & GUICtrlRead($Input1) & ";uid=" & GUICtrlRead($Input2) & ";pwd=" & GUICtrlRead($Input3) & ";database=" & GUICtrlRead($Input4) & "")
$RS.ActiveConnection = $conn
Dim $hardware = "idcy_dept,idcy_user_info"
$RS.open("select * from " & $hardware & " where (idcy_dept.bmdm=idcy_user_info.bmdm) and (idcy_dept.name=" & "'" & GUICtrlRead($Combo1) & "') and (idcy_user_info.user_sex=" & "'" & GUICtrlRead($Combo2) & "')")
Local $n = 0
While Not $RS.eof And Not $RS.bof
GUICtrlSetData($Combo3, $RS.Fields(5).value)
$n += 1
$RS.movenext
WEnd
$RS.close
GUICtrlSetState($Combo3, $GUI_ENABLE)
EndFunc ;==>Combo2
Func Close()
Exit
EndFunc ;==>Close