📄 frmdataenv.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
BackColor = &H80000009&
BorderStyle = 0 'None
Caption = "登录"
ClientHeight = 3825
ClientLeft = 0
ClientTop = -105
ClientWidth = 6840
Icon = "frmDataEnv.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3825
ScaleWidth = 6840
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 2160
Top = 3360
Visible = 0 'False
Width = 2415
_ExtentX = 4260
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drilling.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drilling.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from admin "
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame frmLogin
BackColor = &H00E0E0E0&
Caption = "登录"
Height = 1455
Left = 1200
TabIndex = 7
Top = 1800
Width = 4335
Begin VB.TextBox txtUser
DataSource = "Adodc1"
Height = 345
Left = 1080
TabIndex = 3
Top = 360
Width = 1485
End
Begin VB.TextBox txtPwd
DataSource = "Adodc1"
Height = 345
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 4
Top = 885
Width = 1485
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 390
Left = 2880
TabIndex = 5
Top = 360
Width = 900
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 2880
TabIndex = 6
Top = 840
Width = 900
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackColor = &H00E0E0E0&
Caption = "口令:"
Height = 195
Index = 1
Left = 540
TabIndex = 9
Top = 915
Width = 540
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackColor = &H00E0E0E0&
Caption = "用户名:"
Height = 195
Index = 0
Left = 360
TabIndex = 8
Top = 390
Width = 720
End
End
Begin VB.Frame fraUser
BackColor = &H00E0E0E0&
Caption = "选择身份"
Height = 735
Left = 1200
TabIndex = 0
Top = 960
Width = 4335
Begin VB.OptionButton optUserType
BackColor = &H00E0E0E0&
Caption = "管理员"
Height = 375
Index = 0
Left = 360
TabIndex = 1
Top = 240
Width = 1455
End
Begin VB.OptionButton optUserType
BackColor = &H00E0E0E0&
Caption = "学生"
Height = 375
Index = 1
Left = 2760
TabIndex = 2
Top = 240
Width = 1095
End
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Height = 495
Left = 6240
TabIndex = 10
Top = 0
Width = 615
End
Begin VB.Image Image1
Height = 3855
Index = 1
Left = 0
Picture = "frmDataEnv.frx":F84A
Stretch = -1 'True
Top = 0
Width = 6855
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'表示当前用户登录所选择的身份,即用户类型, 0-表示管理员;1-表示学生
Dim mnUserType As Integer
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
'取得用户输入的用户名和密码
Dim user As String, pwd As String
user = txtUser
pwd = txtPwd
'根据不同的身份,选择不同的表用以查询
Dim r As New ADODB.Recordset
Set r = Adodc1.Recordset
Dim strSQL As String
Select Case mnUserType
Case 0: '若身份为管理员
strSQL = "select * from admin where name='" & user & "' and pwd='" & pwd & "'"
Case 1: '若身份为学生
strSQL = "select * from admin where name='" & user & "' and pwd='" & pwd & "'"
End Select
On Error Resume Next
'查询adodc1的状态,如果已经打开,则先关闭
If r.State = adStateOpen Then r.Close
r.Open strSQL '根据strSQL的内容刷新adodc1
'用户密码错误的次数,如果错误次数超过3次,则退出系统
Static nTryCount As Integer
If r.EOF Then '登录失败
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
txtUser.Text = ""
txtPwd.Text = ""
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox "您无权操作本系统!再见!", vbCritical, "无权限"
Unload Me
End If
Else '登陆成功
'显示frmmain窗体, 并将用户类型和用户名传到frmmain窗体中的mnUserType, msUserName中
Load frmmain
With frmmain
.mnUserType = mnUserType
.msUserName = pwd
.Show
End With
loginname = cg1.Fields(0)
Unload Me
End If
End Sub
Private Sub Form_Load()
optUserType(0).Value = True
End Sub
Private Sub Label1_Click()
End
End Sub
Private Sub optUserType_Click(Index As Integer)
mnUserType = Index
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -