VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form FCO1050A 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Alta Reportes ALA"
   ClientHeight    =   5085
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6150
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Definicion de reportes ala A.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5085
   ScaleWidth      =   6150
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame fraTipoReporte 
      Caption         =   "Tipo de Reporte"
      Height          =   1560
      Left            =   225
      TabIndex        =   4
      Top             =   825
      Width           =   5685
      Begin VB.CheckBox chkEPS 
         Caption         =   "Salud"
         Height          =   255
         Left            =   300
         TabIndex        =   5
         Top             =   270
         Width           =   1455
      End
      Begin VB.CheckBox chkFPO 
         Caption         =   "Pensión"
         Height          =   255
         Left            =   300
         TabIndex        =   6
         Top             =   630
         Width           =   1935
      End
      Begin VB.CheckBox chkSIGA 
         Caption         =   "Integrado (SIGA)"
         Enabled         =   0   'False
         Height          =   255
         Left            =   3345
         TabIndex        =   9
         Top             =   630
         Width           =   1695
      End
      Begin VB.CheckBox chkSUC 
         Caption         =   "Por &Sucursal"
         Height          =   255
         Left            =   300
         TabIndex        =   10
         Top             =   1110
         Width           =   1695
      End
      Begin VB.CheckBox chkARP 
         Caption         =   "Riesgos Profesionales"
         Height          =   255
         Left            =   2460
         TabIndex        =   7
         Top             =   270
         Width           =   2535
      End
      Begin VB.CheckBox chkISS 
         Caption         =   "I.S.S."
         Height          =   255
         Left            =   2460
         TabIndex        =   8
         Top             =   630
         Width           =   795
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Genera"
      Height          =   2100
      Left            =   240
      TabIndex        =   11
      Top             =   2400
      Width           =   5670
      Begin VB.Frame fraOrden 
         Caption         =   "Orden Reporte"
         Enabled         =   0   'False
         Height          =   660
         Left            =   1005
         TabIndex        =   18
         Top             =   1305
         Width           =   2805
         Begin VB.OptionButton optAlf 
            Caption         =   "Alfabético"
            Height          =   240
            Left            =   150
            TabIndex        =   20
            Top             =   285
            Value           =   -1  'True
            Width           =   1030
         End
         Begin VB.OptionButton optNum 
            Caption         =   "Numérico"
            Height          =   240
            Left            =   1425
            TabIndex        =   19
            Top             =   285
            Width           =   1030
         End
      End
      Begin VB.TextBox txtRuta 
         BackColor       =   &H8000000F&
         Enabled         =   0   'False
         Height          =   285
         Left            =   1005
         TabIndex        =   15
         Top             =   555
         Width           =   4035
      End
      Begin VB.CheckBox chkMM 
         Caption         =   "Medio Magnético"
         Height          =   255
         Left            =   2010
         TabIndex        =   13
         Top             =   225
         Width           =   1695
      End
      Begin VB.TextBox txtRutaMM 
         BackColor       =   &H8000000F&
         Enabled         =   0   'False
         Height          =   315
         Left            =   1005
         TabIndex        =   17
         Top             =   915
         Width           =   4035
      End
      Begin VB.CheckBox chkRep 
         Caption         =   "Reporte"
         Height          =   255
         Left            =   270
         TabIndex        =   12
         Top             =   240
         Width           =   1650
      End
      Begin VB.Image imgListaRutMM 
         Enabled         =   0   'False
         Height          =   375
         Index           =   1
         Left            =   5115
         Top             =   900
         Width           =   405
      End
      Begin VB.Image imgListaRut 
         Enabled         =   0   'False
         Height          =   375
         Index           =   1
         Left            =   5115
         Top             =   465
         Width           =   405
      End
      Begin VB.Image imgListaRutMM 
         Enabled         =   0   'False
         Height          =   375
         Index           =   0
         Left            =   5115
         Top             =   900
         Width           =   405
      End
      Begin VB.Image imgListaRut 
         Enabled         =   0   'False
         Height          =   375
         Index           =   0
         Left            =   5115
         Top             =   465
         Width           =   405
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "R&uta"
         Height          =   210
         Index           =   2
         Left            =   165
         TabIndex        =   14
         Top             =   555
         Width           =   330
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Ruta &salida"
         Height          =   210
         Index           =   3
         Left            =   135
         TabIndex        =   16
         Top             =   915
         Width           =   795
      End
   End
   Begin VB.TextBox txtNombre 
      Height          =   285
      Left            =   930
      MaxLength       =   100
      TabIndex        =   3
      Top             =   435
      Width           =   4965
   End
   Begin VB.TextBox txtCod 
      Height          =   285
      Left            =   930
      MaxLength       =   10
      TabIndex        =   1
      Top             =   75
      Width           =   1170
   End
   Begin MSComDlg.CommonDialog dlgRuta 
      Left            =   5430
      Top             =   -15
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   4905
      Top             =   -15
      _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           =   "Definicion de reportes ala A.frx":030A
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Nombre"
      Height          =   210
      Index           =   1
      Left            =   240
      TabIndex        =   2
      Top             =   435
      Width           =   555
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Codigo"
      Height          =   210
      Index           =   0
      Left            =   240
      TabIndex        =   0
      Top             =   75
      Width           =   495
   End
