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

📄 login.frm

📁 程序主要是关于学生成绩管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form login 
   AutoRedraw      =   -1  'True
   BackColor       =   &H00C0C0C0&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登录"
   ClientHeight    =   2355
   ClientLeft      =   6750
   ClientTop       =   5895
   ClientWidth     =   4410
   Icon            =   "login.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "login.frx":12532
   ScaleHeight     =   1391.412
   ScaleMode       =   0  'User
   ScaleWidth      =   4140.751
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   2520
      TabIndex        =   5
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "登录"
      Height          =   375
      Left            =   840
      TabIndex        =   4
      Top             =   1800
      Width           =   1215
   End
   Begin VB.TextBox txtUserName 
      BackColor       =   &H00FFFFFF&
      Height          =   288
      Left            =   1800
      TabIndex        =   0
      Top             =   600
      Width           =   1845
   End
   Begin VB.TextBox txtPassword 
      BackColor       =   &H00FFFFFF&
      Height          =   288
      IMEMode         =   3  'DISABLE
      Left            =   1800
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1080
      Width           =   1845
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0C0&
      Height          =   180
      Index           =   3
      Left            =   600
      TabIndex        =   3
      Top             =   1080
      Width           =   600
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0C0&
      Height          =   180
      Index           =   2
      Left            =   600
      TabIndex        =   2
      Top             =   720
      Width           =   795
   End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public LoginSucceeded As Boolean

Private Sub Command1_Click()
Static loginno As Integer
On Error GoTo errh:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set rs = cn.Execute("SELECT UserName , Password  FROM 用户表 ")
    If rs.EOF Then
        rs.Close
        Set rs = Nothing
        Unload Me
        Load FrmMain
        Exit Sub
    End If
    rs.MoveFirst
    Dim i As Integer
    '校验是否为超级用户
    Do
        If rs.Fields("UserName") = txtUserName.Text Then
            If rs.Fields("Password") = txtPassword.Text Then
                UserType = True
                LoginSucceeded = True
                rs.Close
                If txtUserName.Text = "admin" Then IsAdmin = True
                Unload Me
                Load FrmMain
                Exit Sub
                Exit Do
            End If
        End If
        rs.MoveNext
    Loop Until rs.EOF
    '校验是否为普通用户
       Set rs = cn.Execute("SELECT 学号 FROM 学生表 WHERE 学号 =" & "'" & txtUserName.Text & "'")
   
        
    If rs.EOF Then
        MsgBox "无效密码或用户名请重试!", 32, "登录"
        loginno = loginno + 1
        
        txtPassword.SetFocus
        SendKeys "{Home}+{End}"
        If loginno > 2 Then
          MsgBox "对不起,您不能使用该系统!", 64, "登录失败"
          Unload Me
          Exit Sub
        End If
    Else
        
        rs.Close
        UserType = False
        LoginSucceeded = True
        Unload Me
        Load FrmMain
    End If
    Exit Sub
errh:
    MsgBox Err.Description
End Sub

Private Sub Command2_Click()
    LoginSucceeded = False
    Unload Me
End Sub

Private Sub Form_Load()
    Dim s As String
    MakeCenter login
    s = MakeConnection() '创建全局ADO连接
    If s <> "OK" Then
        MsgBox s, , "错误!"
        Unload Me
        LoginSucceeded = False
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Not LoginSucceeded Then '如果登陆失败
        cn.Close '释放连接
        Set cn = Nothing
    End If
End Sub



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

⌨️ 快捷键说明

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