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

📄 login.vb

📁 vb.net+sql进销存管理系统
💻 VB
字号:
Public Class 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 tbpwd As System.Windows.Forms.TextBox
    Friend WithEvents tbname As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btcancel As System.Windows.Forms.Button
    Friend WithEvents btpwd As System.Windows.Forms.Button
    Friend WithEvents btok As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.tbpwd = New System.Windows.Forms.TextBox
        Me.tbname = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.btcancel = New System.Windows.Forms.Button
        Me.btpwd = New System.Windows.Forms.Button
        Me.btok = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'tbpwd
        '
        Me.tbpwd.Location = New System.Drawing.Point(150, 56)
        Me.tbpwd.Name = "tbpwd"
        Me.tbpwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.tbpwd.Size = New System.Drawing.Size(120, 21)
        Me.tbpwd.TabIndex = 7
        Me.tbpwd.Text = ""
        '
        'tbname
        '
        Me.tbname.Location = New System.Drawing.Point(22, 56)
        Me.tbname.Name = "tbname"
        Me.tbname.TabIndex = 6
        Me.tbname.Text = ""
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(150, 32)
        Me.Label2.Name = "Label2"
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "密码"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(22, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "姓名"
        '
        'btcancel
        '
        Me.btcancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btcancel.Location = New System.Drawing.Point(104, 104)
        Me.btcancel.Name = "btcancel"
        Me.btcancel.TabIndex = 10
        Me.btcancel.Text = "取消"
        '
        'btpwd
        '
        Me.btpwd.Location = New System.Drawing.Point(184, 104)
        Me.btpwd.Name = "btpwd"
        Me.btpwd.TabIndex = 9
        Me.btpwd.Text = "修改密码"
        '
        'btok
        '
        Me.btok.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.btok.Location = New System.Drawing.Point(24, 104)
        Me.btok.Name = "btok"
        Me.btok.TabIndex = 8
        Me.btok.Text = "登录"
        '
        'Login
        '
        Me.AcceptButton = Me.btok
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.btcancel
        Me.ClientSize = New System.Drawing.Size(322, 192)
        Me.Controls.Add(Me.btcancel)
        Me.Controls.Add(Me.btpwd)
        Me.Controls.Add(Me.btok)
        Me.Controls.Add(Me.tbpwd)
        Me.Controls.Add(Me.tbname)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Name = "Login"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "登录"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public flag = False

    Private Sub btok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btok.Click

        Dim sflag As Boolean = True

        If Me.tbname.Text.Trim() = String.Empty Then
            MessageBox.Show("姓名不能为空")
            Me.tbname.Focus()
        ElseIf Me.tbpwd.Text.Trim() = String.Empty Then
            MessageBox.Show("密码不能为空")
            Me.tbpwd.Focus()
        Else

            Try
                Sample02.SqlCon.Open()
            Catch
                sflag = False
                MessageBox.Show("数据库连接不正常")
            Finally
                If Sample02.SqlCon.State = ConnectionState.Open Then
                    Sample02.SqlCon.Close()
                End If
            End Try

            If sflag Then

                Dim sql As String = "SELECT * FROM [USER] WHERE USERID = '" + Me.tbname.Text.Trim() + "' AND PWD = '" + Me.tbpwd.Text.Trim() + "'"
                Dim dt As DataTable

                Try
                    dt = Sample02.GetDataTable(sql)
                    If dt.Rows.Count = 0 Then
                        MessageBox.Show("用户名不存在或密码不正确")
                        Me.tbpwd.Focus()
                    Else
                        Sample02.UserId = Me.tbname.Text.Trim()
                        Sample02.Purview = dt.Rows(0)("PURVIEW").ToString().Trim()
                        flag = True

                        Me.Close()
                    End If
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                End Try

            End If
        End If
    End Sub

    Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcancel.Click
        Application.Exit()
    End Sub

    Private Sub btpwd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpwd.Click
        Dim ChangePwd As New ChangePwd
        ChangePwd.ShowDialog()
    End Sub
End Class

⌨️ 快捷键说明

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