⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 登录.frm

📁 一间公司的管理系统的源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form denglu 
   Caption         =   "登录"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   Icon            =   "登录.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.ComboBox UserList 
      Height          =   300
      Left            =   1800
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   840
      Width           =   1575
   End
   Begin VB.CommandButton cmdLogin 
      Caption         =   "登录"
      Height          =   375
      Left            =   2400
      TabIndex        =   2
      Top             =   2160
      Width           =   975
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   375
      Left            =   1200
      TabIndex        =   3
      Top             =   2160
      Width           =   975
   End
   Begin VB.TextBox UserPass 
      Height          =   270
      Left            =   1800
      TabIndex        =   1
      Top             =   1440
      Width           =   1575
   End
   Begin VB.Label password 
      Caption         =   "密码:"
      Height          =   255
      Left            =   1080
      TabIndex        =   5
      Top             =   1440
      Width           =   615
   End
   Begin VB.Label username 
      Caption         =   "帐号:"
      Height          =   255
      Left            =   1080
      TabIndex        =   4
      Top             =   840
      Width           =   615
   End
End
Attribute VB_Name = "denglu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim InputTime As Integer '密码输入次数
Private Sub cmdExit_Click()
CloseDB
End
End Sub

Private Sub cmdLogin_Click()
If UserList.Text = "" Then
    MsgBox "请选择你的帐号!", vbOKOnly + vbExclamation, "系统登陆"
    UserList.SetFocus
    Exit Sub
ElseIf UserPass.Text = "" Then
    MsgBox "请输入你的密码!", vbOKOnly + vbExclamation, "系统登陆"
    UserPass.SetFocus
    Exit Sub
Else
    sql = "Select * from [用户登录] where [帐号]='" & UserList.Text & "' and [密码]='" & UserPass.Text & "'"
    rs.Open sql, conn, adOpenKeyset, adLockPessimistic
    
        If rs.Fields("是否禁用") = True Then
           rs.Close
           Set rs = Nothing
           MsgBox "该用户目前处于禁用状态,暂时无法登录!", vbOKOnly + vbInformation, App.Title
           UserPass.Text = ""
           UserList.SetFocus
           Exit Sub
        End If
            
        If UserPass.Text <> rs.Fields("密码") Then
        
            InputTime = InputTime + 1 '登录次数统计
            
            If InputTime >= 3 Then
                MsgBox "多次错误登录,再见!"
                rs.Close
                Set rs = Nothing
                Call CloseDB
                End
            End If
            
            rs.Close
            Set rs = Nothing
            MsgBox "你输入的密码不正确!" & vbCr & "你已试登录【" & InputTime & "】次!", vbOKOnly + vbInformation, App.Title
            UserPass.Text = ""
            UserPass.SetFocus
        Else
            Login = True
            ID = rs.Fields("id")
            User = rs.Fields("帐号")
            Level = rs.Fields("等级")
            rs.Fields("登录次数") = rs.Fields("登录次数") + 1
            rs.Fields("登录时间") = Now()
            rs.Update
            rs.Close
            Set rs = Nothing
            Call CloseDB
            
            Unload Me
            zhuyao.Show
            
            popTitle = "登录成功"
            popContent = "姓名:" & User & vbCr & vbCr & "登录时间:" & Now()
            tanchu.Show
        End If
End If

End Sub

Private Sub Form_Load()

Call SetCenter(Me)
Call dengluSet(Me)
Call OpenDB
InputTime = 0
sql = "Select [帐号] from [用户登录]"
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
TotalNum = rs.RecordCount
For i = 1 To TotalNum
  UserList.AddItem rs.Fields("帐号")
  rs.MoveNext
Next i
rs.Close
Set rs = Nothing
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call CloseSystem(UnloadMode, Cancel)
End Sub

Private Sub UserList_Click()
If UserList.Text <> "" Then
    UserPass.SetFocus
End If
End Sub

Private Sub UserPass_Change()
If Len(UserPass.Text) > 0 Then
  cmdLogin.Default = True
Else
  cmdLogin.Default = False
End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -