VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Begin VB.Form FCO2005T 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Aportantes Fuera de Nómina, Datos para Planilla de Activos"
   ClientHeight    =   4470
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6510
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FCO2005T Aportantes Fuera Datos Adi.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4470
   ScaleWidth      =   6510
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame fraFrame 
      Caption         =   "Datos para la planilla integrada"
      Height          =   2775
      Index           =   1
      Left            =   120
      TabIndex        =   9
      Top             =   960
      Width           =   6255
      Begin VB.ComboBox cboTipoCot 
         Height          =   330
         ItemData        =   "FCO2005T Aportantes Fuera Datos Adi.frx":030A
         Left            =   2040
         List            =   "FCO2005T Aportantes Fuera Datos Adi.frx":031D
         TabIndex        =   1
         Top             =   240
         Width           =   3375
      End
      Begin VB.CheckBox chkExtranjero 
         Caption         =   "Extranjero no obligado a cotizar a pensiones"
         Height          =   210
         Left            =   600
         TabIndex        =   6
         Top             =   1920
         Width           =   3735
      End
      Begin VB.CheckBox chkResideExt 
         Caption         =   "Colombiano residente en el exterior"
         Height          =   210
         Left            =   600
         TabIndex        =   7
         Top             =   2400
         Width           =   3735
      End
      Begin VB.ComboBox cboDpto 
         Height          =   330
         Left            =   2040
         TabIndex        =   3
         Top             =   840
         Width           =   3375
      End
      Begin VB.ComboBox cboMpio 
         Height          =   330
         Left            =   2040
         TabIndex        =   5
         Top             =   1320
         Width           =   3375
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "&Tipo de Cotizante: "
         Height          =   210
         Index           =   10
         Left            =   600
         TabIndex        =   0
         Top             =   240
         Width           =   1335
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "&Departamento:"
         Height          =   210
         Index           =   0
         Left            =   600
         TabIndex        =   2
         Top             =   840
         Width           =   1050
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "&Municipio:"
         Height          =   210
         Index           =   1
         Left            =   600
         TabIndex        =   4
         Top             =   1320
         Width           =   705
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Aportante por fuera de Nómina"
      Height          =   735
      Index           =   0
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   6255
      Begin VB.Label lblNombre 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Name"
         Height          =   210
         Left            =   360
         TabIndex        =   10
         Top             =   360
         Width           =   405
      End
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   120
      Top             =   3840
      _ExtentX        =   847
      _ExtentY        =   847
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Bands           =   "FCO2005T Aportantes Fuera Datos Adi.frx":03C7
   End
End
Attribute VB_Name = "FCO2005T"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private MiCx As Integer 'Conexión
Private MsDptos() As String
Private MsMunis() As String
Private MsMpios() As String
Private miTotalMunis As Integer

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlsel"
            GuardaCambios
        Case "tlsalida"
            Unload Me
    End Select
End Sub

Private Sub cboDpto_Click()
    Dim i As Integer
    If cboDpto.ListIndex = -1 Then Exit Sub
    
    GbHuboCambios = True
    'Renovar combo de Municipios
    cboMpio.Clear
    Erase MsMpios
    For i = 1 To miTotalMunis
        If MsMunis(3, i) = MsDptos(cboDpto.ListIndex) Then
            cboMpio.AddItem MsMunis(2, i)
            ReDim Preserve MsMpios(cboMpio.NewIndex)
            MsMpios(cboMpio.NewIndex) = MsMunis(1, i)
        Else
            If cboMpio.ListCount > 0 Then i = miTotalMunis + 1
        End If
    Next i
End Sub

Private Sub cboDpto_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        Autocompletar cboDpto, KeyAscii
    End If
End Sub

Private Sub cboMpio_Click()
    GbHuboCambios = True
End Sub

Private Sub cboMpio_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        Autocompletar cboMpio, KeyAscii
    End If
End Sub

Private Sub cboTipoCot_Click()
    GbHuboCambios = True
End Sub

Private Sub cboTipoCot_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendEnter
End Sub

Private Sub chkExtranjero_Click()
    GbHuboCambios = True
End Sub

Private Sub chkExtranjero_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendEnter
End Sub

Private Sub chkResideExt_Click()
    GbHuboCambios = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF11: GuardaCambios
    End Select
End Sub

Private Sub Form_Load()
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    MiCx = Gven(Val(Me.Tag)).icx
    Set MAdo = Gtc(MiCx).Ado

    Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
    Screen.MousePointer = vbDefault
    
    Me.Width = 6600
    Me.Height = 4950

    Caption = GsDsn & " / " & GsCveCia & " - Más Datos Planilla Integrada"
    
    AsignaIconos abToolbar, 3, LSEL, LSALIDA
    ToolInicioGrupo abToolbar, 3, True, 1
    
    LlenarCombos
    
    lblNombre = GsDatoAux
    
    If Val(GsOtrosDatos(1)) <= 1 Then cboTipoCot.ListIndex = 0
    If Val(GsOtrosDatos(1)) = 12 Then cboTipoCot.ListIndex = 1
    If Val(GsOtrosDatos(1)) = 17 Then cboTipoCot.ListIndex = 2
    If Val(GsOtrosDatos(1)) = 19 Then cboTipoCot.ListIndex = 3
    If Val(GsOtrosDatos(1)) = 20 Then cboTipoCot.ListIndex = 4
    chkExtranjero.Value = IIf(GsOtrosDatos(2) = "S", vbChecked, vbUnchecked)
    chkResideExt.Value = IIf(GsOtrosDatos(3) = "S", vbChecked, vbUnchecked)
    BuscarDpto
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set MAdo = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
    Set FCO2005T = Nothing
End Sub

Private Sub GuardaCambios()
    Dim sTCo As String
    Dim sDpto As String
    Dim sMuni As String
    
    sTCo = "1"
    sDpto = ""
    sMuni = ""
    
    If cboTipoCot.ListIndex > -1 Then sTCo = Left(cboTipoCot.Text, 2)
    GsOtrosDatos(1) = sTCo
    GsOtrosDatos(2) = IIf(chkExtranjero.Value = vbChecked, "S", "N")
    GsOtrosDatos(3) = IIf(chkResideExt.Value = vbChecked, "S", "N")
    If cboDpto.ListIndex > -1 Then GsOtrosDatos(4) = MsDptos(cboDpto.ListIndex)
    If cboMpio.ListIndex > -1 Then GsOtrosDatos(5) = MsMpios(cboMpio.ListIndex)
    Unload Me
End Sub

Private Sub BuscarDpto()
    Dim i As Integer
    Dim bEncontrado As Boolean
    
    i = 0
    bEncontrado = False
    Do Until i = cboDpto.ListCount Or bEncontrado
        If MsDptos(i) = GsOtrosDatos(4) Then
            bEncontrado = True
        Else
            i = i + 1
        End If
    Loop
    
    If bEncontrado Then
        cboDpto.ListIndex = i
    Else
        cboDpto.ListIndex = -1
    End If
    
    'Logica para deducir el municipio
    i = 0
    bEncontrado = False
    Do Until i = cboMpio.ListCount Or bEncontrado
        If MsMpios(i) = GsOtrosDatos(5) Then
            bEncontrado = True
        Else
            i = i + 1
        End If
    Loop

    If bEncontrado Then
        cboMpio.ListIndex = i
    Else
        cboMpio.ListIndex = -1
    End If
    GbHuboCambios = False
End Sub

Private Sub LlenarCombos()
    Dim i As Integer
    
    'Departamento y Municipios
    If cboDpto.ListCount = 0 Then
        MAdo.Sql = "SELECT codigo, nombre FROM fco_departamentos ORDER BY 2"
        MAdo.SendSQL
        Do Until MAdo.EOF
            cboDpto.AddItem MAdo.GetField(2)
            ReDim Preserve MsDptos(cboDpto.NewIndex)
            MsDptos(cboDpto.NewIndex) = MAdo.GetField(1)
            MAdo.Mnext
        Loop
        
        MAdo.Sql = "SELECT codigo, nombre, cod_dpto FROM fco_ciudades ORDER BY 3, 2"
        MAdo.SendSQL
        i = 1
        Do Until MAdo.EOF
            ReDim Preserve MsMunis(1 To 3, i)
            MsMunis(1, i) = MAdo.GetField(1)
            MsMunis(2, i) = MAdo.GetField(2)
            MsMunis(3, i) = MAdo.GetField(3)
            MAdo.Mnext
            i = i + 1
        Loop
        miTotalMunis = i - 1
    End If
End Sub
