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

📄 login.frm

📁 Visual Basic 6.0+ Access2000设计制作图书管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form login_frm 
   Caption         =   "Form1"
   ClientHeight    =   3225
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4920
   LinkTopic       =   "Form1"
   ScaleHeight     =   3225
   ScaleWidth      =   4920
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   2880
      TabIndex        =   6
      Top             =   2640
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "确定"
      Height          =   375
      Left            =   600
      TabIndex        =   5
      Top             =   2640
      Width           =   1095
   End
   Begin VB.TextBox txtPassword 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2040
      PasswordChar    =   "*"
      TabIndex        =   4
      Text            =   "5566"
      Top             =   1800
      Width           =   2175
   End
   Begin VB.TextBox txtUserName 
      Height          =   375
      Left            =   2040
      TabIndex        =   3
      Text            =   "swj"
      Top             =   1200
      Width           =   2175
   End
   Begin VB.Label label2 
      Caption         =   "密码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   495
      Left            =   240
      TabIndex        =   2
      Top             =   1800
      Width           =   1095
   End
   Begin VB.Label label3 
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   1200
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "图书馆管理系统"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   615
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   3855
   End
End
Attribute VB_Name = "login_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public LoginSucceeded As Boolean
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim strUserName$, strPassword$, strSQL$
Static Count As Byte
'数据规格化

strUserName = Replace(Trim(txtUserName.Text), "", "")
strPassword = Replace(Trim(txtPassword.Text), "", "")
'非空验证
If strUserName = "" Then
 MsgBox "用户名不能为空,请输入用户名!", , "登录错误"
 txtUserName.SetFocus
 Exit Sub
ElseIf strPassword = "" Then
 MsgBox "密码不能为空,请输入密码!", , "登录错误"
 txtPassword.SetFocus
 Exit Sub
End If
'查询数据库中是否存在满足条件的用户名
Connstring = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\图书馆管理系统\db1.mdb;Persist Security Info=False"
With Conn
   .ConnectionString = Connstring
   .CommandTimeout = 10
   .Open
End With
MsgBox "连接成功"

strSQL = "SELECT * FROM pwd WHERE UserName='" & strUserName & "' "
strSQL = strSQL & "AND Password= '" & strPassword & "';"
rs.Open strSQL, Conn
If rs.EOF Then
  Count = Count + 1
  MsgBox "用户名不存在或密码错误!", , "登录失败"
  txtUserName.Text = ""
  txtPassword.Text = ""
  txtUserName.SetFocus
Else
  UserName = Trim(txtUserName.Text)
  MDIForm1.Show
  Me.Hide
End If
rs.Close
Conn.Close
Set rs = Nothing
Set Conn = Nothing
If Count >= 3 Then
  MsgBox "超过登录次数,无权登录本系统!", , "登录失败"
  End          '退出整个系统
End If
End Sub

Private Sub Form_Load()
LoginSucceeded = False
End Sub

⌨️ 快捷键说明

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