VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "tabctl32.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#50.0#0"; "pry_list.ocx"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Begin VB.Form FReporteCostos 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Reporte de Costos (10.240.00)"
   ClientHeight    =   6150
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6495
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   6150
   ScaleWidth      =   6495
   Begin TabDlg.SSTab SSTab1 
      Height          =   6135
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   10821
      _Version        =   393216
      Tabs            =   2
      TabHeight       =   520
      TabCaption(0)   =   "Criterios"
      TabPicture(0)   =   "FReportedeCostos.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Frame1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "cmdAceptar"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "cmdSalir"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "Frame2"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "FraHistorico"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "ChKHistorico"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "CrlistaPrecios"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).ControlCount=   7
      TabCaption(1)   =   "Almacen"
      TabPicture(1)   =   "FReportedeCostos.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "ctrl_SITES"
      Tab(1).ControlCount=   1
      Begin Crystal.CrystalReport CrlistaPrecios 
         Left            =   2880
         Top             =   5280
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin VB.CheckBox ChKHistorico 
         Caption         =   "Histórico"
         Height          =   195
         Left            =   4080
         TabIndex        =   18
         Top             =   600
         Width           =   1335
      End
      Begin VB.Frame FraHistorico 
         Enabled         =   0   'False
         Height          =   1575
         Left            =   4080
         TabIndex        =   14
         Top             =   600
         Width           =   2175
         Begin MSDataListLib.DataCombo Dtcmoneda 
            Height          =   315
            Left            =   120
            TabIndex        =   19
            Top             =   1080
            Width           =   1815
            _ExtentX        =   3201
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   ""
         End
         Begin MSComCtl2.UpDown UpDown1 
            Height          =   285
            Left            =   1695
            TabIndex        =   17
            Top             =   360
            Width           =   240
            _ExtentX        =   423
            _ExtentY        =   503
            _Version        =   393216
            Value           =   2000
            BuddyControl    =   "txtanio"
            BuddyDispid     =   196611
            OrigLeft        =   1200
            OrigTop         =   600
            OrigRight       =   1440
            OrigBottom      =   975
            Max             =   3000
            Min             =   2000
            SyncBuddy       =   -1  'True
            BuddyProperty   =   65547
            Enabled         =   -1  'True
         End
         Begin VB.TextBox txtanio 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   840
            TabIndex        =   16
            Top             =   360
            Width           =   855
         End
         Begin VB.Label Label4 
            Caption         =   "Moneda"
            Height          =   255
            Left            =   120
            TabIndex        =   20
            Top             =   720
            Width           =   1095
         End
         Begin VB.Label Label3 
            Caption         =   "Periódo"
            Height          =   255
            Left            =   120
            TabIndex        =   15
            Top             =   360
            Width           =   1575
         End
      End
      Begin VB.Frame Frame2 
         Height          =   1575
         Left            =   240
         TabIndex        =   6
         Top             =   600
         Width           =   3735
         Begin MiControl.CtrlNumber CtrlctRepo 
            Height          =   375
            Left            =   2400
            TabIndex        =   13
            Top             =   1180
            Width           =   975
            _ExtentX        =   1720
            _ExtentY        =   661
            BackColor       =   -2147483643
            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
         End
         Begin VB.ComboBox cmbctrepo 
            Height          =   315
            ItemData        =   "FReportedeCostos.frx":0038
            Left            =   1440
            List            =   "FReportedeCostos.frx":004B
            Style           =   2  'Dropdown List
            TabIndex        =   12
            Top             =   1200
            Width           =   855
         End
         Begin VB.ComboBox cmbcondicion 
            Height          =   315
            ItemData        =   "FReportedeCostos.frx":0060
            Left            =   1440
            List            =   "FReportedeCostos.frx":006A
            Style           =   2  'Dropdown List
            TabIndex        =   10
            Top             =   720
            Width           =   735
         End
         Begin MiControl.CtrlNumber ctrlctprom 
            Height          =   375
            Left            =   2400
            TabIndex        =   9
            Top             =   240
            Width           =   975
            _ExtentX        =   1720
            _ExtentY        =   661
            BackColor       =   -2147483643
            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
         End
         Begin VB.ComboBox cmbctprom 
            Height          =   315
            ItemData        =   "FReportedeCostos.frx":0074
            Left            =   1440
            List            =   "FReportedeCostos.frx":0087
            Style           =   2  'Dropdown List
            TabIndex        =   8
            Top             =   240
            Width           =   855
         End
         Begin VB.Label Label2 
            Caption         =   "Costo Reposición"
            Height          =   255
            Left            =   120
            TabIndex        =   11
            Top             =   1200
            Width           =   1455
         End
         Begin VB.Label Label1 
            Caption         =   "Costo Promedio"
            Height          =   255
            Left            =   120
            TabIndex        =   7
            Top             =   240
            Width           =   1215
         End
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "Sa&lir"
         Height          =   735
         Left            =   4680
         Picture         =   "FReportedeCostos.frx":009C
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   5160
         Width           =   1215
      End
      Begin VB.CommandButton cmdAceptar 
         Caption         =   "&Generar"
         Height          =   735
         Left            =   480
         Picture         =   "FReportedeCostos.frx":03A6
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   5160
         Width           =   1215
      End
      Begin VB.Frame Frame1 
         Height          =   2655
         Left            =   240
         TabIndex        =   2
         Top             =   2400
         Width           =   6015
         Begin pry_list.ctrl_listarray ctrl_lista 
            Height          =   2175
            Left            =   120
            TabIndex        =   3
            Top             =   360
            Width           =   5655
            _ExtentX        =   9975
            _ExtentY        =   3836
         End
      End
      Begin pry_list.ctrl_listarray ctrl_SITES 
         Height          =   4455
         Left            =   -74640
         TabIndex        =   1
         Top             =   480
         Width           =   5775
         _ExtentX        =   10186
         _ExtentY        =   7858
      End
   End
End
Attribute VB_Name = "FReporteCostos"
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 pb_tiposcreen As String
'*******************************************************************************************************************
'falta decidir la cantidad de decimales para redondear los precios, calculos y costos
'debe obtenerse de la tabla in_setup
Dim cnxprueba As ADODB.Connection
Dim mobj_calmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Dim mobj_ccategoria As DB_INV_MANTENIMIENTOS.C_CATEGORIA
Dim mobj_csubcategoria As DB_INV_MANTENIMIENTOS.C_SUBCATEGORIA
Dim mobj_ctipo As DB_INV_MANTENIMIENTOS.C_TIPO
Dim mobj_cproveedor As DB_INV_MANTENIMIENTOS.C_PROVEEDOR
Dim mobj_carticulo As DB_INV_ARTICULO.C_ARTICULO
Dim mobj_cmoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
Dim mobj_ctprecio As DB_INV_MANTENIMIENTOS.C_TIPOPRECIO

Private Sub ChKHistorico_Click()
  
  If ChKHistorico.Value = 1 Then
     FraHistorico.Enabled = True
  Else
     FraHistorico.Enabled = False
  End If
  
End Sub

Private Sub cmdaceptar_Click()

On Error GoTo errhandler
    
  Dim LinttodoSite As Integer
  Dim LinttodoCat  As Integer
  Dim Lstrcondicion As String
  Dim LstrCategorias As String
  Dim LstrAlmacenes As String
  
  
  CrlistaPrecios.Reset
  
  If UCase(LTrim(cmbcondicion.Text)) = "Y" Then
     Lstrcondicion = " and "
  Else
     If UCase(LTrim(cmbcondicion.Text)) = "O" Then
       Lstrcondicion = " or "
     End If
  End If
  
  If ctrl_lista.ndisponibles = 0 Or ctrl_lista.nseleccionados = 0 Then
     LstrCategorias = "*"
     LinttodoCat = 1
  Else
     LinttodoCat = 0
     LstrCategorias = ctrl_lista.listar_codigos()
     If Len(LstrCategorias) >= 255 Then    'se excedio el numero de items que soporta crystal
        MsgBox "Seleccione menos Items o Todos", vbCritical, "Demasiados Items Seleccionados"
        Exit Sub
     End If
  End If
        
  If ctrl_SITES.nseleccionados = 0 Then
     MsgBox "Debe Seleccionar un almacen como minimo", vbExclamation, "Parametros Incompletos"
     Exit Sub
  End If
  LstrAlmacenes = ctrl_SITES.listar_codigos()
    
  If ChKHistorico.Value = 0 Then
     CrlistaPrecios.ReportFileName = GstrReportesInv + "rpt_listar_costos.RPT"
     CrlistaPrecios.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
     CrlistaPrecios.Formulas(2) = "formscreen=stringvar strpantalla; strpantalla:='" & " (10.240.00)" & "'"
     CrlistaPrecios.Formulas(3) = "frmdesccosto=" + Str(GintDecCosto)
           
        
     CrlistaPrecios.StoredProcParam(0) = LstrAlmacenes
     CrlistaPrecios.StoredProcParam(1) = LinttodoSite
     CrlistaPrecios.StoredProcParam(2) = LstrCategorias
     CrlistaPrecios.StoredProcParam(3) = LinttodoCat
     CrlistaPrecios.StoredProcParam(4) = ctrlctprom.Text
     CrlistaPrecios.StoredProcParam(5) = cmbctprom.Text
     CrlistaPrecios.StoredProcParam(6) = CtrlctRepo.Text
     CrlistaPrecios.StoredProcParam(7) = cmbctrepo.Text
     CrlistaPrecios.StoredProcParam(8) = Lstrcondicion
                
  Else
     ' Es un Reporte Histórico
       
      If Dtcmoneda.BoundText = "PEN" Then
        CrlistaPrecios.ReportFileName = GstrReportesInv + "IN_listarcostosHISTO.RPT"
      Else
        CrlistaPrecios.ReportFileName = GstrReportesInv + "IN_listarcostosHISTOExt.RPT"
      End If
      
      CrlistaPrecios.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
      CrlistaPrecios.Formulas(2) = "formscreen=stringvar strpantalla; strpantalla:='" & " (10.240.00)" & "'"
      CrlistaPrecios.Formulas(3) = "frmdesccosto=" + Str(GintDecCosto)
        
      CrlistaPrecios.StoredProcParam(0) = LstrAlmacenes
      CrlistaPrecios.StoredProcParam(1) = LinttodoSite
      CrlistaPrecios.StoredProcParam(2) = LstrCategorias
      CrlistaPrecios.StoredProcParam(3) = LinttodoCat
      CrlistaPrecios.StoredProcParam(4) = txtanio.Text
      
     ' Fin de es un Reporte Histórico
  End If
  
  CrlistaPrecios.WindowTitle = "Reporte de Costos por Artículo"
  CrlistaPrecios.WindowShowPrintSetupBtn = True
  CrlistaPrecios.WindowShowSearchBtn = True
  CrlistaPrecios.WindowState = crptMaximized
  
  CrlistaPrecios.Action = 1

Exit Sub

errhandler:

MsgBox Err.Description, vbDefaultButton1 + vbExclamation, "Mensaje"


End Sub

Private Sub cmdSalir_Click()
    Unload Me
End Sub

Private Sub Form_Activate()

    Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
    Call gactualiza_barra(Me) 'pb_editar, pb_primerregistro, pb_ultimoregistro)
    If pbderecho_consultar = False Then
       Unload Me
    End If
    
End Sub

Private Sub Form_Load()

'********************************************************************************
'Código que se Tiene que Copiar para Invocar a la Rutina de Seguridad para poder
 Call gseguridad(Me)
 If pbderecho_consultar Then
 Else
    MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
 End If
'********************************************************************************

Me.Left = (MDIFInventarios.Width - Me.Width) / 2
Me.Top = ((MDIFInventarios.Height - Me.Height) / 2) - MDIFInventarios.Toolbar1.Height


Set mobj_calmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
Set mobj_cmoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
Set mobj_ctprecio = New DB_INV_MANTENIMIENTOS.C_TIPOPRECIO
Set mobj_ccategoria = New DB_INV_MANTENIMIENTOS.C_CATEGORIA

cmbctprom.ListIndex = 1
cmbctrepo.ListIndex = 1
cmbcondicion.ListIndex = 0

ctrlctprom.Enteros = 8
ctrlctprom.Decimales = 4
ctrlctprom.ValorPorDefecto

CtrlctRepo.Enteros = 8
CtrlctRepo.Decimales = 4
CtrlctRepo.ValorPorDefecto


ctrl_SITES.Size (20)
ctrl_SITES.llena_lista mobj_calmacen.ListarAlmacenesPorStatus(0), mobj_calmacen.ListarAlmacenesPorStatus(1)

ctrl_lista.llena_lista mobj_ccategoria.ListarCategoriasayuda


Set mobj_cmoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA

Set Dtcmoneda.RowSource = mobj_cmoneda.ListarMonedas
Dtcmoneda.ListField = "descr"
Dtcmoneda.BoundColumn = "CURYID"
Dtcmoneda.BoundText = "PEN"

txtanio.Text = Year(Now)


End Sub

Private Sub txtanio_KeyPress(KeyAscii As Integer)
  
    If KeyAscii < Asc("0") Then
      If KeyAscii <> 8 Then
         KeyAscii = 0
      End If
    End If
    
    If KeyAscii > Asc("9") Then
       KeyAscii = 0
    End If

End Sub

Sub salir_formulario()
   gformmdi.Toolbar1.Buttons(18).Caption = "Salir"
   Unload Me
End Sub

