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 FCO1020T 
   Caption         =   "Trabajar con ..."
   ClientHeight    =   3450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5775
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Administradoras_T.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3450
   ScaleWidth      =   5775
   StartUpPosition =   2  'CenterScreen
   Begin FPSpread.vaSpread sprMtto 
      Height          =   2355
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   5295
      _Version        =   131077
      _ExtentX        =   9340
      _ExtentY        =   4154
      _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  =   "Administradoras_T.frx":030A
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   0
      Top             =   0
      _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           =   "Administradoras_T.frx":0463
   End
   Begin VB.Label lblTitulo 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Label1"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   120
      Width           =   5295
   End
End
Attribute VB_Name = "FCO1020T"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private objBitacora As New ADAMBitacora.Bitacora
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private Micx As Integer
Private MiX As Integer
Private MiY As Integer
Private MsCodAgr As String
Private MSOrder As String
Private MsSql As String
Private MbRenovar As Boolean

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlalta": Altas
        Case "tlbaja": Bajas
        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 vbKeyF6: Altas
        Case vbKeyF7: Bajas
        Case vbKeyF11: GuardaCambios
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    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
    Me.Icon = LoadPicture(sIconoForma)
    
    'Inicio clase para el llenado de los Spread's
    Set clsSpread = New NSpread
    GAdam.ObtieneColores
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 5895
        MiY = 3855
        Me.Width = MiX
        Me.Height = MiY
    End If
    
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - EPS Conceptos Relacionados"
    AsignaIconos abToolbar, 3, LALTA, LBAJA, LRENUEVA, LGUARDA, LSALIDA
    
    CreaBitacora
    
    MSOrder = ""
    Select Case GsTipo
        Case "EPS"
            MsCodAgr = sRecuperarParamALA(MAdo, 21)
        Case "AFP"
            MsCodAgr = sRecuperarParamALA(MAdo, 22)
        Case "CCF"
            MsCodAgr = sParametroFDT(MAdo, "parafiscal", "COL", 1)
    End Select
    RenuevaDatos
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 clsSpread = Nothing
    Set objBitacora = Nothing
    Set FCO1020T = Nothing
End Sub

Private Sub Form_Resize()
    On Error Resume Next
    If Me.WindowState <> 1 Then
        GAdam.MaximizaControles Me, 1, 2, 5895, 3855, MiX, MiY, False, True, False, -1
    End If
End Sub

Private Sub sprMtto_Change(ByVal Col As Long, ByVal Row As Long)
    objBitacora.mCambia
End Sub

Private Sub Altas()
    GsCodAgr = MsCodAgr
    FCO1020TA.lblTitulo = lblTitulo
    FCO1020TA.Show 1
    RenuevaDatos
End Sub

Private Sub Bajas()
    If sprMtto.VirtualMaxRows <= 0 Then Exit Sub
    objBitacora.mBorra
End Sub

Private Sub ConfiguraSpread()
    With sprMtto
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprMtto
        .ColWidth(1) = 4
        .ColWidth(2) = 38
        .SetText 1, 0, "Cod."
        .SetText 2, 0, "Descripcion"
        ConfiguraSpreadJCL sprMtto
    End With
End Sub

Private Sub CreaBitacora()
   objBitacora.mCreaBitacora sprMtto, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
   objBitacora.p_ConfirmaBaja = True
   objBitacora.mTablaSPInfo 1, "sp_fco_cambio_entidad_conc", "'" & GsCveCia & "'", 1
   objBitacora.mColNoNulls 1
End Sub

Private Sub GuardaCambios()
   If sprMtto.MaxRows = 0 Then Exit Sub
   Screen.MousePointer = vbHourglass
   MbRenovar = objBitacora.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 objBitacora.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
             objBitacora.mVaciaBuffer 'Vacía el Buffer de la Bitácora
       End Select
    Else
        iDeseaGuardar = 1
    End If
End Function

Private Sub RenuevaDatos()
    ConfiguraSpread
    
    MsSql = _
    " SELECT concepto, descripcion FROM conceptos_ns" & _
    " WHERE compania='" & GsCveCia & "' And" & _
    " cond_agr_01='" & MsCodAgr & "' And" & _
    " cond_dato_01_01='" & GsDatoAux & "'"
    
    MAdo.Sql = MsSql & MSOrder
    If Not MAdo.SendSQL Then Exit Sub
    
'    If MAdo.EOF Then
'        MsSql = _
'        " SELECT concepto, descripcion FROM conceptos_ns" & _
'        " WHERE compania='" & GsCveCia & "' And" & _
'        " cond_agr_01='" & MsCodAgr & "'"
        
'        MAdo.Sql = MsSql & MSOrder
'        If Not MAdo.SendSQL Then Exit Sub
'    End If
    
    clsSpread.LlenaSpread 0, sprMtto, MAdo, MAdo.lhDbc, MAdo.lhstmt
    GAdam.AjustaSpread sprMtto, 2
End Sub
