📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "用户登录"
ClientHeight = 3015
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3975
MaxButton = 0 'False
MinButton = 0 'False
NegotiateMenus = 0 'False
OLEDropMode = 1 'Manual
ScaleHeight = 1781.361
ScaleMode = 0 'User
ScaleWidth = 3732.31
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtUserName
Height = 345
Left = 1410
TabIndex = 1
Top = 600
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 390
Left = 600
TabIndex = 4
Top = 1800
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 2280
TabIndex = 5
Top = 1800
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1410
PasswordChar = "*"
TabIndex = 3
Top = 990
Width = 2325
End
Begin VB.Label Label3
Alignment = 2 'Center
BackColor = &H00FF8080&
BorderStyle = 1 'Fixed Single
Caption = "神兵国际广告(北京)有限公司广告系统 beta1"
ForeColor = &H8000000E&
Height = 255
Left = 0
TabIndex = 7
Top = 0
Width = 4095
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00FF8080&
BorderStyle = 1 'Fixed Single
Caption = " Copyright 2003 by hoga All Right Reserved."
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 255
Left = 0
TabIndex = 6
Top = 2760
Width = 4095
End
Begin VB.Label lblLabels
Caption = "用户名称(&U):"
Height = 270
Index = 0
Left = 225
TabIndex = 0
Top = 615
Width = 1080
End
Begin VB.Label lblLabels
Caption = "密 码(&P):"
Height = 270
Index = 1
Left = 225
TabIndex = 2
Top = 1005
Width = 1080
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public LoginSucceeded As Boolean
Public username As String
Public level As String
Public id As String
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload frmmain
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim password As String
Dim sql As String
Dim str As String
username = Trim(txtUserName.Text)
password = Trim(txtPassword.Text)
'检查正确的密码
Dim con As ADODB.Connection
Set con = New Connection
str = "provider=microsoft.jet.oledb.4.0;Data Source=" & App.Path & "\database.mdb"
con.Open str
Dim rs As ADODB.Recordset
Set rs = New Recordset
sql = "select * from userlogin where name='" & username & "' and password='" & password & "'"
rs.Open sql, con, 3, 2
If Not rs.EOF And Not rs.BOF Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
LoginSucceeded = True
id = rs!id
level = rs!level
username = rs!Name
rs!lastlogintime = Now
rs.Update
Me.Hide
frmmain.Enabled = True
frmmain.Show
frmmain.Label2.Caption = UCase(frmLogin.username) & "您辛苦咯,请选择您要操作的内容!"
If level = "ADMIN" Then
frmmain.Command1.Visible = True
frmmain.Command2.Visible = True
frmmain.Command3.Visible = True
frmmain.Command4.Visible = True
frmmain.Command5.Visible = True
frmmain.Command6.Visible = True
frmmain.Command7.Visible = True
frmmain.Command8.Visible = True
frmmain.Command9.Visible = True
frmmain.Command10.Visible = True
frmmain.Command11.Visible = True
frmmain.Command12.Visible = True
ElseIf level = "EDITER" Then
frmmain.Command1.Visible = True
frmmain.Command2.Visible = True
frmmain.Command3.Visible = True
frmmain.Command6.Visible = True
frmmain.Command7.Visible = True
frmmain.Command8.Visible = True
Else
frmmain.Command3.Visible = True
frmmain.Command4.Visible = True
frmmain.Command6.Visible = True
frmmain.Command9.Visible = True
frmmain.Command10.Visible = True
frmmain.Command11.Visible = True
frmmain.Command12.Visible = True
End If
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
txtUserName.Text = "admin"
txtPassword.Text = "admin"
frmmain.Show
frmmain.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload frmmain
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -