📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form login
BackColor = &H008080FF&
Caption = "用户登录"
ClientHeight = 3135
ClientLeft = 60
ClientTop = 345
ClientWidth = 4710
Icon = "Form2.frx":0000
LinkTopic = "form2"
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3135
ScaleWidth = 4710
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
BackColor = &H00C0C0FF&
Height = 3135
Left = 0
TabIndex = 0
Top = 0
Width = 4695
Begin VB.TextBox Text3
BackColor = &H00C0C0FF&
Height = 270
Left = 2760
TabIndex = 9
Top = 2760
Visible = 0 'False
Width = 1575
End
Begin VB.OptionButton Option2
BackColor = &H00C0C0FF&
Caption = "用户"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 255
Left = 2760
TabIndex = 8
Top = 1920
Width = 975
End
Begin VB.OptionButton Option1
BackColor = &H00C0C0FF&
Caption = "管理员"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 255
Left = 1200
TabIndex = 7
Top = 1920
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 2
Top = 1320
Width = 1935
End
Begin VB.CommandButton Command2
BackColor = &H00C0C0FF&
Caption = "取 消"
Default = -1 'True
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2520
MaskColor = &H00C0C0FF&
TabIndex = 6
Top = 2280
Width = 855
End
Begin VB.Data userData
Caption = "Data1"
Connect = "Access"
DatabaseName = "db2.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 1560
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "manager"
Top = 2640
Visible = 0 'False
Width = 1140
End
Begin VB.CommandButton Command1
BackColor = &H80000018&
Caption = "登 录"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 840
MaskColor = &H8000000A&
TabIndex = 3
Top = 2280
Width = 855
End
Begin VB.TextBox Text1
Height = 390
Left = 1680
TabIndex = 1
Top = 600
Width = 1935
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0FF&
Caption = "姓 名:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 240
Index = 0
Left = 600
TabIndex = 5
Top = 720
Width = 795
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0FF&
Caption = "密 码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 240
Index = 1
Left = 600
TabIndex = 4
Top = 1440
Width = 795
End
End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public jibie As String
Private Sub Command1_Click()
Dim ts As Recordset
Set ts = userData.Recordset
Dim condition As String
Dim condition1 As String
Dim condition2 As String
ts.MoveFirst
condition = "username='" & Text1.Text & "' And password='" & Text2.Text & "'"
userData.Recordset.FindFirst condition
If userData.Recordset.NoMatch Then
MsgBox "用户名或密码不正确,请重试!"
Text1.SetFocus
Exit Sub
Else
If Option1.Value = False Then
If Option2.Value = False Then
MsgBox "你还没有选择用户类型呢,请选择!"
Exit Sub
Else
Text3.Text = Option2.Caption
jibie = Text3.Text
userData.Recordset.MoveFirst
condition1 = "username='" & Text1.Text & "' And password='" & Text2.Text & "' and class='" & Text3.Text & "'"
userData.Recordset.FindFirst condition1
If Not userData.Recordset.NoMatch Then
Load MDIForm1
MDIForm1.Enabled = True
MDIForm1.Toolbar1.Buttons(1).Enabled = False
MDIForm1.Toolbar1.Buttons(5).Enabled = False
MDIForm1.用户管理.Enabled = False
MDIForm1.管理读者.Enabled = False
MDIForm1.激活卡号.Enabled = False
MDIForm1.图书管理.Enabled = False
MDIForm1.Show
Unload login
Else
MsgBox "用户类型选择不正确!请重试!"
Exit Sub
End If
End If
Else
Text3.Text = Option1.Caption
jibie = Text3.Text
userData.Recordset.MoveFirst
condition2 = "username='" & Text1.Text & "' And password='" & Text2.Text & "' and class='" & Text3.Text & "'"
userData.Recordset.FindFirst condition2
If Not userData.Recordset.NoMatch Then
Load MDIForm1
MDIForm1.Show
MDIForm1.Enabled = True
Unload login
Else
MsgBox "用户类型选择不正确!请重试!"
Exit Sub
End If
End If
End If
End Sub
Private Sub Command2_Click()
Unload login
Dim i As Integer
For i = 1 To 11 Step 1
MDIForm1.Toolbar1.Buttons(i).Enabled = True
Next
MDIForm1.图书管理.Enabled = True
MDIForm1.系统管理.Enabled = True
MDIForm1.读者管理.Enabled = True
MDIForm1.借书还书.Enabled = True
MDIForm1.帮助.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -