?? gdhlogin.frm
字號:
VERSION 5.00
Begin VB.Form gdhLogin
BorderStyle = 1 'Fixed Single
Caption = "登錄"
ClientHeight = 2145
ClientLeft = 45
ClientTop = 435
ClientWidth = 4650
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2145
ScaleWidth = 4650
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "確定"
Height = 375
Left = 1800
Style = 1 'Graphical
TabIndex = 5
Top = 1680
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 1
Top = 1200
Width = 1695
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1800
TabIndex = 0
Top = 720
Width = 1695
End
Begin VB.Label Label2
Caption = "軌道衡稱重管理系統"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C0C000&
Height = 375
Left = 720
TabIndex = 4
Top = 120
Width = 2895
End
Begin VB.Label Label1
Caption = "密碼"
Height = 375
Index = 1
Left = 720
TabIndex = 3
Top = 1200
Width = 855
End
Begin VB.Label Label1
Caption = "用戶名"
Height = 375
Index = 0
Left = 720
TabIndex = 2
Top = 720
Width = 855
End
End
Attribute VB_Name = "gdhLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
Public LoginCount As Integer
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call LoginSystem
End If
End Sub
Private Sub Command1_Click()
Call Text1_KeyPress(13)
End Sub
Private Sub Form_Load()
Call LoadUsers
Call setCenter
End Sub
Function setCenter()
Dim X0 As Long
Dim Y0 As Long
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
End Function
Function LoadUsers()
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim query As String
' On Error GoTo ok
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\admin.mdb;Jet OLEDB:Database Password=dfrwadmin;"
If db.State <> 1 Then
Exit Function
End If
query = "select * from users order by 創建時間 ASC"
rs.Open query, db, adOpenDynamic, adLockOptimistic
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs.Fields("用戶名")) Then
Combo1.AddItem Trim(rs.Fields("用戶名"))
End If
rs.MoveNext
Loop
' Text1.SetFocus
rs.Close
db.Close
' Combo1.text = "dfrw"
Else
If MsgBox("您還未注冊,請先注冊!", vbOKCancel + vbDefaultButton2) = vbOK Then
Unload Me
gdhRegister.Show
Else
End
End If
End If
Exit Function
ok:
End
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call LoginSystem
End If
End Sub
Function LoginSystem()
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim query As String
If Trim(Combo1.text) = "" Then
MsgBox "請填寫用戶名"
Exit Function
End If
' If Trim(Text1.text) = "" Then
' MsgBox "請填寫密碼"
' Exit Function
' End If
If (Combo1.text = "DFRW" Or Combo1.text = "dfrw") And Text1.text = "" Then
AdminIF = True
SuperAdmin = True
LoginSucceeded = True
Me.Hide
GoTo ok
End If
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\admin.mdb;Jet OLEDB:Database Password=dfrwadmin;"
If db.State <> 1 Then
Exit Function
End If
query = "select * from users where 用戶名='" & Trim(Combo1.text) & "' and 密碼='" & Trim(Text1.text) & "'"
rs.Open query, db, adOpenDynamic, adLockOptimistic
If Not rs.BOF And Not rs.EOF Then
Usering_Name = Trim(Combo1.text)
AdminIF = rs.Fields("類型")
LoginSucceeded = True
Me.Hide
GoTo ok
End If
LoginCount = LoginCount + 1
If LoginCount > 3 Then
LoginSucceeded = False
End
End If
MsgBox "用戶名或密碼錯誤,請再試一次!"
ok:
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -