VERSION 5.00
Object = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#49.0#0"; "pry_list.ocx"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FReimpresionCierreZ 
   Caption         =   "Reimpresión de Cierres Z"
   ClientHeight    =   5160
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10695
   LinkTopic       =   "Form1"
   ScaleHeight     =   5160
   ScaleWidth      =   10695
   StartUpPosition =   3  'Windows Default
   Begin TabDlg.SSTab SSTab2 
      Height          =   5175
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10695
      _ExtentX        =   18865
      _ExtentY        =   9128
      _Version        =   393216
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   520
      TabCaption(0)   =   "Datos Generales"
      TabPicture(0)   =   "FReimpresionCierreZ.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Image1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Label5"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "Label2"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "Shape1"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Line1"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Label7"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "lstCriterios"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "cmdSalir"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "cmdGenerar"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "Frame2"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).ControlCount=   10
      TabCaption(1)   =   "Puntos de Venta"
      TabPicture(1)   =   "FReimpresionCierreZ.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Shape3"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).Control(1)=   "Label8"
      Tab(1).Control(1).Enabled=   0   'False
      Tab(1).Control(2)=   "Image3"
      Tab(1).Control(2).Enabled=   0   'False
      Tab(1).Control(3)=   "Label9"
      Tab(1).Control(3).Enabled=   0   'False
      Tab(1).Control(4)=   "Line2"
      Tab(1).Control(4).Enabled=   0   'False
      Tab(1).Control(5)=   "lstPtoVta"
      Tab(1).Control(5).Enabled=   0   'False
      Tab(1).Control(6)=   "Command1"
      Tab(1).Control(6).Enabled=   0   'False
      Tab(1).Control(7)=   "Command2"
      Tab(1).Control(7).Enabled=   0   'False
      Tab(1).ControlCount=   8
      Begin VB.CommandButton Command2 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   -74190
         Picture         =   "FReimpresionCierreZ.frx":0038
         Style           =   1  'Graphical
         TabIndex        =   21
         Top             =   3735
         Width           =   1335
      End
      Begin VB.CommandButton Command1 
         Caption         =   "&Salir"
         Height          =   855
         Left            =   -72840
         Picture         =   "FReimpresionCierreZ.frx":0342
         Style           =   1  'Graphical
         TabIndex        =   20
         Top             =   3735
         Width           =   1335
      End
      Begin VB.CommandButton cmdGenerar2 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   -66000
         Picture         =   "FReimpresionCierreZ.frx":064C
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Frame Frame2 
         Caption         =   "Rango de Fechas de Proceso "
         Height          =   855
         Left            =   240
         TabIndex        =   4
         Top             =   1800
         Width           =   3735
         Begin MSComCtl2.DTPicker dtpFechaFin 
            Height          =   315
            Left            =   2280
            TabIndex        =   5
            Top             =   360
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   58916865
            CurrentDate     =   37533
         End
         Begin MSComCtl2.DTPicker dtpFechaIni 
            Height          =   315
            Left            =   480
            TabIndex        =   6
            Top             =   360
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   58916865
            CurrentDate     =   37533
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "Al"
            Height          =   195
            Left            =   2040
            TabIndex        =   8
            Top             =   360
            Width           =   135
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            Caption         =   "Del"
            Height          =   195
            Left            =   120
            TabIndex        =   7
            Top             =   360
            Width           =   240
         End
      End
      Begin VB.CommandButton cmdGenerar 
         Caption         =   "&Generar"
         Height          =   765
         Left            =   810
         Picture         =   "FReimpresionCierreZ.frx":0956
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   3735
         Width           =   975
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   795
         Left            =   1800
         Picture         =   "FReimpresionCierreZ.frx":0C60
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   3720
         Width           =   945
      End
      Begin VB.CommandButton cmdSalir2 
         Cancel          =   -1  'True
         Caption         =   "&Salir"
         Height          =   855
         Left            =   -66000
         Picture         =   "FReimpresionCierreZ.frx":0F6A
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   2760
         Width           =   1335
      End
      Begin pry_list.ctrl_listarray lstCriterios 
         Height          =   2475
         Left            =   4380
         TabIndex        =   10
         Top             =   1800
         Width           =   5775
         _ExtentX        =   10186
         _ExtentY        =   4366
      End
      Begin pry_list.ctrl_listarray lstAlmacen 
         Height          =   2295
         Left            =   -73080
         TabIndex        =   11
         Top             =   1620
         Width           =   6630
         _ExtentX        =   11695
         _ExtentY        =   4048
      End
      Begin pry_list.ctrl_listarray lstPtoVta 
         Height          =   2475
         Left            =   -70620
         TabIndex        =   17
         Top             =   1800
         Width           =   5775
         _ExtentX        =   10186
         _ExtentY        =   4366
      End
      Begin VB.Line Line2 
         X1              =   -74760
         X2              =   -64680
         Y1              =   960
         Y2              =   960
      End
      Begin VB.Label Label9 
         Caption         =   "REIMPRESIÓN DE CIERRES Z"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   -74235
         TabIndex        =   19
         Top             =   675
         Width           =   4830
      End
      Begin VB.Image Image3 
         Height          =   480
         Left            =   -74760
         Picture         =   "FReimpresionCierreZ.frx":1274
         Top             =   480
         Width           =   480
      End
      Begin VB.Label Label8 
         Alignment       =   2  'Center
         Caption         =   "PUNTOS DE VENTA"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   -70680
         TabIndex        =   18
         Top             =   1470
         Width           =   5835
      End
      Begin VB.Shape Shape3 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3255
         Left            =   -70830
         Top             =   1260
         Width           =   6255
      End
      Begin VB.Label Label7 
         Alignment       =   2  'Center
         Caption         =   "ALMACENES"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   4380
         TabIndex        =   16
         Top             =   1470
         Width           =   5835
      End
      Begin VB.Label Label6 
         Caption         =   "REGISTRO DE VENTAS"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   -74235
         TabIndex        =   15
         Top             =   675
         Width           =   2670
      End
      Begin VB.Line Line1 
         X1              =   240
         X2              =   10320
         Y1              =   960
         Y2              =   960
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3255
         Left            =   4170
         Top             =   1260
         Width           =   6255
      End
      Begin VB.Line Line4 
         X1              =   -74760
         X2              =   -64560
         Y1              =   960
         Y2              =   960
      End
      Begin VB.Line Line5 
         X1              =   -74760
         X2              =   -64560
         Y1              =   4500
         Y2              =   4500
      End
      Begin VB.Image Image2 
         Height          =   480
         Left            =   -74760
         Picture         =   "FReimpresionCierreZ.frx":157E
         Top             =   480
         Width           =   480
      End
      Begin VB.Shape Shape2 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3000
         Left            =   -73380
         Top             =   1215
         Width           =   7185
      End
      Begin VB.Label Label2 
         Caption         =   "TIPOS DE DOCUMENTOS"
         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            =   6120
         TabIndex        =   14
         Top             =   1485
         Width           =   2310
      End
      Begin VB.Label Label1 
         Caption         =   "ALMACENES"
         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            =   -70545
         TabIndex        =   13
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "REIMPRESIÓN DE CIERRES Z"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   765
         TabIndex        =   12
         Top             =   675
         Width           =   4830
      End
      Begin VB.Image Image1 
         Height          =   480
         Left            =   240
         Picture         =   "FReimpresionCierreZ.frx":1888
         Top             =   480
         Width           =   480
      End
   End
End
Attribute VB_Name = "FReimpresionCierreZ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'   PROGRAMADOR: JOE BREÑA HUACHIN
'   REGISTRO DE VENTAS

Option Explicit
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

Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String

Public objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Public objDocumentos As DB_MA_MANTENIMIENTOS.C_DOCUMENTO
Public objMoneda  As DB_MA_MANTENIMIENTOS.C_MONEDA

Dim MstrCadena_Criterios As String
Dim MstrCadena_Almacenes As String
Dim MstrGrupo As String
Dim MintTodos_Alm As Integer
Dim MintTodos_Cri As Integer

Dim MstrFechaIni As String
Dim MstrFechaFin As String

Dim objCorrelativo As DB_CORRELATIVO.C_Correlativos
Dim lngCorrelativo As Long

Private Sub cmdGenerar_Click()
    lngCorrelativo = objCorrelativo.ObtenerCorrelativo(GCUSERID)
    imprimir
End Sub

Private Sub cmdGenerar2_Click()
    imprimir
End Sub

Private Sub cmdSalir_Click()
Unload Me
End Sub

Public Sub actualizar_registro()

End Sub

Private Sub cmdSalir2_Click()
    Unload Me
End Sub

Private Sub dtcMoneda_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        dtpFechaIni.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_Activate()

'    Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
'    Call gactualiza_barra(Me)
    'lineas nuevas
    If pbderecho_consultar = False Then
        Unload Me
    End If

End Sub

Private Sub Form_Initialize()
    'Call gHabilitarReg(Me, False)
End Sub

Private Sub Form_Load()
    'seguridad
    Call gseguridad(Me)
    pbderecho_consultar = True
    If pbderecho_consultar Then
        InstanciaObjetos
        CargaListaCriterios
        CargaListaAlmacen
        'Call CargaDataCombo(dtcmoneda, objMoneda.ListarMonedas, "CuryId", "Descr")
        
    Else

        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    End If
     
    dtpFechaIni.Value = Date
    dtpFechaFin.Value = Date
    'dtcmoneda.BoundText = GstrCodMonedaBase
         
    Me.Top = 200
    Me.Left = (Screen.Width - Me.Width) / 2
     
 
End Sub

Function valida_datos()
   
    If GVDATO(dtcmoneda.Text) = Empty And dtcmoneda.Enabled Then
        valida_datos = False
        MsgBox "Ingrese Moneda", vbExclamation, "Falta Parámetro"
        SSTab1.Tab = 0
        dtcmoneda.SetFocus
        Exit Function
    End If

    If dtpFechaIni.Value > dtpFechaFin.Value Then
        valida_datos = False
        MsgBox "Rango de Fecha Incorrecto", vbExclamation, "Error de ingreso"
        SSTab1.Tab = 0
        dtpFechaIni.SetFocus
        Exit Function
    End If
    
    If lstAlmacen.ndisponibles = 0 And lstAlmacen.nseleccionados = 0 Then
        valida_datos = False
        MsgBox "No existen registros de Categorias o Sub Categorias", vbExclamation, "Error de ingreso"
        SSTab1.Tab = 0
        Exit Function
    End If
    
    If lstPtoVta.ndisponibles = 0 And lstPtoVta.nseleccionados = 0 Then
        valida_datos = False
        MsgBox "No existen registros de Almacenes", vbExclamation, "Error de ingreso"
        SSTab1.Tab = 0
        Exit Function
    End If
        
    ' PARA LOS CRITERIOS DE TIPOS DE DOCUMENTOS
    If lstAlmacen.ndisponibles = 0 Or lstAlmacen.nseleccionados = 0 Then
        MintTodos_Cri = 1
        MstrCadena_Criterios = " "
    Else
        MintTodos_Cri = 0
        If Len(lstAlmacen.listar_codigos_seleccionados) > 255 Then
            valida_datos = False
            MsgBox "Selecione menos Tipos de Documentos o Seleccione Todos", vbExclamation, "Error de ingreso"
            SSTab1.Tab = 0
            Exit Function
        Else
            MstrCadena_Criterios = lstAlmacen.listar_codigos_seleccionados
        End If
    End If
        
    ' PARA LOS ALMACENES
    If lstPtoVta.ndisponibles = 0 Or lstPtoVta.nseleccionados = 0 Then
        MintTodos_Alm = 1
        MstrCadena_Almacenes = " "
    Else
        MintTodos_Alm = 0
        If Len(lstPtoVta.listar_codigos_seleccionados) > 255 Then
            valida_datos = False
            MsgBox "Selecione menos Almacenes o Seleccione Todos", vbExclamation, "Error de ingreso"
            SSTab1.Tab = 1
            Exit Function
        Else
            MstrCadena_Almacenes = lstPtoVta.listar_codigos_seleccionados
        End If
    End If
    

    MstrFechaIni = CStr(Format(dtpFechaIni.Value, "YYYYMMdd"))
    MstrFechaFin = CStr(Format(dtpFechaFin.Value, "YYYYMMdd"))
    valida_datos = True
End Function

Sub salir_formulario()
    ' validar que no haya procesos pendientes
    ' si no hay problemas
    MDIFVENTAS.Toolbar1.Buttons(18).Caption = "Salir"    ' boton salir
    Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set objAlmacen = Nothing
    Set objDocumentos = Nothing
    Set objMoneda = Nothing
    Set objCorrelativo = Nothing
End Sub


Sub imprimir()

If Not valida_datos Then
    Exit Sub
End If

Screen.MousePointer = 11

'GstrReportesVta = "k:\sies\fuentes\Ventas\Report\"
    
    
    If optResumido.Value Then
        crRegistroVentas.ReportFileName = GstrReportesVta + "rpt_Reg_Ventas_Res.rpt"
        
        crRegistroVentas.StoredProcParam(0) = lngCorrelativo
        crRegistroVentas.StoredProcParam(1) = MstrFechaIni
        crRegistroVentas.StoredProcParam(2) = MstrFechaFin
        crRegistroVentas.StoredProcParam(3) = dtcmoneda.BoundText
        crRegistroVentas.StoredProcParam(4) = 1
        crRegistroVentas.StoredProcParam(5) = MstrCadena_Almacenes
        crRegistroVentas.StoredProcParam(6) = MintTodos_Alm
        crRegistroVentas.StoredProcParam(7) = MstrCadena_Criterios
        crRegistroVentas.StoredProcParam(8) = MintTodos_Cri
    Else
    
        crRegistroVentas.ReportFileName = GstrReportesVta + "rpt_Reg_Ventas_Det.rpt"
        
        crRegistroVentas.StoredProcParam(0) = MstrFechaIni
        crRegistroVentas.StoredProcParam(1) = MstrFechaFin
        crRegistroVentas.StoredProcParam(2) = dtcmoneda.BoundText
        crRegistroVentas.StoredProcParam(3) = 1
        crRegistroVentas.StoredProcParam(4) = MstrCadena_Almacenes
        crRegistroVentas.StoredProcParam(5) = MintTodos_Alm
        crRegistroVentas.StoredProcParam(6) = MstrCadena_Criterios
        crRegistroVentas.StoredProcParam(7) = MintTodos_Cri
    End If
        

                
    crRegistroVentas.WindowTitle = "Registro de Ventas"
    crRegistroVentas.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
    crRegistroVentas.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='05.150.00'"
    crRegistroVentas.Formulas(3) = "formMoneda=stringvar strMoneda; strMoneda:='" & Trim(dtcmoneda.Text) & "'"
    crRegistroVentas.Formulas(4) = "formFechaIni= datevar FechaIni; FechaIni:=date(" & Format(dtpFechaIni.Value, "YYYY,MM,dd") & ")"
    crRegistroVentas.Formulas(5) = "formFechaFin= datevar FechaFin; FechaFin:=date(" & Format(dtpFechaFin.Value, "YYYY,MM,dd") & ")"
    crRegistroVentas.Formulas(6) = "formNDStock=" & GintDecStock
    crRegistroVentas.Formulas(7) = "formNDCosto=" & GintDecCosto
    crRegistroVentas.Formulas(8) = "formNDMonto=" & GintDecResultado
    crRegistroVentas.Formulas(9) = "formNDPrecio=" & GintDecPrecio

    crRegistroVentas.WindowState = crptMaximized
    crRegistroVentas.WindowShowPrintSetupBtn = True
    
'    crRegistroVentas.StoredProcParam(0) = MstrFechaIni
'    crRegistroVentas.StoredProcParam(1) = MstrFechaFin
'    crRegistroVentas.StoredProcParam(2) = dtcMoneda.BoundText
'    crRegistroVentas.StoredProcParam(3) = 1
'    crRegistroVentas.StoredProcParam(4) = MstrCadena_Almacenes
'    crRegistroVentas.StoredProcParam(5) = MintTodos_Alm
'    crRegistroVentas.StoredProcParam(6) = MstrCadena_Criterios
'    crRegistroVentas.StoredProcParam(7) = MintTodos_Cri
    crRegistroVentas.Connect = "DSN=SIES"
    crRegistroVentas.Action = 1
    
    crRegistroVentas.Reset
    
Screen.MousePointer = 0

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 InstanciaObjetos()
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objDocumentos = New DB_MA_MANTENIMIENTOS.C_DOCUMENTO
    Set objMoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
    Set objCorrelativo = New DB_CORRELATIVO.C_Correlativos
End Sub

Private Sub CargaListaCriterios()
        lstAlmacen.Size 15, 30
        lstAlmacen.llena_lista objDocumentos.ListarDocumentos
End Sub

Private Sub CargaListaAlmacen()
        lstPtoVta.Size 15, 30
        lstPtoVta.llena_lista objAlmacen.ListarAlmacenesPorStatus(1)
End Sub




