📄 login.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "请登录"
ClientHeight = 2100
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 4695
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1240.75
ScaleMode = 0 'User
ScaleWidth = 4408.349
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 390
Left = 3480
TabIndex = 3
Top = 480
Width = 1020
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 3480
TabIndex = 4
Top = 1200
Width = 1020
End
Begin VB.Frame fraLogin
Caption = "登录"
Height = 1935
Left = 120
TabIndex = 5
Top = 0
Width = 3015
Begin VB.TextBox txtPwd
Height = 345
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 1
Top = 900
Width = 1605
End
Begin VB.ComboBox cboUserType
Height = 300
ItemData = "Login.frx":0000
Left = 1080
List = "Login.frx":0002
Style = 2 'Dropdown List
TabIndex = 2
Top = 1440
Width = 1605
End
Begin VB.TextBox txtUser
Height = 345
Left = 1080
TabIndex = 0
Top = 360
Width = 1605
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "口令:"
Height = 195
Index = 1
Left = 540
TabIndex = 8
Top = 975
Width = 540
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "选择身份:"
Height = 180
Index = 2
Left = 180
TabIndex = 7
Top = 1500
Width = 900
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "用户名:"
Height = 195
Index = 0
Left = 360
TabIndex = 6
Top = 435
Width = 720
End
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo errHandler
Set gConn = New ADODB.Connection '数据库连接
Dim strConn As String
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Supmarket;Data Source=(local);UID=Admin;PWD=111"
gConn.Open strConn, "Admin", "111"
Dim user As String, pwd As String '登陆界面初始化
user = txtUser
pwd = txtPwd
gnUserType = cboUserType.ListIndex
gsUserName = user
Dim strSQL As String
strSQL = "select * from userlist where 用户名= '" & user & "' and 用户密码 ='" & pwd & "' and 用户类型=" & gnUserType
Dim r As New ADODB.Recordset '定义数据记录集
r.Open strSQL, gConn, adOpenStatic
Static nTryCount As Integer
If r.EOF Then
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox "您无权操作本系统!再见!", vbCritical, "无权限"
Unload Me
gConn.Close
End If
Else
Unload Me
frmMain.Show
End If
r.Close
Exit Sub
errHandler:
MsgBox Err.Description, vbCritical, "错误"
End Sub
Private Sub Form_Load()
cboUserType.Clear
cboUserType.AddItem "管理人员", 0
cboUserType.AddItem "仓管人员", 1
cboUserType.AddItem "销售人员", 2
cboUserType.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -