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

📄 frmlogin.frm

📁 商品销售管理系统,用Accsee作为数据库,VB编程,可直接运行,用以作为课程设计足以!
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Login"
   ClientHeight    =   1470
   ClientLeft      =   2835
   ClientTop       =   3480
   ClientWidth     =   3885
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   868.525
   ScaleMode       =   0  'User
   ScaleWidth      =   3647.805
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox txtUserName 
      Height          =   270
      Left            =   1440
      TabIndex        =   1
      Top             =   120
      Width           =   2325
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确认"
      Default         =   -1  'True
      Height          =   390
      Left            =   720
      TabIndex        =   4
      Top             =   960
      Width           =   1140
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   390
      Left            =   2040
      TabIndex        =   5
      Top             =   960
      Width           =   1140
   End
   Begin VB.TextBox txtPassword 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   1440
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   525
      Width           =   2325
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "用户名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   240
      Index           =   0
      Left            =   465
      TabIndex        =   0
      Top             =   120
      Width           =   720
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "密  码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   240
      Index           =   1
      Left            =   480
      TabIndex        =   2
      Top             =   540
      Width           =   720
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MyDB As Database
Dim MyRecord As Recordset
Dim TestCounter As Integer
Public IsAdmin As Boolean   '记录当前用户身份,IsAdmin为true表示超级用户,为false表示一般用户

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    If txtUserName.Text = "" Then   '判断输入的用户名是否为空
        MsgBox "用户名不能为空!"
        txtUserName.SetFocus
    Else
        MyRecord.Index = "PrimaryKey"   '设置索引为"PrimaryKey",字段名为"DBUserName"
        MyRecord.Seek "=", txtUserName.Text
        If MyRecord.NoMatch Then    '没有找到输入的用户名
            MsgBox "没有" + txtUserName.Text + "这个用户名!"
            txtUserName.SetFocus
            SendKeys "{Home}+{End}"
        Else
            '判断输入的密码与数据库中的是否一致
            If txtPassword.Text = MyRecord.Fields("DBPassWord") Or (IsNull(MyRecord.Fields("DBPassWord")) And txtPassword.Text = "") Then
                IsAdmin = MyRecord.Fields("DBIsAdmin")  '当密码正确后,记录用户权限
                MainForm.Show
                Unload Me
            Else
                If TestCounter = 0 Then 'TestCounter为输入错误计数器,当输入密码五次错误后,程序自动退出
                    Unload Me
                Else
                    MsgBox "密码错误,请重试!" & Chr(13) & Chr(10) & " 您还有 " & TestCounter & " 次机会"
                    TestCounter = TestCounter - 1
                    txtPassword.SetFocus
                    SendKeys "{Home}+{End}"
                End If
            End If
        End If
    End If
End Sub



Private Sub Form_Load()
'    Me.Visible = True
'    MoveToCenter

    Set MyDB = OpenDatabase(VB.App.Path + "\MySampleDB.mdb", False, False)
    Set MyRecord = MyDB.OpenRecordset("用户列表")
    TestCounter = 4
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MyRecord.Close
    MyDB.Close
End Sub


Private Sub txtUserName_KeyDown(KeyCode As Integer, Shift As Integer)
             If KeyCode = 13 Then
                txtPassword.SetFocus
             End If
End Sub

⌨️ 快捷键说明

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