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

📄 changepw.vb

📁 图书馆管理系统,是数据库的课程设计,报告里面包含了需求分析数据字典概念结构设计逻辑结构设计数据库物理设计数据库实施
💻 VB
字号:
Imports System.Data
'引入数据库操作类命名空间
Imports System.Data.OleDb
'引入ADO.NET操作命名空间

Public Class win_changepw
    Inherits System.Windows.Forms.Form
    Dim sqlstr As String, stuID As Integer 'SQL语句标记
    Dim objDS As DataSet '数据在内存中的缓存
    Dim login As New library2.win_login

#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 GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents btOK As System.Windows.Forms.Button
    Friend WithEvents btCancel As System.Windows.Forms.Button
    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 tborpw As System.Windows.Forms.TextBox
    Friend WithEvents tbNewpw As System.Windows.Forms.TextBox
    Friend WithEvents tbConfirm As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(win_changepw))
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.tbConfirm = New System.Windows.Forms.TextBox
        Me.tbNewpw = New System.Windows.Forms.TextBox
        Me.tborpw = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.btCancel = New System.Windows.Forms.Button
        Me.btOK = New System.Windows.Forms.Button
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label4)
        Me.GroupBox1.Controls.Add(Me.tbConfirm)
        Me.GroupBox1.Controls.Add(Me.tbNewpw)
        Me.GroupBox1.Controls.Add(Me.tborpw)
        Me.GroupBox1.Controls.Add(Me.Label3)
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Controls.Add(Me.btCancel)
        Me.GroupBox1.Controls.Add(Me.btOK)
        Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ControlDark
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(216, 160)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "更改密码"
        '
        'Label4
        '
        Me.Label4.ForeColor = System.Drawing.SystemColors.ControlDark
        Me.Label4.Location = New System.Drawing.Point(17, 104)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(182, 16)
        Me.Label4.TabIndex = 8
        Me.Label4.Text = "系统自动过滤 ' "" + & | 字符"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.Label4.UseMnemonic = False
        '
        'tbConfirm
        '
        Me.tbConfirm.ForeColor = System.Drawing.SystemColors.ControlText
        Me.tbConfirm.Location = New System.Drawing.Point(104, 72)
        Me.tbConfirm.MaxLength = 10
        Me.tbConfirm.Name = "tbConfirm"
        Me.tbConfirm.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.tbConfirm.Size = New System.Drawing.Size(88, 21)
        Me.tbConfirm.TabIndex = 3
        Me.tbConfirm.Text = ""
        '
        'tbNewpw
        '
        Me.tbNewpw.ForeColor = System.Drawing.SystemColors.ControlText
        Me.tbNewpw.Location = New System.Drawing.Point(104, 48)
        Me.tbNewpw.MaxLength = 10
        Me.tbNewpw.Name = "tbNewpw"
        Me.tbNewpw.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.tbNewpw.Size = New System.Drawing.Size(88, 21)
        Me.tbNewpw.TabIndex = 2
        Me.tbNewpw.Text = ""
        '
        'tborpw
        '
        Me.tborpw.ForeColor = System.Drawing.SystemColors.ControlText
        Me.tborpw.Location = New System.Drawing.Point(104, 16)
        Me.tborpw.MaxLength = 10
        Me.tborpw.Name = "tborpw"
        Me.tborpw.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.tborpw.Size = New System.Drawing.Size(88, 21)
        Me.tborpw.TabIndex = 1
        Me.tborpw.Text = ""
        '
        'Label3
        '
        Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label3.Location = New System.Drawing.Point(32, 72)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(72, 24)
        Me.Label3.TabIndex = 4
        Me.Label3.Text = "确定密码:"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label2.Location = New System.Drawing.Point(32, 48)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(72, 24)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "新密码:"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label1
        '
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(32, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 24)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "原密码:"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btCancel
        '
        Me.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btCancel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btCancel.Location = New System.Drawing.Point(116, 128)
        Me.btCancel.Name = "btCancel"
        Me.btCancel.Size = New System.Drawing.Size(56, 24)
        Me.btCancel.TabIndex = 5
        Me.btCancel.Text = "取消"
        '
        'btOK
        '
        Me.btOK.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btOK.Location = New System.Drawing.Point(44, 128)
        Me.btOK.Name = "btOK"
        Me.btOK.Size = New System.Drawing.Size(56, 24)
        Me.btOK.TabIndex = 4
        Me.btOK.Text = "确定"
        '
        'win_changepw
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.btCancel
        Me.ClientSize = New System.Drawing.Size(232, 176)
        Me.ControlBox = False
        Me.Controls.Add(Me.GroupBox1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MaximumSize = New System.Drawing.Size(240, 203)
        Me.MinimizeBox = False
        Me.MinimumSize = New System.Drawing.Size(240, 203)
        Me.Name = "win_changepw"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "更改密码"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOK.Click
        Dim canchange As Boolean = True, orpw As String, Newpw As String, Confirm As String
        orpw = filter(Trim(tborpw.Text).ToString)
        Newpw = filter(Trim(tbNewpw.Text).ToString)
        Confirm = filter(Trim(tbConfirm.Text).ToString)
        If orpw = "" Then '登陆名为空!
            MessageBox.Show("原密码不能有空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            tborpw.Focus()
            Exit Sub
        ElseIf Newpw = "" Then '密码为空
            MessageBox.Show("新密码不能有空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            tbNewpw.Focus()
            Exit Sub
        ElseIf Confirm = "" Then
            MessageBox.Show("确定密码不能有空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            tbConfirm.Focus()
            Exit Sub
        ElseIf Newpw <> Confirm Then
            MsgBox("新密码与确定密码不一致。", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "错误")
            tbNewpw.Focus()
            canchange = False
        End If

        stuID = login.loginid '学生自动编号
        Try
            sqlstr = "select * from studentinfo where id=" & stuID & " and lpassword='" & orpw & "'"
            objDS = GetData(sqlstr)
            If objDS.Tables(0).Rows.Count = 0 Then
                MsgBox("原密码错误。", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "错误")
                tborpw.Focus()
                canchange = False
            End If

            If canchange Then
                sqlstr = "update studentinfo set lpassword='" & Newpw & "' where id=" & stuID & "" '更新密码
                objDS = GetData(sqlstr)
                MessageBox.Show("密码已修改!" & ControlChars.CrLf & "新密码为:" & Newpw, "密码修改成功", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                Me.Close()
            End If
        Catch
            MsgBox("数据更新错误。。", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "错误")
        End Try
    End Sub

    Private Sub btCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCancel.Click
        Me.Close()
    End Sub

    Private Sub win_changepw_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tborpw.Focus()
    End Sub
End Class

⌨️ 快捷键说明

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