VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.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 FEstadoCuenta 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Estado de Cuenta (08.020.00)"
   ClientHeight    =   6150
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10695
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   6150
   ScaleWidth      =   10695
   Begin TabDlg.SSTab SSTab1 
      Height          =   6135
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10695
      _ExtentX        =   18865
      _ExtentY        =   10821
      _Version        =   393216
      TabHeight       =   520
      TabCaption(0)   =   "Datos Generales"
      TabPicture(0)   =   "0802000.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Label2"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Image1"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "Label5"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "Line1"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Shape1"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Label7"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "Label11"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "Label12"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "lstCriterios"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "Frame3"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).Control(10)=   "fratipodocu"
      Tab(0).Control(10).Enabled=   0   'False
      Tab(0).Control(11)=   "cmdSalir"
      Tab(0).Control(11).Enabled=   0   'False
      Tab(0).Control(12)=   "Frame1"
      Tab(0).Control(12).Enabled=   0   'False
      Tab(0).Control(13)=   "Frame2"
      Tab(0).Control(13).Enabled=   0   'False
      Tab(0).Control(14)=   "cmdGenerar"
      Tab(0).Control(14).Enabled=   0   'False
      Tab(0).Control(15)=   "Frame4"
      Tab(0).Control(15).Enabled=   0   'False
      Tab(0).Control(16)=   "dtcmoneda"
      Tab(0).Control(16).Enabled=   0   'False
      Tab(0).Control(17)=   "CREstadoCuenta"
      Tab(0).Control(17).Enabled=   0   'False
      Tab(0).Control(18)=   "CmbTipoCliente"
      Tab(0).Control(18).Enabled=   0   'False
      Tab(0).ControlCount=   19
      TabCaption(1)   =   "Almacenes"
      TabPicture(1)   =   "0802000.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "cmdGenerar2"
      Tab(1).Control(1)=   "cmdSalir2"
      Tab(1).Control(2)=   "lstAlmacen"
      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
      TabCaption(2)   =   "Tipo de Documentos"
      TabPicture(2)   =   "0802000.frx":0038
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "cmdgenerar3"
      Tab(2).Control(1)=   "cmdsalir3"
      Tab(2).Control(2)=   "lstTipoDocumentos"
      Tab(2).Control(3)=   "Label10"
      Tab(2).Control(4)=   "Label9"
      Tab(2).Control(5)=   "Line3"
      Tab(2).Control(6)=   "Line2"
      Tab(2).Control(7)=   "Image3"
      Tab(2).Control(8)=   "Shape3"
      Tab(2).ControlCount=   9
      Begin VB.ComboBox CmbTipoCliente 
         Height          =   315
         ItemData        =   "0802000.frx":0054
         Left            =   7920
         List            =   "0802000.frx":005E
         Style           =   2  'Dropdown List
         TabIndex        =   38
         Top             =   720
         Width           =   2535
      End
      Begin Crystal.CrystalReport CREstadoCuenta 
         Left            =   3360
         Top             =   5280
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin MSDataListLib.DataCombo dtcmoneda 
         Height          =   315
         Left            =   4680
         TabIndex        =   36
         Top             =   720
         Visible         =   0   'False
         Width           =   2295
         _ExtentX        =   4048
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   "DataCombo1"
      End
      Begin VB.Frame Frame4 
         Caption         =   "Formato de Estado de Cuenta"
         Height          =   735
         Left            =   240
         TabIndex        =   30
         Top             =   1320
         Width           =   2535
         Begin VB.OptionButton OptDetalle 
            Caption         =   "Detalle"
            Height          =   255
            Left            =   1200
            TabIndex        =   32
            Top             =   360
            Width           =   975
         End
         Begin VB.OptionButton OptTodos 
            Caption         =   "Todos"
            Height          =   195
            Left            =   240
            TabIndex        =   31
            Top             =   360
            Value           =   -1  'True
            Width           =   1695
         End
      End
      Begin VB.CommandButton cmdgenerar3 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   -66000
         Picture         =   "0802000.frx":0075
         Style           =   1  'Graphical
         TabIndex        =   26
         Top             =   2160
         Width           =   1335
      End
      Begin VB.CommandButton cmdsalir3 
         Cancel          =   -1  'True
         Caption         =   "&Salir"
         Height          =   855
         Left            =   -66000
         Picture         =   "0802000.frx":037F
         Style           =   1  'Graphical
         TabIndex        =   25
         Top             =   3000
         Width           =   1335
      End
      Begin VB.CommandButton cmdGenerar2 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   -66000
         Picture         =   "0802000.frx":0689
         Style           =   1  'Graphical
         TabIndex        =   16
         Top             =   2220
         Width           =   1335
      End
      Begin VB.CommandButton cmdGenerar 
         Caption         =   "&Generar"
         Height          =   855
         Left            =   8040
         Picture         =   "0802000.frx":0993
         Style           =   1  'Graphical
         TabIndex        =   15
         Top             =   5100
         Width           =   1200
      End
      Begin VB.Frame Frame2 
         Caption         =   "Rango de Fechas"
         Height          =   1440
         Left            =   240
         TabIndex        =   10
         Top             =   2280
         Width           =   2505
         Begin VB.OptionButton OptFechaVenci 
            Caption         =   "Vencimiento"
            Height          =   255
            Left            =   1080
            TabIndex        =   34
            Top             =   240
            Visible         =   0   'False
            Width           =   1215
         End
         Begin VB.OptionButton OptFechaEmi 
            Caption         =   "Emisión "
            Height          =   255
            Left            =   120
            TabIndex        =   33
            Top             =   240
            Value           =   -1  'True
            Visible         =   0   'False
            Width           =   975
         End
         Begin MSComCtl2.DTPicker dtpFechaFin 
            Height          =   315
            Left            =   480
            TabIndex        =   11
            Top             =   915
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   22740993
            CurrentDate     =   37533
         End
         Begin MSComCtl2.DTPicker dtpFechaIni 
            Height          =   315
            Left            =   480
            TabIndex        =   12
            Top             =   480
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   556
            _Version        =   393216
            Format          =   22740993
            CurrentDate     =   37533
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            Caption         =   "Del"
            Height          =   195
            Left            =   120
            TabIndex        =   14
            Top             =   480
            Width           =   240
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "Al"
            Height          =   195
            Left            =   150
            TabIndex        =   13
            Top             =   915
            Width           =   135
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "Formato de Reporte"
         Height          =   990
         Left            =   240
         TabIndex        =   7
         Top             =   4680
         Width           =   2535
         Begin VB.OptionButton optDetallado 
            Caption         =   "Detallado"
            Height          =   255
            Left            =   420
            TabIndex        =   9
            Top             =   585
            Width           =   1095
         End
         Begin VB.OptionButton optResumido 
            Caption         =   "Resumido"
            Height          =   255
            Left            =   420
            TabIndex        =   8
            Top             =   270
            Value           =   -1  'True
            Width           =   1095
         End
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   855
         Left            =   9240
         Picture         =   "0802000.frx":0C9D
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   5100
         Width           =   1200
      End
      Begin VB.CommandButton cmdSalir2 
         Caption         =   "&Salir"
         Height          =   855
         Left            =   -66000
         Picture         =   "0802000.frx":0FA7
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   3060
         Width           =   1335
      End
      Begin VB.Frame fratipodocu 
         Caption         =   "Ordenado por"
         Height          =   735
         Left            =   4800
         TabIndex        =   3
         Top             =   5040
         Visible         =   0   'False
         Width           =   2535
         Begin VB.ComboBox cmbOrden 
            Height          =   315
            ItemData        =   "0802000.frx":12B1
            Left            =   120
            List            =   "0802000.frx":12C4
            Style           =   2  'Dropdown List
            TabIndex        =   4
            Top             =   240
            Width           =   2175
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Estado"
         Height          =   735
         Left            =   240
         TabIndex        =   1
         Top             =   3840
         Width           =   2535
         Begin VB.ComboBox cmbestado 
            Height          =   315
            ItemData        =   "0802000.frx":1304
            Left            =   120
            List            =   "0802000.frx":1311
            Style           =   2  'Dropdown List
            TabIndex        =   2
            Top             =   240
            Width           =   2175
         End
      End
      Begin pry_list.ctrl_listarray lstAlmacen 
         Height          =   3015
         Left            =   -73080
         TabIndex        =   17
         Top             =   1920
         Width           =   6630
         _ExtentX        =   11695
         _ExtentY        =   5318
      End
      Begin pry_list.ctrl_listarray lstCriterios 
         Height          =   2970
         Left            =   3120
         TabIndex        =   18
         Top             =   1680
         Width           =   7170
         _ExtentX        =   12647
         _ExtentY        =   5239
      End
      Begin pry_list.ctrl_listarray lstTipoDocumentos 
         Height          =   2295
         Left            =   -73080
         TabIndex        =   27
         Top             =   1860
         Width           =   6630
         _ExtentX        =   11695
         _ExtentY        =   4048
      End
      Begin VB.Label Label12 
         Caption         =   "Tipo de Cliente"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   6360
         TabIndex        =   37
         Top             =   720
         Width           =   1575
      End
      Begin VB.Label Label11 
         Caption         =   "Moneda"
         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            =   4680
         TabIndex        =   35
         Top             =   480
         Visible         =   0   'False
         Width           =   1815
      End
      Begin VB.Label Label10 
         Alignment       =   2  'Center
         Caption         =   "TIPO 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            =   -73020
         TabIndex        =   29
         Top             =   1590
         Width           =   6480
      End
      Begin VB.Label Label9 
         Caption         =   "REPORTE DE ESTADO DE CUENTA"
         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        =   28
         Top             =   915
         Width           =   6450
      End
      Begin VB.Line Line3 
         X1              =   -74760
         X2              =   -64560
         Y1              =   1200
         Y2              =   1200
      End
      Begin VB.Line Line2 
         X1              =   -74760
         X2              =   -64560
         Y1              =   4740
         Y2              =   4740
      End
      Begin VB.Image Image3 
         Height          =   480
         Left            =   -74760
         Picture         =   "0802000.frx":1334
         Top             =   720
         Width           =   480
      End
      Begin VB.Shape Shape3 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3000
         Left            =   -73380
         Top             =   1455
         Width           =   7185
      End
      Begin VB.Label Label7 
         Caption         =   "CLIENTES"
         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            =   5880
         TabIndex        =   24
         Top             =   1440
         Width           =   1005
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3525
         Left            =   3000
         Top             =   1320
         Width           =   7470
      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        =   23
         Top             =   1650
         Width           =   6480
      End
      Begin VB.Label Label6 
         Caption         =   "REPORTE DE ESTADO DE CUENTA"
         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        =   22
         Top             =   960
         Width           =   6450
      End
      Begin VB.Line Line1 
         X1              =   240
         X2              =   10320
         Y1              =   1140
         Y2              =   1140
      End
      Begin VB.Line Line4 
         X1              =   -74760
         X2              =   -64560
         Y1              =   1260
         Y2              =   1260
      End
      Begin VB.Line Line5 
         X1              =   -74760
         X2              =   -64560
         Y1              =   5280
         Y2              =   5280
      End
      Begin VB.Image Image2 
         Height          =   480
         Left            =   -74760
         Picture         =   "0802000.frx":163E
         Top             =   780
         Width           =   480
      End
      Begin VB.Shape Shape2 
         BackColor       =   &H80000004&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H80000006&
         Height          =   3600
         Left            =   -73380
         Top             =   1515
         Width           =   7185
      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            =   -70095
         TabIndex        =   21
         Top             =   1740
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "REPORTE DE ESTADO DE CUENTA"
         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        =   20
         Top             =   780
         Width           =   5700
      End
      Begin VB.Image Image1 
         Height          =   480
         Left            =   240
         Picture         =   "0802000.frx":1948
         Top             =   660
         Width           =   480
      End
      Begin VB.Label Label2 
         Caption         =   "CLIENTES"
         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            =   6120
         TabIndex        =   19
         Top             =   1620
         Width           =   1005
      End
   End
End
Attribute VB_Name = "FEstadoCuenta"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Se retiraron los Fuentes de la red el 24/04/2003
 
Option Explicit
' Manejo de la Seguridad

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

' Manejo de Búsquedas

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

Public objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Public objClientes As DB_MA_MANTENIMIENTOS.C_CLIENTE
Public objDocumentos As DB_MA_MANTENIMIENTOS.C_DOCUMENTO
Private MobjMoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
Private MobjCorrelativo As DB_CORRELATIVO.C_Correlativos
Private MobjCobranzas As DB_AR_CUENTASCOBRAR.C_COBRANZAS

Private MdblCorrelativo As Double

Dim MstrCadena_Criterios As String
Dim MstrCadena_Almacenes As String
Dim MstrCadena_TipoDocumentos As String

Dim MstrGrupo As String
Dim MintTodos_Alm As Integer
Dim MintTodos_Cri As Integer
Dim MintTodos_Docu As Integer

Dim MstrFechaIni As String
Dim MstrFechaFin As String

Private Sub InstanciaObjetos()
    
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objClientes = New DB_MA_MANTENIMIENTOS.C_CLIENTE
    Set objDocumentos = New DB_MA_MANTENIMIENTOS.C_DOCUMENTO
    Set MobjMoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
    Set MobjCorrelativo = New DB_CORRELATIVO.C_Correlativos
    Set MobjCobranzas = New DB_AR_CUENTASCOBRAR.C_COBRANZAS
    
End Sub

Private Sub CargaListaCriterios()
    lstCriterios.Size 15, 33
    lstCriterios.llena_lista objClientes.ListarClientesAyudaNocontado
End Sub

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

Private Sub CargaListaDocumentos()
    lstTipoDocumentos.Size 15, 27
    lstTipoDocumentos.llena_lista objDocumentos.ListarDocumentos
End Sub

Private Sub CmbTipoCliente_Change()
 If CmbTipoCliente.ListIndex = 0 Then
'    dtpFechaIni.Enabled = False
 Else
    dtpFechaIni.Enabled = True
 End If
End Sub

Private Sub CmbTipoCliente_Click()
 If CmbTipoCliente.ListIndex = 0 Then
'    dtpFechaIni.Enabled = False
    Frame3.Enabled = True
    cmbestado.Enabled = True
 Else
    dtpFechaIni.Enabled = True
    Frame3.Enabled = False
    cmbestado.Enabled = False
 End If
End Sub

Private Sub cmdGenerar_Click()


   Dim i As Integer
   Dim LArrayAlmacenes()
   Dim LArrayAlmacenesDispo()
   Dim LArrayClientes()
   Dim LArrayClientesDispo()
   Dim LArrayDocumentos()
   Dim LArrayDocumentosDispo()
   Dim LintFilas As Integer
   Dim MstrFechaIni As String
   Dim MstrFechaFin As String
                    
          
On Error GoTo errhandler
          
   Screen.MousePointer = 11
          
   MobjCobranzas.EliminarTmpAlmacenes (MdblCorrelativo)
   MobjCobranzas.EliminarTmpClientes (MdblCorrelativo)
   MobjCobranzas.EliminarTmpDocumentos (MdblCorrelativo)
          
  ' Se Asume que si no se ha seleccionado Nada son Todos
  
  ' Parte de Clientes
    LArrayClientes = lstCriterios.llenar_matriz
    
    If lstCriterios.ndisponibles > 0 Then
      LArrayClientesDispo = lstCriterios.llenar_matrizdisponibles
    End If
    
    LintFilas = UBound(LArrayClientes)
          
    If LintFilas = 0 Then ' No se ha seleccionado Ningún Cliente
       LintFilas = UBound(LArrayClientesDispo)
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpClientes MdblCorrelativo, LArrayClientesDispo(i, 1)
       Next
    Else
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpClientes MdblCorrelativo, LArrayClientes(i, 1)
       Next
    End If
         
  ' Parte de Almacenes

  ' Hay que Insertar en el Temporal de Almacenes
        
    LArrayAlmacenes = lstAlmacen.llenar_matriz
    If lstAlmacen.ndisponibles > 0 Then
      LArrayAlmacenesDispo = lstAlmacen.llenar_matrizdisponibles
    End If
    
    LintFilas = UBound(LArrayAlmacenes)
          
    If LintFilas = 0 Then ' No se ha seleccionado Ningún Almacen
       LintFilas = UBound(LArrayAlmacenesDispo)
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpAlmacenes MdblCorrelativo, LArrayAlmacenesDispo(i, 1)
       Next
    Else
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpAlmacenes MdblCorrelativo, LArrayAlmacenes(i, 1)
       Next
    End If
        
  ' Parte de Documentos
  
    LArrayDocumentos = lstTipoDocumentos.llenar_matriz
    
    If lstTipoDocumentos.ndisponibles > 0 Then
       LArrayDocumentosDispo = lstTipoDocumentos.llenar_matrizdisponibles
    End If
     
    LintFilas = UBound(LArrayDocumentos)
          
    If LintFilas = 0 Then ' No se ha seleccionado Ningún Cliente
       LintFilas = UBound(LArrayDocumentosDispo)
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpDocumentos MdblCorrelativo, LArrayDocumentosDispo(i, 1)
       Next
    Else
       For i = 1 To LintFilas
           MobjCobranzas.GrabarTmpDocumentos MdblCorrelativo, LArrayDocumentos(i, 1)
       Next
    End If
  
    CREstadoCuenta.Reset
    If CmbTipoCliente.ListIndex = 0 Then
        If OptTodos.Value = True Then
           CREstadoCuenta.ReportFileName = GstrReportesVta + "Rpt_EstadoCuentaTotal.rpt"
           CREstadoCuenta.WindowTitle = "Reporte de Estado de Cuenta"
           CREstadoCuenta.StoredProcParam(0) = MdblCorrelativo
           CREstadoCuenta.StoredProcParam(1) = cmbestado.ListIndex
           CREstadoCuenta.StoredProcParam(2) = CStr(Format(dtpFechaIni.Value, "YYYYMMdd"))
           CREstadoCuenta.StoredProcParam(3) = CStr(Format(dtpFechaFin.Value, "YYYYMMdd"))
                     
           
           CREstadoCuenta.Formulas(0) = "formusuario='" + GCUSERID + "'"
           CREstadoCuenta.Formulas(1) = "formscreen='08.020.00'"
           CREstadoCuenta.Formulas(2) = "formdecresultado=" + Str(GintDecResultado)
           CREstadoCuenta.Formulas(3) = "formfecha='" + CStr(Format(dtpFechaFin.Value, "dd/MM/YYYY")) + "'"
           
           
           CREstadoCuenta.WindowState = crptMaximized
           CREstadoCuenta.WindowShowPrintSetupBtn = True
           CREstadoCuenta.WindowShowExportBtn = True
           CREstadoCuenta.WindowShowSearchBtn = True
           CREstadoCuenta.Action = 1
         End If
     Else
        If OptTodos.Value = True Then
           CREstadoCuenta.ReportFileName = GstrReportesVta + "rpt_EstacoCuentaAdelantado.rpt"
           CREstadoCuenta.WindowTitle = "Reporte de Estado de Cuenta"
           CREstadoCuenta.StoredProcParam(0) = MdblCorrelativo
           
           MstrFechaIni = CStr(Format(dtpFechaIni.Value, "YYYYMMdd"))
           MstrFechaFin = CStr(Format(dtpFechaFin.Value, "YYYYMMdd"))
            
           CREstadoCuenta.StoredProcParam(1) = MstrFechaIni
           CREstadoCuenta.StoredProcParam(2) = MstrFechaFin
           
           CREstadoCuenta.Formulas(0) = "formusuario='" + GCUSERID + "'"
           CREstadoCuenta.Formulas(1) = "formscreen='08.020.00'"
           CREstadoCuenta.Formulas(2) = "formdecresultado=" + Str(GintDecResultado)
           CREstadoCuenta.WindowState = crptMaximized
           CREstadoCuenta.WindowShowPrintSetupBtn = True
           CREstadoCuenta.WindowShowExportBtn = True
           CREstadoCuenta.WindowShowSearchBtn = True
           CREstadoCuenta.Action = 1
        End If
     End If
     
     Screen.MousePointer = 0
          
Exit Sub

errhandler:
     Screen.MousePointer = 0
     MsgBox Err.Description, vbDefaultButton1 + vbExclamation, "Advertencia"
                      
End Sub

Private Sub cmdGenerar2_Click()
   cmdGenerar_Click
End Sub

Private Sub cmdgenerar3_Click()
  cmdGenerar_Click
End Sub

Private Sub cmdsalir_Click()
  Unload Me
End Sub

Private Sub cmdSalir2_Click()
  Unload Me
End Sub

Private Sub cmdsalir3_Click()
 Unload Me
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_Load()
    
    Call gseguridad(Me)
    
    If pbderecho_consultar Then
        InstanciaObjetos
        CargaListaCriterios
        CargaListaAlmacen
        CargaListaDocumentos
        
        Call CargaDataCombo(dtcmoneda, MobjMoneda.ListarMonedas, "CuryId", "Descr")
        dtcmoneda.BoundText = GstrCodMonedaBase
            
        'Hay que Obtener un Correlativo
            
        MdblCorrelativo = MobjCorrelativo.ObtenerCorrelativo(GCUSERID)
        OptTodos_Click
    Else
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    End If
     
    dtpFechaIni.Value = Date
    dtpFechaIni.Day = 1
    dtpFechaFin.Value = Date
    cmbestado.ListIndex = 0
    
    ' Estos controles se habilitan por ser primero credito
      CmbTipoCliente.ListIndex = 0
'      dtpFechaIni.Enabled = False
      Frame3.Enabled = True
      cmbestado.Enabled = True
      
      Frame1.Visible = False
    ' ****************************************************

    SSTab1.Tab = 0
    OptDetalle.Visible = False
    Me.Top = 200
    Me.Width = 10815
    Me.Left = (Screen.Width - Me.Width) / 2

End Sub

Function valida_datos()
    valida_datos = True
End Function

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

Private Sub Form_Unload(Cancel As Integer)

    Set objAlmacen = Nothing
    Set objClientes = Nothing
    Set objDocumentos = Nothing
    Set MobjMoneda = Nothing
    Set MobjCorrelativo = Nothing
    
    MobjCobranzas.EliminarTmpAlmacenes (MdblCorrelativo)
    MobjCobranzas.EliminarTmpClientes (MdblCorrelativo)
    MobjCobranzas.EliminarTmpDocumentos (MdblCorrelativo)

    Set MobjCobranzas = Nothing
    
End Sub

Sub Actualizar_Registro()

End Sub
Sub imprimir()

End Sub

Private Sub OptDetalle_Click()
   
   If OptDetalle.Value = True Then
      Frame1.Enabled = True
      'Frame2.Enabled = True
      Frame3.Enabled = True
   Else
      Frame1.Enabled = False
      'Frame2.Enabled = False
      Frame3.Enabled = False
   End If
   
End Sub

Private Sub OptTodos_Click()
   
   If OptTodos.Value = True Then
      Frame1.Enabled = False
      'Frame2.Enabled = False
      Frame3.Enabled = False
   Else
      Frame1.Enabled = True
      'Frame2.Enabled = True
      Frame3.Enabled = True
   End If
   
End Sub
