VERSION 5.00
Begin VB.Form Importar 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Importacion de datos"
   ClientHeight    =   6450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11565
   Icon            =   "Importar.frx":0000
   LinkTopic       =   "Form2"
   ScaleHeight     =   6450
   ScaleWidth      =   11565
   StartUpPosition =   2  'CenterScreen
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access 2000;"
      DatabaseName    =   ""
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   6240
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "Empleados"
      Top             =   6720
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H00C0FFC0&
      BeginProperty Font 
         Name            =   "Courier"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   5535
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Text            =   "Importar.frx":11570
      Top             =   0
      Width           =   11535
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Click Aqui para importar -->"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   7920
      TabIndex        =   2
      Top             =   5880
      Width           =   2415
   End
   Begin VB.Image Image1 
      Height          =   735
      Left            =   10560
      Picture         =   "Importar.frx":11576
      Stretch         =   -1  'True
      ToolTipText     =   "Importar datos"
      Top             =   5640
      Width           =   855
   End
   Begin VB.Shape Shape1 
      Height          =   735
      Left            =   120
      Top             =   5640
      Width           =   5895
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00800000&
      Caption         =   "Recuerde que el boton IMPORTAR realizara un borrado de la base de datos antes de realizar el proceso. "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   735
      Left            =   120
      TabIndex        =   1
      Top             =   5640
      Width           =   5895
   End
End
Attribute VB_Name = "Importar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim emple(1000) As String
Dim ii As Integer
Dim comas(9) As String



Private Sub Command1_Click()

End Sub

Private Sub Form_Load()
Data1.DatabaseName = App.Path + "\boleta.mdb"

Text1 = ""
linea = ""
ii = 0
renglon = ""

Open App.Path + "\importar.txt" For Input As #1
    While Not EOF(1)
        Line Input #1, linea
        renglon = renglon + linea + Chr(13) + Chr(10)
        emple(ii) = linea
        ii = ii + 1
    Wend
Close #1

ii = ii - 1
Text1 = renglon
End Sub

Private Sub Image1_Click()
    'Recorro los empleados del txt
    For u = 0 To ii
    ' me fijo donde estan los ;
        y = 0
        For t = 1 To Len(Trim(emple(u)))
            If Mid(emple(u), t, 1) = ";" Then
                comas(y) = t
                y = y + 1
            End If
        
        Next t
        'Paso el empleado a la base de datos
        elelcuil = Mid(Trim(emple(u)), 1, comas(0) - 1)
        With Data1.Recordset
            If .RecordCount > 0 Then
            .FindFirst "cuil='" & elelcuil & "'"
            
            If .NoMatch Then
            
            'Si la base de datos esta en cero lo agrego
            .AddNew
                !cuil = Mid(Trim(emple(u)), 1, comas(0) - 1)
                !empresa = Em.Label8.Caption
                !cuit = Em.Label7.Caption
                !apellidoynombre = Mid(Trim(emple(u)), comas(0) + 1, comas(1) - comas(0) - 1)
                !categoria = Mid(Trim(emple(u)), comas(1) + 1, comas(2) - comas(1) - 1)
                !sueldo = Val(Mid(Trim(emple(u)), comas(2) + 1, comas(3) - comas(2) - 1))
                !aporte2 = Val(Mid(Trim(emple(u)), comas(3) + 1, comas(4) - comas(3) - 1))
                !aporte25 = Val(Mid(Trim(emple(u)), comas(4) + 1, comas(5) - comas(4) - 1))
                !acuerdos = Val(Mid(Trim(emple(u)), comas(5) + 1, comas(6) - comas(5) - 1))
                !fechaalta = Mid(Trim(emple(u)), comas(6) + 1, comas(7) - comas(6) - 1)
                !total = Val(Mid(Trim(emple(u)), comas(7) + 1, comas(8) - comas(7) - 1))
                !fechabaja = Mid(Trim(emple(u)), comas(8) + 1, comas(9) - comas(8) - 1)
                !afiliado = Val(Mid(Trim(emple(u)), comas(9) + 1))
                
            .Update
            Else
            .Edit
                 !categoria = Mid(Trim(emple(u)), comas(1) + 1, comas(2) - comas(1) - 1)
                !sueldo = Val(Mid(Trim(emple(u)), comas(2) + 1, comas(3) - comas(2) - 1))
                !aporte2 = Val(Mid(Trim(emple(u)), comas(3) + 1, comas(4) - comas(3) - 1))
                !aporte25 = Val(Mid(Trim(emple(u)), comas(4) + 1, comas(5) - comas(4) - 1))
                !acuerdos = Val(Mid(Trim(emple(u)), comas(5) + 1, comas(6) - comas(5) - 1))
                !fechaalta = Mid(Trim(emple(u)), comas(6) + 1, comas(7) - comas(6) - 1)
                !total = Val(Mid(Trim(emple(u)), comas(7) + 1, comas(8) - comas(7) - 1))
                !fechabaja = Mid(Trim(emple(u)), comas(8) + 1, comas(9) - comas(8) - 1)
                !afiliado = Val(Mid(Trim(emple(u)), comas(9) + 1))
           
            
            
            .Update
            End If
            
            Else
            .AddNew
                !cuil = Mid(Trim(emple(u)), 1, comas(0) - 1)
                !empresa = Em.Label8.Caption
                !cuit = Em.Label7.Caption
                !apellidoynombre = Mid(Trim(emple(u)), comas(0) + 1, comas(1) - comas(0) - 1)
                !categoria = Mid(Trim(emple(u)), comas(1) + 1, comas(2) - comas(1) - 1)
                !sueldo = Val(Mid(Trim(emple(u)), comas(2) + 1, comas(3) - comas(2) - 1))
                !aporte2 = Val(Mid(Trim(emple(u)), comas(3) + 1, comas(4) - comas(3) - 1))
                !aporte25 = Val(Mid(Trim(emple(u)), comas(4) + 1, comas(5) - comas(4) - 1))
                !acuerdos = Val(Mid(Trim(emple(u)), comas(5) + 1, comas(6) - comas(5) - 1))
                !fechaalta = Mid(Trim(emple(u)), comas(6) + 1, comas(7) - comas(6) - 1)
                !total = Val(Mid(Trim(emple(u)), comas(7) + 1, comas(8) - comas(7) - 1))
                !fechabaja = Mid(Trim(emple(u)), comas(8) + 1, comas(9) - comas(8) - 1)
                !afiliado = Val(Mid(Trim(emple(u)), comas(9) + 1))
                
            .Update
            
            
            
            End If
            
        End With
        Em.Data1.Refresh
        
        
    Next u
End Sub
