Imports SentEmpresa.Empresa
Imports System.Data.SqlClient
Imports System.Configuration

Public Class Empresa
#Region " Variables "
    Inherits System.Windows.Forms.Form
    Dim max As New Funcion.Funcion
    Dim fecha As New Funcion.Funcion
    Dim Grabar As New SentEmpresa.Empresa
    Dim Eliminar As New SentEmpresa.Empresa
    Dim conectar As New Funcion.Funcion
    Dim funBuscar As New Funcion.Buscar     'se utiliza para aplicar las búsquedas
    Dim cnn As New SqlConnection
    Dim ds As New DataSet
    Dim DsMover As New DataSet
    'ds es para el indice, el DsMover es para el Recorrido en si
    Dim SentEmpresa As New SentEmpresa.Empresa
    Dim retentor As Integer     'para manejar si es retentora 1 y si no 0
    Dim Cargar As Boolean = True
    Dim frmBuscar As New Buscar
#End Region
#Region " Código generado por el Diseñador de Windows Forms "

    Public Sub New()
        MyBase.New()

        'El Diseñador de Windows Forms requiere esta llamada.
        InitializeComponent()
        'Skin()
        'Agregar cualquier inicialización después de la llamada a InitializeComponent()

    End Sub

    'Form reemplaza a Dispose para limpiar la lista de componentes.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

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

    'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
    'Puede modificarse utilizando el Diseñador de Windows Forms. 
    'No lo modifique con el editor de código.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox8 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox9 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox10 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents cmdGrabar As System.Windows.Forms.Button
    Friend WithEvents cmdNuevo As System.Windows.Forms.Button
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents cmdModificar As System.Windows.Forms.Button
    Friend WithEvents cmdPrimero As System.Windows.Forms.Button
    Friend WithEvents cmdSiguiente As System.Windows.Forms.Button
    Friend WithEvents cmdUltimo As System.Windows.Forms.Button
    Friend WithEvents cmdBuscar As System.Windows.Forms.Button
    Friend WithEvents cmdCancelar As System.Windows.Forms.Button
    Friend WithEvents cmdEliminar As System.Windows.Forms.Button
    Friend WithEvents cmdAnterior As System.Windows.Forms.Button
    Friend WithEvents BottomRightColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents TopLeftColor As LaMarvin.Windows.Forms.ColorPicker
    Friend WithEvents Si As System.Windows.Forms.RadioButton
    Friend WithEvents No As System.Windows.Forms.RadioButton
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents timerFecha As System.Windows.Forms.Timer

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.TextBox5 = New System.Windows.Forms.TextBox
        Me.TextBox6 = New System.Windows.Forms.TextBox
        Me.TextBox7 = New System.Windows.Forms.TextBox
        Me.TextBox8 = New System.Windows.Forms.TextBox
        Me.TextBox9 = New System.Windows.Forms.TextBox
        Me.TextBox10 = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.cmdGrabar = New System.Windows.Forms.Button
        Me.cmdNuevo = New System.Windows.Forms.Button
        Me.cmdModificar = New System.Windows.Forms.Button
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.cmdPrimero = New System.Windows.Forms.Button
        Me.cmdAnterior = New System.Windows.Forms.Button
        Me.cmdSiguiente = New System.Windows.Forms.Button
        Me.cmdUltimo = New System.Windows.Forms.Button
        Me.cmdBuscar = New System.Windows.Forms.Button
        Me.cmdCancelar = New System.Windows.Forms.Button
        Me.cmdEliminar = New System.Windows.Forms.Button
        Me.BottomRightColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.TopLeftColor = New LaMarvin.Windows.Forms.ColorPicker
        Me.Si = New System.Windows.Forms.RadioButton
        Me.No = New System.Windows.Forms.RadioButton
        Me.Label12 = New System.Windows.Forms.Label
        Me.timerFecha = New System.Windows.Forms.Timer(Me.components)
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox1.Location = New System.Drawing.Point(232, 72)
        Me.TextBox1.MaxLength = 5
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
        '
        'TextBox2
        '
        Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox2.Location = New System.Drawing.Point(232, 96)
        Me.TextBox2.MaxLength = 5
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.TabIndex = 1
        Me.TextBox2.Text = "TextBox2"
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(232, 120)
        Me.TextBox3.MaxLength = 80
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(208, 20)
        Me.TextBox3.TabIndex = 2
        Me.TextBox3.Text = "TextBox3"
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(232, 144)
        Me.TextBox4.MaxLength = 80
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(208, 20)
        Me.TextBox4.TabIndex = 3
        Me.TextBox4.Text = "TextBox4"
        '
        'TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(232, 168)
        Me.TextBox5.MaxLength = 80
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(208, 20)
        Me.TextBox5.TabIndex = 4
        Me.TextBox5.Text = "TextBox5"
        '
        'TextBox6
        '
        Me.TextBox6.Location = New System.Drawing.Point(232, 192)
        Me.TextBox6.MaxLength = 80
        Me.TextBox6.Name = "TextBox6"
        Me.TextBox6.Size = New System.Drawing.Size(208, 20)
        Me.TextBox6.TabIndex = 5
        Me.TextBox6.Text = "TextBox6"
        '
        'TextBox7
        '
        Me.TextBox7.Location = New System.Drawing.Point(232, 216)
        Me.TextBox7.MaxLength = 25
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(96, 20)
        Me.TextBox7.TabIndex = 6
        Me.TextBox7.Text = "TextBox7"
        '
        'TextBox8
        '
        Me.TextBox8.Location = New System.Drawing.Point(232, 240)
        Me.TextBox8.MaxLength = 50
        Me.TextBox8.Name = "TextBox8"
        Me.TextBox8.Size = New System.Drawing.Size(232, 20)
        Me.TextBox8.TabIndex = 7
        Me.TextBox8.Text = "TextBox8"
        '
        'TextBox9
        '
        Me.TextBox9.Location = New System.Drawing.Point(232, 264)
        Me.TextBox9.MaxLength = 10
        Me.TextBox9.Name = "TextBox9"
        Me.TextBox9.TabIndex = 8
        Me.TextBox9.Text = "TextBox9"
        '
        'TextBox10
        '
        Me.TextBox10.Location = New System.Drawing.Point(240, 288)
        Me.TextBox10.Name = "TextBox10"
        Me.TextBox10.Size = New System.Drawing.Size(72, 20)
        Me.TextBox10.TabIndex = 9
        Me.TextBox10.Text = "TextBox10"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label1.Location = New System.Drawing.Point(72, 72)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(152, 23)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "Código"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label2.Location = New System.Drawing.Point(72, 96)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(152, 23)
        Me.Label2.TabIndex = 12
        Me.Label2.Text = "Usuario de Grabación"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label3.Location = New System.Drawing.Point(72, 120)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(152, 23)
        Me.Label3.TabIndex = 13
        Me.Label3.Text = "Nombre de Fantasía"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.Color.Transparent
        Me.Label4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label4.Location = New System.Drawing.Point(72, 144)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(152, 23)
        Me.Label4.TabIndex = 14
        Me.Label4.Text = "Nombre del Contribuyente"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label5
        '
        Me.Label5.BackColor = System.Drawing.Color.Transparent
        Me.Label5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label5.Location = New System.Drawing.Point(72, 168)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(152, 23)
        Me.Label5.TabIndex = 15
        Me.Label5.Text = "Descripción"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label6
        '
        Me.Label6.BackColor = System.Drawing.Color.Transparent
        Me.Label6.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label6.Location = New System.Drawing.Point(72, 192)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(152, 23)
        Me.Label6.TabIndex = 16
        Me.Label6.Text = "Dirección"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label7
        '
        Me.Label7.BackColor = System.Drawing.Color.Transparent
        Me.Label7.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label7.Location = New System.Drawing.Point(72, 216)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(152, 23)
        Me.Label7.TabIndex = 17
        Me.Label7.Text = "Teléfono"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label8
        '
        Me.Label8.BackColor = System.Drawing.Color.Transparent
        Me.Label8.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label8.Location = New System.Drawing.Point(72, 240)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(152, 23)
        Me.Label8.TabIndex = 18
        Me.Label8.Text = "E-mail"
        Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label9
        '
        Me.Label9.BackColor = System.Drawing.Color.Transparent
        Me.Label9.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label9.Location = New System.Drawing.Point(72, 264)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(152, 23)
        Me.Label9.TabIndex = 19
        Me.Label9.Text = "Número de Registro Patronal"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label10
        '
        Me.Label10.BackColor = System.Drawing.Color.Transparent
        Me.Label10.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label10.Location = New System.Drawing.Point(72, 288)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(152, 23)
        Me.Label10.TabIndex = 20
        Me.Label10.Text = "Retentor"
        Me.Label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label11
        '
        Me.Label11.BackColor = System.Drawing.Color.Transparent
        Me.Label11.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label11.Location = New System.Drawing.Point(72, 312)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(152, 23)
        Me.Label11.TabIndex = 21
        Me.Label11.Text = "Fecha de Grabación"
        Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'cmdGrabar
        '
        Me.cmdGrabar.BackColor = System.Drawing.Color.Transparent
        Me.cmdGrabar.Location = New System.Drawing.Point(472, 168)
        Me.cmdGrabar.Name = "cmdGrabar"
        Me.cmdGrabar.TabIndex = 22
        Me.cmdGrabar.Text = "&Grabar"
        '
        'cmdNuevo
        '
        Me.cmdNuevo.BackColor = System.Drawing.Color.Transparent
        Me.cmdNuevo.Location = New System.Drawing.Point(472, 120)
        Me.cmdNuevo.Name = "cmdNuevo"
        Me.cmdNuevo.TabIndex = 23
        Me.cmdNuevo.Text = "&Nuevo"
        '
        'cmdModificar
        '
        Me.cmdModificar.BackColor = System.Drawing.Color.Transparent
        Me.cmdModificar.Location = New System.Drawing.Point(472, 144)
        Me.cmdModificar.Name = "cmdModificar"
        Me.cmdModificar.TabIndex = 24
        Me.cmdModificar.Text = "Modificar"
        '
        'ImageList1
        '
        Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit
        Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'cmdPrimero
        '
        Me.cmdPrimero.BackColor = System.Drawing.Color.Transparent
        Me.cmdPrimero.Location = New System.Drawing.Point(552, 120)
        Me.cmdPrimero.Name = "cmdPrimero"
        Me.cmdPrimero.TabIndex = 26
        Me.cmdPrimero.Text = "Primero"
        '
        'cmdAnterior
        '
        Me.cmdAnterior.BackColor = System.Drawing.Color.Transparent
        Me.cmdAnterior.Location = New System.Drawing.Point(552, 144)
        Me.cmdAnterior.Name = "cmdAnterior"
        Me.cmdAnterior.TabIndex = 27
        Me.cmdAnterior.Text = "Anterior"
        '
        'cmdSiguiente
        '
        Me.cmdSiguiente.BackColor = System.Drawing.Color.Transparent
        Me.cmdSiguiente.Location = New System.Drawing.Point(552, 168)
        Me.cmdSiguiente.Name = "cmdSiguiente"
        Me.cmdSiguiente.TabIndex = 28
        Me.cmdSiguiente.Text = "Siguiente"
        '
        'cmdUltimo
        '
        Me.cmdUltimo.BackColor = System.Drawing.Color.Transparent
        Me.cmdUltimo.Location = New System.Drawing.Point(552, 192)
        Me.cmdUltimo.Name = "cmdUltimo"
        Me.cmdUltimo.TabIndex = 29
        Me.cmdUltimo.Text = "Ultimo"
        '
        'cmdBuscar
        '
        Me.cmdBuscar.BackColor = System.Drawing.Color.Transparent
        Me.cmdBuscar.Location = New System.Drawing.Point(552, 216)
        Me.cmdBuscar.Name = "cmdBuscar"
        Me.cmdBuscar.TabIndex = 30
        Me.cmdBuscar.Text = "Buscar"
        '
        'cmdCancelar
        '
        Me.cmdCancelar.BackColor = System.Drawing.Color.Transparent
        Me.cmdCancelar.Location = New System.Drawing.Point(472, 192)
        Me.cmdCancelar.Name = "cmdCancelar"
        Me.cmdCancelar.TabIndex = 31
        Me.cmdCancelar.Text = "Cancelar"
        '
        'cmdEliminar
        '
        Me.cmdEliminar.BackColor = System.Drawing.Color.Transparent
        Me.cmdEliminar.Location = New System.Drawing.Point(472, 216)
        Me.cmdEliminar.Name = "cmdEliminar"
        Me.cmdEliminar.TabIndex = 32
        Me.cmdEliminar.Text = "Eliminar"
        '
        'BottomRightColor
        '
        Me.BottomRightColor.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.BottomRightColor.Color = System.Drawing.Color.PapayaWhip
        Me.BottomRightColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.BottomRightColor.Location = New System.Drawing.Point(680, 416)
        Me.BottomRightColor.Name = "BottomRightColor"
        Me.BottomRightColor.Size = New System.Drawing.Size(16, 16)
        Me.BottomRightColor.TabIndex = 41
        Me.BottomRightColor.Text = "ColorPicker1"
        Me.BottomRightColor.TextDisplayed = False
        '
        'TopLeftColor
        '
        Me.TopLeftColor.Color = System.Drawing.Color.SteelBlue
        Me.TopLeftColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.TopLeftColor.ForeColor = System.Drawing.Color.Cyan
        Me.TopLeftColor.Location = New System.Drawing.Point(0, 0)
        Me.TopLeftColor.Name = "TopLeftColor"
        Me.TopLeftColor.Size = New System.Drawing.Size(16, 16)
        Me.TopLeftColor.TabIndex = 40
        Me.TopLeftColor.Text = "ColorPicker1"
        Me.TopLeftColor.TextDisplayed = False
        '
        'Si
        '
        Me.Si.BackColor = System.Drawing.Color.Transparent
        Me.Si.Location = New System.Drawing.Point(232, 288)
        Me.Si.Name = "Si"
        Me.Si.Size = New System.Drawing.Size(64, 24)
        Me.Si.TabIndex = 42
        Me.Si.Text = "Si"
        '
        'No
        '
        Me.No.BackColor = System.Drawing.Color.Transparent
        Me.No.Location = New System.Drawing.Point(280, 288)
        Me.No.Name = "No"
        Me.No.Size = New System.Drawing.Size(56, 24)
        Me.No.TabIndex = 43
        Me.No.Text = "No"
        '
        'Label12
        '
        Me.Label12.BackColor = System.Drawing.Color.Transparent
        Me.Label12.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label12.Location = New System.Drawing.Point(232, 312)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(152, 23)
        Me.Label12.TabIndex = 44
        Me.Label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'timerFecha
        '
        Me.timerFecha.Interval = 1000
        '
        'Empresa
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(230, Byte), CType(230, Byte), CType(230, Byte))
        Me.ClientSize = New System.Drawing.Size(696, 430)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.No)
        Me.Controls.Add(Me.Si)
        Me.Controls.Add(Me.BottomRightColor)
        Me.Controls.Add(Me.TopLeftColor)
        Me.Controls.Add(Me.cmdEliminar)
        Me.Controls.Add(Me.cmdCancelar)
        Me.Controls.Add(Me.cmdBuscar)
        Me.Controls.Add(Me.cmdUltimo)
        Me.Controls.Add(Me.cmdSiguiente)
        Me.Controls.Add(Me.cmdAnterior)
        Me.Controls.Add(Me.cmdPrimero)
        Me.Controls.Add(Me.cmdModificar)
        Me.Controls.Add(Me.cmdNuevo)
        Me.Controls.Add(Me.cmdGrabar)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox10)
        Me.Controls.Add(Me.TextBox9)
        Me.Controls.Add(Me.TextBox8)
        Me.Controls.Add(Me.TextBox7)
        Me.Controls.Add(Me.TextBox6)
        Me.Controls.Add(Me.TextBox5)
        Me.Controls.Add(Me.TextBox4)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Cursor = System.Windows.Forms.Cursors.Arrow
        Me.ForeColor = System.Drawing.Color.Navy
        Me.Name = "Empresa"
        Me.Text = "Empresa"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Empresa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        No.Checked = True
        Try
            Me.ResizeRedraw = True
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
        End Try
        Call Texto()
        Call Limpiar()
        conectar.Conectar()     'Es para acelerar las conecciones al servidor ya que solo la 1era vez es lento
        Call Probar_carga()
        TextBox1.DataBindings.Add("Text", ds, "Table.CODEMPRESA")
        Call DataSource(DsMover, ds)
        Call cancelar()
    End Sub

#Region " Carga de los indices de la base de datos "
    Public Sub Probar_carga()
        If Cargar = True Then
            ds.Clear()
            ds = SentEmpresa.DsEmpresa()
            Cargar = False
        End If
    End Sub
    Public Sub Siguiente()
        Call Probar_carga()
        DsMover.Clear()
        Me.BindingContext(ds, "Table").Position += 1
        'DsMover = SentEmpresa.DsMover(TextBox1.Text)
        Call DataSource(DsMover, ds)
    End Sub
    Public Sub Anterior()
        Call Probar_carga()
        DsMover.Clear()
        Me.BindingContext(ds, "table").Position -= 1
        'DsMover = SentEmpresa.DsMover(TextBox1.Text)
        Call DataSource(DsMover, ds)
    End Sub
    Public Sub Ultimo()
        Call Probar_carga()
        DsMover.Clear()
        Me.BindingContext(ds, "table").Position = Me.BindingContext(ds, "table").Count - 1
        'DsMover = SentEmpresa.DsMover(TextBox1.Text)
        Call DataSource(DsMover, ds)
    End Sub
    Public Sub Primero()
        Call Probar_carga()
        DsMover.Clear()
        Me.BindingContext(ds, "table").Position = 0
        'DsMover = SentEmpresa.DsMover(TextBox1.Text)
        Call DataSource(DsMover, ds)
    End Sub
    Public Sub Recuperar(ByVal parametro_busqueda As Integer)
        DsMover.Clear()
        TextBox1.Text = parametro_busqueda
        Call DataSource(DsMover, ds)
    End Sub
#End Region

    Private Sub cmdNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNuevo.Click
        cmdNuevo.Enabled = False
        cmdGrabar.Enabled = True
        cmdCancelar.Enabled = True
        cmdModificar.Enabled = False
        cmdPrimero.Enabled = False
        cmdSiguiente.Enabled = False
        cmdUltimo.Enabled = False
        cmdAnterior.Enabled = False
        cmdBuscar.Enabled = False
        cmdEliminar.Enabled = False
        Call Limpiar()
        'TextBox1.Text = max.Maximo("CODEMPRESA", "EMPRESA")
        TextBox3.Focus()
        TextBox1.Text = "####"
        No.Checked = True
        timerFecha.Enabled = True
    End Sub
    Public Sub Texto()
        Label1.Text = "Código"
        Label2.Text = "Usuario de Grabación"
        Label3.Text = "Nombre de Fantasía"
        Label4.Text = "Nombre del Contribuyente"
        Label5.Text = "Descripción de la Empresa"
        Label6.Text = "Dirección"
        Label7.Text = "Teléfono"
        Label8.Text = "Email"
        Label9.Text = "Número de Registro Patronal"
        Label10.Text = "Retentor"
        Label11.Text = "Fecha de Grabación"
        cmdNuevo.Text = "&Nuevo"
        cmdModificar.Text = "&Modificar"
        cmdGrabar.Text = "&Grabar"
        cmdCancelar.Text = "&Cancelar"
        cmdEliminar.Text = "&Eliminar"
        cmdBuscar.Text = "&Buscar"
        cmdPrimero.Text = "&Primero"
        cmdAnterior.Text = "&Anterior"
        cmdSiguiente.Text = "&Siguiente"
        cmdUltimo.Text = "&Ultimo"
    End Sub
    Public Sub Limpiar()
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
    End Sub
    Private Sub cmdGrabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGrabar.Click
        If Si.Checked = True Then
            retentor = 1
        End If
        If No.Checked = True Then
            retentor = 0
        End If
        Grabar.Insertar(1, 1, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text, TextBox8.Text, TextBox9.Text, retentor, fecha.fechahora())
        TextBox1.Text = max.Maximo("CODEMPRESA", "EMPRESA") + 1
        TextBox1.Enabled = True
        TextBox2.Focus()
        timerFecha.Enabled = False
        Cargar = True
        Call cancelar()
    End Sub
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox2.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox3.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox3_KeyPress(ByVal sender As 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 = 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
            TextBox5.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox6.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.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 TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox8.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            TextBox9.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox9_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox9.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            No.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
    Private Sub TextBox10_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox10.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            cmdGrabar.Focus()
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
 
    Private Sub cmdBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBuscar.Click
        Call LimpiarData()
        Me.Enabled = False
        frmBuscar.Show()
        frmBuscar.Cargar(funBuscar.AyudaBuscar("DESEMPRESA", "CODEMPRESA", "EMPRESA", 0))
        Me.Enabled = True
        TextBox1.Text = frmBuscar.DialogResult
    End Sub
    Private Sub cmdSiguiente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSiguiente.Click
        Call Siguiente()
    End Sub

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

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

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

    End Sub

#Region " Asignar DataBindigns "
    Public Sub DataSource(ByRef DsMover As DataSet, ByRef Ds As DataSet)
        DsMover = SentEmpresa.DsMover(TextBox1.Text)
        Call LimpiarData()
        TextBox1.DataBindings.Add("Text", Ds, "Table.CODEMPRESA")
        TextBox2.DataBindings.Add("Text", DsMover, "Table.USUGRA")
        TextBox3.DataBindings.Add("Text", DsMover, "Table.NOMFANTASIA")
        TextBox4.DataBindings.Add("Text", DsMover, "Table.NOMCONTRIBUYENTE")
        TextBox5.DataBindings.Add("Text", DsMover, "Table.DESEMPRESA")
        TextBox6.DataBindings.Add("Text", DsMover, "Table.DIRECCION")
        TextBox7.DataBindings.Add("Text", DsMover, "Table.TELEFONO")
        TextBox8.DataBindings.Add("Text", DsMover, "Table.EMAIL")
        TextBox9.DataBindings.Add("Text", DsMover, "Table.NUMREGPATRONAL")
        TextBox10.DataBindings.Add("Text", DsMover, "Table.RETENTOR")
        Label12.DataBindings.Add("Text", DsMover, "Table.FECGRA")
        Me.Refresh()
    End Sub
    Public Sub LimpiarData()
        TextBox1.DataBindings.Clear()
        TextBox2.DataBindings.Clear()
        TextBox3.DataBindings.Clear()
        TextBox4.DataBindings.Clear()
        TextBox5.DataBindings.Clear()
        TextBox6.DataBindings.Clear()
        TextBox7.DataBindings.Clear()
        TextBox8.DataBindings.Clear()
        TextBox9.DataBindings.Clear()
        TextBox10.DataBindings.Clear()
        Label12.DataBindings.Clear()
    End Sub
#End Region

    Private Sub cmdEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEliminar.Click
        Dim msn As New MensajeSINO
        msn.Mensaje.Text = "Desea Eliminar?"
        msn.Text = "Pregunta"
        msn.ShowDialog()
        If msn.DialogResult = 1 Then
            Eliminar.Eliminar(TextBox1.Text.Trim())
            Call Limpiar()
            Cargar = True
        End If
    End Sub

    Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged
        If Val(TextBox10.Text.Trim) = 1 Then
            Si.Checked = True
            'No.Checked = False
        Else
            No.Checked = True
            'Si.Checked = False
        End If
    End Sub

    Private Sub No_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles No.CheckedChanged
        If No.Checked = True Then
            retentor = False
        End If
    End Sub

    Private Sub Si_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Si.CheckedChanged
        If Si.Checked = True Then
            retentor = True
        End If
    End Sub

    Private Sub timerFecha_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerFecha.Tick
        Label12.Text = Now
    End Sub
    Private Sub cmdCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancelar.Click
        Call cancelar()
        Call Limpiar()
    End Sub


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