VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Begin VB.Form FCO5015T 
   Caption         =   "Planilla Integrada - Trabajar con..."
   ClientHeight    =   5850
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   11715
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FCO5015T Planilla Integrada Trabajar Con.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5850
   ScaleWidth      =   11715
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame fraWarning 
      Height          =   615
      Left            =   120
      TabIndex        =   0
      Top             =   1080
      Visible         =   0   'False
      Width           =   10095
      Begin VB.Label lblWarning 
         Caption         =   "No se encontró información del archivo.  Debe generar el archivo una vez para poder editar estos valores."
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   960
         TabIndex        =   4
         Top             =   240
         Width           =   9015
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Riesgos Profesionales"
      Height          =   1335
      Index           =   2
      Left            =   120
      TabIndex        =   2
      Top             =   3840
      Width           =   11415
      Begin FPSpread.vaSpread sprRiesgos 
         Bindings        =   "FCO5015T Planilla Integrada Trabajar Con.frx":030A
         Height          =   945
         Left            =   240
         TabIndex        =   5
         Top             =   240
         Width           =   10935
         _Version        =   131077
         _ExtentX        =   19288
         _ExtentY        =   1667
         _StockProps     =   64
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO5015T Planilla Integrada Trabajar Con.frx":0320
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Salud"
      Height          =   3615
      Index           =   1
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   11415
      Begin FPSpread.vaSpread sprSalud 
         Bindings        =   "FCO5015T Planilla Integrada Trabajar Con.frx":0479
         Height          =   3225
         Left            =   240
         TabIndex        =   3
         Top             =   240
         Width           =   10935
         _Version        =   131077
         _ExtentX        =   19288
         _ExtentY        =   5689
         _StockProps     =   64
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO5015T Planilla Integrada Trabajar Con.frx":048F
      End
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   360
      Top             =   5280
      _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           =   "FCO5015T Planilla Integrada Trabajar Con.frx":05E8
   End
End
Attribute VB_Name = "FCO5015T"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private MoBitaSalud As New ADAMBitacora.Bitacora
Private MoBitaRiesgos As New ADAMBitacora.Bitacora
Private Micx As Integer

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

Private Sub abToolbar_PreCustomizeMenu(ByVal Cancel As ActiveBarLibraryCtl.ReturnBool)
    Cancel = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        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
    
    'Inicio clase para el llenado de los Spread's
    GAdam.ObtieneColores
    
    'Tamaño de la forma
    Width = 11835
    Height = 6360
    
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Planilla Integrada - Año: " & GsAño & " Mes: " & GsMes & " Suc." & GsDatoAux & " " & GsTitulo & " Planilla Tipo " & GsTipo
    AsignaIconos abToolbar, 3, LRENUEVA, LGUARDA, LSALIDA
    ToolInicioGrupo abToolbar, 3, True, 1, 2
    
    CreaBitacora
    
    RenuevaDatos
    If sprSalud.MaxRows = 0 Then
        fraWarning.Visible = True
        fraFrame(1).Visible = False
    End If
    
    Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then abToolbar.Bands(1).TrackPopup -1, -1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If iDeseaGuardar = vbCancel Then Cancel = True
    Set MAdo = Nothing
    Set MoBitaSalud = Nothing
    Set FCO5015T = Nothing
End Sub

Private Sub sprRiesgos_Change(ByVal Col As Long, ByVal Row As Long)
    MoBitaRiesgos.mCambia
End Sub

Private Sub sprSalud_Change(ByVal Col As Long, ByVal Row As Long)
    MoBitaSalud.mCambia
End Sub

Private Sub ConfiguraSpread()
    With sprSalud
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprSalud
        .Col = 1: .ColHidden = True
        .Col = 2: .ColHidden = True
        .Col = 3: .ColHidden = True
        .ColWidth(4) = 6
        .ColWidth(5) = 16
        .ColWidth(6) = 8
        .ColWidth(7) = 9
        .ColWidth(8) = 8
        .ColWidth(9) = 9
        .ColWidth(10) = 9
        .ColWidth(11) = 12
        .ColWidth(12) = 12
        .Col = 13: .ColHidden = True
        
        .SetText 1, 0, "Año Oculto"
        .SetText 2, 0, "Mes Oculto"
        .SetText 3, 0, "Suc Oculta"
        .SetText 4, 0, "EPS"
        .SetText 5, 0, "Nombre"
        .SetText 6, 0, "Nro.Aut.IGE"
        .SetText 7, 0, "Vlr.Aut.IGE"
        .SetText 8, 0, "Nro.Aut.LMA"
        .SetText 9, 0, "Vlr.Aut.LMA"
        .SetText 10, 0, "Formulario (SF)"
        .SetText 11, 0, "Sdo.Fav.Aportes"
        .SetText 12, 0, "Sdo.Fav.UPC"
        .SetText 13, 0, "Tipo de Planilla Oculta"
                
        ConfiguraSpreadJCL sprSalud
    End With

    With sprRiesgos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprRiesgos
        .Col = 1: .ColHidden = True
        .Col = 2: .ColHidden = True
        .Col = 3: .ColHidden = True
        .ColWidth(4) = 18
        .ColWidth(5) = 18
        .ColWidth(6) = 18
        .ColWidth(7) = 18
        .ColWidth(8) = 18
        .Col = 9: .ColHidden = True
        
        .SetText 1, 0, "Año Oculto"
        .SetText 2, 0, "Mes Oculto"
        .SetText 3, 0, "Suc Oculta"
        .SetText 4, 0, "Nro.Aut.Incapacidades"
        .SetText 5, 0, "Vlr.Aut.Incapacidades"
        .SetText 6, 0, "Aportes pag. a otros"
        .SetText 7, 0, "Formulario Sdo a Favor"
        .SetText 8, 0, "Valor Saldo a Favor"
        .SetText 9, 0, "Tipo de Planilla Oculta"
                
        ConfiguraSpreadJCL sprRiesgos
    End With
