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

📄 f重新登录.frm

📁 vb加sql
💻 FRM
字号:
VERSION 5.00
Begin VB.Form F重新登录 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "用户登录"
   ClientHeight    =   2295
   ClientLeft      =   -15
   ClientTop       =   375
   ClientWidth     =   4095
   Icon            =   "F重新登录.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2295
   ScaleWidth      =   4095
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Caption         =   "登录信息"
      Height          =   2055
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3855
      Begin VB.TextBox txtUserName 
         Height          =   375
         Left            =   1440
         TabIndex        =   1
         Top             =   240
         Width           =   1845
      End
      Begin VB.CommandButton CmdCancel 
         BackColor       =   &H00C0C0C0&
         Caption         =   "退出(&Q)"
         Height          =   360
         Left            =   2040
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   1560
         Width           =   800
      End
      Begin VB.CommandButton CmdOk 
         BackColor       =   &H00C0C0C0&
         Caption         =   "确定(&O)"
         Height          =   360
         Left            =   960
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   1560
         Width           =   800
      End
      Begin VB.TextBox txtPassword 
         Height          =   345
         IMEMode         =   3  'DISABLE
         Left            =   1455
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   840
         Width           =   1845
      End
      Begin VB.Label UserY 
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   3360
         TabIndex        =   7
         Top             =   360
         Width           =   135
      End
      Begin VB.Label lblLabels 
         Caption         =   "用户名称:"
         Height          =   270
         Index           =   0
         Left            =   360
         TabIndex        =   6
         Top             =   390
         Width           =   1080
      End
      Begin VB.Label lblLabels 
         Caption         =   "密    码:"
         Height          =   270
         Index           =   1
         Left            =   360
         TabIndex        =   5
         Top             =   840
         Width           =   1080
      End
   End
End
Attribute VB_Name = "F重新登录"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim SQL As String
Dim pwnum As Integer
Dim msg As String

Private Sub Form_Load()
    Dim rst As ADODB.Recordset
    Dim strItem As String
    
    ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;"
    ConnectionString = ConnectionString & "User ID=" & "sa" & ";Password=" & "" & ";"
    ConnectionString = ConnectionString & "Initial Catalog=" & "人事管理系统" & ";Data Source=" & ""

   ' 初始化ComboBox 注释掉初始化
   ' SQL = " select 用户ID,用户名称 from 用户信息表 order by 用户ID"
   ' Set rst = SelectSQL(SQL, msg)
   ' If rst.RecordCount > 0 Then
   '     Do While Not rst.EOF
   '     '添加到ComboBox列表
   '     strItem = rst.Fields(0) & " " & rst.Fields(1)
   '     CboName.AddItem (strItem)
   '     rst.MoveNext                            '指向下一条记录
   '     Loop
   '     rst.Close
   '     CboName.ListIndex = 0                   '默认ComboBox
   ' Else
   '     MsgBox ("请先创建用户信息!")
   '     CmdOk.Enabled = False
   '     Exit Sub
   ' End If
End Sub
Private Sub CmdOK_Click()
    
    Dim rst As ADODB.Recordset
    Dim password As String
    
    '判断用户是否存在
  ''  UserID = Left(Trim(CboName.Text), 10)       '取出用户的ID
    UserName = txtUserName.Text '取出用户名
  ''  SQL = " select 用户ID,密码 from 用户信息表 where 用户ID='" & UserID & "'"
    SQL = " select 用户名称,密码 from 用户信息表 where 用户名称='" & UserName & "'"
    Set rst = SelectSQL(SQL, msg)
    If txtUserName = "" Then
        MsgBox ("用户名不能为空!")
        Exit Sub
    End If
    If rst.RecordCount > 0 Then                 '如果存在这个用户
        password = Trim(rst.Fields(1))          '取出该用户的密码
        rst.Close
    Else
        MsgBox ("用户名不存在!")
        Exit Sub
    End If
    '判断密码是否正确
    If password = Trim(txtPassword.Text) Then
      LoginSucceeded = True
      人事管理系统.Show
      Unload Me
    Else
        If pwnum < 2 Then
      MsgBox ("密码错误,请重新输入!")
      txtPassword.Text = ""
      txtPassword.SetFocus
      pwnum = pwnum + 1
        Else
      pwnum = MsgBox("密码错误超过三次,请确定你拥有该账户!", 0 + 16 + 0, "Error!")
      Unload Me
      End If
      LoginSucceeded = False
    End If
End Sub
Private Sub cmdCancel_Click()
    '设置全局变量为 false
    '不提示失败的登录
    LoginSucceeded = False
    Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
    LoginSucceeded = False
    Unload Me
End Sub


Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call CmdOK_Click
End If
End Sub

Private Sub txtUserName_GotFocus()
UserY.Caption = ""
End Sub

Private Sub txtUserName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPassword.SetFocus
End If
End Sub

Private Sub txtUserName_LostFocus()
If txtUserName.Text = "" Then
    UserY.Caption = "*"
End If
End Sub

⌨️ 快捷键说明

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