📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 4 'Fixed ToolWindow
Caption = "供应商与客户关系管理"
ClientHeight = 4365
ClientLeft = 45
ClientTop = 285
ClientWidth = 7110
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
Picture = "frmLogin.frx":0000
ScaleHeight = 4365
ScaleWidth = 7110
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox NowPwd
Height = 330
IMEMode = 3 'DISABLE
Left = 4200
PasswordChar = "*"
TabIndex = 1
Text = "admin"
Top = 1695
Width = 1935
End
Begin VB.TextBox NowUser
Height = 330
Left = 4200
TabIndex = 0
Text = "admin"
Top = 1200
Width = 1935
End
Begin VB.CommandButton Command1
Caption = "确定"
Default = -1 'True
Height = 330
Left = 3435
TabIndex = 2
Top = 2295
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 330
Left = 4995
TabIndex = 3
Top = 2295
Width = 1095
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "销售客户信息管理"
BeginProperty Font
Name = "华文琥珀"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFF80&
Height = 495
Left = 1320
TabIndex = 9
Top = 3000
Width = 3135
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "客户服务信息"
BeginProperty Font
Name = "华文琥珀"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFF80&
Height = 495
Left = 4440
TabIndex = 8
Top = 3600
Width = 2655
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "供应商信息管理"
BeginProperty Font
Name = "华文琥珀"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFF80&
Height = 495
Left = 360
TabIndex = 7
Top = 1920
Width = 2775
End
Begin VB.Label Label2
Alignment = 2 'Center
BackColor = &H8000000A&
BackStyle = 0 'Transparent
Caption = "密 码:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3240
TabIndex = 6
Top = 1755
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H8000000A&
BackStyle = 0 'Transparent
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3240
TabIndex = 5
Top = 1260
Width = 1215
End
Begin VB.Label Label3
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "客户关系管理系统"
BeginProperty Font
Name = "华文彩云"
Size = 24
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 615
Left = 2640
TabIndex = 4
Top = 360
Width = 4095
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim CnnBool As Boolean '判断数据库连接是否成功
Dim Rst As New ADODB.Recordset
Dim strSQL As String
Dim rstCount As Integer '记录数据集中记录条数
On Error GoTo ErrorExit '错误处理
If NowUser.Text = "" Then '登录名不能为空
MsgBox "请输入登录者用户名。", vbExclamation, Me.Caption
Me.NowUser.SetFocus
Exit Sub
End If
Screen.MousePointer = vbHourglass
CnnBool = ConnectDB '连接数据库
If CnnBool = False Then '数据库连接失败
Unload Me
Exit Sub
End If
strSQL = "SELECT * FROM tb_Login WHERE LoginID ='" & NowUser.Text & "'"
Rst.Open strSQL, CnnDatabase, adOpenDynamic, adLockReadOnly '执行选取记录集的SQL语句
rstCount = 0
Do While Rst.EOF = False '计算记录集中记录数
rstCount = rstCount + 1
Rst.MoveNext
Loop
If rstCount = 0 Then '判断用户名是否存在:记录集中记录应不为0条
MsgBox "无此用户!"
CnnDatabase.Close '关闭数据库
Screen.MousePointer = vbDefault
Me.NowUser.Text = ""
Me.NowPwd.Text = ""
Me.NowUser.SetFocus
Exit Sub
End If
If Rst.RecordCount > 1 Then '记录集中记录数不唯一
MsgBox "数据库错误:用户有重复!"
CnnDatabase.Close '关闭数据库
Screen.MousePointer = vbDefault
Unload Me '关闭系统
Exit Sub
End If
Rst.MoveFirst
If IsNull(Rst.Fields("LoginPwd").Value) Then '判断用户密码是否正确
If NowPwd.Text <> "" Then
MsgBox "用户密码不正确!"
CnnDatabase.Close
Screen.MousePointer = vbDefault
Me.NowPwd.Text = ""
Me.NowPwd.SetFocus
Exit Sub
End If
Else
If NowPwd.Text <> Rst.Fields("LoginPwd").Value Then
MsgBox "用户密码不正确!"
CnnDatabase.Close
Screen.MousePointer = vbDefault
Me.NowPwd.Text = ""
Me.NowPwd.SetFocus
Exit Sub
End If
End If
strNowUser = Rst.Fields("UserName").Value '记下当前登录的用户名
Screen.MousePointer = vbDefault
Set Rst = Nothing '关闭动态的记录集
Unload Me '关闭当前窗口
frmMDIMain.Show '显示主窗口
Exit Sub
ErrorExit:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbInformation, Me.Caption
Set Rst = Nothing '关闭记录集
Set CnnDatabase = Nothing '关闭数据库
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Height = 4700
Me.Width = 7200
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -