📄 edituserform.vb
字号:
Me.txtUserEmail.Enabled = CType(resources.GetObject("txtUserEmail.Enabled"), Boolean)
Me.txtUserEmail.Font = CType(resources.GetObject("txtUserEmail.Font"), System.Drawing.Font)
Me.txtUserEmail.ImeMode = CType(resources.GetObject("txtUserEmail.ImeMode"), System.Windows.Forms.ImeMode)
Me.txtUserEmail.Location = CType(resources.GetObject("txtUserEmail.Location"), System.Drawing.Point)
Me.txtUserEmail.MaxLength = CType(resources.GetObject("txtUserEmail.MaxLength"), Integer)
Me.txtUserEmail.Multiline = CType(resources.GetObject("txtUserEmail.Multiline"), Boolean)
Me.txtUserEmail.Name = "txtUserEmail"
Me.txtUserEmail.PasswordChar = CType(resources.GetObject("txtUserEmail.PasswordChar"), Char)
Me.txtUserEmail.RightToLeft = CType(resources.GetObject("txtUserEmail.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.txtUserEmail.ScrollBars = CType(resources.GetObject("txtUserEmail.ScrollBars"), System.Windows.Forms.ScrollBars)
Me.txtUserEmail.Size = CType(resources.GetObject("txtUserEmail.Size"), System.Drawing.Size)
Me.txtUserEmail.TabIndex = CType(resources.GetObject("txtUserEmail.TabIndex"), Integer)
Me.txtUserEmail.Text = resources.GetString("txtUserEmail.Text")
Me.txtUserEmail.TextAlign = CType(resources.GetObject("txtUserEmail.TextAlign"), System.Windows.Forms.HorizontalAlignment)
Me.txtUserEmail.Visible = CType(resources.GetObject("txtUserEmail.Visible"), Boolean)
Me.txtUserEmail.WordWrap = CType(resources.GetObject("txtUserEmail.WordWrap"), Boolean)
'
'txtUserFullName
'
Me.txtUserFullName.AccessibleDescription = resources.GetString("txtUserFullName.AccessibleDescription")
Me.txtUserFullName.AccessibleName = resources.GetString("txtUserFullName.AccessibleName")
Me.txtUserFullName.Anchor = CType(resources.GetObject("txtUserFullName.Anchor"), System.Windows.Forms.AnchorStyles)
Me.txtUserFullName.AutoSize = CType(resources.GetObject("txtUserFullName.AutoSize"), Boolean)
Me.txtUserFullName.BackgroundImage = CType(resources.GetObject("txtUserFullName.BackgroundImage"), System.Drawing.Image)
Me.txtUserFullName.Dock = CType(resources.GetObject("txtUserFullName.Dock"), System.Windows.Forms.DockStyle)
Me.txtUserFullName.Enabled = CType(resources.GetObject("txtUserFullName.Enabled"), Boolean)
Me.txtUserFullName.Font = CType(resources.GetObject("txtUserFullName.Font"), System.Drawing.Font)
Me.txtUserFullName.ImeMode = CType(resources.GetObject("txtUserFullName.ImeMode"), System.Windows.Forms.ImeMode)
Me.txtUserFullName.Location = CType(resources.GetObject("txtUserFullName.Location"), System.Drawing.Point)
Me.txtUserFullName.MaxLength = CType(resources.GetObject("txtUserFullName.MaxLength"), Integer)
Me.txtUserFullName.Multiline = CType(resources.GetObject("txtUserFullName.Multiline"), Boolean)
Me.txtUserFullName.Name = "txtUserFullName"
Me.txtUserFullName.PasswordChar = CType(resources.GetObject("txtUserFullName.PasswordChar"), Char)
Me.txtUserFullName.RightToLeft = CType(resources.GetObject("txtUserFullName.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.txtUserFullName.ScrollBars = CType(resources.GetObject("txtUserFullName.ScrollBars"), System.Windows.Forms.ScrollBars)
Me.txtUserFullName.Size = CType(resources.GetObject("txtUserFullName.Size"), System.Drawing.Size)
Me.txtUserFullName.TabIndex = CType(resources.GetObject("txtUserFullName.TabIndex"), Integer)
Me.txtUserFullName.Text = resources.GetString("txtUserFullName.Text")
Me.txtUserFullName.TextAlign = CType(resources.GetObject("txtUserFullName.TextAlign"), System.Windows.Forms.HorizontalAlignment)
Me.txtUserFullName.Visible = CType(resources.GetObject("txtUserFullName.Visible"), Boolean)
Me.txtUserFullName.WordWrap = CType(resources.GetObject("txtUserFullName.WordWrap"), Boolean)
'
'EditUserForm
'
Me.AcceptButton = Me.btnAccept
Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
Me.AccessibleName = resources.GetString("$this.AccessibleName")
Me.Anchor = CType(resources.GetObject("$this.Anchor"), System.Windows.Forms.AnchorStyles)
Me.AutoScaleBaseSize = CType(resources.GetObject("$this.AutoScaleBaseSize"), System.Drawing.Size)
Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.CancelButton = Me.btnCancel
Me.ClientSize = CType(resources.GetObject("$this.ClientSize"), System.Drawing.Size)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.cbLocked, Me.Label2, Me.Label1, Me.btnCancel, Me.btnAccept, Me.cbAdministrator, Me.txtUserEmail, Me.txtUserFullName})
Me.Dock = CType(resources.GetObject("$this.Dock"), System.Windows.Forms.DockStyle)
Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
Me.MaximizeBox = False
Me.MaximumSize = CType(resources.GetObject("$this.MaximumSize"), System.Drawing.Size)
Me.MinimumSize = CType(resources.GetObject("$this.MinimumSize"), System.Drawing.Size)
Me.Name = "EditUserForm"
Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.ShowInTaskbar = False
Me.StartPosition = CType(resources.GetObject("$this.StartPosition"), System.Windows.Forms.FormStartPosition)
Me.Text = resources.GetString("$this.Text")
Me.Visible = CType(resources.GetObject("$this.Visible"), Boolean)
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private m_DataLayer As DataLayer
Private m_UserRow As DataRow
Private Const c_DefaultPassword As String = "********"
Private m_ResourceManager As New Resources.ResourceManager("TaskVision.Localize", System.Reflection.Assembly.GetExecutingAssembly())
Private Sub EditUserForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not m_UserRow Is Nothing Then
txtPassword.Text = c_DefaultPassword
txtConfirmPassword.Text = c_DefaultPassword
txtUserName.Text = CType(m_UserRow.Item("UserName"), String)
txtUserFullName.Text = CType(m_UserRow.Item("UserFullName"), String)
txtUserEmail.Text = CType(m_UserRow.Item("UserEmail"), String)
cbAdministrator.Checked = CType(m_UserRow.Item("IsAdministrator"), Boolean)
cbLocked.Checked = CType(m_UserRow.Item("IsAccountLocked"), Boolean)
End If
End Sub
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 CType(m_UserRow.Item("UserName"), String) = "jdoe" Then
MessageBox.Show("Changes to the 'jdoe' user account are not allowed.")
Me.DialogResult = DialogResult.None
Return
End If
'TODO: Remove the code above to enable changes to the 'jdoe' account.
If IsFormValid() Then
Dim editUserInfo As New UserInformation()
editUserInfo.UserID = CType(m_UserRow.Item("UserID"), Integer)
editUserInfo.UserFullName = txtUserFullName.Text
editUserInfo.UserEmail = txtUserEmail.Text
editUserInfo.IsAdministrator = cbAdministrator.Checked
editUserInfo.IsAccountLocked = cbLocked.Checked
'if password changed
If txtPassword.Text <> c_DefaultPassword Then
editUserInfo.UserPassword = txtPassword.Text
Else
editUserInfo.UserPassword = String.Empty
End If
Dim dlResult As DataLayerResult = m_DataLayer.UpdateUser(editUserInfo)
If dlResult = DataLayerResult.Success Then
m_UserRow.Item("UserFullName") = txtUserFullName.Text
m_UserRow.Item("UserEmail") = txtUserEmail.Text
m_UserRow.Item("IsAdministrator") = cbAdministrator.Checked
m_UserRow.Item("IsAccountLocked") = cbLocked.Checked
'did we just edit the current user
If editUserInfo.UserID = m_DataLayer.CurrentUserInformation.UserID Then
m_DataLayer.CurrentUserInformation.UserFullName = txtUserFullName.Text
m_DataLayer.CurrentUserInformation.UserEmail = txtUserEmail.Text
m_DataLayer.CurrentUserInformation.IsAdministrator = cbAdministrator.Checked
m_DataLayer.CurrentUserInformation.IsAccountLocked = cbLocked.Checked
If txtPassword.Text <> c_DefaultPassword Then
m_DataLayer.CurrentUserInformation.UserPassword = txtPassword.Text
End If
End If
Me.Close()
Else
MessageBox.Show(m_ResourceManager.GetString("Unable_to_edit_user_at_this_time"))
Me.DialogResult = DialogResult.None
End If
Else
Me.DialogResult = 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
txtUserFullName.Text = txtUserFullName.Text.Trim() 'remove white space from ends
If txtUserFullName.Text.Length < 3 Then
MessageBox.Show(m_ResourceManager.GetString("Full_name_must_be_between"))
Return False
End If
Dim r As New Regex("\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase)
If Not r.IsMatch(txtUserEmail.Text) Then
MessageBox.Show(m_ResourceManager.GetString("Email_address_is_not_valid"))
Return False
End If
Return True
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -