VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Begin VB.Form frmFiltroAgr 
   Caption         =   "Filtro por Agrupación"
   ClientHeight    =   2115
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4140
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FiltroAgr.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   2115
   ScaleWidth      =   4140
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtDato 
      Height          =   330
      Left            =   1950
      TabIndex        =   1
      Top             =   945
      Width           =   1095
   End
   Begin VB.ComboBox cboOper 
      Height          =   330
      ItemData        =   "FiltroAgr.frx":030A
      Left            =   1200
      List            =   "FiltroAgr.frx":0314
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   945
      Width           =   645
   End
   Begin VB.TextBox txtAgr 
      Height          =   345
      Left            =   1965
      MaxLength       =   10
      TabIndex        =   0
      Top             =   360
      Width           =   1095
   End
   Begin VB.Image imgListaDato 
      Height          =   480
      Left            =   3225
      Picture         =   "FiltroAgr.frx":031F
      Top             =   945
      Width           =   480
   End
   Begin VB.Image imgListaAgr 
      Height          =   480
      Left            =   3210
      Picture         =   "FiltroAgr.frx":0629
      Top             =   360
      Width           =   480
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   195
      Top             =   1245
      _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           =   "FiltroAgr.frx":0933
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Dato:"
      Height          =   210
      Index           =   1
      Left            =   705
      TabIndex        =   3
      Top             =   960
      Width           =   375
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Agrupación:"
      Height          =   210
      Index           =   0
      Left            =   700
      TabIndex        =   2
      Top             =   375
      Width           =   885
   End
End
Attribute VB_Name = "frmFiltroAgr"
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 Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlsel"
            Seleccionar
        Case "tlsalida"
            GsFiltroAgr = ""
            GsFiltroTit = ""
            Unload Me
    End Select
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF4
            If LCase(ActiveControl.Name) = "txtagr" Then
                imgListaAgr_Click
            ElseIf LCase(ActiveControl.Name) = "txtdato" Then
                imgListaDato_Click
            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 = 4260
        MiY = 2520
        Me.Width = MiX
        Me.Height = MiY
    End If

    Caption = GsDsn & " / " & GsCveCia & " - Filtro por Agrupación"
    AsignaIconos abToolbar, 3, LSEL, LSALIDA
    cboOper.ListIndex = 0
    Screen.MousePointer = vbDefault
    txtAgr = GsAgr
    txtDato = GsDato
    Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
End Sub

Private Sub Seleccionar()
    Dim sDato As String
    
    GsAgr = txtAgr
    GsDato = txtDato
    If Trim(txtAgr) = "" Then
        GsFiltroAgr = ""
        GsFiltroTit = ""
    Else
        sDato = ""
        txtDato = Trim(txtDato)
        If cboOper.ListIndex = 0 Then
            sDato = " AND dato = " & IIf(Left(txtDato, 1) = "'", txtDato, "'" & txtDato & "'")
        Else
            sDato = " AND dato in (" & txtDato & ")"
        End If
        GsFiltroAgr = " AND COD_TRAB IN (SELECT trabajador FROM rel_trab_agr " & _
        " WHERE compania = '" & GsCveCia & "' AND agrupacion = '" & txtAgr & "'" & _
        sDato & ")"
        GsFiltroTit = "Filtrando Agr. " & Trim(txtAgr) & IIf(Trim(txtDato) = "", "", " Dato " & IIf(Left(txtDato, 1) = "'", txtDato, "'" & txtDato & "'"))
    End If
    Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set Mado = Nothing
    Gtc(Micx).ihijas = Gtc(Micx).ihijas - 1
    Set frmFiltroAgr = Nothing

End Sub

Private Sub imgListaAgr_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT agrupacion, descripcion FROM agrupaciones_trab WHERE tipo_agrupacion = 1"
    GsParamIN(1) = "agrupacion"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Agr."
    GsParamIN(4) = "Descripción"
    GsParamIN(5) = "Agrupaciones"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtAgr = GsParamOUT(0)
    End If
End Sub

Private Sub imgListaDato_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT dato, descripcion FROM datos_agr_trab WHERE agrupacion = '" & txtAgr & "'"
    GsParamIN(1) = "dato"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Dato"
    GsParamIN(4) = "Descripción"
    GsParamIN(5) = "Datos de la Agrupación " & txtAgr
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        If cboOper.ListIndex = 0 Then
            txtDato = "'" & Trim(GsParamOUT(0)) & "'"
        Else
            txtDato = txtDato & IIf(Trim(txtDato) = "", "", ",") & "'" & Trim(GsParamOUT(0)) & "'"
        End If
    End If
End Sub

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

Private Sub txtDato_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        Seleccionar
    End If
End Sub
