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"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Begin VB.Form FResumenVentas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Resumenes de Ventas (95.210.00)"
   ClientHeight    =   6915
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10785
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   6915
   ScaleWidth      =   10785
   Begin Crystal.CrystalReport crReporte 
      Left            =   4800
      Top             =   240
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin VB.CommandButton cmdBusAlmacen 
      Height          =   375
      Left            =   4320
      MouseIcon       =   "FResumenVentas.frx":0000
      MousePointer    =   99  'Custom
      Picture         =   "FResumenVentas.frx":0152
      Style           =   1  'Graphical
      TabIndex        =   3
      ToolTipText     =   "Buscar Almacén"
      Top             =   240
      Width           =   375
   End
   Begin VB.CommandButton cmdImprimir 
      Height          =   615
      Left            =   9360
      Picture         =   "FResumenVentas.frx":0684
      Style           =   1  'Graphical
      TabIndex        =   2
      ToolTipText     =   "Imprimir documento seleccionado"
      Top             =   120
      Width           =   1095
   End
   Begin MSDataGridLib.DataGrid dbDetalle 
      Height          =   3135
      Left            =   240
      TabIndex        =   0
      Top             =   3480
      Width           =   10215
      _ExtentX        =   18018
      _ExtentY        =   5530
      _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
      Caption         =   "DETALLE DE MOVIMIENTO"
      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 MSDataGridLib.DataGrid dbCabecera 
      Height          =   2415
      Left            =   240
      TabIndex        =   1
      Top             =   840
      Width           =   10215
      _ExtentX        =   18018
      _ExtentY        =   4260
      _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
      Caption         =   "CABECERAS DE MOVIMIENTOS"
      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 MSComCtl2.DTPicker dtpHasta 
      Height          =   375
      Left            =   7800
      TabIndex        =   4
      Top             =   240
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      _Version        =   393216
      Format          =   61276161
      CurrentDate     =   37797
   End
   Begin MSComCtl2.DTPicker dtpDesde 
      Height          =   375
      Left            =   5760
      TabIndex        =   5
      Top             =   240
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      _Version        =   393216
      Format          =   61276161
      CurrentDate     =   37797
   End
   Begin MSDataListLib.DataCombo dtcAlmacen 
      Height          =   315
      Left            =   1080
      TabIndex        =   6
      Top             =   240
      Width           =   3135
      _ExtentX        =   5530
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   ""
   End
   Begin VB.Label Label1 
      Caption         =   "Desde"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5040
      TabIndex        =   9
      Top             =   240
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "Hasta"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   7200
      TabIndex        =   8
      Top             =   240
      Width           =   495
   End
   Begin VB.Label lblAlmacen 
      AutoSize        =   -1  'True
      Caption         =   "Almacen"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Left            =   240
      TabIndex        =   7
      Top             =   240
      Width           =   735
   End
End
Attribute VB_Name = "FResumenVentas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'*************************************
'Variables para el Control de la Barra General
 Public pb_editar As Boolean
 Public pb_agregar As Boolean
 Public pb_primerregistro As Boolean
 Public pb_ultimoregistro As Boolean
 Public pbderecho_agregar As Boolean
 Public pbderecho_consultar As Boolean
 Public pbderecho_editar As Boolean
 Public pbderecho_borrar As Boolean
 Public pbderecho_imprimir As Boolean
 Public pbderecho_anular As Boolean
 Public pbderecho_emitir As Boolean
 Public pb_tiposcreen As String
'*******************************************************************************************************************
' Variables para las ayudas
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String 'columna para codigo de compra
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String
Public GrecibeColumnaOpcional4 As String 'columna para costo
'*************************************

Private objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN

Private objResumenes As DB_UT_MANTENIMIENTOS.C_PROCESOS
Public rsCabecera As ADODB.Recordset
Public rsDetalle As ADODB.Recordset

