Public Class FrmClaveAdmin
    Public Sub New(ByRef owner As Form)
        If TypeOf owner IsNot FrmMenuPrincipal Then Throw New Exception("El formulario clave administrador solo se puede abrir desde el menu principal.")
        InitializeComponent()
        Me.Owner = owner
    End Sub

    Private Sub BtnIniciarSesion_Click(sender As Object, e As EventArgs) Handles BtnIniciarSesion.Click
        ProcesarContraseña()
    End Sub

    Private Sub ProcesarContraseña()
        If (TxtContraseña.Text.Equals("chile", StringComparison.CurrentCultureIgnoreCase)) Then
            CType(Me.Owner, FrmMenuPrincipal).AbrirMenuSecundario()
            Me.Close()

        Else
            MessageBox.Show("Contraseña incorrecta.", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
            TxtContraseña.Select()
            TxtContraseña.SelectAll()
        End If
    End Sub

    Private Sub Keypress_Enter(sender As Object, e As KeyPressEventArgs) Handles TxtContraseña.KeyPress, Me.KeyPress
        If e.KeyChar = Chr(13) Then
            ProcesarContraseña()
            e.Handled = True
        ElseIf e.KeyChar = Chr(27) Then
            e.Handled = True
            Me.Close()
        End If
    End Sub

    Private Sub LinkSalir_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) 
        Me.Close()
    End Sub
End Class