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

📄 frm_login.vb

📁 图书管理系统 VB加SQL 数据库在文件里的DATA里 进到SQL里附加进去就可以使用了
💻 VB
字号:
Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Frm_Login
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents BtnOk As System.Windows.Forms.Button
    Friend WithEvents BtnCancel As System.Windows.Forms.Button
    Friend WithEvents TxbName As System.Windows.Forms.TextBox
    Friend WithEvents TxbPwd As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.TxbName = New System.Windows.Forms.TextBox
        Me.TxbPwd = New System.Windows.Forms.TextBox
        Me.BtnOk = New System.Windows.Forms.Button
        Me.BtnCancel = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label1.Location = New System.Drawing.Point(64, 104)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(112, 24)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "请输入用户名:"
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label2.Location = New System.Drawing.Point(64, 152)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(112, 24)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "请输入密 码:"
        '
        'Label3
        '
        Me.Label3.Font = New System.Drawing.Font("楷体_GB2312", 21.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label3.Location = New System.Drawing.Point(104, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(192, 40)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "系统登录界面"
        '
        'TxbName
        '
        Me.TxbName.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.TxbName.Location = New System.Drawing.Point(184, 104)
        Me.TxbName.Name = "TxbName"
        Me.TxbName.Size = New System.Drawing.Size(144, 23)
        Me.TxbName.TabIndex = 1
        Me.TxbName.Text = ""
        '
        'TxbPwd
        '
        Me.TxbPwd.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.TxbPwd.Location = New System.Drawing.Point(184, 152)
        Me.TxbPwd.Name = "TxbPwd"
        Me.TxbPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.TxbPwd.Size = New System.Drawing.Size(144, 23)
        Me.TxbPwd.TabIndex = 1
        Me.TxbPwd.Text = ""
        '
        'BtnOk
        '
        Me.BtnOk.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.BtnOk.Location = New System.Drawing.Point(88, 232)
        Me.BtnOk.Name = "BtnOk"
        Me.BtnOk.Size = New System.Drawing.Size(75, 32)
        Me.BtnOk.TabIndex = 2
        Me.BtnOk.Text = "登录"
        '
        'BtnCancel
        '
        Me.BtnCancel.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.BtnCancel.Location = New System.Drawing.Point(216, 232)
        Me.BtnCancel.Name = "BtnCancel"
        Me.BtnCancel.Size = New System.Drawing.Size(75, 32)
        Me.BtnCancel.TabIndex = 2
        Me.BtnCancel.Text = "退出"
        '
        'Frm_Login
        '
        Me.AcceptButton = Me.BtnOk
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(408, 304)
        Me.Controls.Add(Me.BtnOk)
        Me.Controls.Add(Me.TxbName)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TxbPwd)
        Me.Controls.Add(Me.BtnCancel)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "Frm_Login"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "登录"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public userlogin As Integer

    '登录
    Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
        If TxbName.Text = "" Then
            MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK)
            Exit Sub
        End If
        If TxbPwd.Text = "" Then
            MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK)
            Exit Sub
        End If
        username = TxbName.Text.Trim()
        userpwd = TxbPwd.Text.Trim()
        Dim db As DataBase = New DataBase
        Dim sqlstr As String = "select * from 用户表 where 用户名='" & username & "' and 密码='" & userpwd & "'"
        Dim dv As DataView = db.RunSelectSQL(sqlstr)
        If dv.Count > 0 Then
            userSF = Trim(dv.Item(0)("身份"))
            Dim Frm As Frm_Main = New Frm_Main
            Frm.Show()
            Me.Hide()
        Else
            userlogin += 1
            MessageBox.Show("用户名或密码有误,请您查证后再登录!", "提示", MessageBoxButtons.OK)
            If userlogin = 3 Then
                MessageBox.Show("已超过最大尝试次数,谢绝登录!", "提示", MessageBoxButtons.OK)
                Application.Exit()
            End If
        End If
    End Sub
    '退出
    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Application.Exit()
    End Sub
End Class

⌨️ 快捷键说明

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