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

📄 ucmodifyuserinfo.vb

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 VB
字号:
Public Class ucModifyUserInfo
  Inherits System.Windows.Forms.UserControl

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

  Public Sub New()
    MyBase.New()

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

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

  End Sub

  'UserControl 重写 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 窗体设计器修改此过程。
  '不要使用代码编辑器修改它。
  Public WithEvents _fr_1 As System.Windows.Forms.GroupBox
  Public WithEvents cmdModifyPwd As System.Windows.Forms.Button
  Public WithEvents _lbl_2 As System.Windows.Forms.Label
  Public WithEvents _lbl_3 As System.Windows.Forms.Label
  Public WithEvents _lbl_4 As System.Windows.Forms.Label
  Public WithEvents _lbl_5 As System.Windows.Forms.Label
  Public WithEvents txtOldPwd As System.Windows.Forms.TextBox
  Public WithEvents txtNewPwd As System.Windows.Forms.TextBox
  Public WithEvents txtConfirmPwd As System.Windows.Forms.TextBox
  Public WithEvents txtAccount As System.Windows.Forms.TextBox
  Friend WithEvents labTrueName As System.Windows.Forms.Label
  Friend WithEvents txtTrueName As System.Windows.Forms.TextBox
  Friend WithEvents chkChangePwd As System.Windows.Forms.CheckBox
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me._fr_1 = New System.Windows.Forms.GroupBox
    Me.chkChangePwd = New System.Windows.Forms.CheckBox
    Me.txtTrueName = New System.Windows.Forms.TextBox
    Me.labTrueName = New System.Windows.Forms.Label
    Me.txtAccount = New System.Windows.Forms.TextBox
    Me.txtOldPwd = New System.Windows.Forms.TextBox
    Me.txtNewPwd = New System.Windows.Forms.TextBox
    Me.txtConfirmPwd = New System.Windows.Forms.TextBox
    Me.cmdModifyPwd = New System.Windows.Forms.Button
    Me._lbl_2 = New System.Windows.Forms.Label
    Me._lbl_3 = New System.Windows.Forms.Label
    Me._lbl_4 = New System.Windows.Forms.Label
    Me._lbl_5 = New System.Windows.Forms.Label
    Me._fr_1.SuspendLayout()
    Me.SuspendLayout()
    '
    '_fr_1
    '
    Me._fr_1.BackColor = System.Drawing.SystemColors.Window
    Me._fr_1.Controls.Add(Me.chkChangePwd)
    Me._fr_1.Controls.Add(Me.txtTrueName)
    Me._fr_1.Controls.Add(Me.labTrueName)
    Me._fr_1.Controls.Add(Me.txtAccount)
    Me._fr_1.Controls.Add(Me.txtOldPwd)
    Me._fr_1.Controls.Add(Me.txtNewPwd)
    Me._fr_1.Controls.Add(Me.txtConfirmPwd)
    Me._fr_1.Controls.Add(Me.cmdModifyPwd)
    Me._fr_1.Controls.Add(Me._lbl_2)
    Me._fr_1.Controls.Add(Me._lbl_3)
    Me._fr_1.Controls.Add(Me._lbl_4)
    Me._fr_1.Controls.Add(Me._lbl_5)
    Me._fr_1.ForeColor = System.Drawing.SystemColors.ControlText
    Me._fr_1.Location = New System.Drawing.Point(38, 23)
    Me._fr_1.Name = "_fr_1"
    Me._fr_1.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._fr_1.Size = New System.Drawing.Size(300, 246)
    Me._fr_1.TabIndex = 21
    Me._fr_1.TabStop = False
    Me._fr_1.Text = "更改用户信息"
    '
    'chkChangePwd
    '
    Me.chkChangePwd.Checked = True
    Me.chkChangePwd.CheckState = System.Windows.Forms.CheckState.Checked
    Me.chkChangePwd.Location = New System.Drawing.Point(16, 94)
    Me.chkChangePwd.Name = "chkChangePwd"
    Me.chkChangePwd.Size = New System.Drawing.Size(81, 20)
    Me.chkChangePwd.TabIndex = 27
    Me.chkChangePwd.Text = "修改密码"
    '
    'txtTrueName
    '
    Me.txtTrueName.Location = New System.Drawing.Point(73, 63)
    Me.txtTrueName.Name = "txtTrueName"
    Me.txtTrueName.Size = New System.Drawing.Size(195, 21)
    Me.txtTrueName.TabIndex = 26
    Me.txtTrueName.Text = ""
    '
    'labTrueName
    '
    Me.labTrueName.AutoSize = True
    Me.labTrueName.Location = New System.Drawing.Point(15, 65)
    Me.labTrueName.Name = "labTrueName"
    Me.labTrueName.Size = New System.Drawing.Size(54, 17)
    Me.labTrueName.TabIndex = 25
    Me.labTrueName.Text = "真实姓名"
    '
    'txtAccount
    '
    Me.txtAccount.AcceptsReturn = True
    Me.txtAccount.AutoSize = False
    Me.txtAccount.BackColor = System.Drawing.SystemColors.Window
    Me.txtAccount.BorderStyle = System.Windows.Forms.BorderStyle.None
    Me.txtAccount.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtAccount.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtAccount.Location = New System.Drawing.Point(73, 37)
    Me.txtAccount.MaxLength = 10
    Me.txtAccount.Name = "txtAccount"
    Me.txtAccount.ReadOnly = True
    Me.txtAccount.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtAccount.Size = New System.Drawing.Size(155, 19)
    Me.txtAccount.TabIndex = 0
    Me.txtAccount.Text = ""
    '
    'txtOldPwd
    '
    Me.txtOldPwd.AcceptsReturn = True
    Me.txtOldPwd.AutoSize = False
    Me.txtOldPwd.BackColor = System.Drawing.SystemColors.Window
    Me.txtOldPwd.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtOldPwd.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtOldPwd.Location = New System.Drawing.Point(73, 117)
    Me.txtOldPwd.MaxLength = 15
    Me.txtOldPwd.Name = "txtOldPwd"
    Me.txtOldPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
    Me.txtOldPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtOldPwd.Size = New System.Drawing.Size(195, 20)
    Me.txtOldPwd.TabIndex = 1
    Me.txtOldPwd.Text = ""
    '
    'txtNewPwd
    '
    Me.txtNewPwd.AcceptsReturn = True
    Me.txtNewPwd.AutoSize = False
    Me.txtNewPwd.BackColor = System.Drawing.SystemColors.Window
    Me.txtNewPwd.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtNewPwd.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtNewPwd.Location = New System.Drawing.Point(73, 143)
    Me.txtNewPwd.MaxLength = 15
    Me.txtNewPwd.Name = "txtNewPwd"
    Me.txtNewPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
    Me.txtNewPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtNewPwd.Size = New System.Drawing.Size(195, 20)
    Me.txtNewPwd.TabIndex = 2
    Me.txtNewPwd.Text = ""
    '
    'txtConfirmPwd
    '
    Me.txtConfirmPwd.AcceptsReturn = True
    Me.txtConfirmPwd.AutoSize = False
    Me.txtConfirmPwd.BackColor = System.Drawing.SystemColors.Window
    Me.txtConfirmPwd.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtConfirmPwd.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtConfirmPwd.Location = New System.Drawing.Point(73, 169)
    Me.txtConfirmPwd.MaxLength = 15
    Me.txtConfirmPwd.Name = "txtConfirmPwd"
    Me.txtConfirmPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
    Me.txtConfirmPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtConfirmPwd.Size = New System.Drawing.Size(195, 20)
    Me.txtConfirmPwd.TabIndex = 3
    Me.txtConfirmPwd.Text = ""
    '
    'cmdModifyPwd
    '
    Me.cmdModifyPwd.BackColor = System.Drawing.SystemColors.Control
    Me.cmdModifyPwd.Cursor = System.Windows.Forms.Cursors.Default
    Me.cmdModifyPwd.ForeColor = System.Drawing.SystemColors.ControlText
    Me.cmdModifyPwd.Location = New System.Drawing.Point(153, 206)
    Me.cmdModifyPwd.Name = "cmdModifyPwd"
    Me.cmdModifyPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.cmdModifyPwd.Size = New System.Drawing.Size(102, 24)
    Me.cmdModifyPwd.TabIndex = 4
    Me.cmdModifyPwd.Text = "更改(&M)"
    '
    '_lbl_2
    '
    Me._lbl_2.AutoSize = True
    Me._lbl_2.BackColor = System.Drawing.Color.Transparent
    Me._lbl_2.Cursor = System.Windows.Forms.Cursors.Default
    Me._lbl_2.ForeColor = System.Drawing.SystemColors.ControlText
    Me._lbl_2.Location = New System.Drawing.Point(14, 39)
    Me._lbl_2.Name = "_lbl_2"
    Me._lbl_2.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._lbl_2.Size = New System.Drawing.Size(42, 17)
    Me._lbl_2.TabIndex = 24
    Me._lbl_2.Text = "用户名"
    '
    '_lbl_3
    '
    Me._lbl_3.AutoSize = True
    Me._lbl_3.BackColor = System.Drawing.Color.Transparent
    Me._lbl_3.Cursor = System.Windows.Forms.Cursors.Default
    Me._lbl_3.ForeColor = System.Drawing.SystemColors.ControlText
    Me._lbl_3.Location = New System.Drawing.Point(14, 121)
    Me._lbl_3.Name = "_lbl_3"
    Me._lbl_3.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._lbl_3.Size = New System.Drawing.Size(42, 17)
    Me._lbl_3.TabIndex = 23
    Me._lbl_3.Text = "旧密码"
    '
    '_lbl_4
    '
    Me._lbl_4.AutoSize = True
    Me._lbl_4.BackColor = System.Drawing.Color.Transparent
    Me._lbl_4.Cursor = System.Windows.Forms.Cursors.Default
    Me._lbl_4.ForeColor = System.Drawing.SystemColors.ControlText
    Me._lbl_4.Location = New System.Drawing.Point(14, 147)
    Me._lbl_4.Name = "_lbl_4"
    Me._lbl_4.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._lbl_4.Size = New System.Drawing.Size(42, 17)
    Me._lbl_4.TabIndex = 22
    Me._lbl_4.Text = "新密码"
    '
    '_lbl_5
    '
    Me._lbl_5.AutoSize = True
    Me._lbl_5.BackColor = System.Drawing.Color.Transparent
    Me._lbl_5.Cursor = System.Windows.Forms.Cursors.Default
    Me._lbl_5.ForeColor = System.Drawing.SystemColors.ControlText
    Me._lbl_5.Location = New System.Drawing.Point(14, 173)
    Me._lbl_5.Name = "_lbl_5"
    Me._lbl_5.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._lbl_5.Size = New System.Drawing.Size(29, 17)
    Me._lbl_5.TabIndex = 21
    Me._lbl_5.Text = "确认"
    '
    'ucChangePwd
    '
    Me.BackColor = System.Drawing.SystemColors.Window
    Me.Controls.Add(Me._fr_1)
    Me.Name = "ucChangePwd"
    Me.Size = New System.Drawing.Size(376, 300)
    Me._fr_1.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub cmdModifyPwd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModifyPwd.Click
    '进行简单验证
    If txtTrueName.Text = "" Then
      MsgBox("请添写用户名", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly)
      Exit Sub
    End If
    If chkChangePwd.Checked = True Then
      If txtOldPwd.Text = "" Or _
        txtNewPwd.Text = "" Or _
        txtConfirmPwd.Text = "" Then
        MsgBox("请将密码信息填写完整", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly)
        Exit Sub
      End If
    End If
    Dim ErrMsg As String
    Dim userObj As New clientMgrBusiness.User
    '修改用户真实姓名
    ErrMsg = userObj.UpdageTrueName(txtAccount.Text, txtTrueName.Text)
    If chkChangePwd.Checked = True Then
      '修改密码
      ErrMsg &= userObj.ChangePwd(txtAccount.Text, txtOldPwd.Text, txtNewPwd.Text, txtConfirmPwd.Text)
    End If
    '如果出错,弹出出错信息
    If ErrMsg <> "" Then
      MsgBox(ErrMsg, MsgBoxStyle.Critical + MsgBoxStyle.OKOnly)
    Else
      MsgBox("修改成功!", MsgBoxStyle.Information + MsgBoxStyle.OKOnly)

    End If

  End Sub

  Private Sub ucChangePwd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    txtAccount.Text = LoginedUserInfo.m_szUserAccount
    txtTrueName.Text = LoginedUserInfo.m_szTrueName
  End Sub

  Private Sub chkChangePwd_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkChangePwd.CheckedChanged
    txtOldPwd.Enabled = chkChangePwd.Checked
    txtNewPwd.Enabled = chkChangePwd.Checked
    txtConfirmPwd.Enabled = chkChangePwd.Checked
  End Sub
End Class

⌨️ 快捷键说明

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