登录窗体.frm

来自「仓库查询系统的管理软件的源代码」· FRM 代码 · 共 208 行

FRM
208
字号
VERSION 5.00
Begin VB.Form 登录窗体 
   Caption         =   "采购管理系统-【登陆】"
   ClientHeight    =   3210
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4560
   LinkTopic       =   "Form1"
   Picture         =   "登录窗体.frx":0000
   ScaleHeight     =   3210
   ScaleWidth      =   4560
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox Text1 
      Height          =   855
      Left            =   3840
      TabIndex        =   7
      Top             =   1920
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   330
      Left            =   2400
      TabIndex        =   3
      Top             =   2520
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   330
      Left            =   960
      TabIndex        =   2
      Top             =   2520
      Width           =   1095
   End
   Begin VB.TextBox NowUser 
      Height          =   330
      Left            =   1800
      TabIndex        =   1
      Text            =   "admin"
      Top             =   1320
      Width           =   1695
   End
   Begin VB.TextBox NowPwd 
      Height          =   330
      IMEMode         =   3  'DISABLE
      Left            =   1800
      PasswordChar    =   "*"
      TabIndex        =   0
      Text            =   "admin"
      Top             =   1815
      Width           =   1695
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "仓库管理系统"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   615
      Left            =   720
      TabIndex        =   6
      Top             =   360
      Width           =   3615
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H8000000A&
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   720
      TabIndex        =   5
      Top             =   1380
      Width           =   1215
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H8000000A&
      BackStyle       =   0  'Transparent
      Caption         =   "密  码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   720
      TabIndex        =   4
      Top             =   1875
      Width           =   1215
   End
End
Attribute VB_Name = "登录窗体"
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 登录 WHERE 用户ID ='" & NowUser.Text & "'"
    Rst.Open strSQL, cnnDatabase, adOpenDynamic, adLockReadOnly
    rstCount = 0
    Do While Rst.EOF = False
        rstCount = rstCount + 1
        Rst.MoveNext
    Loop
    If rstCount = 0 Then
        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("密码").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("密码").Value Then
            MsgBox "用户密码不正确!"
            cnnDatabase.Close
            Screen.MousePointer = vbDefault
            Me.NowPwd.Text = ""
            Me.NowPwd.SetFocus
            Exit Sub
        End If
    End If
       Me.Text1.Text = Rst.Fields("用户名").Value
    If Me.Text1.Text = "admin" Then
       主窗体.Command10.Visible = True
    Else
       主窗体.Command10.Visible = False
    End If
    Screen.MousePointer = vbDefault
    Set Rst = Nothing
    Unload Me
    主窗体.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


⌨️ 快捷键说明

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