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

📄 changepasswordform.vb

📁 使用Access数据库演示的任务分配管理程序 一个使用ADO.NET基于Microsoft Access数据库演示的任务分配管理的程序
💻 VB
字号:
'---------------------------------------------------------------------
'  This file is part of the Microsoft .NET Framework SDK Code Samples.
' 
'  Copyright (C) Microsoft Corporation.  All rights reserved.
' 
' This source code is intended only as a supplement to Microsoft
' Development Tools and/or on-line documentation.  See these other
' materials for detailed information regarding Microsoft code samples.
' 
' THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'---------------------------------------------------------------------

Public Class ChangePasswordForm
    Inherits System.Windows.Forms.Form

    Public Sub New(ByVal dl As DataLayer)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        m_DataLayer = dl
    End Sub

    Private m_DataLayer As DataLayer
    Private m_ResourceManager As New Resources.ResourceManager("TeamVision.Localize", System.Reflection.Assembly.GetExecutingAssembly())


    Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
        'TODO: Remove the code below to enable changes to the 'jdoe' account.
        If m_DataLayer.CurrentUser.Name = "jdoe" Then
            MessageBox.Show("Changes to the 'jdoe' user account are not allowed.")
            Me.DialogResult = System.Windows.Forms.DialogResult.None
            Return
        End If
        'TODO: Remove the code above to enable changes to the 'jdoe' account.

        If IsFormValid() Then
            m_DataLayer.CurrentUser.Password = txtPassword.Text

            Dim dlResult As DataLayerResult = m_DataLayer.UpdateCurrentUser

            'if the database update was successful, update our local data
            If dlResult = DataLayerResult.Success Then
                Me.Close()
            Else
                MessageBox.Show(m_ResourceManager.GetString("Unable_to_change_password_at_this_time"))
                Me.DialogResult = System.Windows.Forms.DialogResult.None
            End If
        Else
            Me.DialogResult = System.Windows.Forms.DialogResult.None
        End If
    End Sub

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

    Private Function IsFormValid() As Boolean
        'check the fields for valid data and
        'display message boxes if neccessary

        If txtPassword.Text.IndexOf(" ") > -1 Then
            MessageBox.Show(m_ResourceManager.GetString("Password_may_not_contain_spaces"))
            Return False
        End If

        If txtPassword.Text.Length < 3 Then
            MessageBox.Show(m_ResourceManager.GetString("Password_must_be_between"))
            Return False
        End If

        If txtPassword.Text <> txtConfirmPassword.Text Then
            MessageBox.Show(m_ResourceManager.GetString("Password_fields_do_not_match"))
            Return False
        End If

        Return True
    End Function
End Class

⌨️ 快捷键说明

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