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

📄 frmchangepass.vb

📁 我大2做的一个关于面向对象的课程设计
💻 VB
字号:
Imports System.Data
Imports System.Data.OleDb
Public Class frmChangePass
    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 Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtOldPass As System.Windows.Forms.TextBox
    Friend WithEvents txtNewPass As System.Windows.Forms.TextBox
    Friend WithEvents txtNewPass2 As System.Windows.Forms.TextBox
    Friend WithEvents cmdSubmit As System.Windows.Forms.Button
    Friend WithEvents lblNumber As System.Windows.Forms.Label
    Friend WithEvents lblWelcome As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lblNumber = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.txtOldPass = New System.Windows.Forms.TextBox
        Me.txtNewPass = New System.Windows.Forms.TextBox
        Me.txtNewPass2 = New System.Windows.Forms.TextBox
        Me.cmdSubmit = New System.Windows.Forms.Button
        Me.lblWelcome = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'lblNumber
        '
        Me.lblNumber.Location = New System.Drawing.Point(88, 72)
        Me.lblNumber.Name = "lblNumber"
        Me.lblNumber.Size = New System.Drawing.Size(128, 23)
        Me.lblNumber.TabIndex = 0
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 128)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(56, 23)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "旧密码:"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(24, 184)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 23)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "新密码:"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 240)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(80, 16)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "重复新密码:"
        '
        'txtOldPass
        '
        Me.txtOldPass.Location = New System.Drawing.Point(88, 128)
        Me.txtOldPass.Name = "txtOldPass"
        Me.txtOldPass.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtOldPass.Size = New System.Drawing.Size(128, 21)
        Me.txtOldPass.TabIndex = 4
        Me.txtOldPass.Text = ""
        '
        'txtNewPass
        '
        Me.txtNewPass.Location = New System.Drawing.Point(88, 184)
        Me.txtNewPass.Name = "txtNewPass"
        Me.txtNewPass.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtNewPass.Size = New System.Drawing.Size(128, 21)
        Me.txtNewPass.TabIndex = 5
        Me.txtNewPass.Text = ""
        '
        'txtNewPass2
        '
        Me.txtNewPass2.Location = New System.Drawing.Point(88, 240)
        Me.txtNewPass2.Name = "txtNewPass2"
        Me.txtNewPass2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtNewPass2.Size = New System.Drawing.Size(128, 21)
        Me.txtNewPass2.TabIndex = 6
        Me.txtNewPass2.Text = ""
        '
        'cmdSubmit
        '
        Me.cmdSubmit.Location = New System.Drawing.Point(248, 240)
        Me.cmdSubmit.Name = "cmdSubmit"
        Me.cmdSubmit.TabIndex = 7
        Me.cmdSubmit.Text = "提交"
        '
        'lblWelcome
        '
        Me.lblWelcome.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.lblWelcome.Location = New System.Drawing.Point(80, 8)
        Me.lblWelcome.Name = "lblWelcome"
        Me.lblWelcome.Size = New System.Drawing.Size(160, 40)
        Me.lblWelcome.TabIndex = 9
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(32, 72)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(48, 23)
        Me.Label1.TabIndex = 10
        Me.Label1.Text = "学号:"
        '
        'frmChangePass
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(342, 306)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.lblWelcome)
        Me.Controls.Add(Me.cmdSubmit)
        Me.Controls.Add(Me.txtNewPass2)
        Me.Controls.Add(Me.txtNewPass)
        Me.Controls.Add(Me.txtOldPass)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.lblNumber)
        Me.MaximizeBox = False
        Me.Name = "frmChangePass"
        Me.Text = "frmChangePass"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmChangePass_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblWelcome.Text = frmLogin.strStrdentName & "同学你好"
        lblNumber.Text = frmLogin.strStrdentNumber
        txtOldPass.Focus()
    End Sub

    Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
        If txtOldPass.Text <> frmLogin.strStrdentPass Then
            MsgBox("密码不正确!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "密码错误")
            txtOldPass.Text = ""
            txtOldPass.Focus()
        ElseIf txtNewPass.Text = "" Then
            MsgBox("新密码不能为空!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "错误")
            txtNewPass.Focus()
        ElseIf txtNewPass.Text <> txtNewPass2.Text Then
            MsgBox("两次输入的密码不相符!", MsgBoxStyle.OKOnly, "警告")
            txtNewPass.Text = ""
            txtNewPass2.Text = ""
            txtNewPass.Focus()
        Else
            Dim updatestring As String = "update 学生 set 密码 = '" & txtNewPass.Text & "' where 学号 ='" & frmLogin.strStrdentNumber & "'"
            Dim com As New oleDbcommand(updatestring)
            Try
                With com
                    .Connection = New OleDbConnection(gLinkString)
                    .Connection.Open()
                    .ExecuteReader()
                    .Connection.Close()
                End With
                MsgBox("密码修改成功!", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "恭喜")
            Catch
                com.Connection.Close()
                MsgBox(Err.Description, MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "错误")
            End Try
            txtOldPass.Text = ""
            txtNewPass.Text = ""
            txtNewPass2.Text = ""

        End If
    End Sub

    
End Class

⌨️ 快捷键说明

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