Imports System.Data.SqlClient
Public Class BuscarCuenta
    Inherits System.Windows.Forms.Form
    Dim sentFuncion As New Funcion.Funcion
    Dim veces As Integer = 1
    Dim codusu As New Funcion.Funcion
    Dim MDI As New MdiClientes
    Dim b As Integer
    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 ConoSinAsentables As String

    '¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
    'para los datos del formulario de búsqueda
    Dim Direccion As Object
    Dim Tira As String
    Dim items As Integer = 0
    Dim encontrado As Boolean

    'para controlar los colores del sistema o sea de la ventana
    Dim Color1, Color2 As String

    Dim funcionbuscarcuenta As New Funcion.Funcion
#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 txtResultado As System.Windows.Forms.TextBox
    Public WithEvents Frame2 As System.Windows.Forms.GroupBox
    Public WithEvents lstDetalle2 As System.Windows.Forms.ListBox
    Public WithEvents lstDetalle1 As System.Windows.Forms.ListBox
    Public WithEvents Frame1 As System.Windows.Forms.GroupBox
    Friend WithEvents txtBuscar As System.Windows.Forms.TextBox
    Friend WithEvents ordenDescripcion As System.Windows.Forms.RadioButton
    Friend WithEvents ordenCodigo As System.Windows.Forms.RadioButton
    Friend WithEvents ordenSubCuenta As System.Windows.Forms.RadioButton
    Public WithEvents lstDetalle3 As System.Windows.Forms.ListBox
    Public WithEvents lstDetalle4 As System.Windows.Forms.ListBox
    Friend WithEvents TopLeftColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents BottomRightColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents Frame3 As System.Windows.Forms.GroupBox
    Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
    Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txtResultado = New System.Windows.Forms.TextBox
        Me.Frame2 = New System.Windows.Forms.GroupBox
        Me.lstDetalle2 = New System.Windows.Forms.ListBox
        Me.lstDetalle1 = New System.Windows.Forms.ListBox
        Me.lstDetalle3 = New System.Windows.Forms.ListBox
        Me.Frame1 = New System.Windows.Forms.GroupBox
        Me.txtBuscar = New System.Windows.Forms.TextBox
        Me.ordenDescripcion = New System.Windows.Forms.RadioButton
        Me.ordenCodigo = New System.Windows.Forms.RadioButton
        Me.ordenSubCuenta = New System.Windows.Forms.RadioButton
        Me.Frame3 = New System.Windows.Forms.GroupBox
        Me.lstDetalle4 = New System.Windows.Forms.ListBox
        Me.TopLeftColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.BottomRightColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
        Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
        Me.Frame2.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.Frame3.SuspendLayout()
        Me.SuspendLayout()
        '
        'txtResultado
        '
        Me.txtResultado.Location = New System.Drawing.Point(240, 56)
        Me.txtResultado.Name = "txtResultado"
        Me.txtResultado.Size = New System.Drawing.Size(160, 20)
        Me.txtResultado.TabIndex = 29
        Me.txtResultado.Text = ""
        Me.txtResultado.Visible = False
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.Color.Transparent
        Me.Frame2.Controls.Add(Me.lstDetalle2)
        Me.Frame2.Controls.Add(Me.lstDetalle1)
        Me.Frame2.Controls.Add(Me.lstDetalle3)
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(8, 96)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(564, 201)
        Me.Frame2.TabIndex = 28
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "Todas las palabras registradas"
        '
        'lstDetalle2
        '
        Me.lstDetalle2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lstDetalle2.BackColor = System.Drawing.SystemColors.Window
        Me.lstDetalle2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstDetalle2.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstDetalle2.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstDetalle2.Location = New System.Drawing.Point(264, 16)
        Me.lstDetalle2.Name = "lstDetalle2"
        Me.lstDetalle2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstDetalle2.Size = New System.Drawing.Size(144, 184)
        Me.lstDetalle2.TabIndex = 6
        '
        'lstDetalle1
        '
        Me.lstDetalle1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lstDetalle1.BackColor = System.Drawing.SystemColors.Window
        Me.lstDetalle1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstDetalle1.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstDetalle1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstDetalle1.Location = New System.Drawing.Point(8, 16)
        Me.lstDetalle1.Name = "lstDetalle1"
        Me.lstDetalle1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstDetalle1.Size = New System.Drawing.Size(256, 184)
        Me.lstDetalle1.TabIndex = 5
        '
        'lstDetalle3
        '
        Me.lstDetalle3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lstDetalle3.BackColor = System.Drawing.SystemColors.Window
        Me.lstDetalle3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstDetalle3.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstDetalle3.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstDetalle3.Location = New System.Drawing.Point(408, 16)
        Me.lstDetalle3.Name = "lstDetalle3"
        Me.lstDetalle3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstDetalle3.Size = New System.Drawing.Size(144, 184)
        Me.lstDetalle3.TabIndex = 7
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.Color.Transparent
        Me.Frame1.Controls.Add(Me.txtBuscar)
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(8, 24)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(328, 64)
        Me.Frame1.TabIndex = 27
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Ingrese las primeras letras de la consulta"
        '
        'txtBuscar
        '
        Me.txtBuscar.Location = New System.Drawing.Point(8, 27)
        Me.txtBuscar.Name = "txtBuscar"
        Me.txtBuscar.Size = New System.Drawing.Size(312, 20)
        Me.txtBuscar.TabIndex = 4
        Me.txtBuscar.Text = ""
        '
        'ordenDescripcion
        '
        Me.ordenDescripcion.BackColor = System.Drawing.Color.Transparent
        Me.ordenDescripcion.Location = New System.Drawing.Point(8, 16)
        Me.ordenDescripcion.Name = "ordenDescripcion"
        Me.ordenDescripcion.Size = New System.Drawing.Size(240, 16)
        Me.ordenDescripcion.TabIndex = 30
        Me.ordenDescripcion.Text = "&Descripción"
        '
        'ordenCodigo
        '
        Me.ordenCodigo.BackColor = System.Drawing.Color.Transparent
        Me.ordenCodigo.Location = New System.Drawing.Point(8, 32)
        Me.ordenCodigo.Name = "ordenCodigo"
        Me.ordenCodigo.Size = New System.Drawing.Size(240, 16)
        Me.ordenCodigo.TabIndex = 31
        Me.ordenCodigo.Text = "&Código de Cuenta"
        '
        'ordenSubCuenta
        '
        Me.ordenSubCuenta.BackColor = System.Drawing.Color.Transparent
        Me.ordenSubCuenta.Location = New System.Drawing.Point(8, 48)
        Me.ordenSubCuenta.Name = "ordenSubCuenta"
        Me.ordenSubCuenta.Size = New System.Drawing.Size(240, 16)
        Me.ordenSubCuenta.TabIndex = 32
        Me.ordenSubCuenta.Text = "&Sub-Cuenta"
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.Color.Transparent
        Me.Frame3.Controls.Add(Me.ordenDescripcion)
        Me.Frame3.Controls.Add(Me.ordenSubCuenta)
        Me.Frame3.Controls.Add(Me.ordenCodigo)
        Me.Frame3.Location = New System.Drawing.Point(352, 24)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.Size = New System.Drawing.Size(216, 72)
        Me.Frame3.TabIndex = 33
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "Ordenar x..."
        '
        'lstDetalle4
        '
        Me.lstDetalle4.Anchor = System.Windows.Forms.AnchorStyles.None
        Me.lstDetalle4.BackColor = System.Drawing.SystemColors.Window
        Me.lstDetalle4.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstDetalle4.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstDetalle4.Location = New System.Drawing.Point(496, 112)
        Me.lstDetalle4.Name = "lstDetalle4"
        Me.lstDetalle4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstDetalle4.Size = New System.Drawing.Size(144, 173)
        Me.lstDetalle4.TabIndex = 34
        '
        'TopLeftColor
        '
        Me.TopLeftColor.Color = System.Drawing.Color.SteelBlue
        Me.TopLeftColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold)
        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 = 280
        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)
        Me.BottomRightColor.Location = New System.Drawing.Point(560, 288)
        Me.BottomRightColor.Name = "BottomRightColor"
        Me.BottomRightColor.Size = New System.Drawing.Size(12, 12)
        Me.BottomRightColor.TabIndex = 281
        Me.BottomRightColor.Text = "ColorPicker1"
        Me.BottomRightColor.TextDisplayed = False
        '
        'SqlSelectCommand1
        '
        Me.SqlSelectCommand1.CommandText = "SELECT NUMCAJA, CODSUCURSAL, CODPLANCUENTA, CODCOBRADOR, CODUSUARIO, CODEMPRESA, " & _
        "FECGRA FROM CAJA"
        Me.SqlSelectCommand1.Connection = Me.SqlConnection1
        '
        'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = "workstation id=GERKE;packet size=4096;integrated security=SSPI;data source=GERKE;" & _
        "persist security info=True;initial catalog=OndaNetN"
        '
        'SqlInsertCommand1
        '
        Me.SqlInsertCommand1.CommandText = "INSERT INTO CAJA(NUMCAJA, CODSUCURSAL, CODPLANCUENTA, CODCOBRADOR, CODUSUARIO, CO" & _
        "DEMPRESA, FECGRA) VALUES (@NUMCAJA, @CODSUCURSAL, @CODPLANCUENTA, @CODCOBRADOR, " & _
        "@CODUSUARIO, @CODEMPRESA, @FECGRA); SELECT NUMCAJA, CODSUCURSAL, CODPLANCUENTA, " & _
        "CODCOBRADOR, CODUSUARIO, CODEMPRESA, FECGRA FROM CAJA WHERE (NUMCAJA = @NUMCAJA)" & _
        ""
        Me.SqlInsertCommand1.Connection = Me.SqlConnection1
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NUMCAJA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "NUMCAJA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODSUCURSAL", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODSUCURSAL", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODPLANCUENTA", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, False, CType(25, Byte), CType(0, Byte), "CODPLANCUENTA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODCOBRADOR", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODCOBRADOR", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODUSUARIO", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODUSUARIO", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODEMPRESA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODEMPRESA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FECGRA", System.Data.SqlDbType.DateTime, 8, "FECGRA"))
        '
        'SqlUpdateCommand1
        '
        Me.SqlUpdateCommand1.CommandText = "UPDATE CAJA SET NUMCAJA = @NUMCAJA, CODSUCURSAL = @CODSUCURSAL, CODPLANCUENTA = @" & _
        "CODPLANCUENTA, CODCOBRADOR = @CODCOBRADOR, CODUSUARIO = @CODUSUARIO, CODEMPRESA " & _
        "= @CODEMPRESA, FECGRA = @FECGRA WHERE (NUMCAJA = @Original_NUMCAJA) AND (CODCOBR" & _
        "ADOR = @Original_CODCOBRADOR OR @Original_CODCOBRADOR IS NULL AND CODCOBRADOR IS" & _
        " NULL) AND (CODEMPRESA = @Original_CODEMPRESA OR @Original_CODEMPRESA IS NULL AN" & _
        "D CODEMPRESA IS NULL) AND (CODPLANCUENTA = @Original_CODPLANCUENTA OR @Original_" & _
        "CODPLANCUENTA IS NULL AND CODPLANCUENTA IS NULL) AND (CODSUCURSAL = @Original_CO" & _
        "DSUCURSAL OR @Original_CODSUCURSAL IS NULL AND CODSUCURSAL IS NULL) AND (CODUSUA" & _
        "RIO = @Original_CODUSUARIO OR @Original_CODUSUARIO IS NULL AND CODUSUARIO IS NUL" & _
        "L) AND (FECGRA = @Original_FECGRA OR @Original_FECGRA IS NULL AND FECGRA IS NULL" & _
        "); SELECT NUMCAJA, CODSUCURSAL, CODPLANCUENTA, CODCOBRADOR, CODUSUARIO, CODEMPRE" & _
        "SA, FECGRA FROM CAJA WHERE (NUMCAJA = @NUMCAJA)"
        Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NUMCAJA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "NUMCAJA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODSUCURSAL", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODSUCURSAL", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODPLANCUENTA", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, False, CType(25, Byte), CType(0, Byte), "CODPLANCUENTA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODCOBRADOR", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODCOBRADOR", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODUSUARIO", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODUSUARIO", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CODEMPRESA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODEMPRESA", System.Data.DataRowVersion.Current, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FECGRA", System.Data.SqlDbType.DateTime, 8, "FECGRA"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NUMCAJA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "NUMCAJA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODCOBRADOR", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODCOBRADOR", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODEMPRESA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODEMPRESA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODPLANCUENTA", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, False, CType(25, Byte), CType(0, Byte), "CODPLANCUENTA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODSUCURSAL", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODSUCURSAL", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODUSUARIO", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODUSUARIO", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FECGRA", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "FECGRA", System.Data.DataRowVersion.Original, Nothing))
        '
        'SqlDeleteCommand1
        '
        Me.SqlDeleteCommand1.CommandText = "DELETE FROM CAJA WHERE (NUMCAJA = @Original_NUMCAJA) AND (CODCOBRADOR = @Original" & _
        "_CODCOBRADOR OR @Original_CODCOBRADOR IS NULL AND CODCOBRADOR IS NULL) AND (CODE" & _
        "MPRESA = @Original_CODEMPRESA OR @Original_CODEMPRESA IS NULL AND CODEMPRESA IS " & _
        "NULL) AND (CODPLANCUENTA = @Original_CODPLANCUENTA OR @Original_CODPLANCUENTA IS" & _
        " NULL AND CODPLANCUENTA IS NULL) AND (CODSUCURSAL = @Original_CODSUCURSAL OR @Or" & _
        "iginal_CODSUCURSAL IS NULL AND CODSUCURSAL IS NULL) AND (CODUSUARIO = @Original_" & _
        "CODUSUARIO OR @Original_CODUSUARIO IS NULL AND CODUSUARIO IS NULL) AND (FECGRA =" & _
        " @Original_FECGRA OR @Original_FECGRA IS NULL AND FECGRA IS NULL)"
        Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NUMCAJA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "NUMCAJA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODCOBRADOR", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODCOBRADOR", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODEMPRESA", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODEMPRESA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODPLANCUENTA", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, False, CType(25, Byte), CType(0, Byte), "CODPLANCUENTA", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODSUCURSAL", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODSUCURSAL", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CODUSUARIO", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, False, CType(9, Byte), CType(0, Byte), "CODUSUARIO", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FECGRA", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "FECGRA", System.Data.DataRowVersion.Original, Nothing))
        '
        'SqlDataAdapter1
        '
        Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
        Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
        Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
        Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "CAJA", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("NUMCAJA", "NUMCAJA"), New System.Data.Common.DataColumnMapping("CODSUCURSAL", "CODSUCURSAL"), New System.Data.Common.DataColumnMapping("CODPLANCUENTA", "CODPLANCUENTA"), New System.Data.Common.DataColumnMapping("CODCOBRADOR", "CODCOBRADOR"), New System.Data.Common.DataColumnMapping("CODUSUARIO", "CODUSUARIO"), New System.Data.Common.DataColumnMapping("CODEMPRESA", "CODEMPRESA"), New System.Data.Common.DataColumnMapping("FECGRA", "FECGRA")})})
        Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
        '
        'BuscarCuenta
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(576, 304)
        Me.Controls.Add(Me.BottomRightColor)
        Me.Controls.Add(Me.TopLeftColor)
        Me.Controls.Add(Me.Frame3)
        Me.Controls.Add(Me.Frame2)
        Me.Controls.Add(Me.Frame1)
        Me.Controls.Add(Me.lstDetalle4)
        Me.Controls.Add(Me.txtResultado)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "BuscarCuenta"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "BuscarCuenta"
        Me.Frame2.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.Frame3.ResumeLayout(False)
        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(Me.Size.Width - 20, 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 - 19, 0)
        Me.PanBtn.Name = "PanBtn"
        Me.PanBtn.Size = New System.Drawing.Size(19, 19)
        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, 1)
        Me.lblNombre.Name = "lblNombre"
        Me.lblNombre.Size = New System.Drawing.Size(180, 16)
        Me.lblNombre.TabIndex = 16
        Me.lblNombre.Text = "Buscar Cuentas"
        '
        '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.Controls.Add(Me.btnCerrar)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Text = "Buscar Cuentas"
        'Me.PanBtn.ResumeLayout(False)

        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
    Private Sub BuscarCuenta_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        Me.Refresh()
    End Sub
    Private Sub FindMyString(ByVal searchString As String)
        If searchString <> String.Empty Then
            If ordenDescripcion.Checked = True Then
                Dim index As Integer = lstDetalle1.FindString(searchString)
                If index <> -1 Then
                    lstDetalle1.SetSelected(index, True)
                    encontrado = True
                Else
                    encontrado = False
                End If
            End If
        End If
        If ordenCodigo.Checked = True Then
            Dim index As Integer = lstDetalle2.FindString(searchString)
            If index <> -1 Then
                lstDetalle2.SetSelected(index, True)
                encontrado = True
            Else
                encontrado = False
            End If
        End If
        If ordenSubCuenta.Checked = True Then
            Dim index As Integer = lstDetalle3.FindString(searchString)
            If index <> -1 Then
                lstDetalle3.SetSelected(index, True)
                encontrado = True
            Else
                encontrado = False
            End If
        End If

    End Sub

    Public Sub Cargar_Datos(ByRef dr As SqlDataReader)
        Dim temp1, temp2, temp3, temp4 As String  'para manejar las variables de los colores
        Try                                             'bloque try
            items = 0
            Do While dr.Read()
                temp1 = dr("DesCuenta")
                temp2 = dr("NumCuenta")
                temp3 = dr("SubCuenta")
                temp4 = dr("CodCuenta")
                lstDetalle1.Items.Add(temp1.Trim())
                lstDetalle2.Items.Add(temp2.Trim())
                lstDetalle3.Items.Add(temp3.Trim())
                lstDetalle4.Items.Add(temp4.Trim())
                items = items + 1
            Loop
        Finally                                         'final del try
            dr.Close()                                 'se cierra la lectura
        End Try
        encontrado = False
    End Sub
    Public ReadOnly Property ResultadoBusqueda() As Parametros
        Get
            Dim Param As New Parametros
            'Param.CodBuscarCuenta = Me.txtResultado.Text
            Param.CodBuscarCuenta = lstDetalle4.SelectedItem
            Param.NumBuscarCuenta = lstDetalle2.SelectedItem
            Return Param
        End Get
    End Property

    Private Sub txtBuscar_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBuscar.KeyPress, BottomRightColor.KeyPress, lstDetalle1.KeyPress, lstDetalle2.KeyPress, lstDetalle3.KeyPress, lstDetalle4.KeyPress, MyBase.KeyPress, TopLeftColor.KeyPress, txtResultado.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 27 Then
            Close()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub _SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstDetalle1.SelectedIndexChanged, lstDetalle2.SelectedIndexChanged, lstDetalle3.SelectedIndexChanged
        lstDetalle1.SelectedIndex = sender.selectedindex
        lstDetalle2.SelectedIndex = sender.SelectedIndex
        lstDetalle3.SelectedIndex = sender.SelectedIndex
        lstDetalle4.SelectedIndex = sender.SelectedIndex
        'txtBuscar.Text = sender.SelectedItem
    End Sub
    Private Sub lstDetalle4_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstDetalle4.SelectedIndexChanged
        txtResultado.Text = lstDetalle4.SelectedItem
    End Sub

    Private Sub _Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstDetalle1.Click, lstDetalle2.Click, lstDetalle3.Click
        txtBuscar.Text = sender.SelectedItem
        txtBuscar.Focus()
    End Sub

    Private Sub txtBuscar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscar.TextChanged
        Call FindMyString(txtBuscar.Text)
    End Sub

    Private Sub lstDetalle1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lstDetalle1.KeyUp, lstDetalle2.KeyUp, lstDetalle3.KeyUp
        If e.KeyCode = Keys.Enter Then
            If encontrado = True Then
                txtResultado.Text = lstDetalle4.SelectedItem
                'Clipboard.SetDataObject("LUIS" & Me.txtResultado.Text)
                Buscar.ActiveForm.Close()
            Else
                Buscar.ActiveForm.Close()
            End If
        End If
    End Sub

    Private Sub txtBuscar_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBuscar.KeyUp
        If e.KeyCode = Keys.Up Then
            If lstDetalle1.SelectedIndex > 0 Then
                lstDetalle1.SetSelected(lstDetalle1.SelectedIndex - 1, True)
            End If
        End If
        If e.KeyCode = Keys.Down Then
            If lstDetalle1.Items.Count - 1 > lstDetalle1.SelectedIndex Then
                lstDetalle1.SetSelected(lstDetalle1.SelectedIndex + 1, True)
            End If
        End If
        If e.KeyCode = Keys.Enter Then
            If encontrado = True Then
                txtResultado.Text = lstDetalle2.SelectedItem
                'Clipboard.SetDataObject("LUIS" & Me.txtResultado.Text)
                Buscar.ActiveForm.Close()
            Else
                Buscar.ActiveForm.Close()
            End If
        End If
    End Sub
    Public Sub Configuraciones()
        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 = "BuscarCuenta" Then
                    If Node.Attributes.GetNamedItem("value").Value = "1" Then
                        ordenDescripcion.Checked = True
                    End If
                    If Node.Attributes.GetNamedItem("value").Value = "2" Then
                        ordenCodigo.Checked = True
                    End If
                    If Node.Attributes.GetNamedItem("value").Value = "3" Then
                        ordenSubCuenta.Checked = True
                    End If
                End If
                Dim a As String
                If Node.Attributes.GetNamedItem("key").Value = "BuscarCuentaColor1" Then
                    TopLeftColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
                If Node.Attributes.GetNamedItem("key").Value = "BuscarCuentaColor2" Then
                    BottomRightColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
            End If
        Next Node
    End Sub

    Private Sub BuscarCuenta_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If encontrado = True Then
            Me.DialogResult = DialogResult.OK
        Else
            Me.DialogResult = DialogResult.Cancel
        End If
        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 = "BuscarCuenta" Then
                    If ordenDescripcion.Checked = True Then
                        Node.Attributes.GetNamedItem("value").Value = CType("1", String)
                    End If
                    If ordenCodigo.Checked = True Then
                        Node.Attributes.GetNamedItem("value").Value = CType("2", String)
                    End If
                    If ordenSubCuenta.Checked = True Then
                        Node.Attributes.GetNamedItem("value").Value = CType("3", String)
                    End If
                End If
                If Node.Attributes.GetNamedItem("key").Value = "BuscarCuentaColor1" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(Color1, String)
                End If
                If Node.Attributes.GetNamedItem("key").Value = "BuscarCuentaColor2" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(Color2, String)
                End If
            End If
        Next Node
        XmlDocument.Save(FileInfo.FullName)
    End Sub
    Private Sub BuscarCuenta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'predetermino el orden de búsqueda que será el por Descripción de la cuenta
        txtResultado.Text = ""
        txtBuscar.Text = ""
        ordenDescripcion.Checked = True
        asignareventos(Me)
        lstDetalle4.Visible = False
        Configuraciones()
    End Sub
    Private Sub AsignarEventos(ByVal elControl As Control)
        'Tamano1 = TextBox's
        'Tamano2 = Label's
        'Tamano3 = Botones

        'Color1 = TextBox's
        'Color2 = Label's
        'Color3 = Botones
        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
            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 = "CheckBox" 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(CONCOLOR4), Byte), CType(sentFuncion.ColorGreen(CONCOLOR4), Byte), CType(sentFuncion.ColorBlue(CONCOLOR4), 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
    Public Sub limpiar()
        lstDetalle1.Items.Clear()
        lstDetalle2.Items.Clear()
        lstDetalle3.Items.Clear()
        lstDetalle4.Items.Clear()
        txtBuscar.Text = ""
        txtResultado.Text = ""
    End Sub
    Public Sub CargarConoSinAsentables(ByVal a As String)
        ConoSinAsentables = a
    End Sub
    Private Sub ordenDescripcion_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ordenDescripcion.CheckedChanged
        'ordenDescripcion.Checked = True
        limpiar()
        Cargar_Datos(funcionbuscarcuenta.BuscarCuenta(EmpCodigo & ConoSinAsentables, 1))
        txtBuscar.Focus()
        'lstDetalle1.Sorted = True
    End Sub

    Private Sub ordenCodigo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ordenCodigo.CheckedChanged
        limpiar()
        Cargar_Datos(funcionbuscarcuenta.BuscarCuenta(EmpCodigo & ConoSinAsentables, 2))
        txtBuscar.Focus()
    End Sub

    Private Sub ordenSubCuenta_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ordenSubCuenta.CheckedChanged
        limpiar()
        Cargar_Datos(funcionbuscarcuenta.BuscarCuenta(EmpCodigo & ConoSinAsentables, 3))
        txtBuscar.Focus()
    End Sub
End Class