End Sub

Private Sub CreaBitacora()
   MoBitaSalud.mCreaBitacora sprSalud, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
   MoBitaSalud.p_ConfirmaBaja = True
   MoBitaSalud.mTablaSPInfo 2, "sp_fco_upd_tc_salud", "'" & GsCveCia & "'", 1, 2, 3, 13, 4, 6, 7, 8, 9, 10, 11, 12
   MoBitaSalud.mColNoNulls 1

   MoBitaRiesgos.mCreaBitacora sprRiesgos, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
   MoBitaRiesgos.p_ConfirmaBaja = True
   MoBitaRiesgos.mTablaSPInfo 2, "sp_fco_upd_tc_riesgos", "'" & GsCveCia & "'", 1, 2, 3, 9, 4, 5, 6, 7, 8
   MoBitaRiesgos.mColNoNulls 1
End Sub

Private Sub GuardaCambios()
   If sprSalud.MaxRows = 0 Then Exit Sub
   Screen.MousePointer = vbHourglass
   GbRen = MoBitaSalud.mActualizaBD
   GbRen = MoBitaRiesgos.mActualizaBD
   Screen.MousePointer = vbDefault
End Sub

Private Function iDeseaGuardar() As Integer
    ' Descripción : Devuelve el valor de la opción seleccionada en la clsMsgBox
    ' Uso : iDeseaGuardarCambios
    ' Regresa : Un Entero , dependiendo de la respuesta en clsMsgBox
    If MoBitaSalud.pTransActual + MoBitaRiesgos.pTransActual > 0 Then
       iDeseaGuardar = clsMsgbox.Mensaje("¿Desea guardar los cambios?", mSiNoCancelar, mConfirma, GsTitMsg)
       Select Case iDeseaGuardar
          Case vbYes
             GuardaCambios
             If GbRen = False Then iDeseaGuardar = 2
          Case vbNo
             MoBitaSalud.mVaciaBuffer 'Vacía el Buffer de la Bitácora
             MoBitaRiesgos.mVaciaBuffer
       End Select
    Else
        iDeseaGuardar = 1
    End If
End Function

Private Sub RenuevaDatos()
    Dim clsSpread As NSpread
    ConfiguraSpread
    
    'Spread de Salud
    MAdo.Sql = "SELECT anio, mes, sucursal, cod_EPS, nombre_EPS," & _
    " nro_aut_IGE, suma_aut_IGE, nro_aut_LMA, suma_aut_LMA," & _
    " nro_radicacion, saldo_favor_aportes, saldo_favor_UPC, tipo_planilla" & _
    " FROM vw_fco_tc_salud" & _
    " WHERE compania = '" & GsCveCia & "'" & _
    " AND anio = " & GsAño & _
    " AND mes = " & GsMes & _
    " AND sucursal = '" & IIf(GsDatoAux = "", " ", GsDatoAux) & "'" & _
    " AND tipo_planilla = '" & GsTipo & "'"
    
    If Not MAdo.SendSQL Then Exit Sub
    
    Set clsSpread = New NSpread
    clsSpread.LlenaSpread 0, sprSalud, MAdo, MAdo.lhDbc, MAdo.lhstmt
    Set clsSpread = Nothing
    With sprSalud
        .Row = -1
        .Col = 4: .Lock = True
        .Col = 5: .Lock = True
        .Col = 7: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
        .Col = 9: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
        .Col = 11: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
        .Col = 12: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
    End With
    GAdam.AjustaSpread sprSalud, 5

    'Spread de Riesgos
    MAdo.Sql = "SELECT anio, mes, sucursal, nro_aut, incapacidades," & _
    " otros_riesgos, nro_radicacion, saldo_favor, tipo_planilla" & _
    " FROM vw_fco_tc_riesgos" & _
    " WHERE compania = '" & GsCveCia & "'" & _
    " AND anio = " & GsAño & _
    " AND mes = " & GsMes & _
    " AND sucursal = '" & IIf(GsDatoAux = "", " ", GsDatoAux) & "'" & _
    " AND tipo_planilla = '" & GsTipo & "'"
    
    If Not MAdo.SendSQL Then Exit Sub
    
    Set clsSpread = New NSpread
    clsSpread.LlenaSpread 0, sprRiesgos, MAdo, MAdo.lhDbc, MAdo.lhstmt
    Set clsSpread = Nothing
    With sprRiesgos
        .Col = 5: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
        .Col = 6: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
        .Col = 8: .CellType = 2: .TypeFloatDecimalPlaces = 0: .TypeFloatMax = 999999999: .TypeFloatMin = 0: .TypeFloatSeparator = True
    End With
    GAdam.AjustaSpread sprRiesgos, 6
End Sub


