📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BackColor = &H00E0E0E0&
BorderStyle = 3 'Fixed Dialog
ClientHeight = 3900
ClientLeft = 45
ClientTop = 45
ClientWidth = 4590
ControlBox = 0 'False
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmLogin.frx":0000
MaxButton = 0 'False
MinButton = 0 'False
Picture = "frmLogin.frx":000C
ScaleHeight = 7500
ScaleMode = 0 'User
ScaleWidth = 4590
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Timer tmrLoad
Interval = 50
Left = 3840
Top = 1200
End
Begin VB.CommandButton CmdExit
BackColor = &H00C0FFC0&
Caption = "退出(&Q)"
Height = 350
Left = 2400
Style = 1 'Graphical
TabIndex = 5
Top = 2025
Visible = 0 'False
Width = 1095
End
Begin VB.CommandButton cmdOK
BackColor = &H00C0FFC0&
Caption = "登录(&L)"
Default = -1 'True
Height = 350
Left = 1200
Style = 1 'Graphical
TabIndex = 4
Top = 2025
Visible = 0 'False
Width = 1095
End
Begin VB.ComboBox cboName
BackColor = &H00C0E0FF&
ForeColor = &H00400040&
Height = 300
ItemData = "frmLogin.frx":291C
Left = 1320
List = "frmLogin.frx":291E
Style = 2 'Dropdown List
TabIndex = 3
Top = 1200
Visible = 0 'False
Width = 2175
End
Begin VB.TextBox txtPassword
BackColor = &H00C0E0FF&
ForeColor = &H00400040&
Height = 300
IMEMode = 3 'DISABLE
Left = 1320
MaxLength = 50
PasswordChar = "*"
TabIndex = 0
Top = 1560
Visible = 0 'False
Width = 2175
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
ForeColor = &H00C00000&
Height = 180
Left = 240
TabIndex = 6
Top = 1080
Width = 90
End
Begin VB.Label lblName
AutoSize = -1 'True
BackColor = &H00C0FFFF&
BackStyle = 0 'Transparent
Caption = "用户名:"
ForeColor = &H00800000&
Height = 180
Left = 600
TabIndex = 2
Top = 1200
Visible = 0 'False
Width = 630
End
Begin VB.Label lblPassword
AutoSize = -1 'True
BackColor = &H00C0FFFF&
BackStyle = 0 'Transparent
Caption = "密 码:"
ForeColor = &H00800000&
Height = 180
Left = 600
TabIndex = 1
Top = 1560
Visible = 0 'False
Width = 630
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim intCount As Integer
Dim gstrCN As String
Private Sub cmdCancel_Click()
frmInfo.Enabled = True
Unload Me
End Sub
Private Sub cmdExit_Click()
Call Shutdown
End Sub
Private Sub cmdOK_Click()
On Error GoTo loadErr
If Len(txtPassword.Text) = 0 Then
MsgBox "输入密码不能为空!"
txtPassword.SetFocus
Exit Sub
Else
With adoLink
If .State = adStateOpen Then .Close
.Open "select * from 系统管理员 where 用户名='" & cboName.Text & "'", adoConn, adOpenDynamic, adLockPessimistic, adCmdText
If .EOF = False Then
If Trim(txtPassword.Text) = Trim(.Fields("密码")) Then
gstrName = Trim(cboName.Text)
gblnPopedom = .Fields("权限")
Unload Me
frmInfo.Show
Else
MsgBox "密码错误!", vbOKOnly + vbCritical, App.Title
txtPassword.Text = ""
txtPassword.SetFocus
End If
Else
Unload Me
frmInfo.Show
End If
End With
End If
Exit Sub
loadErr:
MsgBox "错误:" & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "运行错误"
End Sub
Private Sub Form_Load()
On Error Resume Next
lblTitle.Caption = "欢迎使用"
End Sub
Private Sub loadUser()
On Error GoTo loadErr
With adoLink
intCount = 0
Do Until .EOF
cboName.AddItem .Fields("用户名"), intCount
.MoveNext
intCount = intCount + 1
Loop
End With
Exit Sub
loadErr:
MsgBox "错误:" & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "运行错误"
End Sub
Private Sub tmrLoad_Timer()
On Error GoTo ErrLink
With adoConn
.CursorLocation = adUseClient
gstrCN = gstrLink
.Open gstrCN
End With
With adoLink
If .State = adStateOpen Then .Close
.Open "select * from 系统管理员 order by 用户名", adoConn, adOpenDynamic, adLockPessimistic, adCmdText
End With
EndTimer:
If gblnLoadError = False Then
Me.Hide
lblTitle.Visible = False
lblName.Visible = True
lblPassword.Visible = True
txtPassword.Visible = True
cmdOK.Visible = True
CmdExit.Visible = True
Me.Height = 2600
Me.Caption = App.Title & " 04计文一班 王立成 035"
Call loadUser
cboName.Visible = True
Me.Show
Me.Refresh
If cboName.ListCount > 0 Then cboName.ListIndex = 0
txtPassword.SetFocus
Else
Unload Me
End If
tmrLoad.Enabled = False
Exit Sub
ErrLink:
gblnLoadError = True
MsgBox "错误:" & Err.Number & vbCrLf & Err.Description & vbCrLf & "请设置数据库连接项或与网络管理员联系!", vbOKOnly + vbExclamation, App.Title
GoTo EndTimer
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -