VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FBusquedaCambios 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Búsqueda de Registros de Tipo de Cambios"
   ClientHeight    =   5985
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8520
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5985
   ScaleWidth      =   8520
   StartUpPosition =   3  'Windows Default
   Begin MSComCtl2.DTPicker dtphasta 
      Height          =   285
      Left            =   3780
      TabIndex        =   1
      Top             =   270
      Width           =   1275
      _ExtentX        =   2249
      _ExtentY        =   503
      _Version        =   393216
      Format          =   60882945
      CurrentDate     =   37611
   End
   Begin VB.CheckBox chktodos 
      Caption         =   "Todos"
      Height          =   240
      Left            =   5940
      TabIndex        =   5
      Top             =   270
      Width           =   780
   End
   Begin VB.CommandButton cmdfiltrar 
      Caption         =   "&Filtrar"
      Height          =   735
      Left            =   7380
      Picture         =   "FBusquedaCambios.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   6
      ToolTipText     =   "Filtar"
      Top             =   630
      Width           =   855
   End
   Begin MSDataGridLib.DataGrid DBListar 
      Height          =   3930
      Left            =   180
      TabIndex        =   7
      Top             =   1620
      Width           =   8115
      _ExtentX        =   14314
      _ExtentY        =   6932
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         AllowRowSizing  =   0   'False
         AllowSizing     =   0   'False
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.ComboBox cmbOperador 
      Height          =   315
      ItemData        =   "FBusquedaCambios.frx":030A
      Left            =   1575
      List            =   "FBusquedaCambios.frx":0314
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   1080
      Width           =   1005
   End
   Begin MSComCtl2.DTPicker dtpdesde 
      Height          =   285
      Left            =   1575
      TabIndex        =   0
      Top             =   270
      Width           =   1320
      _ExtentX        =   2328
      _ExtentY        =   503
      _Version        =   393216
      Format          =   60882945
      CurrentDate     =   37611
   End
   Begin MSDataListLib.DataCombo dtcTipoCambio 
      Height          =   315
      Left            =   1575
      TabIndex        =   2
      Top             =   675
      Width           =   3480
      _ExtentX        =   6138
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   "DataCombo1"
   End
   Begin VB.Label lblRegistro 
      Alignment       =   1  'Right Justify
      Caption         =   "Label5"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   5310
      TabIndex        =   11
      Top             =   5625
      Width           =   2985
   End
   Begin VB.Label Label4 
      Caption         =   "Hasta :"
      Height          =   240
      Left            =   3195
      TabIndex        =   10
      Top             =   315
      Width           =   690
   End
   Begin VB.Label Label3 
      Caption         =   "Operador :"
      Height          =   285
      Left            =   720
      TabIndex        =   9
      Top             =   1170
      Width           =   825
   End
   Begin VB.Label Label2 
      Caption         =   "Tipo de Cambio :"
      Height          =   240
      Left            =   315
      TabIndex        =   8
      Top             =   765
      Width           =   1320
   End
   Begin VB.Label Label1 
      Caption         =   "Desde :"
      Height          =   285
      Left            =   945
      TabIndex        =   3
      Top             =   315
      Width           =   915
   End
End
Attribute VB_Name = "FBusquedaCambios"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'PROGRAMADOR: JOE GERARDO BREÑA HUACHIN

Dim Mrs_BuscarCambios As ADODB.Recordset
Dim MobjBuscarCambios As DB_UT_MANTENIMIENTOS.C_TIPOCAMBIO

Dim MstrOrden As String

Private Sub chktodos_Click()
On Error GoTo merror
    If chktodos.Value = 1 Then
        Call habilitar_controles(False)
        cmdfiltrar.SetFocus
    Else
        Call habilitar_controles(True)
        dtpDesde.SetFocus
    End If
merror:
End Sub

Private Sub cmbOperador_KeyPress(KeyAscii As Integer)
    cmdfiltrar.SetFocus
End Sub

Private Sub cmdFiltrar_Click()
On Error Resume Next
    If dtpDesde.Value > dtpHasta.Value Then
        MsgBox "Fecha Inicial no puede ser mayor a la Fecha Final", vbExclamation, "Mensaje"
        dtcTipoCambio.SetFocus
        Exit Sub
    End If
    
    If chktodos.Value = 1 Then
        Set Mrs_BuscarCambios = MobjBuscarCambios.ListarCambiosAyuda(True, "", "", "")
    Else
        Set Mrs_BuscarCambios = MobjBuscarCambios.ListarCambiosAyuda(False, dtcTipoCambio.BoundText, dtpDesde.Value, dtpHasta.Value, cmboperador.Text)
    End If
    Call CargaDataGrid
End Sub

Private Sub DBListar_DblClick()
   RetornarValores
   Unload Me
End Sub

Private Sub dtcTipoCambio_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        cmboperador.SetFocus
    End If
End Sub

Private Sub dtpFechaFin_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        cmdfiltrar.SetFocus
    End If
End Sub

Private Sub dtpFechaIni_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        DTPFechaFin.SetFocus
    End If
End Sub

Private Sub dtpdesde_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        dtpHasta.SetFocus
    End If
End Sub

Private Sub dtphasta_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        dtcTipoCambio.SetFocus
    End If
End Sub

