VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FBuscarPreciosEstacion 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Busqueda de Precios de Estación"
   ClientHeight    =   5925
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7575
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5925
   ScaleWidth      =   7575
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Caption         =   "Filtrar por"
      Height          =   1575
      Left            =   90
      TabIndex        =   0
      Top             =   90
      Width           =   7335
      Begin VB.CommandButton cmdFiltar 
         Caption         =   "&Filtrar"
         Height          =   735
         Left            =   6240
         Picture         =   "FBuscarPreciosEstacion.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   2
         ToolTipText     =   "Filtar"
         Top             =   600
         Width           =   855
      End
      Begin VB.CheckBox ChkAlmacen 
         Caption         =   "Todos"
         Height          =   255
         Left            =   4800
         TabIndex        =   1
         Top             =   360
         Value           =   1  'Checked
         Width           =   975
      End
      Begin MSDataListLib.DataCombo dtcAlmacen 
         Height          =   315
         Left            =   1080
         TabIndex        =   3
         Top             =   360
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin MSComCtl2.DTPicker dtpFechaFin 
         Height          =   315
         Left            =   3840
         TabIndex        =   4
         Top             =   960
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   556
         _Version        =   393216
         CalendarBackColor=   16777152
         Format          =   61079553
         CurrentDate     =   37533
      End
      Begin MSComCtl2.DTPicker dtpFechaIni 
         Height          =   315
         Left            =   2160
         TabIndex        =   5
         Top             =   960
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   556
         _Version        =   393216
         CalendarBackColor=   16777152
         Format          =   61079553
         CurrentDate     =   37533
      End
      Begin VB.Label Label5 
         Caption         =   "Fecha de Proceso :"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   960
         Width           =   1455
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Del"
         Height          =   195
         Left            =   1800
         TabIndex        =   8
         Top             =   960
         Width           =   240
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "Al"
         Height          =   195
         Left            =   3600
         TabIndex        =   7
         Top             =   960
         Width           =   135
      End
      Begin VB.Label Label2 
         Caption         =   "Almacen"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   735
      End
   End
   Begin MSDataGridLib.DataGrid DBListar 
      Height          =   3735
      Left            =   90
      TabIndex        =   10
      ToolTipText     =   "Haga Doble Click para Seleccionar"
      Top             =   1800
      Width           =   7335
      _ExtentX        =   12938
      _ExtentY        =   6588
      _Version        =   393216
      BackColor       =   16777152
      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
      Caption         =   "Haga Click en la cabecera de la columna que desee ordenar"
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            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            =   10250
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label lblRegistro 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   7290
      TabIndex        =   11
      Top             =   5565
      Width           =   75
   End
End
Attribute VB_Name = "FBuscarPreciosEstacion"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'PROGRAMADOR: EDGAR CANCHO RUIZ

Private MobjAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Private MObjCtrlPrecios As DB_OP_MANTENIMIENTOS.C_PRECIOS_COMP
Private MrsobtieneRegistros As ADODB.Recordset
Private MstrOrden As String

Private Sub cmdFiltar_Click()
On Error Resume Next
    If ChkAlmacen.Value = 0 And dtcAlmacen.BoundText = Empty Then
        MsgBox "Elija un Almacen o Seleccione todos ", vbExclamation, "Mensaje"
        dtcAlmacen.SetFocus
        Exit Sub
    End If
    
    If dtpFechaIni.Value > dtpFechaFin.Value Then
        MsgBox "Fecha Inicial no puede ser mayor a la fecha final", vbExclamation, "Mensaje"
        dtpFechaIni.SetFocus
        Exit Sub
    End If
    
    Set MrsobtieneRegistros = MObjCtrlPrecios.ListarCtrlPrecios2(dtcAlmacen.BoundText, dtpFechaIni.Value, dtpFechaFin.Value, ChkAlmacen.Value)
    Call CargaDataGrid
End Sub

Private Sub DBListar_DblClick()
   RetornarValores
   Unload Me
End Sub

Private Sub DBListar_Scroll(Cancel As Integer)
    FormatoGrilla
End Sub

Private Sub dtcAlmacen_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        dtpFechaIni.SetFocus
    End If
End Sub

Private Sub dtpFechaFin_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        cmdFiltar.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 Form_Load()

    MstrOrden = "ASC"
    Set MobjAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set MObjCtrlPrecios = New DB_OP_MANTENIMIENTOS.C_PRECIOS_COMP
    
    Call CargaDataCombo(dtcAlmacen, MobjAlmacen.ListarAlmacenesPorStatus(1), "SiteId", "Name")

    Me.Top = 1000
    Me.Left = (Screen.Width - Me.Width) / 2
    
    dtpFechaIni.Year = Year(Date)
    dtpFechaIni.Month = Month(Date)
    dtpFechaIni.Day = 1
    
    
    dtpFechaFin.Value = Date
    
    Set MrsobtieneRegistros = MObjCtrlPrecios.ListarCtrlPrecios2(dtcAlmacen.BoundText, dtpFechaIni.Value, dtpFechaFin.Value, ChkAlmacen.Value)
    Call CargaDataGrid
    
    
End Sub

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As 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 MDIFVENTAS.ActiveForm
        .CargaDatos DBListar.Columns(0).Text, CDate(DBListar.Columns(1).Text)
    End With
TrataError:
End Sub
Private Sub Form_Unload(Cancel As Integer)
  Set MrsobtieneRegistros = Nothing
End Sub


'Private Sub TxtDatoBuscado_Change()
'On Error GoTo TrataError
'  If Not MrsobtieneRegistros.EOF And Trim(TxtDatoBuscado.Text) <> Empty Then
'   MrsobtieneRegistros.MoveFirst
'   MrsobtieneRegistros.Find CmbCriterioBusqueda.Text & " LIKE '" & Trim(TxtDatoBuscado.Text) & "%'"
'   Set DBListar.DataSource = MrsobtieneRegistros
'   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 = MrsobtieneRegistros
    lblRegistro.Caption = MrsobtieneRegistros.RecordCount & " registros encontrados"
    FormatoGrilla
End Sub

Private Sub DBListar_HeadClick(ByVal ColIndex As Integer)
On Error GoTo TrataError
    Select Case ColIndex
        Case 0
            MrsobtieneRegistros.Sort = "Almacen" & " " & MstrOrden
        Case 1
            MrsobtieneRegistros.Sort = "Fech_Proce" & " " & MstrOrden
        Case 2
            MrsobtieneRegistros.Sort = "CodArt" & " " & MstrOrden
        Case 3
            MrsobtieneRegistros.Sort = "Articulo" & " " & MstrOrden
        Case 4
            MrsobtieneRegistros.Sort = "Sugerido" & " " & MstrOrden
        Case 5
            MrsobtieneRegistros.Sort = "Actual" & " " & MstrOrden
        Case 6
            MrsobtieneRegistros.Sort = "Anterior" & " " & 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()
    DBListar.Columns(0).Width = 700
    DBListar.Columns(1).Width = 1000
    DBListar.Columns(2).Visible = False
    DBListar.Columns(2).Width = 3000
    DBListar.Columns(3).Width = 3000
    DBListar.Columns(4).NumberFormat = GMascara(GintDecPrecio)
    DBListar.Columns(4).Alignment = dbgRight
    DBListar.Columns(4).Width = 1200
    
    DBListar.Columns(5).NumberFormat = GMascara(GintDecPrecio)
    DBListar.Columns(5).Alignment = dbgRight
    DBListar.Columns(5).Width = 1200
    
    DBListar.Columns(6).NumberFormat = GMascara(GintDecPrecio)
    DBListar.Columns(6).Alignment = dbgRight
    DBListar.Columns(6).Width = 1200


End Sub