End
Attribute VB_Name = "FCO1050A"
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 MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma

Private MBCambio As Boolean
Private MbFocoForm  As Boolean

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

Private Sub chkARP_Click()
If Me.chkARP.Value = 1 Then
  Me.chkEPS.Value = 0
  Me.chkFPO.Value = 0
  Me.chkISS.Value = 0
  Me.chkSIGA.Value = 0
  MBCambio = True
End If
End Sub

Private Sub chkEPS_Click()
If Me.chkEPS.Value = 1 Then
    Me.chkFPO.Value = 0
    Me.chkARP.Value = 0
    Me.chkISS.Value = 0
    Me.chkSIGA.Value = 0
    MBCambio = True
End If

End Sub

Private Sub chkFPO_Click()
If Me.chkFPO.Value = 1 Then
  Me.chkEPS.Value = 0
  Me.chkARP.Value = 0
  Me.chkISS.Value = 0
  Me.chkSIGA.Value = 0
  MBCambio = True
End If
End Sub

Private Sub chkISS_Click()
    chkSIGA.Enabled = IIf(chkISS.Value = vbChecked, True, False)
    If Me.chkISS.Value = 1 Then
       Me.chkEPS.Value = 0
       Me.chkFPO.Value = 0
       Me.chkARP.Value = 0
       MBCambio = True
    End If
End Sub

Private Sub chkMM_Click()
    txtRutaMM.Text = ""
    txtRutaMM.Enabled = (chkMM.Value = vbChecked)
    txtRutaMM.BackColor = IIf(txtRutaMM.Enabled, vbWindowBackground, vbButtonFace)
    imgListaRutMM(0).Enabled = txtRutaMM.Enabled
    imgListaRutMM(1).Enabled = txtRutaMM.Enabled
    MBCambio = True
    If chkMM.Value = 1 Then chkRep.Value = 0
End Sub

Private Sub chkRep_Click()
    txtRuta.Text = ""
    txtRuta.Enabled = (chkRep.Value = vbChecked)
    fraOrden.Enabled = (chkRep.Value = vbChecked)
    txtRuta.BackColor = IIf(txtRuta.Enabled, vbWindowBackground, vbButtonFace)
    imgListaRut(0).Enabled = txtRuta.Enabled
    imgListaRut(1).Enabled = txtRuta.Enabled
    MBCambio = True
    If chkRep.Value = 1 Then chkMM.Value = 0
End Sub

Private Sub chkSIGA_Click()
If Me.chkSIGA.Value = 1 Then
  Me.chkEPS.Value = 0
  Me.chkFPO.Value = 0
  Me.chkARP.Value = 0
  MBCambio = True
End If
End Sub

Private Sub chkSUC_Click()
  MBCambio = 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_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF4
            If LCase(ActiveControl.Name) = "txtruta" Then
                imgListaRut_Click 0
            ElseIf LCase(ActiveControl.Name) = "txtrutamm" Then
                imgListaRutMM_Click 0
            End If
    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)
    
    If Not MDIChild Then
        WindowState = 0
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        Screen.MousePointer = vbDefault
    End If
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 6240
        MiY = 5460
        Me.Width = MiX
        Me.Height = MiY
    End If
    
    If GsLlave <> "A" Then
        RecuperarDatos
    End If
        
    AsignaIconos abToolbar, 3, LGUARDA, LSALIDA
    imgListaRut(0).Picture = LoadPicture(App.Path & "\images\F4a2.ico")
    imgListaRut(1).Picture = LoadPicture(App.Path & "\images\F4a1.ico")
    imgListaRutMM(0).Picture = LoadPicture(App.Path & "\images\F4a2.ico")
    imgListaRutMM(1).Picture = LoadPicture(App.Path & "\images\F4a1.ico")
    
    MbFocoForm = True
    MBCambio = False
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Not MbFocoForm Then
        imgListaRut(0).ZOrder
        imgListaRutMM(0).ZOrder
    End If
    MbFocoForm = True

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If MBCambio Then
        If clsMsgbox.Mensaje("¿Desea guardar los cambios?", mSiNoCancelar, mConfirma, GsTitMsg) = vbYes Then
            GuardaCambios
        End If
    End If
    Set MAdo = Nothing
    Set FCO1050A = Nothing
End Sub

Private Function bValidarDatos() As Boolean
    Dim sMensaje As String
    
    bValidarDatos = True
    If Trim(txtCod) = "" Then bValidarDatos = False: sMensaje = "el Codigo"
    If bValidarDatos Then If Trim(txtNombre) = "" Then bValidarDatos = False: sMensaje = "el Nombre"
    
    If Not bValidarDatos Then clsMsgbox.Mensaje "Antes de guardar debe definir " & sMensaje, mAceptar, mAdvierte, GsTitMsg
End Function

