#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Local Const $sFileName = "OITool.ini"
Local $sFileOpen = FileOpen ($sFileName)
Local $sType, $sFile, $sPassowrd, $Data_v
Local $sRead = IniRead($sFileName, "General", "Setup", "Default Value")
If $sRead = "1" Then
;~ MsgBox(0,"配制文件已存在","如需修改请删除配制文件。",5)
;~ Exit
EndIf
#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("OIT Auto", 356, 186, -1, -1)
$Database = GUICtrlCreateLabel("数据库类型", 50, 20, 64, 21)
$Datebasetype = GUICtrlCreateCombo("", 120, 16, 217, 21);~, BitOR($ES_READONLY,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "ACCESS|MSSQL", "ACCESS")
$Label1 = GUICtrlCreateLabel("数据库名称或路径", 15, 68, 100, 21)
$File_path = GUICtrlCreateInput("", 120, 64, 185, 21)
;~ GUICtrlSetState($File_path, $GUI_DROPACCEPTED)
$Select_file = GUICtrlCreateButton("选择", 308, 64, 30, 21)
$EnterPassLabel = GUICtrlCreateLabel("MSSQL密码", 57, 108, 65, 17, 0)
$PasswordEdit = GUICtrlCreateInput("", 120, 104, 217, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
;~ GUICtrlSetState(-1, $GUI_DISABLE)
$ButtonSave = GUICtrlCreateButton("保存[&S]", 182, 152, 75, 25)
$ButtonExit = GUICtrlCreateButton("退出[&C]", 263, 152, 75, 25)
GUISetState(@SW_SHOW, $hGUI)
#EndRegion ### END Koda GUI section ###
While 1
Local $sMessage = "请选择 MDB 文件"
$Data_v = GUICtrlRead($Datebasetype)
Switch $Data_v
Case "MSSQL"
_GUICtrlEdit_SetReadOnly($PasswordEdit, False)
Case "ACCESS"
_GUICtrlEdit_SetReadOnly($PasswordEdit, True)
EndSwitch
$nMsg = GUIGetMsg()
If $nMsg=$Select_file And $Data_v <> "MSSQL" Then
Local $sFileOpenDialog = FileOpenDialog($sMessage, "", "(*.mdb)", $FD_FILEMUSTEXIST)
GUICtrlSetData($File_path, $sFileOpenDialog)
EndIf
Switch $nMsg
Case $ButtonSave
_SaveFile()
Case $GUI_EVENT_CLOSE,$ButtonExit
ExitLoop
Case $GUI_EVENT_DROPPED
EndSwitch
FileClose($sFileOpen)
WEnd
GUIDelete($hGUI)
Func _SaveFile()
$sType = GUICtrlRead($Datebasetype)
$sFile = GUICtrlRead($File_path)
$sPassowrd = GUICtrlRead($PasswordEdit)
IniWrite($sFileName, "General", "Setup", "1")
IniWrite($sFileName, "DataType", "Type", $sType)
IniWrite($sFileName, "FilePath", "Path", $sFile)
IniWrite($sFileName, "Password_Set", "Password", $sPassowrd)
EndFunc ;==>_SaveFile