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

📄 authentication1.frm

📁 simple supermarket for beginners
💻 FRM
字号:
VERSION 5.00
Begin VB.Form authentication 
   AutoRedraw      =   -1  'True
   BackColor       =   &H80000013&
   BorderStyle     =   0  'None
   Caption         =   "Login"
   ClientHeight    =   2235
   ClientLeft      =   0
   ClientTop       =   -105
   ClientWidth     =   4425
   ControlBox      =   0   'False
   Icon            =   "authentication.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "authentication.frx":000C
   ScaleHeight     =   2235
   ScaleWidth      =   4425
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.PictureBox cmddeluser 
      BackColor       =   &H000000FF&
      Height          =   1000
      Left            =   0
      ScaleHeight     =   945
      ScaleWidth      =   945
      TabIndex        =   4
      Top             =   1440
      Width           =   1000
   End
   Begin VB.PictureBox cmdregister 
      BackColor       =   &H000000FF&
      Height          =   1000
      Left            =   1440
      ScaleHeight     =   945
      ScaleWidth      =   945
      TabIndex        =   5
      Top             =   1320
      Width           =   1000
   End
   Begin VB.PictureBox cmdcancel 
      BackColor       =   &H000000FF&
      Height          =   1000
      Left            =   1680
      ScaleHeight     =   945
      ScaleWidth      =   945
      TabIndex        =   6
      Top             =   1560
      Width           =   1000
   End
   Begin VB.PictureBox xVistaForm1 
      BackColor       =   &H000000FF&
      Height          =   1000
      Left            =   1560
      ScaleHeight     =   945
      ScaleWidth      =   945
      TabIndex        =   7
      Top             =   1320
      Width           =   1000
   End
   Begin VB.TextBox txtname 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   6.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1320
      TabIndex        =   0
      Top             =   600
      Width           =   3015
   End
   Begin VB.TextBox txtpass 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   6.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000080&
      Height          =   315
      IMEMode         =   3  'DISABLE
      Left            =   1320
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1080
      Width           =   3015
   End
   Begin VB.PictureBox cmdok 
      BackColor       =   &H000000FF&
      Height          =   1000
      Left            =   1920
      ScaleHeight     =   945
      ScaleWidth      =   945
      TabIndex        =   8
      Top             =   1440
      Width           =   1000
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "User Name"
      BeginProperty Font 
         Name            =   "BankGothic Md BT"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   600
      Width           =   1095
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Password"
      BeginProperty Font 
         Name            =   "BankGothic Md BT"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   1080
      Width           =   1095
   End
End
Attribute VB_Name = "authentication"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cn As New ADODB.Connection, strCNString As String
Dim RS As New ADODB.Recordset
Dim admin As Boolean, deluser As Boolean

Private Sub cmddeluser_Click()
    On Error GoTo Errhandler
    'Connect to database
    If txtname.Text = "" Or txtpass.Text = "" Then GoTo Message
    
    strCNString = "Data Source=" & App.Path & "\transport.mdb"
    cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
    cn.ConnectionString = strCNString
    cn.Open
    'Open recordsource
    
    With RS
       
            .Open "Select * from Admin where uname='" & txtname.Text & "' and upass='" & txtpass.Text & "'", cn
            'Check username and password
            If .EOF Then
                MsgBox "Authority to Delete Denied!!", vbOKOnly + vbCritical, "Deletion Protect"
                   txtname.Text = ""
                   txtpass.Text = ""
                   txtname.SetFocus
                   cn.Close
                   admin = False
            Else
                cn.Close
                authentication.Hide
                frmassess.Hide
                employee.Hide
                services.Hide
                vehicle.Hide
                frmmain.Enabled = True
                frmusers.Show
            End If
    End With
    Exit Sub
         
Errhandler:
    MsgBox Err.Description, vbCritical, "Login"
    'cn.Close
Message:
        MsgBox "You must enter a User Name and Password.", vbCritical, "Error"

End Sub

Private Sub cmdok_Click()
    
    On Error GoTo Errhandler
    'Connect to database
    If txtname.Text = "" Or txtpass.Text = "" Then GoTo Message
    
    strCNString = "Data Source=" & App.Path & "\transport.mdb"
    cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
    cn.ConnectionString = strCNString
    cn.Open
    'Open recordsource
    
    With RS
       
            .Open "Select * from Admin where uname='" & txtname.Text & "' and upass='" & txtpass.Text & "'", cn
            'Check username and password
            If .EOF Then
                MsgBox "User not recognised!", vbOKOnly + vbCritical, "Administrator Delete"
                   txtname.Text = ""
                   txtpass.Text = ""
                   txtname.SetFocus
                   cn.Close
                   admin = False
            Else
                cn.Close
                Unload Me
                frmmain.Show
                frmmain.Enabled = True
                admin = True
                deluser = True
            End If
        End With
    
         Exit Sub
         
Errhandler:
    MsgBox Err.Description, vbCritical, "Login"
    'cn.Close
Message:
        MsgBox "You must enter a User Name and Password.", vbCritical, "Error"
    
End Sub

Private Sub cmdcancel_Click()
    Unload Me
End Sub

Private Sub cmdregister_Click()
Call cmdok_Click
If admin = True Then
    frmregister.Show
Else
    MsgBox "Only an Administrator can register a user", vbCritical, "Failed Attempt"
End If
End Sub

Private Sub Form_Load()
'Disable Register button until data is entered into both text boxes
cmdregister.Visible = False
frmmain.Show
frmmain.Enabled = False
cmdregister.Enabled = False
cmddeluser.Visible = False
cmdok.Visible = True

Me.Show
txtname.SetFocus
End Sub

Private Sub txtpass_Change()
cmdregister.Enabled = True
cmdok.Enabled = True
End Sub

⌨️ 快捷键说明

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