📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
ClientHeight = 3405
ClientLeft = 2790
ClientTop = 3150
ClientWidth = 5250
ControlBox = 0 'False
LinkTopic = "Form1"
Moveable = 0 'False
ScaleHeight = 2011.784
ScaleMode = 0 'User
ScaleWidth = 4929.465
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "退出"
DownPicture = "frmLogin.frx":0000
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2760
Picture = "frmLogin.frx":38444
Style = 1 'Graphical
TabIndex = 3
Top = 2520
Width = 1455
End
Begin VB.CommandButton Command1
BackColor = &H00808080&
Caption = "登录"
Default = -1 'True
DownPicture = "frmLogin.frx":39A7E
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 960
Picture = "frmLogin.frx":71EC2
Style = 1 'Graphical
TabIndex = 2
Top = 2520
Width = 1455
End
Begin VB.TextBox Text2
ForeColor = &H00000000&
Height = 270
IMEMode = 3 'DISABLE
Left = 2640
PasswordChar = "*"
TabIndex = 0
Top = 1920
Width = 1575
End
Begin VB.TextBox Text1
Height = 285
Left = 2640
TabIndex = 7
Top = 1560
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 315
Left = 2640
TabIndex = 6
Top = 1200
Width = 1575
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "密 码(&P):"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 4
Top = 1920
Width = 1815
End
Begin VB.Label Label1
BackColor = &H80000004&
BackStyle = 0 'Transparent
Caption = "用户名称(&U):"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 1
Top = 1560
Width = 1695
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "用户类别(&B):"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 5
Top = 1200
Width = 1695
End
Begin VB.Image Image1
Height = 3660
Left = -120
Picture = "frmLogin.frx":734FC
Top = -120
Width = 5490
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
Private Sub Combo1_Click()
If Combo1.Text = "管理员" Then
Text1.Text = "administrator"
Text1.Enabled = False
Text2.SetFocus
End If
If Combo1.Text = "一般用户" Then
Text1.Enabled = True
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" Then
MsgBox "请选择用户类别"
Exit Sub
End If
Set rsuser = New ADODB.Recordset
rsuser.Open "select * from userinfo where username='" + Text1.Text + "'", cn, adOpenStatic, adLockOptimistic
gusername = Text1.Text
If rsuser.RecordCount > 0 Then
'检查正确的密码
If Text2.Text = rsuser.Fields(1) Then
' If Combo1.Text = "管理员" And Text1 = "administrator" Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
'gusername = rsuser.Fields(0)
LoginSucceeded = True
Me.Hide
frmmain.Show
Else
MsgBox "无效的密码 ,请重试!", , "登录"
Text2.SetFocus
SendKeys "{Home}+{End}"
End If
Else
MsgBox "请输入有效的用户名与密码!"
Text1.Text = ""
Text2.Text = ""
Text2.SetFocus
End If
rsuser.Close
Set rsuser = Nothing
End Sub
Private Sub Command2_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
End
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
'cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ok;Initial Catalog=hhhh;Data Source=QQ", "sa", ""
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ok;Initial Catalog=man;Data Source=75DE96E8084748F", "sa", ""
'cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=man;Data Source=75DE96E8084748F", "sa", """"
DataEnvironment1.人事档案管理.ConnectionString = cn.ConnectionString
Combo1.AddItem "一般用户"
Combo1.AddItem "管理员"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -