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 = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.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 FReporteAnulaciones 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Reporte de Anulaciones (05.250.00)"
   ClientHeight    =   5160
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10695
   Icon            =   "0525000.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5160
   ScaleWidth      =   10695
   Begin TabDlg.SSTab SSTab1 
      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)   =   "0525000.frx":030A
      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)=   "lblMoneda"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Shape1"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Line1"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "Label7"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "lstCriterios"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "dtcMoneda"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "crVentasAnuladas"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).Control(10)=   "cmdSalir"
      Tab(0).Control(10).Enabled=   0   'False
      Tab(0).Control(11)=   "cmdGenerar"
      Tab(0).Control(11).Enabled=   0   'False
      Tab(0).Control(12)=   "Frame2"
      Tab(0).Control(12).Enabled=   0   'False
      Tab(0).Control(13)=   "Frame1"
      Tab(0).Control(13).Enabled=   0   'False
      Tab(0).ControlCount=   14
      TabCaption(1)   =   "Almacenes"
      TabPicture(1)   =   "0525000.frx":0326
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "cmdSalir2"
      Tab(1).Control(1)=   "lstAlmacen"
      Tab(1).Control(2)=   "cmdGenerar2"
      Tab(1).Control(3)=   "Label8"
      Tab(1).Control(4)=   "Label6"
      Tab(1).Control(5)=   "Line4"
      Tab(1).Control(6)=   "Line5"
      Tab(1).Control(7)=   "Image2"
      Tab(1).Control(8)=   "Shape2"
      Tab(1).Control(9)=   "Label1"
      Tab(1).ControlCount=   10
      Begin VB.Frame Frame1 
         Caption         =   "Formato"
         Height          =   855
         Left            =   240
         TabIndex        =   9
         Top             =   2940
         Visible         =   0   'False
         Width           =   3735
         Begin VB.OptionButton optResumido 
            Caption         =   "Resumido"
            Height          =   255
            Left            =   600
            TabIndex        =   11
            Top             =   360
            Width           =   1095
         End
         Begin VB.OptionButton optDetallado 
            Caption         =   "Detallado"
            Height          =   255
            Left            =   2040
            TabIndex        =   10
            Top             =   360
            Value           =   -1  'True
            Width           =   1095
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Rango de Fechas"
         Height          =   855
         Left            =   240
         TabIndex        =   4
         Top             =   1980
         Width           =   3735
         Begin MSComCtl2.DTPicker dtpFechaFin 
            Height          =   315
            Left            =   2280
            TabIndex        =   5
            Top             =   360
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   24641537
            CurrentDate     =   37533
         End
         Begin MSComCtl2.DTPicker dtpFechaIni 
            Height          =   315
            Left            =   480
            TabIndex        =   6
            Top             =   360
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   24641537
            CurrentDate     =   37533
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "Al"
            Height          =   195
            Left            =   2040
            TabIndex        =   8
            Top             =   420
            Width           =   135
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            Caption         =   "Del"
            Height          =   195
            Left            =   120
            TabIndex        =   7
            Top             =   420
            Width           =   240
         End
      End
      Begin VB.CommandButton cmdGenerar 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   240
         Picture         =   "0525000.frx":0342
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   4005
         Width           =   1335
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   855
         Left            =   1570
         Picture         =   "0525000.frx":064C
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   4005
         Width           =   1335
      End
      Begin VB.CommandButton cmdSalir2 
         Cancel          =   -1  'True
         Caption         =   "&Salir"
         Height          =   855
         Left            =   -66000
         Picture         =   "0525000.frx":0956
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   2760
         Width           =   1335
      End
      Begin Crystal.CrystalReport crVentasAnuladas 
         Left            =   3600
         Top             =   4185
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin MSDataListLib.DataCombo dtcMoneda 
         Height          =   315
         Left            =   1320
         TabIndex        =   13
         Top             =   1260
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin pry_list.ctrl_listarray lstCriterios 
         Height          =   2475
         Left            =   4410
         TabIndex        =   14
         Top             =   1800
         Width           =   5775
         _ExtentX        =   10186
         _ExtentY        =   4366
      End
      Begin pry_list.ctrl_listarray lstAlmacen 
         Height          =   2295
         Left            =   -73080
         TabIndex        =   15
         Top             =   1620
         Width           =   6630
         _ExtentX        =   11695
         _ExtentY        =   4048
      End
      Begin VB.CommandButton cmdGenerar2 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   -66000
         Picture         =   "0525000.frx":0C60
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Label Label8 
         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          =   240
         Left            =   -73020
         TabIndex        =   22
         Top             =   1350
         Width           =   6480
      End
      Begin VB.Label Label7 
         Alignment       =   2  'Center
         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            =   4470
         TabIndex        =   21
         Top             =   1500
         Width           =   5790
      End
      Begin VB.Label Label6 
         Caption         =   "REPORTE DE ANULACIONES"
         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        =   20
         Top             =   675
         Width           =   4500
      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            =   4200
         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         =   "0525000.frx":0F6A
         Top             =   480
         Width           =   480
      End
      Begin VB.Label lblMoneda 
         Caption         =   "Moneda"
         Height          =   195
         Left            =   240
         TabIndex        =   19
         Top             =   1320
         Width           =   585
      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        =   18
         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        =   17
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "REPORTE DE ANULACIONES"
         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        =   16
         Top             =   675
         Width           =   3360
      End
      Begin VB.Image Image1 
         Height          =   480
         Left            =   240
         Picture         =   "0525000.frx":1274
         Top             =   480
         Width           =   480
      End
   End
