VERSION 5.00
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"
Begin VB.Form Frpt_costosinventario 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Reporte Costos de Inventario (10.210.00)"
   ClientHeight    =   5610
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6555
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5610
   ScaleWidth      =   6555
   Begin TabDlg.SSTab SSTab1 
      Height          =   5415
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   9551
      _Version        =   393216
      Tabs            =   2
      TabHeight       =   520
      TabCaption(0)   =   "Criterios"
      TabPicture(0)   =   "10021000.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "lblMoneda"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "dtc_moneda"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "cmdSalir"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "cmdAceptar"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Frame1"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Frame2"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "RP"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).ControlCount=   7
      TabCaption(1)   =   "Almacen"
      TabPicture(1)   =   "10021000.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "ctrl_SITES"
      Tab(1).ControlCount=   1
      Begin Crystal.CrystalReport RP 
         Left            =   2760
         Top             =   4800
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin pry_list.ctrl_listarray ctrl_SITES 
         Height          =   4455
         Left            =   -74640
         TabIndex        =   12
         Top             =   480
         Width           =   5775
         _ExtentX        =   10186
         _ExtentY        =   7858
      End
      Begin VB.Frame Frame2 
         Caption         =   "Costo"
         Height          =   1095
         Left            =   2520
         TabIndex        =   10
         Top             =   600
         Width           =   2175
         Begin VB.OptionButton opt_creposicion 
            Caption         =   "Costo Reposicion"
            Height          =   255
            Left            =   120
            TabIndex        =   2
            Top             =   720
            Width           =   1815
         End
         Begin VB.OptionButton opt_cpromedio 
            Caption         =   "Costo Promedio"
            Height          =   255
            Left            =   120
            TabIndex        =   8
            Top             =   360
            Value           =   -1  'True
            Width           =   1695
         End
      End
      Begin VB.Frame Frame1 
         Height          =   2655
         Left            =   240
         TabIndex        =   5
         Top             =   1800
         Width           =   5895
         Begin pry_list.ctrl_listarray ctrl_lista 
            Height          =   1935
            Left            =   120
            TabIndex        =   11
            Top             =   600
            Width           =   5655
            _ExtentX        =   9975
            _ExtentY        =   3413
         End
         Begin VB.ComboBox cmbcriterio 
            Height          =   315
            ItemData        =   "10021000.frx":0038
            Left            =   1680
            List            =   "10021000.frx":0042
            Style           =   2  'Dropdown List
            TabIndex        =   6
            Top             =   240
            Width           =   2175
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "Agrupar Por:"
            Height          =   195
            Left            =   360
            TabIndex        =   7
            Top             =   360
            Width           =   885
         End
      End
      Begin VB.CommandButton cmdAceptar 
         Caption         =   "&Aceptar"
         Height          =   735
         Left            =   480
         Picture         =   "10021000.frx":0060
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   4560
         Width           =   1215
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "Sa&lir"
         Height          =   735
         Left            =   4680
         Picture         =   "10021000.frx":036A
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   4560
         Width           =   1215
      End
      Begin MSDataListLib.DataCombo dtc_moneda 
         Height          =   315
         Left            =   240
         TabIndex        =   9
         Top             =   720
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin VB.Label lblMoneda 
         AutoSize        =   -1  'True
         Caption         =   "Moneda:"
         Height          =   195
         Left            =   240
         TabIndex        =   1
         Top             =   480
         Width           =   630
      End
   End
End
Attribute VB_Name = "Frpt_costosinventario"
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_cmoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
Dim mobj_ctprecio As DB_INV_MANTENIMIENTOS.C_TIPOPRECIO
Dim mobj_ctoma As DB_INV_TOMADEINVENTARIO.C_inventario

Private Sub cmbcriterio_Click()

Set mobj_ctoma = New DB_INV_TOMADEINVENTARIO.C_inventario
Dim ls_criterio As String
ls_criterio = cmbcriterio.Text
Select Case ls_criterio
    Case "Categoria"
        ctrl_lista.llena_lista mobj_ctoma.CAT_SELECCIONADAS
    Case "Sub Categoria"
        ctrl_lista.llena_lista mobj_ctoma.SCAT_SELECCIONADAS
End Select

End Sub

Private Sub cmdaceptar_Click()

Dim ls_criterio As String
Dim ls_condicion As String
Dim li_todos                ' 1 todos los elementos, 0 algunos
Dim LS_MONEDA As String
Dim ls_dmoneda As String
Dim ls_rutar As String  'ruta de los reportes

ls_rutar = GstrReportesInv

ls_dmoneda = dtc_moneda.Text
LS_MONEDA = dtc_moneda.BoundText


If LS_MONEDA = "" Then
    MsgBox "Debe Seleccionar un tipo de moneda", vbExclamation, "Parametros Incompletos"
    dtc_moneda.SetFocus
    Exit Sub
End If


ls_criterio = cmbcriterio.Text
If ctrl_lista.ndisponibles = 0 Or ctrl_lista.nseleccionados = 0 Then
    li_todos = 1
    ls_condicion = "*"
Else
    li_todos = 0
    ls_condicion = ctrl_lista.listar_codigos()
End If

If ctrl_SITES.nseleccionados = 0 Then
    MsgBox "Debe Seleccionar un almacen como minimo", vbExclamation, "Parametros Incompletos"
    Exit Sub
End If
If opt_cpromedio.Value = True Then
    ls_costo = "PRO"
    LS_DCOSTO = "PROMEDIO"
End If

If opt_creposicion.Value = True Then
    ls_costo = "PRO"
    LS_DCOSTO = "REPOSICION"
End If

ls_sites = ctrl_SITES.listar_codigos()
RP.Reset
RP.WindowState = crptMaximized
RP.Destination = crptToWindow
RP.WindowShowPrintSetupBtn = True
RP.WindowShowCloseBtn = True
RP.WindowShowSearchBtn = True


RP.ReportFileName = ls_rutar + "RPTvalorinventariofisico.RPT"

Select Case ls_criterio
     Case "Categoria"
         ls_tcriterio = "CAT"
         Call ocultaseccion(ls_tcriterio)
     Case "Sub Categoria"
         ls_tcriterio = "SCA"
         Call ocultaseccion(ls_tcriterio)
     Case Else
         MsgBox "Debe Seleccionar un Criterio", vbCritical
         cmbcriterio.SetFocus
         Exit Sub
 End Select
RP.Formulas(0) = "form_nreporte='1021000'"
RP.Formulas(1) = "form_descmoneda='" + ls_dmoneda + "'"
RP.Formulas(2) = "form_ndeccosto=" + Str(GintDecCosto)
RP.Formulas(3) = "form_usuario='" + GCUSERID + "'"
RP.Formulas(4) = "form_usuario='" + GCUSERID + "'"
RP.Formulas(5) = "form_TIPOCOSTO='" + LS_DCOSTO + "'"

RP.StoredProcParam(0) = Trim(LS_MONEDA)
RP.StoredProcParam(1) = ls_sites
RP.StoredProcParam(2) = Trim(ls_tcriterio)
RP.StoredProcParam(3) = li_todos
RP.StoredProcParam(4) = Trim(ls_condicion)
RP.StoredProcParam(5) = ls_costo
RP.Action = 1
End Sub

Private Sub cmdSalir_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Dim LBOL_ESTADOINVENTARIO As Boolean

'********************************************************************************
'Código que se Tiene que Copiar para Invocar a la Rutina de Seguridad para poder
    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
'********************************************************************************

LBOL_ESTADOINVENTARIO = mobj_calmacen.estadoinventarioAlmacen()
If Not LBOL_ESTADOINVENTARIO Then
    MsgBox "La toma de Inventario no esta Activada", vbCritical, "No Puede Ingresar a esta Pantalla"
    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
'********************************************************************************

Set mobj_calmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
Set mobj_cmoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA


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

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

Set dtc_moneda.RowSource = mobj_cmoneda.ListarMonedas
dtc_moneda.ListField = "descr"
dtc_moneda.BoundColumn = "CURYID"


End Sub

Sub ocultaseccion(ByVal seccion As String)
    Select Case seccion
    Case "CAT"
        RP.SectionFormat(0) = "GH2;T;X;X;X;X;X;X"   'CATEGORIA
        RP.SectionFormat(1) = "GF2;T;X;X;X;X;X;X"
        RP.SectionFormat(2) = "GH3;F;X;X;X;X;X;X"   'SUB CATEGORIA
        RP.SectionFormat(3) = "GF3;F;X;X;X;X;X;X"
    Case "SCA"
        RP.SectionFormat(0) = "GH2;T;X;X;X;X;X;X"   'CATEGORIA
        RP.SectionFormat(1) = "GF2;T;X;X;X;X;X;X"
        RP.SectionFormat(2) = "GH3;T;X;X;X;X;X;X"   'SUB CATEGORIA
        RP.SectionFormat(3) = "GF3;T;X;X;X;X;X;X"
    End Select
End Sub

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

End Sub

