#region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_icon=C:\Windows\system32\SHELL32.dll|-3
#PRE_Outfile=H:\2225.exe
#PRE_Res_requestedExecutionLevel=None
#PRE_Run_Tidy=y
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $Uid
$mdb_pwd = ""
$mdb_path = "z.mdb"
$tblname = "zzm"
#region ### START Koda GUI section ###
$Form1 = GUICreate("登入框", 186, 131, -1, -1)
$Input1 = GUICtrlCreateInput("", 16, 16, 153, 21)
$Input2 = GUICtrlCreateInput("", 16, 52, 153, 21, $ES_PASSWORD)
$Button1 = GUICtrlCreateButton("注 册", 16, 88, 65, 25)
$Button2 = GUICtrlCreateButton("登 入", 104, 88, 65, 25)
$Form2 = GUICreate("注册框", 204, 215, -1, -1)
$Input01 = GUICtrlCreateInput("", 64, 16, 121, 21)
$Input02 = GUICtrlCreateInput("", 64, 54, 121, 21)
$Input03 = GUICtrlCreateInput("", 64, 93, 121, 21)
$Input04 = GUICtrlCreateInput("", 64, 131, 121, 21)
$Label1 = GUICtrlCreateLabel("用户名", 16, 20, 40, 17)
$Label2 = GUICtrlCreateLabel("密码", 16, 57, 28, 17)
$Label3 = GUICtrlCreateLabel("Q Q", 16, 95, 26, 17)
$Label4 = GUICtrlCreateLabel("E-mail", 16, 132, 34, 17)
$Button01 = GUICtrlCreateButton("提 交", 16, 168, 75, 25)
$Button02 = GUICtrlCreateButton("取 消", 112, 168, 75, 25)
#endregion ### END Koda GUI section #
GUISwitch($Form1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_SHOW, $Form2)
Case $Button2
If GUICtrlRead($Input1) = "" Then
MsgBox(64, "提示", "请输入用户名!", 5)
ElseIf GUICtrlRead($Input2) = "" Then
MsgBox(64, "提示", "请输入密码!", 5)
Else
login()
EndIf
Case $Button02
GUISetState(@SW_HIDE, $Form2)
Case $Button01
reg()
EndSwitch
WEnd
Func login()
$user1 = GUICtrlRead($Input1)
$pass1 = GUICtrlRead($Input2)
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("SELECT zzm.name, zzm.pass FROM zzm WHERE zzm.name=" & "'" & $user1 & "'")
If $RS.bof < 0 Then
MsgBox(64, "提示", "未注册用户,请先注册!", 5)
Else
$user2 = StringReplace($RS.Fields(0).value, " ", "")
$pass2 = StringReplace($RS.Fields(1).value, " ", "")
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
If $user1 = $user2 And $pass1 = $pass2 Then
$Uid = $user1
MsgBox(64, "登入口", "欢迎回来尊敬的 " & $Uid, 5)
GUISetState(@SW_HIDE, $Form1)
main()
Else
MsgBox(64, "错误", "密码错误!", 5)
EndIf
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndIf
EndFunc ;==>login
Func reg()
$reg_user = GUICtrlRead($Input01)
$reg_pass = GUICtrlRead($Input02)
$reg_qq = GUICtrlRead($Input03)
$reg_email = GUICtrlRead($Input04)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_path & ";Jet Oledb:Database Password=" & $mdb_pwd)
$addfld.Execute("insert into zzm (name,pass,qq,e_mail) values('" & $reg_user & "','" & $reg_pass & "','" & $reg_qq & "','" & $reg_email & "')")
$addfld.close
MsgBox(4096, "提示:", " 注册成功!")
GUISetState(@SW_HIDE, $Form2)
GUICtrlSetData($Input01, '')
GUICtrlSetData($Input02, '')
GUICtrlSetData($Input03, '')
GUICtrlSetData($Input04, '')
EndFunc ;==>reg
Func main()
$Form3 = GUICreate("主窗体 " & "当前用户: " & $Uid, 633, 447, -1, -1)
$Button001 = GUICtrlCreateButton("我只是个测试的!", 128, 120, 377, 161)
GUICtrlSetFont(-1, 24, 400, 0, "黑体")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button001
Exit
EndSwitch
WEnd
EndFunc ;==>main
论坛有例子 搜出来 |