End
Attribute VB_Name = "FReporteAnulaciones"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'   PROGRAMADOR: JOE BREÑA HUACHIN
'   REPORTE DE ANULACIONES

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)
    
    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 lstCriterios.ndisponibles = 0 And lstCriterios.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 lstAlmacen.ndisponibles = 0 And lstAlmacen.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 lstCriterios.ndisponibles = 0 Or lstCriterios.nseleccionados = 0 Then
        MintTodos_Cri = 1
        MstrCadena_Criterios = " "
    Else
        MintTodos_Cri = 0
        If Len(lstCriterios.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 = lstCriterios.listar_codigos_seleccionados
        End If
    End If
        
    ' PARA LOS ALMACENES
    If lstAlmacen.ndisponibles = 0 Or lstAlmacen.nseleccionados = 0 Then
        MintTodos_Alm = 1
        MstrCadena_Almacenes = " "
    Else
        MintTodos_Alm = 0
        If Len(lstAlmacen.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 = lstAlmacen.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
        crVentasAnuladas.ReportFileName = GstrReportesVta + "rpt_VentasAnuladas.rpt"
       
        'crVentasAnuladas.StoredProcParam(0) = lngCorrelativo
        crVentasAnuladas.StoredProcParam(0) = MstrFechaIni
        crVentasAnuladas.StoredProcParam(1) = MstrFechaFin
        crVentasAnuladas.StoredProcParam(2) = dtcMoneda.BoundText
        crVentasAnuladas.StoredProcParam(3) = 1
        crVentasAnuladas.StoredProcParam(4) = MstrCadena_Almacenes
        crVentasAnuladas.StoredProcParam(5) = MintTodos_Alm
        crVentasAnuladas.StoredProcParam(6) = MstrCadena_Criterios
        crVentasAnuladas.StoredProcParam(7) = MintTodos_Cri
    Else
    
        crVentasAnuladas.ReportFileName = GstrReportesVta + "rpt_VentasAnuladas.rpt"
        
        crVentasAnuladas.StoredProcParam(0) = MstrFechaIni
        crVentasAnuladas.StoredProcParam(1) = MstrFechaFin
        crVentasAnuladas.StoredProcParam(2) = dtcMoneda.BoundText
        crVentasAnuladas.StoredProcParam(3) = 1
        crVentasAnuladas.StoredProcParam(4) = MstrCadena_Almacenes
        crVentasAnuladas.StoredProcParam(5) = MintTodos_Alm
        crVentasAnuladas.StoredProcParam(6) = MstrCadena_Criterios
        crVentasAnuladas.StoredProcParam(7) = MintTodos_Cri
    End If
        
    crVentasAnuladas.WindowTitle = "Registro de Anulaciones"
    crVentasAnuladas.Formulas(0) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
    crVentasAnuladas.Formulas(1) = "formscreen=stringvar strscreen; strscreen:='05.250.00'"
    crVentasAnuladas.Formulas(2) = "formMoneda=stringvar strMoneda; strMoneda:='" & Trim(dtcMoneda.Text) & "'"
    crVentasAnuladas.Formulas(3) = "formFechaIni= datevar FechaIni; FechaIni:=date(" & Format(DTPFechaIni.Value, "YYYY,MM,dd") & ")"
    crVentasAnuladas.Formulas(4) = "formFechaFin= datevar FechaFin; FechaFin:=date(" & Format(DTPFechaFin.Value, "YYYY,MM,dd") & ")"
    crVentasAnuladas.Formulas(5) = "formNDStock=" & GintDecStock
    crVentasAnuladas.Formulas(6) = "formNDCosto=" & GintDecCosto
    crVentasAnuladas.Formulas(7) = "formNDMonto=" & GintDecResultado
    crVentasAnuladas.Formulas(8) = "formNDPrecio=" & GintDecPrecio

    crVentasAnuladas.WindowState = crptMaximized
    crVentasAnuladas.WindowShowPrintSetupBtn = True
    
    crVentasAnuladas.Connect = "DSN=SIES"
    crVentasAnuladas.Action = 1
    
    crVentasAnuladas.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()
        lstCriterios.Size 15, 27
        lstCriterios.llena_lista objDocumentos.ListarDocumentos
End Sub

Private Sub CargaListaAlmacen()
        lstAlmacen.Size 15, 33
        lstAlmacen.llena_lista objAlmacen.ListarAlmacenesPorStatus(1)
End Sub