Private Sub GuardaCambios()
Dim sOrden As String
    On Error GoTo AclararError
    
    Screen.MousePointer = vbHourglass
    
    sOrden = "NULL"
    If Me.chkRep.Value = 1 Then
        If Len(Trim(Me.txtRuta)) = 0 Then
            clsMsgbox.Mensaje "No ha definido la ruta para el reporte", mAceptar, mAdvierte, GsTitMsg
            Exit Sub
        End If
        
        If Me.optAlf Then sOrden = "'A'"
        If Me.optNum Then sOrden = "'N'"
    End If
            
    MAdo.Sql = _
    "sp_fco_alta_reportes_ala " & _
    "'" & Trim(txtCod) & "'," & _
    "'" & Trim(txtNombre) & "'," & _
    IIf(chkEPS.Value = vbChecked, "1", "0") & "," & _
    IIf(chkFPO.Value = vbChecked, "1", "0") & "," & _
    IIf(chkSIGA.Value = vbChecked, "1", "0") & "," & _
    IIf(chkSUC.Value = vbChecked, "1", "0") & "," & _
    IIf(chkARP.Value = vbChecked, "1", "0") & "," & _
    IIf(chkISS.Value = vbChecked, "1", "0") & "," & _
    IIf(chkRep.Value = vbChecked, "'1'", "'0'") & "," & _
    IIf(chkMM.Value = vbChecked, "'1'", "'0'") & "," & _
    "'" & IIf(Mid(UCase(GsDsn), 1, 3) = "ORA", Replace(txtRuta, "\", "/"), txtRuta) & "'," & _
    "'" & IIf(Mid(UCase(GsDsn), 1, 3) = "ORA", Replace(txtRutaMM, "\", "/"), txtRutaMM) & "'," & _
    sOrden
    MAdo.ExecSQL
            
    MBCambio = False
    Screen.MousePointer = vbDefault
    Unload Me
    Exit Sub

AclararError:
    If Err > 0 Then
        clsMsgbox.Mensaje Err & Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub txtCod_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If
End Sub

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

Private Sub imgListaRut_Click(Index As Integer)
    On Error GoTo Salir
    dlgRuta.FileName = "*.rpt"
    dlgRuta.Filter = "Reportes (*.rpt)|*.rpt"
    dlgRuta.CancelError = True
    dlgRuta.ShowOpen
    txtRuta = dlgRuta.FileName
    MBCambio = True
Salir:
End Sub

Private Sub imgListaRut_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    imgListaRut(1).ZOrder
    MbFocoForm = False
End Sub

Private Sub imgListaRutMM_Click(Index As Integer)
    GsDatoAux = ""
    frmCarpeta.Show 1
    If GsDatoAux <> "" Then
        txtRutaMM = GsDatoAux
        MBCambio = True
    End If
End Sub

Private Sub imgListaRutMM_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    imgListaRutMM(1).ZOrder
    MbFocoForm = False
End Sub

Private Sub RecuperarDatos()

MAdo.Sql = " SELECT nombre, maneja_EPS, maneja_FPO, ISS_Integrado, maneja_SUC," & _
          " maneja_ARP, maneja_ISS, maneja_rep, maneja_mm, ruta_rep, ruta_mm, orden" & _
          " FROM fco_reportes_ala" & _
          " WHERE codigo = '" & GsLlave & "'"

MAdo.SendSQL
    
If MAdo.EOF Then
    clsMsgbox.Mensaje "Codigo no existe", mAceptar, mAdvierte, GsTitMsg
Else
    txtCod = GsLlave
    txtNombre = "" & MAdo.GetField(1)
    chkEPS = IIf(MAdo.GetFieldInt(2) = 1, vbChecked, vbUnchecked)
    chkFPO = IIf(MAdo.GetFieldInt(3) = 1, vbChecked, vbUnchecked)
    chkSIGA = IIf(MAdo.GetFieldInt(4) = 1, vbChecked, vbUnchecked)
    chkSUC = IIf(MAdo.GetFieldInt(5) = 1, vbChecked, vbUnchecked)
    chkARP = IIf(MAdo.GetFieldInt(6) = 1, vbChecked, vbUnchecked)
    chkISS = IIf(MAdo.GetFieldInt(7) = 1, vbChecked, vbUnchecked)
    Me.chkRep = IIf(Val("" & MAdo.GetField(8)) = 1, vbChecked, vbUnchecked)
    Me.chkMM = IIf(Val("" & MAdo.GetField(9)) = 1, vbChecked, vbUnchecked)
    txtRuta = "" & MAdo.GetField(10)
    txtRutaMM = "" & MAdo.GetField(11)
    If Trim(txtRutaMM) = "" Then txtRutaMM.BackColor = vbButtonFace
    If Trim(txtRuta) = "" Then txtRuta.BackColor = vbButtonFace
    txtCod.Locked = True
    
    If MAdo.GetField(12) = "A" Then Me.optAlf.Value = True
    If MAdo.GetField(12) = "N" Then Me.optNum.Value = True
    
End If
        
End Sub