Private Sub cmdBusAlmacen_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "Siteid"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "Name"
    ArrayBusqueda(2, 2) = "Descripción "
    ArrayBusqueda(2, 3) = 4000
      
    FBusquedasUt.GObtenerRegistros objAlmacen.ListarAlmacenesPorStatus(1), ArrayBusqueda, 2, 2
    FBusquedasUt.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
        dtcAlmacen.BoundText = GrecibeColumnaID
    End If
End Sub

Private Sub cmdImprimir_Click()
Call imprimir
End Sub

Private Sub dbCabecera_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyDown Or KeyAscii = vbKeyUp Then
    FiltraDetalle
End If
End Sub

Private Sub dbCabecera_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
FiltraDetalle
End Sub


Private Sub dtcAlmacen_Change()
On Error Resume Next
FiltraCabecera
FiltraDetalle
End Sub

Private Sub dtpDesde_Change()
On Error Resume Next
FiltraCabecera
FiltraDetalle
End Sub

Private Sub dtpHasta_Change()
On Error Resume Next
FiltraCabecera
FiltraDetalle
End Sub


Private Sub Form_Load()

    Set objResumenes = New DB_UT_MANTENIMIENTOS.C_PROCESOS
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    
    Call CargaDataCombo(dtcAlmacen, objAlmacen.ListarAlmacenesPorStatus(1), "SiteId", "Name")
    Set rsCabecera = objResumenes.ObtenerCabecerasResumenesVentas
    Set rsDetalle = objResumenes.ObtenerDetallesResumenesVentas

    Set dbCabecera.DataSource = rsCabecera
    Set dbDetalle.DataSource = rsDetalle
    FiltraCabecera
    FiltraDetalle
    
    Me.Top = 100
    Me.Left = (Screen.Width - Me.Width) / 2
   
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set objResumenes = Nothing
End Sub

Private Sub FiltraCabecera()
On Error Resume Next
    rsCabecera.Filter = "[DATEPROCE]>='" & Format(dtpDesde.Value, "DD/MM/YYYY") & "' AND [DATEPROCE]<='" & Format(dtpHasta.Value, "DD/MM/YYYY") & "' AND [SITEID]='" & GVDATO(dtcAlmacen.BoundText) & "'"
    'rsDetalle.Sort = "[SECUENCIA] ASC"
End Sub

Private Sub FiltraDetalle()
On Error GoTo trataerror
    rsDetalle.Filter = "[SITEID]='" & dbCabecera.Columns(0).Text & "' AND [DATEPROCE]='" & dbCabecera.Columns(1).Text & "'"
    'rsDetalle.Sort = "[SECUENCIA] ASC"
Exit Sub
trataerror:
    rsDetalle.Filter = "[SITEID]='00'"
    
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

Public Sub salir_formulario()
Unload Me
End Sub

Public Sub imprimir()
On Error GoTo trataerror
    
    Dim mstrfecha As String
    
    mstrfecha = CStr(Format(CDate(dbCabecera.Columns(1).Text), "YYYYMMdd"))
    Screen.MousePointer = 11

    crReporte.ReportFileName = GstrReportesVta + "rpt_resumen_ventas.rpt"
    crReporte.WindowTitle = "Resumen de Inventario"
    crReporte.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
    crReporte.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='95.210.00'"
    crReporte.Formulas(3) = "formNDStock=" & GintDecStock
    crReporte.Formulas(4) = "formNDCosto=" & GintDecCosto
    crReporte.Formulas(5) = "formNDMonto=" & GintDecResultado
    crReporte.Formulas(6) = "formNDPrecio=" & GintDecPrecio
    
    crReporte.StoredProcParam(0) = dbCabecera.Columns(0).Text
    crReporte.StoredProcParam(1) = mstrfecha
    
    
    crReporte.WindowState = crptMaximized
    crReporte.WindowShowPrintSetupBtn = True
    crReporte.Action = 1
    crReporte.Reset
        
    Screen.MousePointer = 0
    Exit Sub

trataerror:
    Screen.MousePointer = 0
    MsgBox "Error Generando reporte", vbExclamation, "Error"
End Sub

