📄 frmlogin1.frm
字号:
VERSION 5.00
Begin VB.Form frmlogin
BackColor = &H00FFC0C0&
Caption = "身份验证"
ClientHeight = 2910
ClientLeft = 5055
ClientTop = 3450
ClientWidth = 4245
ControlBox = 0 'False
Icon = "frmlogin1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 2910
ScaleWidth = 4245
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtPwd
Height = 495
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 5
Top = 2040
Width = 1335
End
Begin VB.Frame frmLogin
BackColor = &H00FFC0C0&
Caption = "系统登录"
Height = 1815
Left = 240
TabIndex = 1
Top = 960
Width = 3735
Begin VB.CommandButton cmdCancel
Height = 375
Left = 2400
Picture = "frmlogin1.frx":08CA
Style = 1 'Graphical
TabIndex = 11
Top = 1080
Width = 855
End
Begin VB.CommandButton Command1
Height = 375
Left = 2400
Picture = "frmlogin1.frx":1456
Style = 1 'Graphical
TabIndex = 10
Top = 720
Width = 855
End
Begin VB.CommandButton cmdOK
Height = 375
Left = 2400
Picture = "frmlogin1.frx":1FE2
Style = 1 'Graphical
TabIndex = 9
Top = 360
Width = 855
End
Begin VB.TextBox txtUser
Height = 495
Left = 840
TabIndex = 4
Top = 240
Width = 1335
End
Begin VB.Label lblPwd
BackColor = &H00FFC0C0&
Caption = "密码:"
Height = 375
Left = 240
TabIndex = 3
Top = 1080
Width = 615
End
Begin VB.Label lblUser
BackColor = &H00FFC0C0&
Caption = "用户名:"
Height = 255
Left = 120
TabIndex = 2
Top = 360
Width = 855
End
End
Begin VB.Frame frmUsertupe
BackColor = &H00FFC0C0&
Caption = "用户身份"
Height = 735
Left = 240
TabIndex = 0
Top = 120
Width = 3735
Begin VB.OptionButton OptUsertype
BackColor = &H00FFC0C0&
Caption = "收银员"
Height = 255
Index = 2
Left = 2280
TabIndex = 8
Top = 360
Width = 975
End
Begin VB.OptionButton OptUsertype
BackColor = &H00FFC0C0&
Caption = "仓储员"
Height = 255
Index = 1
Left = 1200
TabIndex = 7
Top = 360
Width = 855
End
Begin VB.OptionButton OptUsertype
BackColor = &H00FFC0C0&
Caption = "管理员"
Height = 255
Index = 0
Left = 240
TabIndex = 6
Top = 360
Width = 855
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
Dim rs_login As New ADODB.Recordset
Dim cnt As Integer
Dim sql As String
Private Sub Command1_Click()
txtUser = ""
txtPwd = ""
End Sub
Private Sub Form_Load()
ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=" & App.Path & "\supermarket1.mdb"
conn.Open ConnectionString
End Sub
Private Sub OptUsertype_Click(index As Integer)
usertype = index
End Sub
Private Sub cmdOK_Click()
Dim user As String, pwd As String
user = Trim(txtUser)
pwd = Trim(txtPwd)
Select Case usertype
Case 0:
sql = "select * from Operatoradmin where name='" & user & "'and pwd='" & pwd & "'"
Case 1:
sql = "select * from Operatorstore where name='" & user & "'and pwd='" & pwd & "'"
Case 2:
sql = "select * from Operatorsell where name='" & user & "'and pwd='" & pwd & "'"
End Select
On Error Resume Next
If rs_login.State = adStateOpen Then
rs_login.Close
End If
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF Then
MsgBox "对不起,无此用户或密码错误!", vbOKOnly + vbExclamation, "提示"
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
cnt = cnt + 1
If cnt > 3 Then
MsgBox "你无权操作本系统!", vbCritical, "错误"
Unload Me
End If
Else
username = user
userpwd = pwd
Unload Me
conn.Close
Select Case usertype
Case 0:
adminface.Show
Case 1:
storemain.Show
Case 2:
Form1.Show
End Select
End If
End Sub
Private Sub cmdcancel_Click()
conn.Close
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -