Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports Funcion.Funcion

Public Class AccesoAutorizado
    Inherits System.Windows.Forms.Form
    Dim sentFuncion As New Funcion.Funcion
    Dim veces As Integer = 1
    Dim Acceso As Boolean
    Dim Password As String

    Dim ImagenEncabezado = New System.Windows.Forms.PictureBox
    Dim btnMaximizar1 = New System.Windows.Forms.PictureBox
    Dim btnCerrar = New System.Windows.Forms.PictureBox
    Dim btnMinimizar = New System.Windows.Forms.PictureBox
    Dim btnMaximizar2 = New System.Windows.Forms.PictureBox
    Dim PanBtn = New System.Windows.Forms.Panel
    Dim lblNombre = New System.Windows.Forms.Label
    Dim PictureBox6 = New System.Windows.Forms.PictureBox
    Dim Linea1 = New System.Windows.Forms.Label
    Dim Linea2 = New System.Windows.Forms.Label
    Dim Linea3 = New System.Windows.Forms.Label
    Dim dr As SqlDataReader
    Dim color1, color2 As String

#Region " Código generado por el Diseñador de Windows Forms "

    Public Sub New()
        MyBase.New()

        'El Diseñador de Windows Forms requiere esta llamada.
        InitializeComponent()
        Skin()

        'Agregar cualquier inicialización después de la llamada a InitializeComponent()

    End Sub

    'Form reemplaza a Dispose para limpiar la lista de componentes.
    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

    'Requerido por el Diseñador de Windows Forms
    Private components As System.ComponentModel.IContainer

    'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
    'Puede modificarse utilizando el Diseñador de Windows Forms. 
    'No lo modifique con el editor de código.
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents btnCancelar As System.Windows.Forms.Button
    Friend WithEvents btnAceptar As System.Windows.Forms.Button
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TopLeftColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents BottomRightColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label4 = New System.Windows.Forms.Label
        Me.btnCancelar = New System.Windows.Forms.Button
        Me.btnAceptar = New System.Windows.Forms.Button
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.TopLeftColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.BottomRightColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.Color.Transparent
        Me.Label4.Location = New System.Drawing.Point(48, 72)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(120, 23)
        Me.Label4.TabIndex = 13
        Me.Label4.Text = "Contraseña"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'btnCancelar
        '
        Me.btnCancelar.Anchor = System.Windows.Forms.AnchorStyles.Bottom
        Me.btnCancelar.BackColor = System.Drawing.Color.Transparent
        Me.btnCancelar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.btnCancelar.Location = New System.Drawing.Point(188, 144)
        Me.btnCancelar.Name = "btnCancelar"
        Me.btnCancelar.Size = New System.Drawing.Size(96, 23)
        Me.btnCancelar.TabIndex = 12
        Me.btnCancelar.Text = "&Cancelar"
        '
        'btnAceptar
        '
        Me.btnAceptar.Anchor = System.Windows.Forms.AnchorStyles.Bottom
        Me.btnAceptar.BackColor = System.Drawing.Color.Transparent
        Me.btnAceptar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.btnAceptar.Location = New System.Drawing.Point(76, 144)
        Me.btnAceptar.Name = "btnAceptar"
        Me.btnAceptar.Size = New System.Drawing.Size(96, 23)
        Me.btnAceptar.TabIndex = 11
        Me.btnAceptar.Text = "&Aceptar"
        '
        'TextBox2
        '
        Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox2.Location = New System.Drawing.Point(184, 72)
        Me.TextBox2.MaxLength = 20
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.TextBox2.Size = New System.Drawing.Size(128, 20)
        Me.TextBox2.TabIndex = 10
        Me.TextBox2.Text = "********************"
        '
        'TopLeftColor
        '
        Me.TopLeftColor.Color = System.Drawing.SystemColors.Control
        Me.TopLeftColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.TopLeftColor.ForeColor = System.Drawing.Color.Cyan
        Me.TopLeftColor.Location = New System.Drawing.Point(0, 0)
        Me.TopLeftColor.Name = "TopLeftColor"
        Me.TopLeftColor.Size = New System.Drawing.Size(12, 12)
        Me.TopLeftColor.TabIndex = 17
        Me.TopLeftColor.Text = "ColorPicker1"
        Me.TopLeftColor.TextDisplayed = False
        '
        'BottomRightColor
        '
        Me.BottomRightColor.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.BottomRightColor.Color = System.Drawing.SystemColors.Control
        Me.BottomRightColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.BottomRightColor.ForeColor = System.Drawing.Color.Cyan
        Me.BottomRightColor.Location = New System.Drawing.Point(348, 172)
        Me.BottomRightColor.Name = "BottomRightColor"
        Me.BottomRightColor.Size = New System.Drawing.Size(12, 12)
        Me.BottomRightColor.TabIndex = 18
        Me.BottomRightColor.Text = "ColorPicker1"
        Me.BottomRightColor.TextDisplayed = False
        '
        'TextBox1
        '
        Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox1.Location = New System.Drawing.Point(184, 40)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(128, 20)
        Me.TextBox1.TabIndex = 19
        Me.TextBox1.Text = "TEXTBOX1"
        '
        'AccesoAutorizado
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(360, 184)
        Me.ControlBox = False
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.BottomRightColor)
        Me.Controls.Add(Me.TopLeftColor)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.btnCancelar)
        Me.Controls.Add(Me.btnAceptar)
        Me.Controls.Add(Me.TextBox2)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "AccesoAutorizado"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region " Skin "
    Public Sub Skin()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Madre))
        Me.PanBtn.SuspendLayout()
        Me.SuspendLayout()
        '
        'ImagenEncabezado
        '
        Me.ImagenEncabezado.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ImagenEncabezado.Cursor = System.Windows.Forms.Cursors.Default
        Me.ImagenEncabezado.Image = CType(resources.GetObject("ImagenEncabezado.Image"), System.Drawing.Image)
        Me.ImagenEncabezado.Location = New System.Drawing.Point(0, 0)
        Me.ImagenEncabezado.Name = "ImagenEncabezado"
        Me.ImagenEncabezado.Size = New System.Drawing.Size(Me.Size.Width, 19)
        Me.ImagenEncabezado.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.ImagenEncabezado.TabIndex = 5
        Me.ImagenEncabezado.TabStop = False
        '
        'btnMaximizar1
        '
        Me.btnMaximizar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.btnMaximizar1.Cursor = System.Windows.Forms.Cursors.Default
        Me.btnMaximizar1.Image = CType(resources.GetObject("btnMaximizar1.Image"), System.Drawing.Image)
        Me.btnMaximizar1.Location = New System.Drawing.Point(18, 0)
        Me.btnMaximizar1.Name = "btnMaximizar1"
        Me.btnMaximizar1.Size = New System.Drawing.Size(19, 19)
        Me.btnMaximizar1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.btnMaximizar1.TabIndex = 13
        Me.btnMaximizar1.TabStop = False
        '
        'btnCerrar
        '
        Me.btnCerrar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.btnCerrar.Cursor = System.Windows.Forms.Cursors.Default
        Me.btnCerrar.Image = CType(resources.GetObject("btnCerrar.Image"), System.Drawing.Image)
        Me.btnCerrar.Location = New System.Drawing.Point(35, 0)
        Me.btnCerrar.Name = "btnCerrar"
        Me.btnCerrar.Size = New System.Drawing.Size(20, 19)
        Me.btnCerrar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.btnCerrar.TabIndex = 12
        Me.btnCerrar.TabStop = False
        '
        'btnMinimizar
        '
        Me.btnMinimizar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.btnMinimizar.Cursor = System.Windows.Forms.Cursors.Arrow
        Me.btnMinimizar.Image = CType(resources.GetObject("btnMinimizar.Image"), System.Drawing.Image)
        Me.btnMinimizar.Location = New System.Drawing.Point(0, 0)
        Me.btnMinimizar.Name = "btnMinimizar"
        Me.btnMinimizar.Size = New System.Drawing.Size(19, 19)
        Me.btnMinimizar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.btnMinimizar.TabIndex = 10
        Me.btnMinimizar.TabStop = False
        '
        'btnMaximizar2
        '
        Me.btnMaximizar2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.btnMaximizar2.Cursor = System.Windows.Forms.Cursors.Default
        Me.btnMaximizar2.Image = CType(resources.GetObject("btnMaximizar2.Image"), System.Drawing.Image)
        Me.btnMaximizar2.Location = New System.Drawing.Point(18, 0)
        Me.btnMaximizar2.Name = "btnMaximizar2"
        Me.btnMaximizar2.Size = New System.Drawing.Size(19, 19)
        Me.btnMaximizar2.TabIndex = 9
        Me.btnMaximizar2.TabStop = False
        Me.btnMaximizar2.Visible = False
        '
        'PanBtn
        '
        Me.PanBtn.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.PanBtn.Controls.Add(Me.btnMaximizar1)
        Me.PanBtn.Controls.Add(Me.btnCerrar)
        Me.PanBtn.Controls.Add(Me.btnMinimizar)
        Me.PanBtn.Controls.Add(Me.btnMaximizar2)
        Me.PanBtn.Cursor = System.Windows.Forms.Cursors.Default
        Me.PanBtn.Location = New System.Drawing.Point(Me.Size.Width - 55, 0)
        Me.PanBtn.Name = "PanBtn"
        Me.PanBtn.Size = New System.Drawing.Size(55, 20)
        Me.PanBtn.TabIndex = 14
        '
        'lblNombre
        '
        Me.lblNombre.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblNombre.ForeColor = System.Drawing.Color.White
        Me.lblNombre.Image = CType(resources.GetObject("lblNombre.Image"), System.Drawing.Image)
        Me.lblNombre.Location = New System.Drawing.Point(20, 0)
        Me.lblNombre.Name = "lblNombre"
        Me.lblNombre.Size = New System.Drawing.Size(150, 16)
        Me.lblNombre.TabIndex = 16
        Me.lblNombre.Text = "Acceso Autorizado"
        '
        'PictureBox6
        '
        Me.PictureBox6.BackColor = System.Drawing.Color.Transparent
        Me.PictureBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.PictureBox6.Cursor = System.Windows.Forms.Cursors.Default
        Me.PictureBox6.Image = CType(resources.GetObject("PictureBox6.Image"), System.Drawing.Image)
        Me.PictureBox6.Location = New System.Drawing.Point(0, 0)
        Me.PictureBox6.Name = "PictureBox6"
        Me.PictureBox6.Size = New System.Drawing.Size(19, 19)
        Me.PictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.PictureBox6.TabIndex = 15
        Me.PictureBox6.TabStop = False
        '
        'Linea1
        '
        Me.Linea1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.Linea1.BackColor = System.Drawing.Color.FromArgb(CType(64, Byte), CType(64, Byte), CType(64, Byte))
        Me.Linea1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Linea1.Location = New System.Drawing.Point(0, 0)
        Me.Linea1.Name = "Linea1"
        Me.Linea1.Size = New System.Drawing.Size(2, Me.Size.Height)
        Me.Linea1.TabIndex = 272

        '
        'Linea2
        '
        Me.Linea2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Linea2.BackColor = System.Drawing.Color.FromArgb(CType(64, Byte), CType(64, Byte), CType(64, Byte))
        Me.Linea2.Cursor = System.Windows.Forms.Cursors.SizeWE
        Me.Linea2.Location = New System.Drawing.Point(Me.Size.Width - 2, 0)
        Me.Linea2.Name = "Linea2"
        Me.Linea2.Size = New System.Drawing.Size(2, Me.Size.Height)
        Me.Linea2.TabIndex = 273
        '
        'Linea3
        '
        Me.Linea3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Linea3.BackColor = System.Drawing.Color.FromArgb(CType(64, Byte), CType(64, Byte), CType(64, Byte))
        Me.Linea3.Cursor = System.Windows.Forms.Cursors.SizeNS
        Me.Linea3.Location = New System.Drawing.Point(0, Me.Size.Height - 2)
        Me.Linea3.Name = "Linea3"
        Me.Linea3.Size = New System.Drawing.Size(Me.Size.Width, 2)
        Me.Linea3.TabIndex = 274
        '
        'TopLeftColor
        '
        Me.TopLeftColor.Color = System.Drawing.Color.SteelBlue
        Me.TopLeftColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.TopLeftColor.ForeColor = System.Drawing.Color.Cyan
        Me.TopLeftColor.Location = New System.Drawing.Point(0, 19)
        Me.TopLeftColor.Name = "TopLeftColor"
        Me.TopLeftColor.Size = New System.Drawing.Size(12, 12)
        Me.TopLeftColor.TabIndex = 277
        Me.TopLeftColor.Text = "ColorPicker1"
        Me.TopLeftColor.TextDisplayed = False
        '
        'BottomRightColor
        '
        Me.BottomRightColor.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.BottomRightColor.Color = System.Drawing.Color.PapayaWhip
        Me.BottomRightColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.BottomRightColor.Location = New System.Drawing.Point(Me.Size.Width - 13, Me.Size.Height - 13)
        Me.BottomRightColor.Name = "BottomRightColor"
        Me.BottomRightColor.Size = New System.Drawing.Size(12, 12)
        Me.BottomRightColor.TabIndex = 278
        Me.BottomRightColor.Text = "ColorPicker1"
        Me.BottomRightColor.TextDisplayed = False

        '
        'Madre
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(230, Byte), CType(230, Byte), CType(230, Byte))
        Me.ClientSize = New System.Drawing.Size(Me.Size.Width, Me.Size.Height)
        Me.Controls.Add(Me.Linea3)
        Me.Controls.Add(Me.Linea2)
        Me.Controls.Add(Me.Linea1)
        Me.Controls.Add(Me.TopLeftColor)
        Me.Controls.Add(Me.BottomRightColor)
        Me.Controls.Add(Me.lblNombre)
        Me.Controls.Add(Me.ImagenEncabezado)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Text = "Acceso"
        Me.ResumeLayout(False)
    End Sub
#End Region

    Private Sub ColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TopLeftColor.ColorChanged, BottomRightColor.ColorChanged
        Me.Refresh()
        color1 = TopLeftColor.Color.Name.ToString
        color2 = BottomRightColor.Color.Name.ToString
    End Sub

    Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim B As Brush
        Try
            B = New Drawing2D.LinearGradientBrush(Me.ClientRectangle, Me.TopLeftColor.Color, Me.BottomRightColor.Color, Drawing2D.LinearGradientMode.ForwardDiagonal)
            e.Graphics.FillRectangle(B, Me.ClientRectangle)
        Catch
        Finally
            If Not B Is Nothing Then
                B.Dispose()
            End If
        End Try
    End Sub

    Public Sub Configuraciones()
        ' Use reflection to find the location of the config file. 
        Dim Asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
        Dim strConfigLoc As String = Asm.Location

        ' The config file is located in the application's bin directory, so
        ' you need to remove the file name.
        Dim strTemp As String
        strTemp = strConfigLoc
        strTemp = System.IO.Path.GetDirectoryName(strConfigLoc)

        ' Declare a FileInfo object for the config file.
        Dim FileInfo As System.IO.FileInfo = New System.IO.FileInfo(strTemp & "\OndaNet.xml")

        ' Load the config file into the XML DOM.
        Dim XmlDocument As New System.Xml.XmlDocument
        XmlDocument.Load(FileInfo.FullName)

        ' Find the right node and change it to the new value.
        Dim Node As System.Xml.XmlNode
        For Each Node In XmlDocument.Item("configuration").Item("Usuario")
            ' Skip any comments.
            If Node.Name = "add" Then
                If Node.Attributes.GetNamedItem("key").Value = "AccesoCobrador" Then
                    If Node.Attributes.GetNamedItem("value").Value = "1" Then
                        Me.WindowState = FormWindowState.Maximized
                    Else
                        Me.WindowState = FormWindowState.Normal
                    End If

                End If
                Dim a As String
                If Node.Attributes.GetNamedItem("key").Value = "AccesoCobradorColor1" Then
                    TopLeftColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
                If Node.Attributes.GetNamedItem("key").Value = "AccesoCobradorColor2" Then
                    BottomRightColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
            End If
        Next Node
    End Sub

    Private Sub AsignarEventos(ByVal elControl As Control)
        Dim sentFuncion As New Funcion.Funcion
        Dim tamanoTextbox As Single = TAMANO1 + 0.25
        Dim tamanoLabels As Single = TAMANO2 + 0.25
        Dim tamanoBotones As Single = TAMANO3 + 0.25
        Dim tamanoCheck As Single = TAMANO4 + 0.25
        Dim ctrl As Control
        For Each ctrl In elControl.Controls
            AddHandler ctrl.KeyPress, AddressOf Me.Salir
            If ctrl.GetType.Name = "TextBox" Or ctrl.GetType.Name = "RadioButton" Or ctrl.GetType.Name = "TxtConta" Or ctrl.GetType.Name = "ComboBox" Then
                ctrl.Font = New System.Drawing.Font("Microsoft Sans Serif", tamanoTextbox, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                ctrl.ForeColor = System.Drawing.Color.FromArgb(CType(sentFuncion.ColorRed(CONCOLOR1), Byte), CType(sentFuncion.ColorGreen(CONCOLOR1), Byte), CType(sentFuncion.ColorBlue(CONCOLOR1), Byte))
            End If
            If ctrl.GetType.Name = "Label" Or ctrl.GetType.Name = "GroupBox" Then
                ctrl.Font = New System.Drawing.Font("Microsoft Sans Serif", tamanoLabels, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                ctrl.ForeColor = System.Drawing.Color.FromArgb(CType(sentFuncion.ColorRed(CONCOLOR2), Byte), CType(sentFuncion.ColorGreen(CONCOLOR2), Byte), CType(sentFuncion.ColorBlue(CONCOLOR2), Byte))
            End If
            If ctrl.GetType.Name = "Button" Then
                ctrl.Font = New System.Drawing.Font("Microsoft Sans Serif", tamanoBotones, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                ctrl.ForeColor = System.Drawing.Color.FromArgb(CType(sentFuncion.ColorRed(CONCOLOR3), Byte), CType(sentFuncion.ColorGreen(CONCOLOR3), Byte), CType(sentFuncion.ColorBlue(CONCOLOR3), Byte))
            End If
        Next
    End Sub

    Private Sub Salir(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 27 Then
            Me.Tag = False
            Close()
        End If
    End Sub

    Private Sub AccesoAutorizado_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

    End Sub

    Private Sub AccesoAutorizado_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        color1 = TopLeftColor.Color.Name.ToString
        color2 = BottomRightColor.Color.Name.ToString

        Dim Asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
        Dim strConfigLoc As String = Asm.Location
        Dim strTemp As String
        strTemp = strConfigLoc
        strTemp = System.IO.Path.GetDirectoryName(strConfigLoc)
        Dim FileInfo As System.IO.FileInfo = New System.IO.FileInfo(strTemp & "\OndaNet.xml")
        Dim XmlDocument As New System.Xml.XmlDocument
        XmlDocument.Load(FileInfo.FullName)
        Dim Node As System.Xml.XmlNode
        For Each Node In XmlDocument.Item("configuration").Item("Usuario")
            If Node.Name = "add" Then
                If Node.Attributes.GetNamedItem("key").Value = "AccesoCobrador" Then
                    If Me.WindowState = FormWindowState.Maximized Then
                        Node.Attributes.GetNamedItem("value").Value = CType("1", String)
                    Else
                        Node.Attributes.GetNamedItem("value").Value = CType("0", String)
                    End If
                End If
                If Node.Attributes.GetNamedItem("key").Value = "VentasColor1" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(color1, String)
                End If
                If Node.Attributes.GetNamedItem("key").Value = "VentasColor2" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(color2, String)
                End If
            End If
        Next Node
        XmlDocument.Save(FileInfo.FullName)
    End Sub

    Private Sub AccesoAutorizado_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BackColorChanged
        Me.Refresh()
    End Sub

    Private Sub AccesoAutorizado_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        Me.Refresh()
    End Sub

    Public Sub limpiar()
        TextBox1.Text = ""
        TextBox2.Text = ""

        TextBox1.Focus()
        TextBox1.Visible = False
    End Sub

    Private Sub AccesoAutorizado_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        limpiar()
        Configuraciones()
        AsignarEventos(Me)

        Me.Refresh()
    End Sub

    'Click
    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Me.Tag = False
        Acceso = False
        Close()
    End Sub

    Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click

        If UsuCodigo <> 0 Then
            If TextBox2.Text.Trim = sentFuncion.Descripcion_Tabla("PASSUSUARIO", "USUARIO", "CODUSUARIO", UsuCodigo, EmpCodigo) Then
                Me.Tag = True
                Acceso = True
                Close()
                Exit Sub
            Else
                MsgBox("Password incorrecto!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation + MsgBoxStyle.DefaultButton1 + MsgBoxStyle.ApplicationModal + MsgBoxStyle.MsgBoxSetForeground)
            End If
        End If

        If TextBox1.Tag <> 0 Then
            TextBox2.SelectionStart = 0
            TextBox2.SelectionLength = Len(TextBox2.Text)
            TextBox2.Focus()
        Else
            TextBox1.SelectionStart = 0
            TextBox1.SelectionLength = Len(TextBox1.Text)
            TextBox1.Focus()
        End If

        If veces = 3 Then
            Me.Tag = False
            Acceso = False
            Close()
        End If

        veces = veces + 1
    End Sub

    'KeyPress
    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Dim KeyAscii As Short = Asc(e.KeyChar)
        Dim cadena As Object

        cadena = StringCadena
        If InStr(cadena, Chr(KeyAscii)) = 0 Then
            KeyAscii = 0
        Else
            If KeyAscii = 13 Then
                TextBox2.Focus()
            End If
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        Dim cadena As Object

        cadena = StringCadena
        If InStr(cadena, Chr(KeyAscii)) = 0 Then
            KeyAscii = 0
        Else
            If KeyAscii = 13 Then
                btnAceptar.Focus()
            End If
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    'KeyDown
    Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Up Then
            TextBox2.Focus()
        ElseIf e.KeyCode = Keys.Down Then
            TextBox2.Focus()
        End If
    End Sub

    Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
        If e.KeyCode = Keys.Up Then
            TextBox1.Focus()
        ElseIf e.KeyCode = Keys.Down Then
            TextBox1.Focus()
        End If
    End Sub

    'Validated
    Private Sub TextBox1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If TextBox1.Text.Trim <> "" Then
            TextBox1.Tag = sentFuncion.Validar_Tabla("CODUSUARIO", "USUARIO", "DESUSUARIO", TextBox1.Text.Trim, EmpCodigo)
        End If
    End Sub

    'GotFocus
    Private Sub TextBox1_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SeleccionaTexto(TextBox1)
    End Sub

    Private Sub TextBox2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.GotFocus
        SeleccionaTexto(TextBox2)
    End Sub

    'Luis Grossling
    '07/09/2005
    Private Sub SeleccionaTexto(ByRef textbox As Windows.Forms.TextBox)
        'Selecciona el texto que esta escrito
        'en el textbox
        textbox.SelectionStart = 0
        textbox.SelectionLength = Len(textbox.Text)
        textbox.Focus()
    End Sub

    '' QUE PELADA CON ESTO CUALQUIER USUARIO PUEDE GRABAR LA VENTA 04-03-2009"

    'Private Sub TextBox2_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Validated
    '    If TextBox2.Text.Trim <> "" Then
    '        TextBox1.Tag = sentFuncion.Validar_Tabla("CODUSUARIO", "USUARIO", "PASSUSUARIO", TextBox2.Text.Trim.ToUpper, EmpCodigo)
    '    End If
    'End Sub
End Class
