Imports System.Drawing.Printing

Public Class Ajustes
    Inherits System.Windows.Forms.Form

    Private sentdetpc As New SentRangoComprobanteDetalle.SentRangoComprobanteDetalle
    Private sentAjustes As New sentAjustes.Ajustes

    Private Color1, Color2 As String

    Private Linea As Integer
    Private CargarDatos As Boolean = True
    Private EstadoDetalle As Integer
    Private dtCodigo As DataTable
    Private dtDescripcion As DataTable
    Private detAjustes As DataTable
    Private dtDatos As DataTable
    Private dtMoneda As DataTable
    Private costo As Decimal
    Private cotiproducto As Decimal
    Private cotizacion As Decimal
    Private cantidad As Decimal
    Private Candecimales As Integer
    Private Decimales As Integer
    Private codSucursalPertenece As Long
    Dim sentFuncion As New funcion.Funcion


    Public Sub New()
        MyBase.New()

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

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

        Limpiar()

        AsignarEventos(Me)
        Configuraciones()
    End Sub

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

    '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 ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents TopLeftColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents BottomRightColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents cmdEliminar As System.Windows.Forms.Button
    Friend WithEvents cmdNuevo As System.Windows.Forms.Button
    Friend WithEvents cmdPrimero As System.Windows.Forms.Button
    Friend WithEvents cmdBuscar As System.Windows.Forms.Button
    Friend WithEvents cmdCancelar As System.Windows.Forms.Button
    Friend WithEvents cmdGrabar As System.Windows.Forms.Button
    Friend WithEvents cmdModificar As System.Windows.Forms.Button
    Friend WithEvents cmdUltimo As System.Windows.Forms.Button
    Friend WithEvents cmdSiguiente As System.Windows.Forms.Button
    Friend WithEvents cmdAnterior As System.Windows.Forms.Button
    Friend WithEvents Label18 As System.Windows.Forms.Label
    Friend WithEvents TxtMoneda12 As TxtMoneda.TxtMoneda
    Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
    Friend WithEvents TxtMoneda2 As TxtMoneda.TxtMoneda
    Friend WithEvents TxtMoneda1 As TxtMoneda.TxtMoneda
    Friend WithEvents TxtMoneda19 As TxtMoneda.TxtMoneda
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TxtMoneda18 As TxtMoneda.TxtMoneda
    Friend WithEvents Label28 As System.Windows.Forms.Label
    Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
    Friend WithEvents Label29 As System.Windows.Forms.Label
    Friend WithEvents TxtMoneda6 As TxtMoneda.TxtMoneda
    Friend WithEvents TxtMoneda4 As TxtMoneda.TxtMoneda
    Friend WithEvents TxtMoneda3 As TxtMoneda.TxtMoneda
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents TextBox9 As System.Windows.Forms.TextBox
    Friend WithEvents Volcar2 As System.Windows.Forms.PictureBox
    Friend WithEvents Volcar1 As System.Windows.Forms.PictureBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents Borrar2 As System.Windows.Forms.PictureBox
    Friend WithEvents Borrar1 As System.Windows.Forms.PictureBox
    Friend WithEvents dgDetalle As System.Windows.Forms.DataGrid
    Friend WithEvents txtFocus As System.Windows.Forms.TextBox
    Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label20 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Textbox4 As System.Windows.Forms.TextBox
    Friend WithEvents Fecha1 As Fecha.Fecha
    Friend WithEvents TxtMoneda15 As TxtMoneda.TxtMoneda
    Friend WithEvents TextBox10 As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents WinPopup1 As WinPopup.WinPopup
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents txtNumSucursal As System.Windows.Forms.TextBox
    Friend WithEvents lblDescripSucursal As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Ajustes))
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.cmdEliminar = New System.Windows.Forms.Button()
        Me.cmdNuevo = New System.Windows.Forms.Button()
        Me.cmdPrimero = New System.Windows.Forms.Button()
        Me.cmdBuscar = New System.Windows.Forms.Button()
        Me.cmdCancelar = New System.Windows.Forms.Button()
        Me.cmdGrabar = New System.Windows.Forms.Button()
        Me.cmdModificar = New System.Windows.Forms.Button()
        Me.cmdUltimo = New System.Windows.Forms.Button()
        Me.cmdSiguiente = New System.Windows.Forms.Button()
        Me.cmdAnterior = New System.Windows.Forms.Button()
        Me.Volcar2 = New System.Windows.Forms.PictureBox()
        Me.Borrar2 = New System.Windows.Forms.PictureBox()
        Me.TopLeftColor = New LaMarvin.Windows.Forms.ColorPicker()
        Me.BottomRightColor = New LaMarvin.Windows.Forms.ColorPicker()
        Me.Panel2 = New System.Windows.Forms.Panel()
        Me.Label18 = New System.Windows.Forms.Label()
        Me.TxtMoneda12 = New TxtMoneda.TxtMoneda(Me.components)
        Me.txtNumSucursal = New System.Windows.Forms.TextBox()
        Me.TextBox6 = New System.Windows.Forms.TextBox()
        Me.TxtMoneda2 = New TxtMoneda.TxtMoneda(Me.components)
        Me.TxtMoneda1 = New TxtMoneda.TxtMoneda(Me.components)
        Me.TxtMoneda19 = New TxtMoneda.TxtMoneda(Me.components)
        Me.Label4 = New System.Windows.Forms.Label()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.TxtMoneda18 = New TxtMoneda.TxtMoneda(Me.components)
        Me.Label28 = New System.Windows.Forms.Label()
        Me.TextBox7 = New System.Windows.Forms.TextBox()
        Me.Label29 = New System.Windows.Forms.Label()
        Me.TxtMoneda6 = New TxtMoneda.TxtMoneda(Me.components)
        Me.TxtMoneda4 = New TxtMoneda.TxtMoneda(Me.components)
        Me.TxtMoneda3 = New TxtMoneda.TxtMoneda(Me.components)
        Me.Label13 = New System.Windows.Forms.Label()
        Me.Label11 = New System.Windows.Forms.Label()
        Me.Label10 = New System.Windows.Forms.Label()
        Me.Label8 = New System.Windows.Forms.Label()
        Me.TextBox9 = New System.Windows.Forms.TextBox()
        Me.Volcar1 = New System.Windows.Forms.PictureBox()
        Me.TextBox3 = New System.Windows.Forms.TextBox()
        Me.Borrar1 = New System.Windows.Forms.PictureBox()
        Me.dgDetalle = New System.Windows.Forms.DataGrid()
        Me.txtFocus = New System.Windows.Forms.TextBox()
        Me.RadioButton1 = New System.Windows.Forms.RadioButton()
        Me.RadioButton2 = New System.Windows.Forms.RadioButton()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.lblDescripSucursal = New System.Windows.Forms.Label()
        Me.Label20 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Textbox4 = New System.Windows.Forms.TextBox()
        Me.Fecha1 = New Fecha.Fecha()
        Me.TxtMoneda15 = New TxtMoneda.TxtMoneda(Me.components)
        Me.TextBox10 = New System.Windows.Forms.TextBox()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.Label9 = New System.Windows.Forms.Label()
        Me.WinPopup1 = New WinPopup.WinPopup()
        Me.Label12 = New System.Windows.Forms.Label()
        CType(Me.Volcar2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.Borrar2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel2.SuspendLayout()
        CType(Me.Volcar1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.Borrar1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dgDetalle, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'cmdEliminar
        '
        Me.cmdEliminar.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdEliminar.BackColor = System.Drawing.Color.Transparent
        Me.cmdEliminar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdEliminar.Image = CType(resources.GetObject("cmdEliminar.Image"), System.Drawing.Image)
        Me.cmdEliminar.Location = New System.Drawing.Point(3, 132)
        Me.cmdEliminar.Name = "cmdEliminar"
        Me.cmdEliminar.Size = New System.Drawing.Size(35, 35)
        Me.cmdEliminar.TabIndex = 4
        Me.ToolTip1.SetToolTip(Me.cmdEliminar, "Eliminar un Comprobante")
        Me.cmdEliminar.UseVisualStyleBackColor = False
        '
        'cmdNuevo
        '
        Me.cmdNuevo.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdNuevo.BackColor = System.Drawing.Color.Transparent
        Me.cmdNuevo.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdNuevo.Image = CType(resources.GetObject("cmdNuevo.Image"), System.Drawing.Image)
        Me.cmdNuevo.Location = New System.Drawing.Point(3, 4)
        Me.cmdNuevo.Name = "cmdNuevo"
        Me.cmdNuevo.Size = New System.Drawing.Size(35, 35)
        Me.cmdNuevo.TabIndex = 0
        Me.ToolTip1.SetToolTip(Me.cmdNuevo, "Crear un nuevo Comprobante")
        Me.cmdNuevo.UseVisualStyleBackColor = False
        '
        'cmdPrimero
        '
        Me.cmdPrimero.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdPrimero.BackColor = System.Drawing.Color.Transparent
        Me.cmdPrimero.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdPrimero.Image = CType(resources.GetObject("cmdPrimero.Image"), System.Drawing.Image)
        Me.cmdPrimero.Location = New System.Drawing.Point(35, 4)
        Me.cmdPrimero.Name = "cmdPrimero"
        Me.cmdPrimero.Size = New System.Drawing.Size(35, 35)
        Me.cmdPrimero.TabIndex = 5
        Me.ToolTip1.SetToolTip(Me.cmdPrimero, "Ir al primer registro")
        Me.cmdPrimero.UseVisualStyleBackColor = False
        '
        'cmdBuscar
        '
        Me.cmdBuscar.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdBuscar.BackColor = System.Drawing.Color.Transparent
        Me.cmdBuscar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdBuscar.Image = CType(resources.GetObject("cmdBuscar.Image"), System.Drawing.Image)
        Me.cmdBuscar.Location = New System.Drawing.Point(35, 132)
        Me.cmdBuscar.Name = "cmdBuscar"
        Me.cmdBuscar.Size = New System.Drawing.Size(35, 35)
        Me.cmdBuscar.TabIndex = 9
        Me.ToolTip1.SetToolTip(Me.cmdBuscar, "Buscar Comprobante")
        Me.cmdBuscar.UseVisualStyleBackColor = False
        '
        'cmdCancelar
        '
        Me.cmdCancelar.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdCancelar.BackColor = System.Drawing.Color.Transparent
        Me.cmdCancelar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdCancelar.Image = CType(resources.GetObject("cmdCancelar.Image"), System.Drawing.Image)
        Me.cmdCancelar.Location = New System.Drawing.Point(3, 100)
        Me.cmdCancelar.Name = "cmdCancelar"
        Me.cmdCancelar.Size = New System.Drawing.Size(35, 35)
        Me.cmdCancelar.TabIndex = 3
        Me.ToolTip1.SetToolTip(Me.cmdCancelar, "Cancelar la acción actual")
        Me.cmdCancelar.UseVisualStyleBackColor = False
        '
        'cmdGrabar
        '
        Me.cmdGrabar.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdGrabar.BackColor = System.Drawing.Color.Transparent
        Me.cmdGrabar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdGrabar.Image = CType(resources.GetObject("cmdGrabar.Image"), System.Drawing.Image)
        Me.cmdGrabar.Location = New System.Drawing.Point(3, 68)
        Me.cmdGrabar.Name = "cmdGrabar"
        Me.cmdGrabar.Size = New System.Drawing.Size(35, 36)
        Me.cmdGrabar.TabIndex = 2
        Me.cmdGrabar.Tag = ""
        Me.ToolTip1.SetToolTip(Me.cmdGrabar, "Grabar el Comprobante")
        Me.cmdGrabar.UseVisualStyleBackColor = False
        '
        'cmdModificar
        '
        Me.cmdModificar.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdModificar.BackColor = System.Drawing.Color.Transparent
        Me.cmdModificar.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdModificar.Image = CType(resources.GetObject("cmdModificar.Image"), System.Drawing.Image)
        Me.cmdModificar.Location = New System.Drawing.Point(3, 36)
        Me.cmdModificar.Name = "cmdModificar"
        Me.cmdModificar.Size = New System.Drawing.Size(35, 35)
        Me.cmdModificar.TabIndex = 1
        Me.ToolTip1.SetToolTip(Me.cmdModificar, "Modificar un Comprobante")
        Me.cmdModificar.UseVisualStyleBackColor = False
        '
        'cmdUltimo
        '
        Me.cmdUltimo.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdUltimo.BackColor = System.Drawing.Color.Transparent
        Me.cmdUltimo.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdUltimo.Image = CType(resources.GetObject("cmdUltimo.Image"), System.Drawing.Image)
        Me.cmdUltimo.Location = New System.Drawing.Point(35, 100)
        Me.cmdUltimo.Name = "cmdUltimo"
        Me.cmdUltimo.Size = New System.Drawing.Size(35, 35)
        Me.cmdUltimo.TabIndex = 8
        Me.ToolTip1.SetToolTip(Me.cmdUltimo, "Ir al últmo registro")
        Me.cmdUltimo.UseVisualStyleBackColor = False
        '
        'cmdSiguiente
        '
        Me.cmdSiguiente.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdSiguiente.BackColor = System.Drawing.Color.Transparent
        Me.cmdSiguiente.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdSiguiente.Image = CType(resources.GetObject("cmdSiguiente.Image"), System.Drawing.Image)
        Me.cmdSiguiente.Location = New System.Drawing.Point(35, 68)
        Me.cmdSiguiente.Name = "cmdSiguiente"
        Me.cmdSiguiente.Size = New System.Drawing.Size(35, 35)
        Me.cmdSiguiente.TabIndex = 7
        Me.ToolTip1.SetToolTip(Me.cmdSiguiente, "Ir al registro siguiente")
        Me.cmdSiguiente.UseVisualStyleBackColor = False
        '
        'cmdAnterior
        '
        Me.cmdAnterior.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdAnterior.BackColor = System.Drawing.Color.Transparent
        Me.cmdAnterior.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.cmdAnterior.Image = CType(resources.GetObject("cmdAnterior.Image"), System.Drawing.Image)
        Me.cmdAnterior.Location = New System.Drawing.Point(35, 36)
        Me.cmdAnterior.Name = "cmdAnterior"
        Me.cmdAnterior.Size = New System.Drawing.Size(35, 35)
        Me.cmdAnterior.TabIndex = 6
        Me.ToolTip1.SetToolTip(Me.cmdAnterior, "Ir al registro anterior")
        Me.cmdAnterior.UseVisualStyleBackColor = False
        '
        'Volcar2
        '
        Me.Volcar2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Volcar2.BackColor = System.Drawing.Color.WhiteSmoke
        Me.Volcar2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Volcar2.Image = CType(resources.GetObject("Volcar2.Image"), System.Drawing.Image)
        Me.Volcar2.Location = New System.Drawing.Point(758, 268)
        Me.Volcar2.Name = "Volcar2"
        Me.Volcar2.Size = New System.Drawing.Size(32, 28)
        Me.Volcar2.TabIndex = 415
        Me.Volcar2.TabStop = False
        Me.ToolTip1.SetToolTip(Me.Volcar2, "Agregar detalle")
        '
        'Borrar2
        '
        Me.Borrar2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Borrar2.BackColor = System.Drawing.Color.WhiteSmoke
        Me.Borrar2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Borrar2.Image = CType(resources.GetObject("Borrar2.Image"), System.Drawing.Image)
        Me.Borrar2.Location = New System.Drawing.Point(757, 296)
        Me.Borrar2.Name = "Borrar2"
        Me.Borrar2.Size = New System.Drawing.Size(34, 30)
        Me.Borrar2.TabIndex = 417
        Me.Borrar2.TabStop = False
        Me.ToolTip1.SetToolTip(Me.Borrar2, "Eliminar Detalle")
        '
        'TopLeftColor
        '
        Me.TopLeftColor.Location = New System.Drawing.Point(0, 0)
        Me.TopLeftColor.Name = "TopLeftColor"
        Me.TopLeftColor.Size = New System.Drawing.Size(0, 0)
        Me.TopLeftColor.TabIndex = 595
        '
        'BottomRightColor
        '
        Me.BottomRightColor.Location = New System.Drawing.Point(0, 0)
        Me.BottomRightColor.Name = "BottomRightColor"
        Me.BottomRightColor.Size = New System.Drawing.Size(0, 0)
        Me.BottomRightColor.TabIndex = 596
        '
        'Panel2
        '
        Me.Panel2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Panel2.BackColor = System.Drawing.Color.Transparent
        Me.Panel2.Controls.Add(Me.cmdEliminar)
        Me.Panel2.Controls.Add(Me.cmdCancelar)
        Me.Panel2.Controls.Add(Me.cmdGrabar)
        Me.Panel2.Controls.Add(Me.cmdNuevo)
        Me.Panel2.Controls.Add(Me.cmdPrimero)
        Me.Panel2.Controls.Add(Me.cmdBuscar)
        Me.Panel2.Controls.Add(Me.cmdModificar)
        Me.Panel2.Controls.Add(Me.cmdUltimo)
        Me.Panel2.Controls.Add(Me.cmdSiguiente)
        Me.Panel2.Controls.Add(Me.cmdAnterior)
        Me.Panel2.Location = New System.Drawing.Point(717, 5)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(72, 171)
        Me.Panel2.TabIndex = 0
        '
        'Label18
        '
        Me.Label18.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label18.BackColor = System.Drawing.Color.Transparent
        Me.Label18.Location = New System.Drawing.Point(437, 552)
        Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(168, 23)
        Me.Label18.TabIndex = 463
        Me.Label18.Text = "Total"
        Me.Label18.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TxtMoneda12
        '
        Me.TxtMoneda12.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TxtMoneda12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda12.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtMoneda12.Location = New System.Drawing.Point(618, 552)
        Me.TxtMoneda12.Name = "TxtMoneda12"
        Me.TxtMoneda12.ReadOnly = True
        Me.TxtMoneda12.Size = New System.Drawing.Size(147, 20)
        Me.TxtMoneda12.TabIndex = 459
        Me.TxtMoneda12.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        Me.TxtMoneda12.TxtMonedaBase = "0"
        Me.TxtMoneda12.TxtMonedaDecimales = Nothing
        '
        'txtNumSucursal
        '
        Me.txtNumSucursal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtNumSucursal.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.txtNumSucursal.Location = New System.Drawing.Point(160, 16)
        Me.txtNumSucursal.MaxLength = 10
        Me.txtNumSucursal.Name = "txtNumSucursal"
        Me.txtNumSucursal.Size = New System.Drawing.Size(104, 20)
        Me.txtNumSucursal.TabIndex = 3
        Me.txtNumSucursal.Text = "TEXTBOXNUM"
        '
        'TextBox6
        '
        Me.TextBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox6.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox6.Location = New System.Drawing.Point(160, 144)
        Me.TextBox6.MaxLength = 5
        Me.TextBox6.Name = "TextBox6"
        Me.TextBox6.ReadOnly = True
        Me.TextBox6.Size = New System.Drawing.Size(104, 20)
        Me.TextBox6.TabIndex = 8
        Me.TextBox6.Text = "TEXTBOX6"
        '
        'TxtMoneda2
        '
        Me.TxtMoneda2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda2.Location = New System.Drawing.Point(16, 296)
        Me.TxtMoneda2.Name = "TxtMoneda2"
        Me.TxtMoneda2.Size = New System.Drawing.Size(183, 20)
        Me.TxtMoneda2.TabIndex = 478
        Me.TxtMoneda2.Text = "TxtMoneda2"
        Me.TxtMoneda2.TxtMonedaBase = "0"
        Me.TxtMoneda2.TxtMonedaDecimales = Nothing
        '
        'TxtMoneda1
        '
        Me.TxtMoneda1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda1.Location = New System.Drawing.Point(160, 168)
        Me.TxtMoneda1.Name = "TxtMoneda1"
        Me.TxtMoneda1.ReadOnly = True
        Me.TxtMoneda1.Size = New System.Drawing.Size(104, 20)
        Me.TxtMoneda1.TabIndex = 9
        Me.TxtMoneda1.Text = "TxtMoneda1"
        Me.TxtMoneda1.TxtMonedaBase = "0"
        Me.TxtMoneda1.TxtMonedaDecimales = Nothing
        '
        'TxtMoneda19
        '
        Me.TxtMoneda19.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TxtMoneda19.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda19.Location = New System.Drawing.Point(483, 224)
        Me.TxtMoneda19.Name = "TxtMoneda19"
        Me.TxtMoneda19.Size = New System.Drawing.Size(127, 20)
        Me.TxtMoneda19.TabIndex = 12
        Me.TxtMoneda19.Text = "TxtMoneda19"
        Me.TxtMoneda19.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        Me.TxtMoneda19.TxtMonedaBase = "0"
        Me.TxtMoneda19.TxtMonedaDecimales = Nothing
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.Color.Transparent
        Me.Label4.Location = New System.Drawing.Point(-24, 91)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(176, 23)
        Me.Label4.TabIndex = 7
        Me.Label4.Text = "fecha"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TextBox1
        '
        Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox1.Location = New System.Drawing.Point(608, 72)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(100, 20)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TEXTBOX1"
        '
        'TxtMoneda18
        '
        Me.TxtMoneda18.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda18.Location = New System.Drawing.Point(16, 344)
        Me.TxtMoneda18.Name = "TxtMoneda18"
        Me.TxtMoneda18.Size = New System.Drawing.Size(183, 20)
        Me.TxtMoneda18.TabIndex = 466
        Me.TxtMoneda18.Text = "TxtMoneda18"
        Me.TxtMoneda18.TxtMonedaBase = "0"
        Me.TxtMoneda18.TxtMonedaDecimales = Nothing
        '
        'Label28
        '
        Me.Label28.BackColor = System.Drawing.Color.Transparent
        Me.Label28.Location = New System.Drawing.Point(-24, 120)
        Me.Label28.Name = "Label28"
        Me.Label28.Size = New System.Drawing.Size(176, 23)
        Me.Label28.TabIndex = 458
        Me.Label28.Text = "concepto"
        Me.Label28.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TextBox7
        '
        Me.TextBox7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox7.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox7.Location = New System.Drawing.Point(160, 120)
        Me.TextBox7.MaxLength = 5
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(104, 20)
        Me.TextBox7.TabIndex = 7
        Me.TextBox7.Text = "TEXTBOX7"
        '
        'Label29
        '
        Me.Label29.BackColor = System.Drawing.Color.Transparent
        Me.Label29.Location = New System.Drawing.Point(280, 120)
        Me.Label29.Name = "Label29"
        Me.Label29.Size = New System.Drawing.Size(448, 23)
        Me.Label29.TabIndex = 459
        Me.Label29.Text = "Label29"
        Me.Label29.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'TxtMoneda6
        '
        Me.TxtMoneda6.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TxtMoneda6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda6.Location = New System.Drawing.Point(618, 224)
        Me.TxtMoneda6.Name = "TxtMoneda6"
        Me.TxtMoneda6.ReadOnly = True
        Me.TxtMoneda6.Size = New System.Drawing.Size(138, 20)
        Me.TxtMoneda6.TabIndex = 13
        Me.TxtMoneda6.Text = "TxtMoneda6"
        Me.TxtMoneda6.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        Me.TxtMoneda6.TxtMonedaBase = "0"
        Me.TxtMoneda6.TxtMonedaDecimales = Nothing
        '
        'TxtMoneda4
        '
        Me.TxtMoneda4.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TxtMoneda4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda4.Location = New System.Drawing.Point(19, 368)
        Me.TxtMoneda4.Name = "TxtMoneda4"
        Me.TxtMoneda4.Size = New System.Drawing.Size(183, 20)
        Me.TxtMoneda4.TabIndex = 12
        Me.TxtMoneda4.Text = "TxtMoneda4"
        Me.TxtMoneda4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        Me.TxtMoneda4.TxtMonedaBase = "0"
        Me.TxtMoneda4.TxtMonedaDecimales = Nothing
        '
        'TxtMoneda3
        '
        Me.TxtMoneda3.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TxtMoneda3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda3.Location = New System.Drawing.Point(348, 224)
        Me.TxtMoneda3.Name = "TxtMoneda3"
        Me.TxtMoneda3.Size = New System.Drawing.Size(127, 20)
        Me.TxtMoneda3.TabIndex = 11
        Me.TxtMoneda3.Text = "TxtMoneda3"
        Me.TxtMoneda3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        Me.TxtMoneda3.TxtMonedaBase = "0"
        Me.TxtMoneda3.TxtMonedaDecimales = ""
        '
        'Label13
        '
        Me.Label13.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label13.BackColor = System.Drawing.Color.Transparent
        Me.Label13.Location = New System.Drawing.Point(629, 200)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(127, 23)
        Me.Label13.TabIndex = 443
        Me.Label13.Text = "total"
        Me.Label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label11
        '
        Me.Label11.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label11.BackColor = System.Drawing.Color.Transparent
        Me.Label11.Location = New System.Drawing.Point(499, 200)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(111, 23)
        Me.Label11.TabIndex = 441
        Me.Label11.Text = "costo"
        Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label10
        '
        Me.Label10.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label10.BackColor = System.Drawing.Color.Transparent
        Me.Label10.Location = New System.Drawing.Point(364, 200)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(111, 23)
        Me.Label10.TabIndex = 440
        Me.Label10.Text = "cantidad"
        Me.Label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label8
        '
        Me.Label8.BackColor = System.Drawing.Color.Transparent
        Me.Label8.Location = New System.Drawing.Point(16, 200)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(91, 23)
        Me.Label8.TabIndex = 438
        Me.Label8.Text = "codigo"
        Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'TextBox9
        '
        Me.TextBox9.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TextBox9.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox9.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox9.Location = New System.Drawing.Point(16, 224)
        Me.TextBox9.MaxLength = 25
        Me.TextBox9.Name = "TextBox9"
        Me.TextBox9.Size = New System.Drawing.Size(324, 20)
        Me.TextBox9.TabIndex = 10
        Me.TextBox9.Text = "TEXTBOX9"
        '
        'Volcar1
        '
        Me.Volcar1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Volcar1.BackColor = System.Drawing.Color.WhiteSmoke
        Me.Volcar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Volcar1.Image = CType(resources.GetObject("Volcar1.Image"), System.Drawing.Image)
        Me.Volcar1.Location = New System.Drawing.Point(757, 268)
        Me.Volcar1.Name = "Volcar1"
        Me.Volcar1.Size = New System.Drawing.Size(34, 29)
        Me.Volcar1.TabIndex = 414
        Me.Volcar1.TabStop = False
        '
        'TextBox3
        '
        Me.TextBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox3.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox3.Location = New System.Drawing.Point(160, 40)
        Me.TextBox3.MaxLength = 5
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(104, 20)
        Me.TextBox3.TabIndex = 4
        Me.TextBox3.Text = "TEXTBOX3"
        '
        'Borrar1
        '
        Me.Borrar1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Borrar1.BackColor = System.Drawing.Color.WhiteSmoke
        Me.Borrar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Borrar1.Image = CType(resources.GetObject("Borrar1.Image"), System.Drawing.Image)
        Me.Borrar1.Location = New System.Drawing.Point(757, 296)
        Me.Borrar1.Name = "Borrar1"
        Me.Borrar1.Size = New System.Drawing.Size(34, 30)
        Me.Borrar1.TabIndex = 416
        Me.Borrar1.TabStop = False
        '
        'dgDetalle
        '
        Me.dgDetalle.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.dgDetalle.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.dgDetalle.CaptionBackColor = System.Drawing.Color.RoyalBlue
        Me.dgDetalle.CaptionText = "Detalle"
        Me.dgDetalle.DataMember = ""
        Me.dgDetalle.FlatMode = True
        Me.dgDetalle.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgDetalle.Location = New System.Drawing.Point(16, 272)
        Me.dgDetalle.Name = "dgDetalle"
        Me.dgDetalle.Size = New System.Drawing.Size(740, 274)
        Me.dgDetalle.TabIndex = 15
        '
        'txtFocus
        '
        Me.txtFocus.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtFocus.Location = New System.Drawing.Point(16, 272)
        Me.txtFocus.Name = "txtFocus"
        Me.txtFocus.Size = New System.Drawing.Size(183, 20)
        Me.txtFocus.TabIndex = 407
        Me.txtFocus.Text = "txtFocus"
        '
        'RadioButton1
        '
        Me.RadioButton1.BackColor = System.Drawing.Color.Transparent
        Me.RadioButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.RadioButton1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.RadioButton1.Location = New System.Drawing.Point(40, 12)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(136, 24)
        Me.RadioButton1.TabIndex = 8
        Me.RadioButton1.Text = "En más (+)"
        Me.RadioButton1.UseVisualStyleBackColor = False
        '
        'RadioButton2
        '
        Me.RadioButton2.BackColor = System.Drawing.Color.Transparent
        Me.RadioButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.RadioButton2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.RadioButton2.Location = New System.Drawing.Point(192, 12)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(136, 24)
        Me.RadioButton2.TabIndex = 9
        Me.RadioButton2.Text = "En menos (-)"
        Me.RadioButton2.UseVisualStyleBackColor = False
        '
        'Label5
        '
        Me.Label5.BackColor = System.Drawing.Color.Transparent
        Me.Label5.Location = New System.Drawing.Point(-24, 15)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(176, 23)
        Me.Label5.TabIndex = 480
        Me.Label5.Text = "sucursal"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Location = New System.Drawing.Point(-24, 39)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(176, 23)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "tipo comprobante"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblDescripSucursal
        '
        Me.lblDescripSucursal.BackColor = System.Drawing.Color.Transparent
        Me.lblDescripSucursal.Location = New System.Drawing.Point(280, 15)
        Me.lblDescripSucursal.Name = "lblDescripSucursal"
        Me.lblDescripSucursal.Size = New System.Drawing.Size(448, 23)
        Me.lblDescripSucursal.TabIndex = 481
        Me.lblDescripSucursal.Text = "Label1"
        Me.lblDescripSucursal.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label20
        '
        Me.Label20.BackColor = System.Drawing.Color.Transparent
        Me.Label20.Location = New System.Drawing.Point(280, 39)
        Me.Label20.Name = "Label20"
        Me.Label20.Size = New System.Drawing.Size(448, 23)
        Me.Label20.TabIndex = 36
        Me.Label20.Text = "Label20"
        Me.Label20.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(-24, 65)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(176, 23)
        Me.Label3.TabIndex = 494
        Me.Label3.Text = "numero"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Textbox4
        '
        Me.Textbox4.BackColor = System.Drawing.Color.White
        Me.Textbox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Textbox4.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Textbox4.ForeColor = System.Drawing.Color.IndianRed
        Me.Textbox4.Location = New System.Drawing.Point(160, 64)
        Me.Textbox4.Name = "Textbox4"
        Me.Textbox4.Size = New System.Drawing.Size(168, 26)
        Me.Textbox4.TabIndex = 5
        Me.Textbox4.Text = "textbox4"
        '
        'Fecha1
        '
        Me.Fecha1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Fecha1.FechaDate = New Date(1900, 1, 1, 0, 0, 0, 0)
        Me.Fecha1.Location = New System.Drawing.Point(160, 96)
        Me.Fecha1.MaxLength = 10
        Me.Fecha1.Name = "Fecha1"
        Me.Fecha1.Size = New System.Drawing.Size(104, 20)
        Me.Fecha1.TabIndex = 6
        Me.Fecha1.Text = "Fecha1"
        '
        'TxtMoneda15
        '
        Me.TxtMoneda15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TxtMoneda15.Location = New System.Drawing.Point(16, 320)
        Me.TxtMoneda15.Name = "TxtMoneda15"
        Me.TxtMoneda15.Size = New System.Drawing.Size(183, 20)
        Me.TxtMoneda15.TabIndex = 456
        Me.TxtMoneda15.Text = "TxtMoneda15"
        Me.TxtMoneda15.TxtMonedaBase = "0"
        Me.TxtMoneda15.TxtMonedaDecimales = Nothing
        '
        'TextBox10
        '
        Me.TextBox10.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TextBox10.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox10.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox10.Location = New System.Drawing.Point(16, 248)
        Me.TextBox10.Name = "TextBox10"
        Me.TextBox10.ReadOnly = True
        Me.TextBox10.Size = New System.Drawing.Size(740, 20)
        Me.TextBox10.TabIndex = 14
        Me.TextBox10.Text = "TEXTBOX10"
        '
        'Label6
        '
        Me.Label6.BackColor = System.Drawing.Color.Transparent
        Me.Label6.Location = New System.Drawing.Point(-24, 144)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(176, 23)
        Me.Label6.TabIndex = 495
        Me.Label6.Text = "moneda"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label7
        '
        Me.Label7.BackColor = System.Drawing.Color.Transparent
        Me.Label7.Location = New System.Drawing.Point(280, 144)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(448, 23)
        Me.Label7.TabIndex = 496
        Me.Label7.Text = "Label7"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.RadioButton1)
        Me.GroupBox1.Controls.Add(Me.RadioButton2)
        Me.GroupBox1.Location = New System.Drawing.Point(373, 62)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(336, 40)
        Me.GroupBox1.TabIndex = 497
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Tipo"
        '
        'Label9
        '
        Me.Label9.BackColor = System.Drawing.Color.Transparent
        Me.Label9.Location = New System.Drawing.Point(-24, 168)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(176, 23)
        Me.Label9.TabIndex = 498
        Me.Label9.Text = "cotizacion"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'WinPopup1
        '
        Me.WinPopup1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.WinPopup1.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.WinPopup1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.WinPopup1.ImeMode = System.Windows.Forms.ImeMode.NoControl
        Me.WinPopup1.Location = New System.Drawing.Point(530, 472)
        Me.WinPopup1.Name = "WinPopup1"
        Me.WinPopup1.Size = New System.Drawing.Size(230, 100)
        Me.WinPopup1.TabIndex = 499
        Me.WinPopup1.Visible = False
        Me.WinPopup1.WinPopupAutoHide = False
        Me.WinPopup1.WinPopupAutoShow = False
        Me.WinPopup1.WinPopupGosth = False
        Me.WinPopup1.WinPopupGosthSpeed = 25
        '
        'Label12
        '
        Me.Label12.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label12.BackColor = System.Drawing.Color.White
        Me.Label12.Location = New System.Drawing.Point(379, 8)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(328, 23)
        Me.Label12.TabIndex = 594
        Me.Label12.Text = "Usuario"
        Me.Label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Ajustes
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(797, 576)
        Me.Controls.Add(Me.WinPopup1)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.dgDetalle)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.TextBox9)
        Me.Controls.Add(Me.Fecha1)
        Me.Controls.Add(Me.TxtMoneda4)
        Me.Controls.Add(Me.TextBox10)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.txtNumSucursal)
        Me.Controls.Add(Me.TextBox7)
        Me.Controls.Add(Me.TxtMoneda6)
        Me.Controls.Add(Me.TxtMoneda3)
        Me.Controls.Add(Me.TxtMoneda12)
        Me.Controls.Add(Me.TxtMoneda1)
        Me.Controls.Add(Me.TextBox6)
        Me.Controls.Add(Me.TxtMoneda19)
        Me.Controls.Add(Me.TxtMoneda18)
        Me.Controls.Add(Me.TxtMoneda15)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.txtFocus)
        Me.Controls.Add(Me.TxtMoneda2)
        Me.Controls.Add(Me.Textbox4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TopLeftColor)
        Me.Controls.Add(Me.BottomRightColor)
        Me.Controls.Add(Me.Borrar1)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.Label20)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label29)
        Me.Controls.Add(Me.Label28)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label13)
        Me.Controls.Add(Me.Volcar1)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Volcar2)
        Me.Controls.Add(Me.Borrar2)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label18)
        Me.Controls.Add(Me.lblDescripSucursal)
        Me.Controls.Add(Me.Label7)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.KeyPreview = True
        Me.Name = "Ajustes"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Ajuste"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        CType(Me.Volcar2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.Borrar2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel2.ResumeLayout(False)
        CType(Me.Volcar1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.Borrar1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dgDetalle, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    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 Ajustes_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        Try
            MakeDataStyle()
        Catch ex As Exception

        End Try
        Me.Refresh()
    End Sub

    Private 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 = Me.Name.ToString Then
                '    If Node.Attributes.GetNamedItem("value").Value = "1" Then
                '        Me.WindowState = FormWindowState.Maximized
                '    Else
                '        Me.WindowState = FormWindowState.Normal
                '    End If
                'End If
                If Node.Attributes.GetNamedItem("key").Value = Me.Name.ToString & "Color1" Then
                    TopLeftColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
                If Node.Attributes.GetNamedItem("key").Value = Me.Name.ToString & "Color2" Then
                    BottomRightColor.Color = System.Drawing.Color.FromName(Node.Attributes.GetNamedItem("value").Value.ToString)
                End If
            End If
        Next Node
    End Sub

    Private Sub _Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Texto()
        Nuevo()
    End Sub

    Private Sub _Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        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 = Me.Name.ToString 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 = Me.Name.ToString & "Color1" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(Color1, String)
                End If
                If Node.Attributes.GetNamedItem("key").Value = Me.Name.ToString & "Color2" Then
                    Node.Attributes.GetNamedItem("value").Value = CType(Color2, String)
                End If
            End If
        Next Node
        XmlDocument.Save(FileInfo.FullName)
    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
            If cmdCancelar.Enabled = True Then
                Cancelar()
            Else
                Close()
            End If
        End If
    End Sub

    Public Sub Limpiar()
        If SucCodigoPertenece = "NULL" Then
            txtNumSucursal.Text = sentFuncion.Descripcion_Tabla("NUMSUCURSAL", "SUCURSAL", "CODSUCURSAL", SucCodigo, EmpCodigo)
            txtNumSucursal.Tag = SucCodigo
            txtNumSucursal.Focus()
            'codSucursalPerteneceLocal = sentFuncion.Validar_Tabla("codSucursalPerteneceLocal", "SUCURSAL", "CODSUCURSAL", SucCodigo, EmpCodigo)
        Else
            txtNumSucursal.Text = sentFuncion.Descripcion_Tabla("NUMSUCURSAL", "SUCURSAL", "CODSUCURSAL", SucCodigoPertenece, EmpCodigo)
            ' ''codSucursalPerteneceLocal = sentFuncion.Validar_Tabla("codSucursalPerteneceLocal", "SUCURSAL", "CODSUCURSAL", SucCodigoPertenece, EmpCodigo)
            txtNumSucursal.Tag = SucCodigoPertenece
            txtNumSucursal.ReadOnly = True
            TextBox3.Focus()
        End If
        lblDescripSucursal.Text = sentFuncion.Descripcion_Tabla("DESSUCURSAL", "SUCURSAL", "NUMSUCURSAL", txtNumSucursal.Text, EmpCodigo)
        TextBox1.Text = ""
        'txtNumSucursal.Text = ""
        TextBox3.Text = ""
        Textbox4.Text = ""
        TextBox6.Text = ""
        Fecha1.Text = ""
        Fecha1.ResetText()
        TextBox7.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""


        detAjustes.Rows.Clear()
        dgDetalle.TableStyles.Clear()
        dgDetalle.DataSource = Nothing

        TxtMoneda1.Text = ""
        TxtMoneda2.Text = ""
        TxtMoneda3.Text = ""
        TxtMoneda4.Text = ""
        TxtMoneda6.Text = ""
        TxtMoneda12.Text = ""
        TxtMoneda15.Text = ""
        TxtMoneda18.Text = ""
        TxtMoneda19.Text = ""

        'lblDescripSucursal.Text = ""
        Label7.Text = ""
        Label20.Text = ""
        Label29.Text = ""
        Label12.Text = ""

        RadioButton2.Checked = True
        cmdGrabar.Text = ""

        EstadoDetalle = 0
        RadioButton1.Enabled = True
        RadioButton2.Enabled = True

        limpiarDetalle()
    End Sub

    Private Sub LimpiarDatabinds()
        TextBox1.DataBindings.Clear()
        txtNumSucursal.DataBindings.Clear()
        TextBox3.DataBindings.Clear()
        Textbox4.DataBindings.Clear()
        Fecha1.DataBindings.Clear()
        TextBox6.DataBindings.Clear()
        TextBox7.DataBindings.Clear()
        TextBox9.DataBindings.Clear()
        TextBox10.DataBindings.Clear()

        lblDescripSucursal.DataBindings.Clear()
        Label7.DataBindings.Clear()
        Label20.DataBindings.Clear()
        Label29.DataBindings.Clear()
        Label12.DataBindings.Clear()

        RadioButton1.DataBindings.Clear()
    End Sub

    Private Sub LimpiarDatabindsMoneda()
        TxtMoneda1.DataBindings.Clear()
        TxtMoneda2.DataBindings.Clear()
        TxtMoneda3.DataBindings.Clear()
        TxtMoneda4.DataBindings.Clear()
        TxtMoneda6.DataBindings.Clear()
        TxtMoneda12.DataBindings.Clear()
        TxtMoneda15.DataBindings.Clear()
        TxtMoneda18.DataBindings.Clear()
        TxtMoneda19.DataBindings.Clear()
    End Sub

    Private Sub limpiarDetalle()
        Volcar1.BringToFront()
        Volcar2.SendToBack()
        TextBox9.Text = ""
        TextBox10.Text = ""
        TxtMoneda3.Text = ""
        TxtMoneda4.Text = ""
        TxtMoneda19.Text = ""
        TxtMoneda6.Text = ""
    End Sub

    Private Sub Texto()
        dtCodigo = New DataTable("CODIGO")
        dtDescripcion = New DataTable("DESCRIPCION")
        dtDatos = New DataTable("PRODUCTO")

        Label5.Text = "Sucursal*"
        Label2.Text = "Comprobante*"
        Label3.Text = "Numero"
        Label4.Text = "Fecha"
        Label6.Text = "Moneda*"
        Label9.Text = "Cotización"
        Label8.Text = "Producto*"
        Label10.Text = "Cantidad"
        Label11.Text = "Costo"
        Label13.Text = "Sub Total"
        Label18.Text = "Total"
        Label28.Text = "Concepto*"
        RadioButton1.Text = "En mas (+)"
        RadioButton2.Text = "En menos (-)"

        'TxtMoneda3.TxtMonedaDecimales = CANDECIMALESCANTIDAD
        TxtMoneda3.TxtMonedaDecimales = 3

        TxtMoneda19.TxtMonedaDecimales = 5

        TextBox1.Visible = False
        TxtMoneda2.Visible = False
        TxtMoneda15.Visible = False
        TxtMoneda18.Visible = False
        TxtMoneda4.Visible = False

        Label3.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
        Textbox4.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
        Textbox4.ForeColor = Color.IndianRed

        RadioButton1.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
        RadioButton2.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)

        Label18.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
        TxtMoneda12.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)

        Label12.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
        Label12.ForeColor = Color.IndianRed

        AddHandler Me.KeyPress, AddressOf Me.Salir
        AddHandler Me.KeyDown, AddressOf Me.Opciones
    End Sub

    Public Sub HabilitarBotones()
        cmdNuevo.Enabled = True
        cmdModificar.Enabled = False
        cmdGrabar.Enabled = False
        cmdCancelar.Enabled = False
        cmdEliminar.Enabled = True
        cmdBuscar.Enabled = True
        cmdPrimero.Enabled = True
        cmdAnterior.Enabled = True
        cmdSiguiente.Enabled = True
        cmdUltimo.Enabled = True

        Volcar1.Visible = False
        Volcar2.Visible = False
        Borrar1.Visible = False
        Borrar2.Visible = False
    End Sub

    Public Sub DeshabilitarBotones()
        cmdNuevo.Enabled = False
        cmdModificar.Enabled = False
        cmdGrabar.Enabled = True
        cmdCancelar.Enabled = True
        cmdEliminar.Enabled = False
        cmdBuscar.Enabled = False
        cmdPrimero.Enabled = False
        cmdAnterior.Enabled = False
        cmdSiguiente.Enabled = False
        cmdUltimo.Enabled = False

        Volcar1.Visible = True
        Volcar2.Visible = True
        Borrar1.Visible = True
        Borrar2.Visible = True
    End Sub

    Private Sub Nuevo()
        Limpiar()

        txtNumSucursal.Tag = SucCodigo
        txtNumSucursal.Text = funcion.Descripcion_Tabla("NUMSUCURSAL", "SUCURSAL", "CODSUCURSAL", SucCodigo, EmpCodigo)
        lblDescripSucursal.Text = funcion.Descripcion_Tabla("DESSUCURSAL", "SUCURSAL", "CODSUCURSAL", SucCodigo, EmpCodigo)

        Fecha1.Text = Now.ToShortDateString

        MonedaPredeterminada()

        txtFocus.Text = "agregarNuevoDetalle()"
        DeshabilitarBotones()
        cmdGrabar.Text = "&Grabar"

        Label12.Text = UsuDescripcion

        txtNumSucursal.Focus()
    End Sub

    Private Sub Modificar()
        'If MsgBox("¿Desea modificar este comprobante?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Ajuste") = MsgBoxResult.Yes Then
        '    DeshabilitarBotones()
        '    cmdGrabar.Text = "&Grabar Mod."

        '    RadioButton1.Enabled = False
        '    RadioButton2.Enabled = False
        '    TextBox3.Focus()
        'End If
    End Sub

    Private Sub Grabar()
        If txtNumSucursal.Text = "" Then
            Mensaje("Ingrese una Sucursal", WinPopup1)
            txtNumSucursal.Focus()
            Exit Sub
        End If

        If TextBox3.Text = "" Then
            Mensaje("Ingrese un Comprobante", WinPopup1)
            TextBox3.Focus()
            Exit Sub
        End If

        If Textbox4.Text = "" Then
            Mensaje("Ingrese un Número", WinPopup1)
            TextBox3.Focus()
            Exit Sub
        End If

        If TextBox7.Tag = 0 Then
            Mensaje("Ingrese un concepto", WinPopup1)
            TextBox7.Focus()
            Exit Sub
        End If

        If TextBox6.Tag = 0 Then
            Mensaje("No existe una Moneda Predeterminada", WinPopup1)
            TextBox6.Focus()
            Exit Sub
        End If

        If TxtMoneda1.Text = "" Then
            Mensaje("Ingrese una Cotizacion", WinPopup1)
            TxtMoneda1.Focus()
            Exit Sub
        ElseIf Val(TxtMoneda1.Text) = 0 Then
            Mensaje("La cotizacion no puede ser 0", WinPopup1)
            TxtMoneda1.Focus()
            Exit Sub
        End If

        If TxtMoneda2.Text = "" Then
            Mensaje("Ingrese una Cotizacion", WinPopup1)
            TxtMoneda2.Focus()
            Exit Sub
        ElseIf Val(TxtMoneda2.Text) = 0 Then
            Mensaje("La cotizacion no puede ser 0", WinPopup1)
            TxtMoneda2.Focus()
            Exit Sub
        End If

        If detAjustes.Rows.Count = 0 Then
            Mensaje("El comprobante número " & Textbox4.Text & " no contiene lineas de Detalle ", WinPopup1)
            TextBox9.Focus()
            Exit Sub
        End If

        Dim tipo As Integer
        If RadioButton1.Checked = True Then
            tipo = 1
        Else
            tipo = 0
        End If

        If cmdGrabar.Text = "&Grabar" Then
            TextBox1.Text = sentAjustes.Insertar(codSucursalPertenece, TextBox6.Tag, UsuCodigo, EmpCodigo, Val(txtNumSucursal.Tag), _
            TextBox3.Tag, Textbox4.Text, Fecha1.FechaCadena, TxtMoneda1.TxtMonedaBase, _
            TxtMoneda2.TxtMonedaBase, TextBox7.Tag, tipo, _
            TxtMoneda12.TxtMonedaBase, detAjustes, IpMaquina)

            If TextBox1.Text = 0 Then
                Mensaje("El registro no se ha grabado, vuelva a intentarlo", WinPopup1)

                Exit Sub
            Else
                Textbox4.Tag = funcion.Descripcion_Tabla("NUMAJUSTE", "AJUSTE", "CODAJUSTE", TextBox1.Text, EmpCodigo)
                'If Textbox4.Text <> Textbox4.Tag Then
                Textbox4.Text = Textbox4.Tag
                Mensaje("Registro grabado con Numero " & Textbox4.Text, WinPopup1)
                'Else
                '  Mensaje("Registro grabado correctamente", WinPopup1)
                'End If
            End If
        Else
            If sentAjustes.Modificar(TextBox1.Text, TextBox6.Tag, UsuCodigo, EmpCodigo, _
            Val(txtNumSucursal.Tag), TextBox3.Tag, Textbox4.Text, Fecha1.FechaCadena, _
            TxtMoneda1.TxtMonedaBase, TxtMoneda2.TxtMonedaBase, TextBox7.Tag, _
            tipo, TxtMoneda12.TxtMonedaBase, detAjustes) = False Then

                Mensaje("El registro no se ha modificado, vuelva a intentarlo", WinPopup1)

                Exit Sub
            Else
                Mensaje("Registro modificado correctamente", WinPopup1)
            End If
        End If

        HabilitarBotones()
        cmdNuevo.Focus()
        CargarDatos = True

        If cmdGrabar.Text = "&Grabar Mod." Then
            cmdGrabar.Text = "&Grabar"
        Else
            AsignarDataBindsBuscar(TextBox1.Text)
        End If

        ImprimirComprobante()
    End Sub

    Private Sub Cancelar()
        If MsgBox("¿Desea cancelar la operación?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Ajuste") = MsgBoxResult.Yes Then
            Mensaje("Operación Cancelada", WinPopup1)
            Limpiar()
            HabilitarBotones()
            CargarDatos = True
            VerificarDatos()
            cmdNuevo.Focus()
        End If
    End Sub

    Private Sub Eliminar()
        If Val(TextBox1.Text) = 0 Then
            Exit Sub
        End If

        If funcion.Validar_Tabla("P.CODPRODUCCION", "PRODUCCIONPOLLO P INNER JOIN PRODUCCIONPOLLODETALLE PD ON PD.CODPRODUCCION = P.CODPRODUCCION", _
        "CODAJUSTE", TextBox1.Text, EmpCodigo) > 0 Then
            Mensaje("Este ajuste no se puede eliminar porque forma parte de una Producción de Pollos", WinPopup1)
            Exit Sub
        End If

        Dim tipo As Integer
        If RadioButton1.Checked = True Then
            tipo = 1
        Else
            tipo = 0
        End If

        If MsgBox("¿Desea eliminar este comprobante?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Ajuste") = MsgBoxResult.Yes Then
            If sentAjustes.Eliminar(Val(TextBox1.Text), Val(txtNumSucursal.Tag), detAjustes, tipo, EmpCodigo, _
            TextBox3.Tag, TxtMoneda1.TxtMonedaBase, TxtMoneda2.TxtMonedaBase, _
            TxtMoneda12.TxtMonedaBase, Fecha1.FechaCadena, TextBox6.Tag, UsuCodigo, Textbox4.Text) = True Then

                Mensaje("Registro eliminado correctamente", WinPopup1)
                Limpiar()
                CargarDatos = True
                VerificarDatos()
                limpiarDetalle()
            Else
                Mensaje("El registro no se ha eliminado", WinPopup1)
            End If
        End If

        cmdNuevo.Focus()
    End Sub

    Public Sub Primero()
        VerificarDatos()
        Me.BindingContext(dtCodigo).Position = 0
        AsignarDataBinds()
    End Sub

    Public Sub Siguiente()
        VerificarDatos()
        Me.BindingContext(dtCodigo).Position += 1
        AsignarDataBinds()
    End Sub

    Public Sub Anterior()
        VerificarDatos()
        Me.BindingContext(dtCodigo).Position -= 1
        AsignarDataBinds()
    End Sub

    Public Sub Ultimo()
        VerificarDatos()
        Me.BindingContext(dtCodigo).Position = Me.BindingContext(dtCodigo).Count - 1
        AsignarDataBinds()
    End Sub

    Public Sub Buscar()
        Buscar_Tabla("AJUSTE A INNER JOIN TIPOCOMPROBANTE TC ON A.CODCOMPROBANTE = TC.CODCOMPROBANTE INNER JOIN CONCEPTO C ON A.CODCONCEPTO = C.CODCONCEPTO " & _
        "INNER JOIN SUCURSAL S ON S.CODSUCURSAL = A.CODSUCURSAL", _
        "RTRIM(TC.NUMTIPOCOMPRO) + ' ' + RTRIM(NUMAJUSTE) + ' - ' + RTRIM(C.DESCONCEPTO)", "CODAJUSTE", "RTRIM(NUMAJUSTE)", _
        "Buscar Ajuste", "A.CODEMPRESA = ", "", "", "(CASE WHEN TIPOAJUSTE = 0 THEN 'MENOS (-)' ELSE 'MAS (+)' END)", "Tipo", _
        "CONVERT(VARCHAR(10),FECHAAJUSTE,103)", "Fecha", "RTRIM(S.NUMSUCURSAL) + ' ' + RTRIM(S.DESSUCURSAL)", "Sucursal")

        If Not Campo_clave_tablas = "0" Then
            TextBox1.Text = Campo_clave_tablas
            AsignarDataBindsBuscar(Val(TextBox1.Text))
            CargarDatos = True
        End If
    End Sub

    Public Sub VerificarDatos()
        If CargarDatos = True Then
            dtCodigo.Rows.Clear()
            If SucCodigoPertenece = "NULL" Then
                dtCodigo = sentAjustes.DsRecorrerCodigo(EmpCodigo)
                'txtNumSucursal.ReadOnly = False
            Else
                dtCodigo = sentAjustes.DsRecorrerCodigoSucursalPertenece(EmpCodigo, SucCodigoPertenece)
                txtNumSucursal.ReadOnly = True
            End If
            dtCodigo = sentAjustes.DsRecorrerCodigo(EmpCodigo)
            AsignarDataBinds()
            CargarDatos = False
        End If
    End Sub

    Private Sub AsignarDataBinds()
        LimpiarDatabinds()
        LimpiarDatabindsMoneda()

        TextBox1.DataBindings.Add(New Binding("Text", dtCodigo, "CODAJUSTE"))

        dtDescripcion.Rows.Clear()
        dtDescripcion = sentAjustes.DsRecorrerDescripcion(Val(TextBox1.Text))

        txtNumSucursal.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMSUCURSAL"))
        txtNumSucursal.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODSUCURSAL"))
        lblDescripSucursal.DataBindings.Add(New Binding("Text", dtDescripcion, "DESSUCURSAL"))

        TextBox3.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMTIPOCOMPRO"))
        TextBox3.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODCOMPROBANTE"))
        Label20.DataBindings.Add(New Binding("Text", dtDescripcion, "DESCOMPROBANTE"))

        Textbox4.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMAJUSTE"))
        Fecha1.DataBindings.Add(New Binding("Text", dtDescripcion, "FECHAAJUSTE"))

        TextBox7.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODCONCEPTO"))
        TextBox7.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMCONCEPTO"))
        Label29.DataBindings.Add(New Binding("Text", dtDescripcion, "DESCONCEPTO"))

        TextBox6.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODMONEDA"))
        TextBox6.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMMONEDA"))
        Label7.DataBindings.Add(New Binding("Text", dtDescripcion, "DESMONEDA"))

        DecimalMoneda()

        TxtMoneda1.DataBindings.Add(New Binding("Text", dtDescripcion, "COTIZACION1"))
        TxtMoneda2.DataBindings.Add(New Binding("Text", dtDescripcion, "COTIZACION2"))

        RadioButton1.DataBindings.Add(New Binding("Checked", dtDescripcion, "TIPOAJUSTE"))
        Label12.DataBindings.Add(New Binding("Text", dtDescripcion, "USUARIO"))

        If RadioButton1.Checked = False Then
            RadioButton2.Checked = True
        End If

        LimpiarDatabinds()
        LimpiarDatabindsMoneda()

        TxtMoneda1.TextoSQL(TxtMoneda1.Text)
        TxtMoneda2.TextoSQL(TxtMoneda2.Text)
        TxtMoneda12.TextoSQL(TxtMoneda12.Text)

        CargarDetalle()

        RadioButton1.Enabled = False
        RadioButton2.Enabled = False
    End Sub

    Private Sub AsignarDataBindsBuscar(ByVal parametro_busqueda As Long)
        LimpiarDatabinds()
        LimpiarDatabindsMoneda()

        dtDescripcion.Rows.Clear()
        dtDescripcion = sentAjustes.DsRecorrerDescripcion(Val(TextBox1.Text))

        txtNumSucursal.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMSUCURSAL"))
        txtNumSucursal.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODSUCURSAL"))
        lblDescripSucursal.DataBindings.Add(New Binding("Text", dtDescripcion, "DESSUCURSAL"))

        TextBox3.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMTIPOCOMPRO"))
        TextBox3.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODCOMPROBANTE"))
        Label20.DataBindings.Add(New Binding("Text", dtDescripcion, "DESCOMPROBANTE"))

        Textbox4.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMAJUSTE"))
        Fecha1.DataBindings.Add(New Binding("Text", dtDescripcion, "FECHAAJUSTE"))

        TextBox7.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODCONCEPTO"))
        TextBox7.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMCONCEPTO"))
        Label29.DataBindings.Add(New Binding("Text", dtDescripcion, "DESCONCEPTO"))

        TextBox6.DataBindings.Add(New Binding("Tag", dtDescripcion, "CODMONEDA"))
        TextBox6.DataBindings.Add(New Binding("Text", dtDescripcion, "NUMMONEDA"))
        Label7.DataBindings.Add(New Binding("Text", dtDescripcion, "DESMONEDA"))

        DecimalMoneda()

        TxtMoneda1.DataBindings.Add(New Binding("Text", dtDescripcion, "COTIZACION1"))
        TxtMoneda2.DataBindings.Add(New Binding("Text", dtDescripcion, "COTIZACION2"))

        RadioButton1.DataBindings.Add(New Binding("Checked", dtDescripcion, "TIPOAJUSTE"))
        Label12.DataBindings.Add(New Binding("Text", dtDescripcion, "USUARIO"))

        If RadioButton1.Checked = False Then
            RadioButton2.Checked = True
        End If

        LimpiarDatabinds()
        LimpiarDatabindsMoneda()

        TxtMoneda1.TextoSQL(TxtMoneda1.Text)
        TxtMoneda2.TextoSQL(TxtMoneda2.Text)
        TxtMoneda12.TextoSQL(TxtMoneda12.Text)

        CargarDetalle()

        RadioButton1.Enabled = False
        RadioButton2.Enabled = False
    End Sub

    Private Sub ImprimirComprobante()
        If MsgBox("¿Desea imprimir este comprobante?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Ajuste") = MsgBoxResult.Yes Then
            'Do While nomImpresora = ""
            '    Mensaje("No ha seleccionado una impresora", WinPopup1)

            '    If MsgBox("Ingrese un nombre de impresora... Seleccione OK para imprimir", _
            '    MsgBoxStyle.OKCancel + MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical, _
            '    "Impresión de Comprobante") = MsgBoxResult.OK Then
            '        'Para traer la impresora
            '        nomImpresora = funcion.Descripcion_Tabla("IMPRESORA", "DETPC", _
            '        "CODSUCURSAL = " & txtNumSucursal.Tag & " AND CODCOMPROBANTE = " & TextBox3.Tag & " AND IP", _
            '        IpMaquina, EmpCodigo)

            '        Dim i As New PrintDocument

            '        i.PrinterSettings.PrinterName = nomImpresora

            '        If i.PrinterSettings.IsValid = False Then
            '            Mensaje("La impresora especificada no es válida", WinPopup1)
            '            nomImpresora = ""
            '        End If

            '        'Finaliza esta clase
            '        i.Dispose()
            '    Else
            '        Exit Do
            '    End If
            'Loop

            If nomImpresora = "" Then
                Mensaje("Comprobante no impreso", WinPopup1)
            Else
                Mensaje("Imprimiendo comprobante", WinPopup1)

                reporte = New Reportes.impAjuste
                reporte.SetDataSource(informe.ImpAjuste(Val(TextBox1.Text), Candecimales))
                reporte.PrintOptions.PrinterName = nomImpresora
                reporte.PrintToPrinter(1, False, 0, 0)
            End If
        End If
    End Sub

    Private Sub MonedaPredeterminada()
        Try
            dtMoneda = funcion.Predeterminado("CODMONEDA", "NUMMONEDA", "DESMONEDA", "MONEDA", EmpCodigo).Tables("Table")

            TextBox6.Tag = dtMoneda.Rows(0)("CODMONEDA")
            TextBox6.Text = dtMoneda.Rows(0)("NUMMONEDA")
            Label7.Text = dtMoneda.Rows(0)("DESMONEDA")

            MonedaCotizacion()
        Catch
            Mensaje("No existe moneda predeterminada", WinPopup1)
            Cancelar()
        Finally

        End Try
    End Sub

    Private Sub DecimalMoneda()
        If funcion.DecimalPrincipal(EmpCodigo) = False Then
            TxtMoneda1.TxtMonedaDecimales = 0
            TxtMoneda2.TxtMonedaDecimales = 0
        Else
            TxtMoneda1.TxtMonedaDecimales = CANDECIMALESIMPORTE
            TxtMoneda2.TxtMonedaDecimales = CANDECIMALESIMPORTE
        End If

        If funcion.Descripcion_Tabla("DECIMALES", "MONEDA", "CODMONEDA", TextBox6.Tag, EmpCodigo) = "0" Then
            Candecimales = 0
        Else
            Candecimales = CANDECIMALESIMPORTE
        End If

        TxtMoneda4.TxtMonedaDecimales = Candecimales
        TxtMoneda6.TxtMonedaDecimales = Candecimales
        TxtMoneda12.TxtMonedaDecimales = Candecimales
    End Sub

    Private Sub MonedaCotizacion()
        Try
            Dim dsCotizacion As New DataSet
            DecimalMoneda()
            dsCotizacion = funcion.Moneda_Cotizacion(EmpCodigo, TextBox6.Tag, Fecha1.FechaCadena)

            TxtMoneda1.DataBindings.Clear()
            TxtMoneda2.DataBindings.Clear()

            TxtMoneda1.DataBindings.Add(New Binding("Text", dsCotizacion, "Table.Cotizacion1venta"))
            TxtMoneda2.DataBindings.Add(New Binding("Text", dsCotizacion, "Table.Cotizacion2venta"))

            TxtMoneda1.DataBindings.Clear()
            TxtMoneda2.DataBindings.Clear()

            TxtMoneda1.TextoSQL(TxtMoneda1.Text)
            TxtMoneda2.TextoSQL(TxtMoneda2.Text)
        Catch

        Finally
            If TxtMoneda1.Text = "0" Or TxtMoneda2.Text = "0" Then
                Mensaje("No existe una cotización cargada para la fecha " & Fecha1.FechaCadena & " , por favor ingrese una", WinPopup1)
            End If
        End Try
    End Sub

    Private Sub CotizacionMonedaProducto()
        Dim dsCotizacion2 As New DataSet
        dsCotizacion2 = funcion.Moneda_Cotizacion(EmpCodigo, TextBox10.Tag, Fecha1.FechaCadena)

        TxtMoneda15.DataBindings.Clear()
        TxtMoneda15.DataBindings.Add(New Binding("Text", dsCotizacion2, "Table.Cotizacion1Venta"))
        TxtMoneda15.DataBindings.Clear()

        TxtMoneda15.TextoSQL(TxtMoneda15.Text)
    End Sub

    Public Sub DecimalCotizacionProducto()
        If funcion.Descripcion_Tabla("DECIMALES", "MONEDA", "CODMONEDA", TextBox10.Tag, EmpCodigo) = True Then
            TxtMoneda15.TxtMonedaDecimales = CANDECIMALESIMPORTE
            TxtMoneda18.TxtMonedaDecimales = CANDECIMALESIMPORTE
        Else
            TxtMoneda15.TxtMonedaDecimales = 0
            TxtMoneda18.TxtMonedaDecimales = 0
        End If
    End Sub

    'Click
    Private Sub cmdNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNuevo.Click
        Nuevo()
    End Sub

    Private Sub cmdModificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModificar.Click
        Modificar()
    End Sub

    Private Sub cmdGrabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGrabar.Click
        Grabar()
    End Sub

    Private Sub cmdCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancelar.Click
        Cancelar()
    End Sub

    Private Sub cmdEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEliminar.Click
        Eliminar()
    End Sub

    Private Sub cmdPrimero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrimero.Click
        Primero()
    End Sub

    Private Sub cmdAnterior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAnterior.Click
        Anterior()
    End Sub

    Private Sub cmdSiguiente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSiguiente.Click
        Siguiente()
    End Sub

    Private Sub cmdUltimo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUltimo.Click
        Ultimo()
    End Sub

    Private Sub cmdBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBuscar.Click
        Buscar()
    End Sub

    Private Sub Volcar2_Click1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volcar2.Click
        txtFocus.Text = "linea"
        txtFocus.Focus()
    End Sub

    Private Sub Borrar2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Borrar2.Click
        EliminarDetalle()
    End Sub

    'Mouse
    Private Sub b_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Borrar1.MouseMove
        Borrar1.Visible = False
        Borrar2.Visible = True
    End Sub

    Private Sub b_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Borrar2.MouseLeave
        Borrar1.Visible = True
        Borrar2.Visible = False
    End Sub

    Private Sub v_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Volcar1.MouseMove
        Volcar1.Visible = False
        Volcar2.Visible = True
    End Sub

    Private Sub v_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volcar2.MouseLeave
        Volcar1.Visible = True
        Volcar2.Visible = False
    End Sub

    'KeyPress
    Private Sub TextBox7_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            txtFocus.Focus()
        End If
        If KeyAscii = 42 Then
            Buscar_Tabla("CONCEPTO", "DESCONCEPTO", "CODCONCEPTO", "NUMCONCEPTO")
            If Not Campo_clave_tablas = "0" Then
                TextBox7.Tag = Campo_clave_tablas
                TextBox7.Text = Campo_numero_tablas
                Label29.Text = Campo_descripcion_tablas
            End If
            e.Handled = True
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub txtNumSucursal_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumSucursal.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox3.Focus()
        End If
        If KeyAscii = 42 And txtNumSucursal.ReadOnly = False Then 'Pedro Silva Britos 03072012 Ascii = 42 = * y el readonly = false p/no acceder al buscador de Sucursal
            Buscar_Tabla("SUCURSAL", "DESSUCURSAL", "CODSUCURSAL", "NUMSUCURSAL", "Buscar Sucursal")
            If Not Campo_clave_tablas = "0" Then
                txtNumSucursal.Tag = Campo_clave_tablas
                txtNumSucursal.Text = Campo_numero_tablas
                lblDescripSucursal.Text = Campo_descripcion_tablas
            End If
            e.Handled = True
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub TextBox3_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            Textbox4.Focus()
        End If
        If KeyAscii = 42 Then
            Buscar_Tabla("TIPOCOMPROBANTE", "DESCOMPROBANTE", "CODCOMPROBANTE", "NUMTIPOCOMPRO", "Tipo Comprobante")
            If Not Campo_clave_tablas = "0" Then
                TextBox3.Tag = Campo_clave_tablas
                TextBox3.Text = Campo_numero_tablas
                Label20.Text = Campo_descripcion_tablas
            End If
            e.Handled = True
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Textbox4.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            Fecha1.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub fecha1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Fecha1.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox7.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

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

        If KeyAscii = 42 Then
            If cmdGrabar.Enabled = True Then
                Buscar_Tabla("PRODUCTOS", "DESPRODUCTO", "CODPRODUCTO", "CODIGOBARRA", "Buscar Productos", "PRODUCTOACTIVO = 1 AND CODEMPRESA = ", "", _
                "", "CODIGOORIGINAL", "Código Original", "CONVERT(VARCHAR, FECHAINGRESO, 103)", "Ingreso")

                'Buscar_Tabla_Complejo("PRODUCTOS", "DESPRODUCTO", "CODPRODUCTO", "CODIGOBARRA", "Buscar Productos", "", "", _
                '"", "CODIGOORIGINAL", "Código Original", "CONVERT(VARCHAR, FECHAINGRESO, 103)", "Ingreso")
                If Not Campo_clave_tablas = 0 Then
                    TextBox9.Tag = Campo_clave_tablas
                    TextBox9.Text = Campo_numero_tablas
                    TextBox10.Text = Campo_descripcion_tablas
                End If
            End If
            e.Handled = True
        End If

        If KeyAscii = 13 Then
            TxtMoneda3.Focus()
        End If

        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub TextBox10_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox10.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TxtMoneda3.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

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

        If KeyAscii = 13 Then
            TxtMoneda19.Focus()
        End If

        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub txtmoneda19_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtMoneda19.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            txtFocus.Text = "linea"
            txtFocus.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    Private Sub txtmoneda6_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtMoneda6.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            txtFocus.Text = "linea"
            txtFocus.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub

    'KeyDown
    Private Sub TextBox9_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox9.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TextBox7.Focus()
            Case Keys.Down
                TxtMoneda3.Focus()
        End Select
    End Sub

    Private Sub TextBox10_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox10.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TextBox9.Focus()
            Case Keys.Down
                TxtMoneda3.Focus()
        End Select
    End Sub

    Private Sub txtmoneda3_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtMoneda3.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TextBox9.Focus()
            Case Keys.Down
                TxtMoneda19.Focus()
        End Select
    End Sub

    Private Sub txtmoneda19_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtMoneda19.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TxtMoneda3.Focus()
            Case Keys.Down
                TextBox9.Focus()
        End Select
    End Sub

    Private Sub txtmoneda6_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtMoneda6.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TxtMoneda19.Focus()
            Case Keys.Down
                TextBox9.Focus()
        End Select
    End Sub

    Private Sub TextBox3_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                txtNumSucursal.Focus()
            Case Keys.Down
                Textbox4.Focus()
        End Select
    End Sub

    Private Sub TextBox4_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Textbox4.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TextBox3.Focus()
            Case Keys.Down
                Fecha1.Focus()
        End Select
    End Sub

    Private Sub Fecha1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Fecha1.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                Textbox4.Focus()
            Case Keys.Down
                TextBox7.Focus()
        End Select
    End Sub

    Private Sub TextBox7_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox7.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                Fecha1.Focus()
            Case Keys.Down
                txtFocus.Focus()
        End Select
    End Sub

    Private Sub txtNumSucursal_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNumSucursal.KeyDown
        Select Case e.KeyCode
            Case Keys.Up
                TextBox7.Focus()
            Case Keys.Down
                TextBox3.Focus()
        End Select
    End Sub

    'Validated
    Private Sub TextBox9_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.Validated
        If Not TextBox9.Text = "" Then
            TextBox9.Tag = funcion.Validar_Tabla("CODPRODUCTO", "PRODUCTOS", "CODIGOBARRA", TextBox9.Text, EmpCodigo & "AND PRODUCTOACTIVO = 1")

            If Val(TextBox9.Tag) <> 0 Then
                Dim i As Integer
                For i = 1 To detAjustes.Rows.Count
                    If EstadoDetalle = 2 And i <> Linea Then
                        If detAjustes.Rows(i - 1)("codigo") = TextBox9.Text Then
                            Mensaje("Ya existe este codigo en el detalle...!", WinPopup1)
                            TextBox9.Focus()
                            Exit Sub
                        End If
                    Else
                        If EstadoDetalle = 0 Then
                            If detAjustes.Rows(i - 1)("codigo") = TextBox9.Text Then
                                Mensaje("Ya existe este codigo en el detalle...!", WinPopup1)
                                TextBox9.Focus()
                                Exit Sub
                            End If
                        End If
                    End If
                Next

                dtDatos = sentAjustes.ProductoDatos(TextBox9.Tag)

                TextBox10.Text = dtDatos.Rows(0)("DESPRODUCTO")
                TextBox10.Tag = dtDatos.Rows(0)("CODMONEDA")

                DecimalCotizacionProducto()
                CotizacionMonedaProducto()

                TxtMoneda18.Text = CType(dtDatos.Rows(0)("ULTIMOCOSTO"), Decimal)
                TxtMoneda19.Text = CType(dtDatos.Rows(0)("COSTOPP"), Decimal)

                TxtMoneda18.TextoSQL(TxtMoneda18.Text)
                TxtMoneda19.TextoSQL(TxtMoneda19.Text)

                If TextBox10.Tag <> TextBox6.Tag Then
                    costo = CType(TxtMoneda18.Text, Decimal)
                    cotiproducto = CType(TxtMoneda15.Text, Decimal)
                    cotizacion = CType(TxtMoneda1.Text, Decimal)

                    TxtMoneda4.TextoSQL((costo * cotiproducto) / cotizacion)

                    costo = CType(TxtMoneda19.Text, Decimal)
                    TxtMoneda19.TextoSQL((costo * cotiproducto) / cotizacion)

                    TxtMoneda18.Text = CType(TxtMoneda4.Text, Decimal)
                    TxtMoneda18.TextoSQL(TxtMoneda4.Text)
                Else
                    TxtMoneda4.Text = CType(TxtMoneda18.Text, Decimal)
                    TxtMoneda4.TextoSQL(TxtMoneda4.Text)
                End If
            Else
                Mensaje("El codigo de producto no existe", WinPopup1)
                limpiarDetalle()

                TextBox9.Focus()
            End If
        Else
            limpiarDetalle()
            cmdGrabar.Focus()
        End If
    End Sub

    Private Sub fecha1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Fecha1.Validated
        Mensaje(Fecha1.Mensaje, WinPopup1)
    End Sub

    Private Sub txtNumSucursal_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNumSucursal.Validated
        Mensaje(funcion.validacion_codigo_tabla_dependiente(cmdGrabar, txtNumSucursal, lblDescripSucursal, "CODSUCURSAL", _
        "SUCURSAL", "DESSUCURSAL", "NUMSUCURSAL", EmpCodigo), WinPopup1)

        If txtNumSucursal.Text <> "" Then
            'codSucursalPertenece = funcion.Validar_Tabla("ISNULL(CODSUCURSALPERTENECE, 0)", "SUCURSAL", "CODSUCURSAL", Val(txtNumSucursal.Tag), EmpCodigo)

            'If codSucursalPertenece = 0 Then
            '    codSucursalPertenece = txtNumSucursal.Tag
            'End If

            codSucursalPertenece = SucCodigo
        End If
    End Sub

    Private Sub TextBox3_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.Validated
        Mensaje(funcion.validacion_codigo_tabla_dependiente(cmdGrabar, TextBox3, Label20, "CODCOMPROBANTE", "TIPOCOMPROBANTE", _
        "DESCOMPROBANTE", "NUMTIPOCOMPRO", EmpCodigo), WinPopup1)

        If cmdGrabar.Enabled = True And TextBox3.ReadOnly = False And cmdGrabar.Text <> "&Grabar Mod." Then
            If Not TextBox3.Tag = 0 Then
                nomImpresora = ""

                Try
                    'Para traer la impresora
                    nomImpresora = funcion.Descripcion_Tabla("IMPRESORA", "DETPC", _
                    "CODSUCURSAL = " & codSucursalPertenece & " AND CODCOMPROBANTE = " & TextBox3.Tag & " AND IP", _
                    IpMaquina, EmpCodigo)

                    'Para traer el ultimo numero de comprobante
                    If funcion.Validar_Tabla_cod_string("ULTIMO", "DETPC", _
                    "CODSUCURSAL = " & codSucursalPertenece & " AND CODCOMPROBANTE = " & TextBox3.Tag & " AND IP", _
                    IpMaquina, EmpCodigo) = True Then
                        Textbox4.Text = funcion.Descripcion_Tabla("ULTIMO", "DETPC", _
                        "CODSUCURSAL = " & codSucursalPertenece & " AND CODCOMPROBANTE = " & TextBox3.Tag & " AND IP", _
                        IpMaquina, EmpCodigo)
                    Else
                        Textbox4.Text = ""
                    End If

                    If Not Textbox4.Text = "" Then
                        Textbox4.Text = Val(Textbox4.Text) + 1

                        If Val(Textbox4.Text) > funcion.Validar_Tabla("RANGO2", "DETPC", _
                        "CODSUCURSAL = " & codSucursalPertenece & " AND CODCOMPROBANTE = " & TextBox3.Tag & " AND IP", _
                        IpMaquina, EmpCodigo) Then
                            Textbox4.Text = ""
                        End If
                    End If
                Catch
                    Mensaje("A ocurrido un error con el nombre de impresora y el último número de comprobante", WinPopup1)

                    nomImpresora = ""
                    TextBox3.Tag = 0
                    TextBox3.Text = ""
                    Label20.Text = ""
                    Textbox4.Text = ""
                Finally
                    'Valida que el comprobante este dentro de un rango
                    If Textbox4.Text = "" Then
                        Mensaje("Este comprobante no tiene un rango de número asignado", WinPopup1)
                        'nomImpresora = ""
                        'TextBox3.Tag = 0
                        'TextBox3.Text = ""
                        'Label20.Text = ""
                        'Textbox4.Text = ""
                        'TextBox3.Focus()
                    Else
                        If nomImpresora = "" Or nomImpresora = "0" Then
                            Mensaje("Esta maquina no tiene definida una impresora válida", WinPopup1)
                        Else
                            Dim i As New PrintDocument

                            i.PrinterSettings.PrinterName = nomImpresora

                            If i.PrinterSettings.IsValid = False Then
                                Mensaje("La impresora especificada no es válida", WinPopup1)
                                nomImpresora = ""
                            End If

                            'Finaliza esta clase
                            i.Dispose()
                        End If
                    End If
                End Try
            Else
                nomImpresora = ""
                Textbox4.Text = ""
            End If
        End If
    End Sub

    Private Sub TextBox4_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox4.Validated
        If cmdGrabar.Enabled = True Then
            If funcion.Validar_Tabla("CODAJUSTE", "AJUSTE", "CODCOMPROBANTE = " & TextBox3.Tag & " " & _
            "AND NUMAJUSTE", Textbox4.Text, EmpCodigo) > 0 Then
                Mensaje("Número de comprobante ya existe", WinPopup1)
                Textbox4.Text = ""
                Textbox4.Focus()
            End If
        End If
    End Sub

    Private Sub TextBox7_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.Validated
        Mensaje(funcion.validacion_codigo_tabla_dependiente(cmdGrabar, TextBox7, Label29, "CODCONCEPTO", _
        "CONCEPTO", "DESCONCEPTO", "NUMCONCEPTO", EmpCodigo), WinPopup1)
    End Sub

    Private Sub TxtMoneda3_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda3.Validated
        Dim cantidadStock As Decimal
        Dim CantidadAjuste As Decimal
        Dim costo As Decimal

        If TxtMoneda3.Text = "" Or TxtMoneda19.Text = "" Then
            Exit Sub
        End If

        CantidadAjuste = CType(TxtMoneda3.Text, Decimal)

        If cmdGrabar.Enabled = True Then
            If RadioButton1.Checked = False Then
                cantidadStock = CType(sentAjustes.ProductoSucursal(TextBox9.Tag, txtNumSucursal.Tag), Decimal)

                If (cantidadStock = 0) And (STOCKNEGATIVO = 0) Then
                    Mensaje("Este producto no tiene existencia en esta Sucursal...Verifique!!!", WinPopup1)
                    TxtMoneda3.Text = ""
                    TxtMoneda3.Focus()

                    Exit Sub
                End If

                If (CantidadAjuste > cantidadStock) And (STOCKNEGATIVO = 0) Then
                    Mensaje("Este producto no tiene suficiente existencia en esta Sucursal", WinPopup1)
                    TxtMoneda3.TextoSQL(cantidadStock)
                    TxtMoneda3.Focus()

                    Exit Sub
                End If
            End If
        End If

        costo = CType(TxtMoneda19.Text, Decimal)
        TxtMoneda6.TextoSQL(Math.Round(CantidadAjuste * costo, Candecimales))
    End Sub

    Private Sub TxtMoneda19_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda19.Validated
        Dim cantidadStock As Decimal
        Dim CantidadAjuste As Decimal
        Dim costo As Decimal

        If TxtMoneda3.Text = "" Or TxtMoneda19.Text = "" Then
            Exit Sub
        End If

        CantidadAjuste = CType(TxtMoneda3.Text, Decimal)

        If cmdGrabar.Enabled = True Then
            If RadioButton1.Checked = False Then
                cantidadStock = CType(sentAjustes.ProductoSucursal(TextBox9.Tag, txtNumSucursal.Tag), Decimal)

                If (cantidadStock = 0) And (STOCKNEGATIVO = 0) Then
                    Mensaje("Este producto no tiene existencia en esta Sucursal...Verifique!!!", WinPopup1)
                    TxtMoneda3.Text = ""
                    TxtMoneda3.Focus()

                    Exit Sub
                End If

                If (CantidadAjuste > cantidadStock) And (STOCKNEGATIVO = 0) Then
                    Mensaje("Este producto no tiene suficiente existencia en esta Sucursal", WinPopup1)
                    TxtMoneda3.TextoSQL(cantidadStock)
                    TxtMoneda3.Focus()

                    Exit Sub
                End If
            End If
        End If

        costo = CType(TxtMoneda19.Text, Decimal)
        TxtMoneda6.TextoSQL(Math.Round(CantidadAjuste * costo, Candecimales))
    End Sub

    'Detalle
    Public Sub CargarDetalle()
        Dim dt As DataTable
        Dim i As Integer

        detAjustes.Rows.Clear()
        dt = sentAjustes.DsRecorrerDetalle(Val(TextBox1.Text))

        limpiarDetalle()
        Try
            For i = 0 To dt.Rows.Count - 1
                TextBox9.Tag = dt.Rows(i)("CODPRODUCTO")
                TextBox9.Text = dt.Rows(i)("CODIGOBARRA")
                TextBox10.Text = dt.Rows(i)("DESPRODUCTO")
                TextBox10.Tag = dt.Rows(i)("CODMONEDA")

                DecimalCotizacionProducto()
                CotizacionMonedaProducto()

                TxtMoneda3.Text = CType(dt.Rows(i)("CANTIDADAJUSTE"), Decimal)
                TxtMoneda4.Text = CType(dt.Rows(i)("COSTOULTIMO"), Decimal)
                TxtMoneda18.Text = CType(dt.Rows(i)("COSTOULTIMO"), Decimal)
                TxtMoneda19.Text = CType(dt.Rows(i)("COSTOPROMEDIO"), Decimal)
                TxtMoneda6.Text = Math.Round(CType(dt.Rows(i)("CANTIDADAJUSTE"), Decimal) * _
                CType(dt.Rows(i)("COSTOPROMEDIO"), Decimal), Candecimales)

                TxtMoneda3.TextoSQL(TxtMoneda3.Text)
                TxtMoneda4.TextoSQL(TxtMoneda4.Text)
                TxtMoneda18.TextoSQL(TxtMoneda18.Text)
                TxtMoneda19.TextoSQL(TxtMoneda19.Text)
                TxtMoneda6.TextoSQL(TxtMoneda6.Text)

                MakeDataSet()
                limpiarDetalle()
            Next
        Finally
            MakeDataStyle()
            dgDetalle.DataSource = detAjustes

            If Not detAjustes.Rows.Count = 0 Then
                Dim ultimaLinea As Integer = detAjustes.Rows.Count - 1
                Dim cell As New DataGridCell(ultimaLinea, 0)
                dgDetalle.CurrentCell = cell
            Else
                dgDetalle.TableStyles.Clear()
                dgDetalle.DataSource = Nothing
            End If
        End Try

        cmdNuevo.Focus()
    End Sub

    Private Sub MakeTable()
        detAjustes = New DataTable("detAjustes")

        Dim colLin As DataColumn
        colLin = New DataColumn("Lin", GetType(System.Int64))

        Dim colCodbarra As DataColumn
        colCodbarra = New DataColumn("Codigo", GetType(System.String))

        Dim colCodProducto As DataColumn
        colCodProducto = New DataColumn("CodProducto", GetType(System.Int64))

        Dim colDescripcion As DataColumn
        colDescripcion = New DataColumn("Descripcion", GetType(System.String))

        Dim colCantidad As DataColumn
        colCantidad = New DataColumn("Cantidad", GetType(System.String))

        Dim colEliminado As DataColumn
        colEliminado = New DataColumn("Eliminado", GetType(System.Int16))

        Dim colUltimoCosto As DataColumn
        colUltimoCosto = New DataColumn("UltimoCosto", GetType(System.String))

        Dim colCostopromedio As DataColumn
        colCostopromedio = New DataColumn("Costopromedio", GetType(System.String))

        Dim colCosto As DataColumn
        colCosto = New DataColumn("Costo", GetType(System.String))

        Dim colTotal As DataColumn
        colTotal = New DataColumn("Total", GetType(System.String))

        detAjustes.Columns.Add(colLin)
        detAjustes.Columns.Add(colCodbarra)
        detAjustes.Columns.Add(colDescripcion)
        detAjustes.Columns.Add(colCantidad)
        detAjustes.Columns.Add(colEliminado)
        detAjustes.Columns.Add(colCodProducto)
        detAjustes.Columns.Add(colCostopromedio)
        detAjustes.Columns.Add(colUltimoCosto)
        detAjustes.Columns.Add(colCosto)
        detAjustes.Columns.Add(colTotal)
    End Sub

    Private Sub MakeDataSet()
        'EstadoDetalle = 2 para modificar
        If EstadoDetalle = 2 Then
            detAjustes.Rows(Linea - 1)("Codigo") = TextBox9.Text
            detAjustes.Rows(Linea - 1)("Descripcion") = TextBox10.Text
            detAjustes.Rows(Linea - 1)("Cantidad") = TxtMoneda3.Text
            detAjustes.Rows(Linea - 1)("UltimoCosto") = TxtMoneda18.Text
            detAjustes.Rows(Linea - 1)("Costopromedio") = TxtMoneda19.Text
            detAjustes.Rows(Linea - 1)("Costo") = TxtMoneda4.Text
            detAjustes.Rows(Linea - 1)("Total") = TxtMoneda6.Text
            detAjustes.Rows(Linea - 1)("Eliminado") = 0
            detAjustes.Rows(Linea - 1)("CodProducto") = TextBox9.Tag
            Linea = 0
            EstadoDetalle = 0
        Else
            Dim newRow1 As DataRow
            Dim i As Integer = detAjustes.Rows.Count + 1

            newRow1 = detAjustes.NewRow
            newRow1("Lin") = i
            detAjustes.Rows.Add(newRow1)
            detAjustes.Rows(i - 1)("Codigo") = TextBox9.Text
            detAjustes.Rows(i - 1)("Descripcion") = TextBox10.Text
            detAjustes.Rows(i - 1)("Cantidad") = TxtMoneda3.Text
            detAjustes.Rows(i - 1)("UltimoCosto") = TxtMoneda18.Text
            detAjustes.Rows(i - 1)("Costopromedio") = TxtMoneda19.Text
            detAjustes.Rows(i - 1)("Costo") = TxtMoneda4.Text
            detAjustes.Rows(i - 1)("Total") = TxtMoneda6.Text
            detAjustes.Rows(i - 1)("Eliminado") = 0
            detAjustes.Rows(i - 1)("CodProducto") = TextBox9.Tag
        End If

        MakeTotales()
    End Sub

    Private Sub MakeDataStyle()
        Dim ts1 As New DataGridTableStyle
        ts1.MappingName = "detAjustes"
        ts1.AlternatingBackColor = Color.LightGray
        ts1.AllowSorting = False

        Dim TextCol As New DataGridTextBoxColumn
        TextCol.MappingName = "Lin"
        TextCol.HeaderText = "Nº"
        TextCol.Width = 50
        ts1.GridColumnStyles.Add(TextCol)

        TextCol = New DataGridTextBoxColumn
        TextCol.MappingName = "Codigo"
        TextCol.HeaderText = "Producto"
        TextCol.Width = 150
        ts1.GridColumnStyles.Add(TextCol)

        TextCol = New DataGridTextBoxColumn
        TextCol.MappingName = "Descripcion"
        TextCol.HeaderText = ""
        TextCol.Width = Me.Width - 620
        ts1.GridColumnStyles.Add(TextCol)

        TextCol = New DataGridTextBoxColumn
        TextCol.MappingName = "Cantidad"
        TextCol.HeaderText = "Cantidad"
        TextCol.Width = 100
        TextCol.Alignment = HorizontalAlignment.Right
        ts1.GridColumnStyles.Add(TextCol)

        TextCol = New DataGridTextBoxColumn
        TextCol.MappingName = "Costopromedio"
        TextCol.HeaderText = "Costo"
        TextCol.Width = 100
        TextCol.Alignment = HorizontalAlignment.Right
        ts1.GridColumnStyles.Add(TextCol)

        TextCol = New DataGridTextBoxColumn
        TextCol.MappingName = "Total"
        TextCol.HeaderText = "Sub Total"
        TextCol.Width = 100
        TextCol.Alignment = HorizontalAlignment.Right
        ts1.GridColumnStyles.Add(TextCol)

        ts1.SelectionBackColor = System.Drawing.Color.PaleGreen
        dgDetalle.ReadOnly = True
        dgDetalle.TableStyles.Clear()
        dgDetalle.TableStyles.Add(ts1)
    End Sub

    Public Sub agregarNuevoDetalle()
        limpiarDetalle()
        TextBox9.Focus()
    End Sub

    Private Sub CargarLinea()
        TextBox9.Text = detAjustes.Rows(Linea - 1)("Codigo")
        TextBox9.Tag = detAjustes.Rows(Linea - 1)("CodProducto")
        TextBox10.Text = detAjustes.Rows(Linea - 1)("Descripcion")

        TxtMoneda3.TextoSQL(CType(detAjustes.Rows(Linea - 1)("Cantidad"), Decimal))
        TxtMoneda4.TextoSQL(CType(detAjustes.Rows(Linea - 1)("Costo"), Decimal))
        TxtMoneda18.TextoSQL(CType(detAjustes.Rows(Linea - 1)("UltimoCosto"), Decimal))
        TxtMoneda19.TextoSQL(CType(detAjustes.Rows(Linea - 1)("CostoPromedio"), Decimal))
        TxtMoneda6.TextoSQL(CType(detAjustes.Rows(Linea - 1)("Total"), Decimal))

        MakeTotales()
        TextBox9.Focus()
        EstadoDetalle = 2
    End Sub

    Public Sub agregarDetalle()
        If TextBox9.Text.Length = 0 Then
            Mensaje("Ingrese un Producto", WinPopup1)
            TextBox9.Focus()
            Exit Sub
        End If

        If IsNumeric(TxtMoneda3.Text) = False Then
            Mensaje("Ingrese la cantidad", WinPopup1)
            txtFocus.Text = "nolimpia"
            TxtMoneda3.Focus()

            Exit Sub
        ElseIf CType(TxtMoneda3.Text, Decimal) = 0 Then
            Mensaje("Ingrese la cantidad", WinPopup1)
            txtFocus.Text = "nolimpia"
            TxtMoneda3.Focus()

            Exit Sub
        End If

        'If IsNumeric(TxtMoneda19.Text) = False Then
        '    Mensaje("El Producto no tiene costo", WinPopup1)
        '    txtFocus.Text = "nolimpia"
        '    TxtMoneda19.Focus()

        '    Exit Sub
        'ElseIf CType(TxtMoneda19.Text, Decimal) = 0 Then
        '    Mensaje("El Producto no tiene costo", WinPopup1)
        '    txtFocus.Text = "nolimpia"
        '    TxtMoneda19.Focus()

        '    Exit Sub
        'End If

        For i As Long = 1 To detAjustes.Rows.Count
            If EstadoDetalle = 2 And i <> Linea Then
                If detAjustes.Rows(i - 1)("codigo") = TextBox9.Text Then
                    Mensaje("Ya existe este codigo en el detalle", WinPopup1)

                    TextBox9.Focus()
                    Exit Sub
                End If
            Else
                If EstadoDetalle = 0 Then
                    If detAjustes.Rows(i - 1)("codigo") = TextBox9.Text Then
                        Mensaje("Ya existe este codigo en el detalle", WinPopup1)

                        TextBox9.Focus()
                        Exit Sub
                    End If
                End If
            End If
        Next

        MakeDataSet()
        MakeDataStyle()

        limpiarDetalle()

        If Not detAjustes.Rows.Count > 0 Then
            dgDetalle.TableStyles.Clear()
            dgDetalle.DataSource = Nothing

            RadioButton1.Enabled = True
            RadioButton2.Enabled = True
        Else
            dgDetalle.DataSource = detAjustes
            Dim ultimaLinea As Integer = detAjustes.Rows.Count - 1
            Dim cell As New DataGridCell(ultimaLinea, 0)

            dgDetalle.CurrentCell = cell
            RadioButton1.Enabled = False
            RadioButton2.Enabled = False
        End If
    End Sub

    Private Sub EliminarDetalle()
        If Linea <> 0 Then
            If MsgBox("¿Desea eliminar este detalle?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Ajuste") = MsgBoxResult.Yes Then
                Dim a As Integer
                Dim dsA As New DataSet
                a = Linea - 1
                Linea = 0
                Try
                    detAjustes.Rows(a).Delete()
                    Dim total As Long
                Catch ex As Exception
                    Mensaje("Seleccione una linea!", WinPopup1)
                End Try

                For a = 0 To detAjustes.Rows.Count - 1
                    detAjustes.Rows(a)("Lin") = a + 1
                Next
                EstadoDetalle = 0
                MakeTotales()
            Else
                dgDetalle.UnSelect(dgDetalle.CurrentRowIndex)
                TextBox9.Focus()
            End If

            limpiarDetalle()
        End If

        If Not detAjustes.Rows.Count = 0 Then
            dgDetalle.DataSource = detAjustes
            Dim ultimaLinea As Integer = detAjustes.Rows.Count - 1
            Dim cell As New DataGridCell(ultimaLinea, 0)
            dgDetalle.CurrentCell = cell

            RadioButton1.Enabled = False
            RadioButton2.Enabled = False
        Else
            dgDetalle.TableStyles.Clear()
            dgDetalle.DataSource = Nothing

            RadioButton1.Enabled = True
            RadioButton2.Enabled = True
        End If

        TextBox9.Focus()
    End Sub

    Private Sub dgDetalle_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgDetalle.MouseUp
        If cmdGrabar.Enabled = False Then
            cmdNuevo.Focus()

            Exit Sub
        End If

        Try
            Dim myGrid As DataGrid = CType(sender, DataGrid)
            Dim myHitInfo As DataGrid.HitTestInfo = myGrid.HitTest(e.X, e.Y)
            Linea = dgDetalle.Item(myHitInfo.Row, 0)
            dgDetalle.Select(myHitInfo.Row)
            CargarLinea()
        Catch

        Finally

        End Try
    End Sub

    Private Sub dgDetalle_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgDetalle.Scroll
        If cmdGrabar.Enabled = True Then
            TextBox9.Focus()
        Else
            cmdNuevo.Focus()
        End If
    End Sub

    Private Sub MakeTotales()
        Dim total As Decimal
        Dim aux As Decimal

        Dim i As Integer

        For i = 1 To detAjustes.Rows.Count
            aux = CType(detAjustes.Rows(i - 1)("Total"), Decimal)
            total = total + aux
        Next

        TxtMoneda12.Text = total
        TxtMoneda12.TextoSQL(TxtMoneda12.Text)
    End Sub

    Private Sub txtFocus_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFocus.GotFocus
        If txtFocus.Text = "linea" Then
            txtFocus.Text = "agregarNuevoDetalle()"
            agregarDetalle()
            TextBox9.Focus()
        End If

        If txtFocus.Text = "agregarNuevoDetalle()" Then
            agregarNuevoDetalle()
            TextBox9.Focus()
        End If

        If txtFocus.Text = "nolimpiar" Then
            TextBox9.Focus()
        End If
    End Sub

    Private Sub RadioButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.Click, RadioButton2.Click
        If cmdGrabar.Enabled = True Then
            TextBox9.Focus()
        End If
    End Sub

    Private Sub Opciones(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.F9 Then ' productos
            Buscar_TablaF9("PRODUCTOS", "DESPRODUCTO", "CODPRODUCTO", "CODIGOBARRA", "Buscar Productos", "", "", _
            "", "ISNULL(CODIGOORIGINAL,'')", "Código Original", "ISNULL(CONVERT(VARCHAR, FECHAINGRESO, 103),'')", "Ingreso", "", "", "", "", "", 1)
        End If
    End Sub

    Private Sub Textbox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox4.TextChanged

    End Sub

    Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged

    End Sub

    Private Sub TxtMoneda3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda3.TextChanged

    End Sub

    Private Sub dgDetalle_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgDetalle.Navigate

    End Sub

    Private Sub Borrar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Borrar1.Click

    End Sub

    Private Sub TxtMoneda18_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda18.TextChanged

    End Sub

    Private Sub Volcar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volcar1.Click

    End Sub

    Private Sub TxtMoneda12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda12.TextChanged

    End Sub

    Private Sub Label18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label18.Click

    End Sub

    Private Sub WinPopup1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WinPopup1.Load

    End Sub

    Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click

    End Sub

    Private Sub Label10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label10.Click

    End Sub

    Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click

    End Sub

    Private Sub Label13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label13.Click

    End Sub

    Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged

    End Sub

    Private Sub TxtMoneda15_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda15.TextChanged

    End Sub

    Private Sub TxtMoneda4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda4.TextChanged

    End Sub

    Private Sub TxtMoneda6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda6.TextChanged

    End Sub

    Private Sub TxtMoneda19_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda19.TextChanged

    End Sub

    Private Sub TxtMoneda2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoneda2.TextChanged

    End Sub

    Private Sub txtFocus_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFocus.TextChanged

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

   
    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

    End Sub

   
End Class