Private Sub Form_Load()
    Me.Top = 1500
    Me.Left = (Screen.Width - Me.Width) / 2
    
    Set MobjBuscarCambios = New DB_UT_MANTENIMIENTOS.C_TIPOCAMBIO
    Call CargaDataCombo(dtcTipoCambio, MobjBuscarCambios.ListarTiposCambio, "CURYTYPEID", "descr")

    dtpDesde.Value = Date
    dtpDesde.Day = "01"
    dtpHasta.Value = Date
    chktodos.Value = 1
    MstrOrden = "ASC"
    
    Set Mrs_BuscarCambios = MobjBuscarCambios.ListarCambiosAyuda(True, "", "", "")
    Call CargaDataGrid
End Sub

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As ADODB.Recordset, istrCampo1 As String, istrCampo2 As String)

    Set objDataCombo.DataSource = rsSource
    objDataCombo.DataField = istrCampo2
    Set objDataCombo.RowSource = rsSource
    objDataCombo.ListField = istrCampo2
    objDataCombo.BoundColumn = istrCampo1
    
    If Not rsSource.EOF Then
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If

End Sub

Private Sub RetornarValores()
On Error GoTo trataerror
    If DBListar.Bookmark = 0 Or IsNull(DBListar.Bookmark) Then
        Exit Sub
    End If
    
    With MDIFUtilitarios.ActiveForm
        '.CargaDatos DBListar.Columns(0).Text, DBListar.Columns(1).Text
        .CargaDatos DBListar.Columns(0).Text, DBListar.Columns(2).Text, _
        DBListar.Columns(4).Text, DBListar.Columns(5).Text, Val(DBListar.Columns(3).Text), DBListar.Columns(6).Text
    End With
trataerror:
End Sub
Private Sub Form_Unload(Cancel As Integer)
  Set Mrs_BuscarCambios = Nothing
End Sub


'Private Sub TxtDatoBuscado_Change()
'On Error GoTo TrataError
'  If Not Mrs_BuscarCambios.EOF And Trim(TxtDatoBuscado.Text) <> Empty Then
'   Mrs_BuscarCambios.MoveFirst
'   Mrs_BuscarCambios.Find CmbCriterioBusqueda.Text & " LIKE '" & Trim(TxtDatoBuscado.Text) & "%'"
'   Set DBListar.DataSource = Mrs_BuscarCambios
'   FormatoGrilla
'   DBListar.Refresh
'  End If
'TrataError:
'
'End Sub

'Private Sub TxtDatoBuscado_KeyPress(KeyAscii As Integer)
'  KeyAscii = GBloqueaCaracter(KeyAscii)
'  Select Case KeyAscii
'     Case 13
'            RetornarValores
'            Unload Me
'     Case 27
'            Unload Me
'  End Select
'End Sub

Private Sub CargaDataGrid()
    Set DBListar.DataSource = Mrs_BuscarCambios
    lblRegistro.Caption = Mrs_BuscarCambios.RecordCount & " registros encontrados"
    FormatoGrilla
End Sub

Private Sub DBListar_HeadClick(ByVal ColIndex As Integer)
On Error GoTo trataerror
    Select Case ColIndex
        'Case 0
        '    Mrs_BuscarCambios.Sort = "Almacen" & " " & MstrOrden
        Case 1
            Mrs_BuscarCambios.Sort = "[TIPO DE CAMBIO]" & " " & MstrOrden
        Case 2
            Mrs_BuscarCambios.Sort = "[FECHA]" & " " & MstrOrden
        Case 3
            Mrs_BuscarCambios.Sort = "[MONTO]" & " " & MstrOrden
        Case 4
            Mrs_BuscarCambios.Sort = "[MON INICIO]" & " " & MstrOrden
        Case 5
            Mrs_BuscarCambios.Sort = "[MON FINAL]" & " " & MstrOrden
        Case 6
            Mrs_BuscarCambios.Sort = "[OPERADOR]" & " " & MstrOrden
    End Select
        
    If MstrOrden = "ASC" Then
       MstrOrden = "DESC"
    Else
       MstrOrden = "ASC"
    End If
    
trataerror:
End Sub

Private Sub DBListar_KeyUp(KeyCode As Integer, Shift As Integer)
   Select Case KeyCode
     Case 13
            'TxtDatoBuscado.SetFocus
            RetornarValores
            Unload Me
     Case 27
            Unload Me
    End Select
End Sub

Private Sub FormatoGrilla()
    Dim Strdecimales As String
    
    DBListar.Columns(0).Visible = False
    DBListar.Columns(1).Width = 2475.213
    DBListar.Columns(1).Alignment = dbgLeft
    DBListar.Columns(2).Width = 1049.953
    DBListar.Columns(3).Width = 824.882
    DBListar.Columns(3).Alignment = dbgRight
    DBListar.Columns(3).NumberFormat = GMascara(GintDecPrecio)
    DBListar.Columns(4).Width = 1049.953
    DBListar.Columns(4).Alignment = dbgRight
    DBListar.Columns(5).Alignment = dbgRight
    DBListar.Columns(5).Width = 1035.213
    DBListar.Columns(6).Alignment = dbgRight
    DBListar.Columns(6).Width = 1080
End Sub

Sub habilitar_controles(valor As Boolean)
    dtpDesde.Enabled = valor
    dtpHasta.Enabled = valor
    dtcTipoCambio.Enabled = valor
    cmboperador.Enabled = valor
End Sub

