client/Seguridad/CambioPassword.vb

191 lines
7.8 KiB
VB.net
Raw Permalink Normal View History

'Noviembre 2005
Imports CLIENTE.Registro 'clase que me permite encriptar el password
Public Class CambioPassword
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents btnAceptar As System.Windows.Forms.Button
Friend WithEvents lblUsuario As System.Windows.Forms.Label
Friend WithEvents txtPass1 As System.Windows.Forms.TextBox
Friend WithEvents txtPass2 As System.Windows.Forms.TextBox
Friend WithEvents btnCancelar As System.Windows.Forms.Button
Friend WithEvents Panel1 As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btnAceptar = New System.Windows.Forms.Button()
Me.txtPass1 = New System.Windows.Forms.TextBox()
Me.txtPass2 = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.lblUsuario = New System.Windows.Forms.Label()
Me.btnCancelar = New System.Windows.Forms.Button()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'btnAceptar
'
Me.btnAceptar.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnAceptar.Location = New System.Drawing.Point(72, 102)
Me.btnAceptar.Name = "btnAceptar"
Me.btnAceptar.Size = New System.Drawing.Size(75, 23)
Me.btnAceptar.TabIndex = 0
Me.btnAceptar.Text = "Aceptar"
'
'txtPass1
'
Me.txtPass1.Location = New System.Drawing.Point(139, 40)
Me.txtPass1.Name = "txtPass1"
Me.txtPass1.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.txtPass1.Size = New System.Drawing.Size(152, 20)
Me.txtPass1.TabIndex = 1
'
'txtPass2
'
Me.txtPass2.Location = New System.Drawing.Point(139, 66)
Me.txtPass2.Name = "txtPass2"
Me.txtPass2.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.txtPass2.Size = New System.Drawing.Size(152, 20)
Me.txtPass2.TabIndex = 2
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.Color.MidnightBlue
Me.Label1.Location = New System.Drawing.Point(82, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(54, 16)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Password"
'
'Label2
'
Me.Label2.ForeColor = System.Drawing.Color.MidnightBlue
Me.Label2.Location = New System.Drawing.Point(6, 66)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(140, 16)
Me.Label2.TabIndex = 4
Me.Label2.Text = "Confirmaci<EFBFBD>n de password"
'
'lblUsuario
'
Me.lblUsuario.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblUsuario.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.lblUsuario.Location = New System.Drawing.Point(100, 8)
Me.lblUsuario.Name = "lblUsuario"
Me.lblUsuario.Size = New System.Drawing.Size(110, 18)
Me.lblUsuario.TabIndex = 6
Me.lblUsuario.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'btnCancelar
'
Me.btnCancelar.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnCancelar.Location = New System.Drawing.Point(162, 102)
Me.btnCancelar.Name = "btnCancelar"
Me.btnCancelar.Size = New System.Drawing.Size(75, 23)
Me.btnCancelar.TabIndex = 7
Me.btnCancelar.Text = "Cancelar"
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(202, Byte), Integer), CType(CType(202, Byte), Integer), CType(CType(183, Byte), Integer))
Me.Panel1.Controls.Add(Me.txtPass1)
Me.Panel1.Controls.Add(Me.lblUsuario)
Me.Panel1.Controls.Add(Me.btnCancelar)
Me.Panel1.Controls.Add(Me.txtPass2)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Controls.Add(Me.btnAceptar)
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Location = New System.Drawing.Point(8, 10)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(300, 142)
Me.Panel1.TabIndex = 8
'
'CambioPassword
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(51, Byte), Integer), CType(CType(102, Byte), Integer))
Me.ClientSize = New System.Drawing.Size(316, 162)
Me.Controls.Add(Me.Panel1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.MaximizeBox = False
Me.Name = "CambioPassword"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Cambio de Password"
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.ResumeLayout(False)
End Sub
#End Region
Dim frmLogin As Login = New Login
Dim clCmp As clsComplejo = New clsComplejo
Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click
Dim Classcom As New clsComplejo
Try
If Me.txtPass1.Text.Length <> 0 Then
If txtPass1.Text = txtPass2.Text Then
Dim NewPass As String
NewPass = Registro.Encripta(txtPass1.Text)
'Construyo el query para la actualizacion
Dim _Fecha As String = Now
Dim SQL As String = ""
SQL = "spCambioPassword ' " & Classcom.ObtenFecha(_Fecha, "yyyymmdd") & "', '" & Me.lblUsuario.Text & "', '" & NewPass & "'"
clCmp.sbGuardaModifica(SQL)
MessageBox.Show("Tu password ha sido cambiado", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
Else
MessageBox.Show("La confirmacion del password no coincide", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtPass2.Text = ""
txtPass2.Focus()
End If
Else
MessageBox.Show("Tu password no puede estar en blanco", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show("Error CambioPassword; btnAceptar_Click: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub CambioPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblUsuario.Text = frmLogin.NombreUsuario
End Sub
Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
Application.Exit()
End Sub
End Class