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 = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Object = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#50.0#0"; "pry_list.ocx"
Begin VB.Form FDocuPorCobrar 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ingreso o Emisión de Documentos por Cobrar (08.010.00)"
   ClientHeight    =   7230
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10905
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   7230
   ScaleWidth      =   10905
   Begin VB.CheckBox Check1 
      Caption         =   "Check1"
      Height          =   225
      Left            =   90
      TabIndex        =   82
      Top             =   7560
      Visible         =   0   'False
      Width           =   885
   End
   Begin MiControl.CtrlNumber CtrlNumber1 
      Height          =   315
      Left            =   60
      TabIndex        =   81
      Top             =   7215
      Visible         =   0   'False
      Width           =   1350
      _ExtentX        =   2381
      _ExtentY        =   556
      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.CommandButton cmdnuevo 
      Caption         =   "Nuevo"
      Height          =   600
      Left            =   7980
      TabIndex        =   22
      Top             =   7380
      Width           =   1320
   End
   Begin VB.CommandButton cmdsalir 
      Caption         =   "Salir"
      Height          =   600
      Left            =   9465
      TabIndex        =   21
      Top             =   7380
      Width           =   1335
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   7110
      Left            =   0
      TabIndex        =   0
      Top             =   75
      Width           =   10800
      _ExtentX        =   19050
      _ExtentY        =   12541
      _Version        =   393216
      Tab             =   1
      TabHeight       =   520
      MouseIcon       =   "0801000.frx":0000
      TabCaption(0)   =   "Datos Generales"
      TabPicture(0)   =   "0801000.frx":031A
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "lblfactura"
      Tab(0).Control(1)=   "lblncredito"
      Tab(0).Control(2)=   "lblterms"
      Tab(0).Control(3)=   "Label19"
      Tab(0).Control(4)=   "Image1"
      Tab(0).Control(5)=   "Label7"
      Tab(0).Control(6)=   "lblfechavenci"
      Tab(0).Control(7)=   "FraClientes"
      Tab(0).Control(8)=   "FraFiltrar"
      Tab(0).Control(9)=   "FraFormato"
      Tab(0).Control(10)=   "FraAlmacenes"
      Tab(0).Control(11)=   "FraCorrelativos"
      Tab(0).Control(12)=   "Frame1"
      Tab(0).ControlCount=   13
      TabCaption(1)   =   "Obtener Resultados"
      TabPicture(1)   =   "0801000.frx":0336
      Tab(1).ControlEnabled=   -1  'True
      Tab(1).Control(0)=   "lblresultados"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).Control(1)=   "Label18"
      Tab(1).Control(1).Enabled=   0   'False
      Tab(1).Control(2)=   "lbligv"
      Tab(1).Control(2).Enabled=   0   'False
      Tab(1).Control(3)=   "lblnoafecto"
      Tab(1).Control(3).Enabled=   0   'False
      Tab(1).Control(4)=   "lblsubtotal"
      Tab(1).Control(4).Enabled=   0   'False
      Tab(1).Control(5)=   "Label15"
      Tab(1).Control(5).Enabled=   0   'False
      Tab(1).Control(6)=   "lbligvmon"
      Tab(1).Control(6).Enabled=   0   'False
      Tab(1).Control(7)=   "lblnoafectomon"
      Tab(1).Control(7).Enabled=   0   'False
      Tab(1).Control(8)=   "lblsubtotalmon"
      Tab(1).Control(8).Enabled=   0   'False
      Tab(1).Control(9)=   "lbltotal"
      Tab(1).Control(9).Enabled=   0   'False
      Tab(1).Control(10)=   "lbltotalmon"
      Tab(1).Control(10).Enabled=   0   'False
      Tab(1).Control(11)=   "lblvencipro"
      Tab(1).Control(11).Enabled=   0   'False
      Tab(1).Control(12)=   "Label22"
      Tab(1).Control(12).Enabled=   0   'False
      Tab(1).Control(13)=   "DbDocumentos"
      Tab(1).Control(13).Enabled=   0   'False
      Tab(1).Control(14)=   "DbVales"
      Tab(1).Control(14).Enabled=   0   'False
      Tab(1).Control(15)=   "DbArticulos"
      Tab(1).Control(15).Enabled=   0   'False
      Tab(1).Control(16)=   "Dbresumenarticulos"
      Tab(1).Control(16).Enabled=   0   'False
      Tab(1).Control(17)=   "cmdacumulaart"
      Tab(1).Control(17).Enabled=   0   'False
      Tab(1).Control(18)=   "Frame2"
      Tab(1).Control(18).Enabled=   0   'False
      Tab(1).Control(19)=   "Frame3"
      Tab(1).Control(19).Enabled=   0   'False
      Tab(1).Control(20)=   "cmdgenerar"
      Tab(1).Control(20).Enabled=   0   'False
      Tab(1).Control(21)=   "CrFactura"
      Tab(1).Control(21).Enabled=   0   'False
      Tab(1).Control(22)=   "CrNcredito"
      Tab(1).Control(22).Enabled=   0   'False
      Tab(1).Control(23)=   "cmdpreciopromed"
      Tab(1).Control(23).Enabled=   0   'False
      Tab(1).Control(24)=   "cmdcambioprecio"
      Tab(1).Control(24).Enabled=   0   'False
      Tab(1).ControlCount=   25
      TabCaption(2)   =   "Consultar / Anular"
      TabPicture(2)   =   "0801000.frx":0490
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "crReporte"
      Tab(2).Control(1)=   "Frame4"
      Tab(2).Control(2)=   "cmdReimprimir"
      Tab(2).Control(3)=   "cmdAnular"
      Tab(2).Control(4)=   "DBDetalle"
      Tab(2).Control(5)=   "Line1"
      Tab(2).Control(6)=   "Shape1"
      Tab(2).Control(7)=   "lbltotalcons"
      Tab(2).Control(8)=   "lbligvcons"
      Tab(2).Control(9)=   "lblSubtotalNoafecto"
      Tab(2).Control(10)=   "lblSubtotalafecto"
      Tab(2).Control(11)=   "lbldesTotal"
      Tab(2).Control(12)=   "lbldesIgv"
      Tab(2).Control(13)=   "lbldescNoafecto"
      Tab(2).Control(14)=   "lbldescafecto"
      Tab(2).ControlCount=   15
      Begin Crystal.CrystalReport crReporte 
         Left            =   -65280
         Top             =   1560
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin VB.CommandButton cmdcambioprecio 
         Caption         =   " TPC"
         Height          =   945
         Left            =   9600
         Picture         =   "0801000.frx":04AC
         Style           =   1  'Graphical
         TabIndex        =   56
         Top             =   3240
         Width           =   1095
      End
      Begin VB.CommandButton cmdpreciopromed 
         Caption         =   "Precio Promedio "
         Height          =   945
         Left            =   9600
         Picture         =   "0801000.frx":07B6
         Style           =   1  'Graphical
         TabIndex        =   57
         Top             =   4320
         Width           =   1095
      End
      Begin VB.Frame Frame4 
         Height          =   2625
         Left            =   -74775
         TabIndex        =   86
         Top             =   480
         Width           =   9015
         Begin VB.CommandButton cmdbuscarnumero 
            Height          =   375
            Left            =   4485
            MouseIcon       =   "0801000.frx":0AC0
            MousePointer    =   99  'Custom
            Picture         =   "0801000.frx":0C12
            Style           =   1  'Graphical
            TabIndex        =   116
            ToolTipText     =   "Buscar Documento"
            Top             =   1005
            Width           =   585
         End
         Begin VB.CommandButton cmdbuscartipodocu 
            Height          =   375
            Left            =   4485
            MouseIcon       =   "0801000.frx":1144
            MousePointer    =   99  'Custom
            Picture         =   "0801000.frx":1296
            Style           =   1  'Graphical
            TabIndex        =   96
            ToolTipText     =   "Buscar Documento"
            Top             =   615
            Width           =   585
         End
         Begin MSDataListLib.DataCombo DtcAlmacenes 
            Height          =   315
            Left            =   1605
            TabIndex        =   95
            Top             =   270
            Width           =   2805
            _ExtentX        =   4948
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   ""
         End
         Begin MSDataListLib.DataCombo DtcTipoDocument 
            Height          =   315
            Left            =   1605
            TabIndex        =   93
            Top             =   642
            Width           =   2805
            _ExtentX        =   4948
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   ""
         End
         Begin VB.TextBox txtnumero 
            Height          =   300
            Left            =   1605
            TabIndex        =   91
            Top             =   1014
            Width           =   1620
         End
         Begin VB.CommandButton cmdbuscaralmacen 
            Height          =   375
            Left            =   4485
            MouseIcon       =   "0801000.frx":17C8
            MousePointer    =   99  'Custom
            Picture         =   "0801000.frx":191A
            Style           =   1  'Graphical
            TabIndex        =   87
            ToolTipText     =   "Buscar Documento"
            Top             =   210
            Width           =   585
         End
         Begin VB.Label lblnnumguias 
            Caption         =   "_"
            Height          =   255
            Left            =   3360
            TabIndex        =   125
            Top             =   1680
            Width           =   1935
         End
         Begin VB.Label lblcodstatus 
            Height          =   375
            Left            =   6225
            TabIndex        =   119
            Top             =   1410
            Visible         =   0   'False
            Width           =   465
         End
         Begin VB.Label lblestado 
            BorderStyle     =   1  'Fixed Single
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   6870
            TabIndex        =   118
            Top             =   1395
            Width           =   1800
         End
         Begin VB.Label Label30 
            AutoSize        =   -1  'True
            Caption         =   "Estado"
            Height          =   195
            Left            =   5475
            TabIndex        =   117
            Top             =   1448
            Width           =   495
         End
         Begin VB.Label Lblmoneda 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   6870
            TabIndex        =   115
            Top             =   1030
            Width           =   1800
         End
         Begin VB.Label Label32 
            AutoSize        =   -1  'True
            Caption         =   "Moneda"
            Height          =   195
            Left            =   5475
            TabIndex        =   114
            Top             =   1083
            Width           =   585
         End
         Begin VB.Label lblfechaproceso 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   6870
            TabIndex        =   105
            Top             =   665
            Width           =   1800
         End
         Begin VB.Label lblfechadocu 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   6870
            TabIndex        =   104
            Top             =   300
            Width           =   1800
         End
         Begin VB.Label lblrazonsocialcons 
            BorderStyle     =   1  'Fixed Single
            Height          =   315
            Left            =   1605
            TabIndex        =   103
            Top             =   2085
            Width           =   4170
         End
         Begin VB.Label lblruc 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   1605
            TabIndex        =   102
            Top             =   1728
            Width           =   1620
         End
         Begin VB.Label Label29 
            AutoSize        =   -1  'True
            Caption         =   "Ruc"
            Height          =   195
            Left            =   150
            TabIndex        =   101
            Top             =   1781
            Width           =   300
         End
         Begin VB.Label lblcodclientecons 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   1605
            TabIndex        =   100
            Top             =   1371
            Width           =   1620
         End
         Begin VB.Label Label16 
            AutoSize        =   -1  'True
            Caption         =   "Razón Social"
            Height          =   195
            Left            =   150
            TabIndex        =   99
            Top             =   2145
            Width           =   945
         End
         Begin VB.Label Label14 
            Height          =   285
            Left            =   1635
            TabIndex        =   98
            Top             =   1395
            Width           =   1695
         End
         Begin VB.Label Label12 
            AutoSize        =   -1  'True
            Caption         =   "Cliente"
            Height          =   195
            Left            =   150
            TabIndex        =   97
            Top             =   1424
            Width           =   480
         End
         Begin VB.Label Label28 
            AutoSize        =   -1  'True
            Caption         =   "Almacén"
            Height          =   195
            Left            =   150
            TabIndex        =   94
            Top             =   330
            Width           =   615
         End
         Begin VB.Label Label27 
            AutoSize        =   -1  'True
            Caption         =   "Número "
            Height          =   195
            Left            =   150
            TabIndex        =   92
            Top             =   1067
            Width           =   600
         End
         Begin VB.Label Label26 
            AutoSize        =   -1  'True
            Caption         =   "Tipo de Documento"
            Height          =   195
            Left            =   150
            TabIndex        =   90
            Top             =   702
            Width           =   1410
         End
         Begin VB.Label Label21 
            AutoSize        =   -1  'True
            Caption         =   "Fecha Documento"
            Height          =   195
            Left            =   5475
            TabIndex        =   89
            Top             =   353
            Width           =   1320
         End
         Begin VB.Label Label23 
            AutoSize        =   -1  'True
            Caption         =   "Fecha Proceso"
            Height          =   195
            Left            =   5475
            TabIndex        =   88
            Top             =   718
            Width           =   1080
         End
         Begin VB.Image Image2 
            Height          =   690
            Left            =   7905
            Picture         =   "0801000.frx":1E4C
            Stretch         =   -1  'True
            Top             =   1800
            Width           =   690
         End
      End
      Begin VB.CommandButton cmdReimprimir 
         Caption         =   "Imprimir"
         Height          =   825
         Left            =   -65625
         Picture         =   "0801000.frx":2156
         Style           =   1  'Graphical
         TabIndex        =   85
         Top             =   5025
         Width           =   1275
      End
      Begin VB.CommandButton cmdAnular 
         Caption         =   "Anular"
         Height          =   825
         Left            =   -65625
         Picture         =   "0801000.frx":2460
         Style           =   1  'Graphical
         TabIndex        =   84
         Top             =   4200
         Width           =   1275
      End
      Begin MSDataGridLib.DataGrid DBDetalle 
         Height          =   2820
         Left            =   -74775
         TabIndex        =   83
         Top             =   3180
         Width           =   9015
         _ExtentX        =   15901
         _ExtentY        =   4974
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {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
         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
         Caption         =   "Detalle de Documento"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin Crystal.CrystalReport CrNcredito 
         Left            =   10080
         Top             =   6240
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin Crystal.CrystalReport CrFactura 
         Left            =   9690
         Top             =   6240
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin VB.CommandButton cmdgenerar 
         Caption         =   "Generar Documentos"
         Enabled         =   0   'False
         Height          =   705
         Left            =   9600
         TabIndex        =   70
         Top             =   5520
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Frame Frame3 
         Height          =   1425
         Left            =   6075
         TabIndex        =   65
         Top             =   435
         Width           =   3420
         Begin VB.TextBox txtncreditoproce 
            Height          =   285
            Left            =   1800
            MaxLength       =   10
            TabIndex        =   72
            Top             =   960
            Width           =   1380
         End
         Begin VB.TextBox txtfacturaproce 
            Height          =   285
            Left            =   1800
            MaxLength       =   10
            TabIndex        =   71
            Top             =   600
            Width           =   1380
         End
         Begin VB.Label Label25 
            AutoSize        =   -1  'True
            Caption         =   "N.Crédito"
            Height          =   195
            Left            =   240
            TabIndex        =   69
            Top             =   1005
            Width           =   660
         End
         Begin VB.Label Label24 
            AutoSize        =   -1  'True
            Caption         =   "Factura"
            Height          =   195
            Left            =   240
            TabIndex        =   68
            Top             =   645
            Width           =   540
         End
         Begin VB.Label lblfechaemi 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   1  'Fixed Single
            ForeColor       =   &H80000008&
            Height          =   285
            Left            =   1800
            TabIndex        =   67
            Top             =   240
            Width           =   1380
         End
         Begin VB.Label Label20 
            AutoSize        =   -1  'True
            Caption         =   "Fecha de Proceso"
            Height          =   195
            Left            =   240
            TabIndex        =   66
            Top             =   285
            Width           =   1305
         End
      End
      Begin VB.Frame Frame2 
         Height          =   1425
         Left            =   195
         TabIndex        =   58
         Top             =   435
         Width           =   5850
         Begin VB.Label Label17 
            AutoSize        =   -1  'True
            Caption         =   "Razón Social"
            Height          =   195
            Left            =   120
            TabIndex        =   64
            Top             =   1028
            Width           =   945
         End
         Begin VB.Label lblrazonsocialpro 
            BackColor       =   &H80000009&
            BorderStyle     =   1  'Fixed Single
            Height          =   270
            Left            =   1155
            TabIndex        =   63
            Top             =   990
            Width           =   4515
         End
         Begin VB.Label lblrucpro 
            BorderStyle     =   1  'Fixed Single
            Height          =   270
            Left            =   1155
            TabIndex        =   62
            Top             =   615
            Width           =   1680
         End
         Begin VB.Label Label13 
            AutoSize        =   -1  'True
            Caption         =   "RUC"
            Height          =   195
            Left            =   120
            TabIndex        =   61
            Top             =   653
            Width           =   345
         End
         Begin VB.Label lblcodclientepro 
            BorderStyle     =   1  'Fixed Single
            Height          =   270
            Left            =   1155
            TabIndex        =   60
            Top             =   240
            Width           =   1695
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Cod. Cliente"
            Height          =   195
            Left            =   120
            TabIndex        =   59
            Top             =   278
            Width           =   855
         End
      End
      Begin VB.CommandButton cmdacumulaart 
         Caption         =   "Acumulado por Artículo"
         Height          =   945
         Left            =   9600
         Picture         =   "0801000.frx":276A
         Style           =   1  'Graphical
         TabIndex        =   55
         Top             =   2160
         Width           =   1095
      End
      Begin MSDataGridLib.DataGrid Dbresumenarticulos 
         Height          =   4245
         Left            =   195
         TabIndex        =   54
         ToolTipText     =   "El precio es el último registrado en el rango de fechas seleccionado"
         Top             =   1995
         Width           =   9300
         _ExtentX        =   16404
         _ExtentY        =   7488
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {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
         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
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin MSDataGridLib.DataGrid DbArticulos 
         Height          =   1395
         Left            =   195
         TabIndex        =   42
         Top             =   4785
         Width           =   6570
         _ExtentX        =   11589
         _ExtentY        =   2461
         _Version        =   393216
         BackColor       =   16777152
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {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
         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
         Caption         =   "Artículos"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.Frame Frame1 
         Height          =   1365
         Left            =   -74805
         TabIndex        =   35
         Top             =   2370
         Width           =   4320
         Begin MSDataListLib.DataCombo Dtcmoneda 
            Height          =   315
            Left            =   1920
            TabIndex        =   36
            Top             =   960
            Width           =   2010
            _ExtentX        =   3545
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   "DataCombo1"
         End
         Begin MSComCtl2.DTPicker DTPEmision 
            Height          =   300
            Left            =   1920
            TabIndex        =   126
            Top             =   240
            Width           =   1350
            _ExtentX        =   2381
            _ExtentY        =   529
            _Version        =   393216
            Enabled         =   0   'False
            Format          =   60751873
            CurrentDate     =   37648
         End
         Begin MSComCtl2.DTPicker DTPFechaDocu 
            Height          =   300
            Left            =   1920
            TabIndex        =   127
            Top             =   600
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   529
            _Version        =   393216
            Format          =   60751873
            CurrentDate     =   38141
         End
         Begin VB.Label Label31 
            AutoSize        =   -1  'True
            Caption         =   "Fecha Documento"
            Height          =   195
            Left            =   360
            TabIndex        =   124
            Top             =   660
            Width           =   1320
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "Fecha de Proceso"
            Height          =   195
            Left            =   360
            TabIndex        =   38
            Top             =   300
            Width           =   1305
         End
         Begin VB.Label Label11 
            AutoSize        =   -1  'True
            Caption         =   "Moneda"
            Height          =   195
            Left            =   360
            TabIndex        =   37
            Top             =   1020
            Width           =   585
         End
      End
      Begin VB.Frame FraCorrelativos 
         Height          =   1710
         Left            =   -68370
         TabIndex        =   28
         Top             =   555
         Width           =   3765
         Begin VB.TextBox txtfactura 
            Height          =   300
            Left            =   1995
            MaxLength       =   7
            TabIndex        =   30
            Top             =   315
            Width           =   1650
         End
         Begin VB.TextBox txtncredito 
            Height          =   300
            Left            =   1995
            MaxLength       =   7
            TabIndex        =   29
            Top             =   765
            Width           =   1650
         End
         Begin MSDataListLib.DataCombo Dtcfactura 
            Height          =   315
            Left            =   780
            TabIndex        =   31
            Top             =   300
            Width           =   1095
            _ExtentX        =   1931
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   "DataCombo1"
         End
         Begin MSDataListLib.DataCombo dtcncredito 
            Height          =   315
            Left            =   780
            TabIndex        =   32
            Top             =   720
            Width           =   1095
            _ExtentX        =   1931
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   "DataCombo1"
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            Caption         =   "Factura"
            Height          =   195
            Left            =   60
            TabIndex        =   34
            Top             =   360
            Width           =   540
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            Caption         =   "N.Crédito"
            Height          =   195
            Left            =   60
            TabIndex        =   33
            Top             =   780
            Width           =   660
         End
      End
      Begin VB.Frame FraAlmacenes 
         Caption         =   "Almacenes"
         Height          =   2895
         Left            =   -74820
         TabIndex        =   26
         Top             =   3915
         Width           =   6360
         Begin pry_list.ctrl_listarray ListRAlmacenes 
            Height          =   2115
            Left            =   195
            TabIndex        =   27
            Top             =   525
            Width           =   5835
            _ExtentX        =   10292
            _ExtentY        =   3731
         End
      End
      Begin VB.Frame FraFormato 
         Caption         =   "Formato"
         Height          =   1365
         Left            =   -67575
         TabIndex        =   9
         Top             =   2370
         Width           =   2985
         Begin VB.OptionButton Optdetallado 
            Caption         =   "Detallado"
            Height          =   300
            Left            =   525
            TabIndex        =   11
            Top             =   765
            Width           =   1095
         End
         Begin VB.OptionButton Optresumido 
            Caption         =   "Resumido"
            Height          =   225
            Left            =   540
            TabIndex        =   10
            Top             =   435
            Value           =   -1  'True
            Width           =   1035
         End
      End
      Begin VB.Frame FraFiltrar 
         Caption         =   "Filtrar Documentos"
         Height          =   1365
         Left            =   -70425
         TabIndex        =   6
         Top             =   2370
         Width           =   2745
         Begin MSComCtl2.DTPicker DTPAL 
            Height          =   300
            Left            =   915
            TabIndex        =   8
            Top             =   720
            Width           =   1260
            _ExtentX        =   2223
            _ExtentY        =   529
            _Version        =   393216
            Format          =   60751873
            CurrentDate     =   37700
         End
         Begin MSComCtl2.DTPicker DTPDel 
            Height          =   300
            Left            =   915
            TabIndex        =   7
            Top             =   360
            Width           =   1260
            _ExtentX        =   2223
            _ExtentY        =   529
            _Version        =   393216
            Format          =   60751873
            CurrentDate     =   37648
         End
         Begin VB.Label Label10 
            AutoSize        =   -1  'True
            Caption         =   "Al"
            Height          =   195
            Left            =   420
            TabIndex        =   17
            Top             =   780
            Width           =   135
         End
         Begin VB.Label Label9 
            AutoSize        =   -1  'True
            Caption         =   "Del"
            Height          =   195
            Left            =   420
            TabIndex        =   16
            Top             =   420
            Width           =   240
         End
      End
      Begin VB.Frame FraClientes 
         Caption         =   "Cliente"
         Height          =   1710
         Left            =   -74805
         TabIndex        =   12
         Top             =   555
         Width           =   6375
         Begin VB.CommandButton cdmbuscararticulo 
            Enabled         =   0   'False
            Height          =   375
            Left            =   3060
            Picture         =   "0801000.frx":2BAC
            Style           =   1  'Graphical
            TabIndex        =   2
            Top             =   255
            Width           =   495
         End
         Begin VB.TextBox txtdireccion 
            Height          =   285
            Left            =   1620
            TabIndex        =   5
            Top             =   1080
            Width           =   4545
         End
         Begin VB.TextBox TxtRuc 
            Height          =   315
            Left            =   1620
            MaxLength       =   11
            TabIndex        =   1
            Top             =   285
            Width           =   1350
         End
         Begin VB.Label lblcodmonedabase 
            Height          =   330
            Left            =   5535
            TabIndex        =   53
            Top             =   270
            Visible         =   0   'False
            Width           =   645
         End
         Begin VB.Label LblTipoCambio 
            Height          =   360
            Left            =   5520
            TabIndex        =   41
            Top             =   255
            Visible         =   0   'False
            Width           =   585
         End
         Begin VB.Label lblclascliente 
            Height          =   375
            Left            =   5475
            TabIndex        =   20
            Top             =   240
            Visible         =   0   'False
            Width           =   615
         End
         Begin VB.Label lblcodcliente 
            BorderStyle     =   1  'Fixed Single
            Height          =   300
            Left            =   3660
            TabIndex        =   3
            Top             =   285
            Width           =   1695
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            Caption         =   "Dirección"
            Height          =   195
            Left            =   330
            TabIndex        =   15
            Top             =   1125
            Width           =   675
         End
         Begin VB.Label lblrazonsocial 
            BackColor       =   &H80000009&
            BorderStyle     =   1  'Fixed Single
            Height          =   285
            Left            =   1620
            TabIndex        =   4
            Top             =   697
            Width           =   4545
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            Caption         =   "Razón Social"
            Height          =   195
            Left            =   330
            TabIndex        =   14
            Top             =   742
            Width           =   945
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "RUC"
            Height          =   195
            Left            =   330
            TabIndex        =   13
            Top             =   345
            Width           =   345
         End
      End
      Begin MSDataGridLib.DataGrid DbVales 
         Height          =   1440
         Left            =   6885
         TabIndex        =   23
         Top             =   4785
         Width           =   2565
         _ExtentX        =   4524
         _ExtentY        =   2540
         _Version        =   393216
         BackColor       =   -2147483624
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {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
         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
         Caption         =   "Vales"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin MSDataGridLib.DataGrid DbDocumentos 
         Height          =   2730
         Left            =   210
         TabIndex        =   24
         Top             =   1995
         Width           =   9240
         _ExtentX        =   16298
         _ExtentY        =   4815
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {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
         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
         Caption         =   "Documentos -[Barra Espaciadora] Selecionar Registros"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.Label Label22 
         Caption         =   "Fecha de Vencimiento"
         Height          =   255
         Left            =   9000
         TabIndex        =   123
         Top             =   5280
         Visible         =   0   'False
         Width           =   1650
      End
      Begin VB.Label lblvencipro 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   9360
         TabIndex        =   122
         Top             =   5640
         Visible         =   0   'False
         Width           =   1320
      End
      Begin VB.Label lblfechavenci 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   -66600
         TabIndex        =   121
         Top             =   5640
         Visible         =   0   'False
         Width           =   1320
      End
      Begin VB.Label Label7 
         Caption         =   "Fecha de Vencimiento"
         Height          =   255
         Left            =   -66600
         TabIndex        =   120
         Top             =   5400
         Visible         =   0   'False
         Width           =   1650
      End
      Begin VB.Line Line1 
         X1              =   -72660
         X2              =   -65790
         Y1              =   6360
         Y2              =   6360
      End
      Begin VB.Shape Shape1 
         Height          =   825
         Left            =   -72660
         Top             =   6075
         Width           =   6870
      End
      Begin VB.Label lbltotalcons 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00E0E0E0&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -67410
         TabIndex        =   113
         Top             =   6405
         Width           =   1575
      End
      Begin VB.Label lbligvcons 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00E0E0E0&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -69075
         TabIndex        =   112
         Top             =   6420
         Width           =   1575
      End
      Begin VB.Label lblSubtotalNoafecto 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00E0E0E0&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -70770
         TabIndex        =   111
         Top             =   6420
         Width           =   1575
      End
      Begin VB.Label lblSubtotalafecto 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00E0E0E0&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -72480
         TabIndex        =   110
         Top             =   6420
         Width           =   1575
      End
      Begin VB.Label lbldesTotal 
         Caption         =   "Total S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -66765
         TabIndex        =   109
         Top             =   6060
         Width           =   855
      End
      Begin VB.Label lbldesIgv 
         Alignment       =   1  'Right Justify
         Caption         =   "IGV S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   -68310
         TabIndex        =   108
         Top             =   6090
         Width           =   810
      End
      Begin VB.Label lbldescNoafecto 
         Alignment       =   1  'Right Justify
         Caption         =   "No Afecto S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   -70725
         TabIndex        =   107
         Top             =   6090
         Width           =   1575
      End
      Begin VB.Label lbldescafecto 
         Caption         =   "Subtotal (Afecto) S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   -72600
         TabIndex        =   106
         Top             =   6105
         Width           =   1815
      End
      Begin VB.Image Image1 
         Height          =   960
         Left            =   -67800
         Picture         =   "0801000.frx":30DE
         Stretch         =   -1  'True
         Top             =   5040
         Width           =   960
      End
      Begin VB.Label lbltotalmon 
         Caption         =   "Total"
         Height          =   255
         Left            =   7365
         TabIndex        =   52
         Top             =   6540
         Width           =   825
      End
      Begin VB.Label lbltotal 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000004&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   8190
         TabIndex        =   51
         Top             =   6510
         Width           =   1275
      End
      Begin VB.Label lblsubtotalmon 
         Caption         =   "SubTotal"
         Height          =   330
         Left            =   240
         TabIndex        =   50
         Top             =   6540
         Width           =   1050
      End
      Begin VB.Label lblnoafectomon 
         Caption         =   "No Afecto"
         Height          =   255
         Left            =   2655
         TabIndex        =   49
         Top             =   6540
         Width           =   1200
      End
      Begin VB.Label lbligvmon 
         Caption         =   "IGV"
         Height          =   255
         Left            =   5310
         TabIndex        =   48
         Top             =   6540
         Width           =   705
      End
      Begin VB.Label Label15 
         Caption         =   "Total"
         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            =   7935
         TabIndex        =   47
         Top             =   7290
         Width           =   795
      End
      Begin VB.Label lblsubtotal 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000004&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   1350
         TabIndex        =   46
         Top             =   6510
         Width           =   1275
      End
      Begin VB.Label lblnoafecto 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000004&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   3870
         TabIndex        =   45
         Top             =   6510
         Width           =   1365
      End
      Begin VB.Label lbligv 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000004&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0.00"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   6060
         TabIndex        =   44
         Top             =   6510
         Width           =   1275
      End
      Begin VB.Label Label18 
         BorderStyle     =   1  'Fixed Single
         Height          =   360
         Left            =   9135
         TabIndex        =   43
         Top             =   7215
         Width           =   1275
      End
      Begin VB.Label Label19 
         Caption         =   "Se Asume que las Ventas están en Moneda  Nacional / por SUNAT"
         ForeColor       =   &H000040C0&
         Height          =   720
         Left            =   -68220
         TabIndex        =   40
         Top             =   4215
         Visible         =   0   'False
         Width           =   3450
      End
      Begin VB.Label lblterms 
         Height          =   360
         Left            =   -71475
         TabIndex        =   39
         Top             =   420
         Visible         =   0   'False
         Width           =   1020
      End
      Begin VB.Label lblresultados 
         Appearance      =   0  'Flat
         BackColor       =   &H80000004&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   660
         Left            =   195
         TabIndex        =   25
         Top             =   6285
         Width           =   9345
      End
      Begin VB.Label lblncredito 
         Height          =   300
         Left            =   -67200
         TabIndex        =   19
         Top             =   405
         Visible         =   0   'False
         Width           =   630
      End
      Begin VB.Label lblfactura 
         Height          =   345
         Left            =   -67530
         TabIndex        =   18
         Top             =   420
         Visible         =   0   'False
         Width           =   525
      End
      Begin VB.Line Line2 
         X1              =   45
         X2              =   10185
         Y1              =   -90
         Y2              =   -90
      End
   End
   Begin VB.Label lbltotalBase 
      Height          =   150
      Left            =   1605
      TabIndex        =   80
      Top             =   7935
      Visible         =   0   'False
      Width           =   1305
   End
   Begin VB.Label lbligvBase 
      Height          =   165
      Left            =   1650
      TabIndex        =   79
      Top             =   7740
      Visible         =   0   'False
      Width           =   1260
   End
   Begin VB.Label lblnoafectoBase 
      Height          =   240
      Left            =   1635
      TabIndex        =   78
      Top             =   7485
      Visible         =   0   'False
      Width           =   1320
   End
   Begin VB.Label lblsubtotalBase 
      Height          =   270
      Left            =   1680
      TabIndex        =   77
      Top             =   7230
      Visible         =   0   'False
      Width           =   1185
   End
   Begin VB.Label lbltotalext 
      Height          =   180
      Left            =   300
      TabIndex        =   76
      Top             =   7905
      Visible         =   0   'False
      Width           =   1170
   End
   Begin VB.Label lbligvext 
      Height          =   270
      Left            =   285
      TabIndex        =   75
      Top             =   7665
      Visible         =   0   'False
      Width           =   1245
   End
   Begin VB.Label lblnoafectoExt 
      Height          =   255
      Left            =   255
      TabIndex        =   74
      Top             =   7455
      Visible         =   0   'False
      Width           =   1230
   End
   Begin VB.Label lblsubtotalExt 
      Height          =   315
      Left            =   285
      TabIndex        =   73
      Top             =   7215
      Visible         =   0   'False
      Width           =   1230
   End
End
Attribute VB_Name = "FDocuPorCobrar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'delete from op_docreference
'delete from AR_CCDOC
'delete from op_salesdet where nbrdocument in (select nbrdocument from op_sales where salesperid='texas')
'delete from op_sales where salesperid='texas'
'******************************************************************************************
' Tablas Relacionadas
'******************************************************************************************

'******************************************************************************************
' Variables para el control de 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 pbderecho_anular As Boolean
  Public pbderecho_emitir As Boolean
  Public pb_tiposcreen As String

'******************************************************************************************
 'Variables para el Trbajo con las Búsquedas
'************************************************************************************************************
  Public GrecibeUbicacion As BookmarkEnum
  Public GrecibeColumnaID As String
  Public GrecibeColumnaOpcional As Variant
  Public GrecibeColumnaOpcional2 As Variant
  Public GrecibeColumnaOpcional3 As Variant

'******************************************************************************************
  Private BlnClienteCargado As Boolean
   
   
  Private MrsdetalleDocumento As ADODB.Recordset
  Public LrsDocumentosporCobrar As ADODB.Recordset
  Public LrsResumenArticulos As ADODB.Recordset
  Private MobjVentasGeneral As DB_OP_FACTURACION.C_VENTASGENERAL
  Private MobjCobranzas As DB_AR_CUENTASCOBRAR.C_COBRANZAS
  Private MobjMoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
  Private MobjAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
  Private MobjCorrelativo As DB_CORRELATIVO.C_Correlativos
  Private MobjDocumento As DB_MA_MANTENIMIENTOS.C_DOCUMENTO
  Private MrsListadoMoneda As ADODB.Recordset
  Public MdblCorrelativo As Double
  Private LrsArticulos As ADODB.Recordset
  Private LrsVales As ADODB.Recordset
  Public BlnDocumentosgenerados As Boolean
  Private BlnDatosCargados As Boolean
  Private MstrOrden As String
    
    
Private Sub cdmbuscararticulo_Click()
      Dim LArrayBusqueda(1 To 3, 1 To 3) As Variant
      Dim LrsClientesAyuda As ADODB.Recordset
       
       
       Set LrsClientesAyuda = MobjVentasGeneral.ListarClientesCtacteAyuda(1)
              
       LArrayBusqueda(1, 1) = "CUSTIDSS"
       LArrayBusqueda(1, 2) = "Código"
       LArrayBusqueda(1, 3) = 1200
       LArrayBusqueda(2, 1) = "CUSTNAME"
       LArrayBusqueda(2, 2) = "Descripción"
       LArrayBusqueda(2, 3) = 4500
       LArrayBusqueda(3, 1) = "TAXREGNBR"
       LArrayBusqueda(3, 2) = "RUC"
       LArrayBusqueda(3, 3) = 1200
      
       GrecibeUbicacion = 0
       GrecibeColumnaID = Empty
       GrecibeColumnaOpcional = Empty
  
       FBusquedaCCobrar.GObtenerRegistros LrsClientesAyuda, LArrayBusqueda, 3, 2
       FBusquedaCCobrar.Show vbModal
       If GrecibeUbicacion <> 0 Then
           lblcodcliente.Caption = GrecibeColumnaID
           TxtRuc.Text = GrecibeColumnaOpcional2
           TxtRuc_KeyPress (13)
       End If
       Set LrsClientesAyuda = Nothing
End Sub

Private Sub cmdacumulaart_Click()

    Screen.MousePointer = 11
    MobjCobranzas.CargarDatosResumenSeleccion MdblCorrelativo, lblcodcliente.Caption, DTPDel.Value, DTPAL.Value, _
                                              dtcmoneda.BoundText, LblTipoCambio.Caption, GintDecPrecio
     
    Screen.MousePointer = 0
    FAcumulado.Show vbModal
              
End Sub

Private Sub cmdAnular_Click()
              
   If Trim(txtnumero.Text) = Empty Then
      MsgBox "Ingrese Número de Documento ", vbDefaultButton1 + vbExclamation, "Advertencia"
      Exit Sub
   End If
   
   If pbderecho_anular = False Then
      MsgBox "No tiene derecho de Anular", vbDefaultButton1 + vbExclamation, "Advertencia"
      Exit Sub
   End If
   
   If DtcTipoDocument.BoundText = lblfactura.Caption Then
      MsgBox "No se puede Anular la Factura " & txtnumero.Text & Chr(13) & _
             "Debe Anular la Nota Crédito relacionada a esta Factura ", vbDefaultButton1 + vbExclamation, "No se puede Anular"
      Exit Sub
   End If
      
   If lblcodstatus.Caption = "AN" Then
      MsgBox "Documento ya está Anulado ", vbDefaultButton1 + vbExclamation, "No se puede Anular"
      Exit Sub
   End If
      
   If MsgBox("Seguro que desea Anular el Documento", vbYesNo + vbQuestion) = vbYes Then
         MobjCobranzas.AnularDocumentosCtaCte DtcTipoDocument.BoundText, txtnumero.Text, DtcAlmacenes.BoundText
         MsgBox "Documento Fue Anulado con éxito", vbDefaultButton1 + vbExclamation, "Advertencia"
         lblcodstatus.Caption = "AN"
         lblEstado.Caption = "Anulado"
   End If
   
End Sub

Private Sub cmdbuscaralmacen_Click()
     
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "siteid"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "Name"
    ArrayBusqueda(2, 2) = "Descripción "
    ArrayBusqueda(2, 3) = 4000
          
    FBusquedaCCobrar.GObtenerRegistros MobjAlmacen.ListarAlmacenesPorStatus(1), ArrayBusqueda, 2, 2
    FBusquedaCCobrar.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
       DtcAlmacenes.BoundText = GrecibeColumnaID
    End If
    
End Sub

Private Sub cmdbuscarnumero_Click()
  FBuscarDoc.Show vbModal
End Sub

Private Sub cmdbuscartipodocu_Click()

  Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
  ArrayBusqueda(1, 1) = "DocTypeid"
  ArrayBusqueda(1, 2) = "Código "
  ArrayBusqueda(1, 3) = 1000
  ArrayBusqueda(2, 1) = "Descr"
  ArrayBusqueda(2, 2) = "Descripción "
  ArrayBusqueda(2, 3) = 4000
    
        
  FBusquedaCCobrar.GObtenerRegistros MobjDocumento.ListarDocumentos, ArrayBusqueda, 2, 2
  FBusquedaCCobrar.Show vbModal
  If GrecibeUbicacion <> 0 Then
      DtcTipoDocument.BoundText = GrecibeColumnaID
  End If
    
End Sub

Private Sub cmdcambioprecio_Click()
    
   FreemplazoporTpc.lblcodalmacen = FDocuPorCobrar.Dbresumenarticulos.Columns(0).Text
   FreemplazoporTpc.lblcodcliente = FDocuPorCobrar.lblcodcliente
   FreemplazoporTpc.lblCodigo = FDocuPorCobrar.Dbresumenarticulos.Columns(2).Text
   FreemplazoporTpc.lblDescripcion = FDocuPorCobrar.Dbresumenarticulos.Columns(3).Text
   FreemplazoporTpc.Show vbModal
      
End Sub

Private Sub cmdGenerar_Click()

On Error GoTo errhandler
   Dim IntFechaVencimiento As Integer
   Dim IntFactura  As Integer
   Dim IntNcredito As Integer
   Dim DblMontoTipoCambio As Double
   
    Dim rsValida As ADODB.Recordset
    Dim LARRAY(1, 2) As Variant
    
    
    Dim Luti As UTIL_SETUP.C_SETUP
    Dim LrsTempFecha As ADODB.Recordset
    Dim Ldate As Date
    
    Set Luti = New UTIL_SETUP.C_SETUP
    Set LrsTempFecha = Luti.Auxiliar3("Select dateproce from setup")
    Ldate = LrsTempFecha!DATEPROCE
    Set Luti = Nothing
    GDatFechaProceso = Ldate
    
    
    LARRAY(1, 1) = GstrSiteProce
    LARRAY(1, 2) = GDatFechaProceso
    
    Set rsValida = MobjCobranzas.Auxiliar1(LARRAY)
        
    'temporalmente desahibilitado**************************
    '******************************************************
'    If Weekday(DTPEmision.Value) = 1 Then
'       MsgBox "La fecha de Proceso no puede ser domingo", vbDefaultButton1 + vbExclamation, "Mensaje"
'       Exit Sub
'    End If
                
    If rsValida!MESCERRADO = 1 Then
        MsgBox "No se puede registrar, el mes al que hace referencia la fecha de proceso " & Chr(13) & _
                   "se encuentra cerrado", vbExclamation, "Emision de Documento"
        Exit Sub
    End If
        
    If rsValida!PDCERRADO = 1 Then
        MsgBox "No se puede registrar, el valor al que hace referencia la fecha de proceso " & Chr(13) & _
                   "es una fecha de Parte Diario cerrado", vbExclamation, "Emision de Documento"
        Exit Sub
    End If
   
    
    ' Ahora hay que Validar la fecha de documentos
    ' que no pertezca a un mes ya cerrado
    
    LARRAY(1, 1) = GstrSiteProce
    LARRAY(1, 2) = DTPFechaDocu.Value
    Set rsValida = MobjCobranzas.Auxiliar1(LARRAY)
      
    If rsValida!MESCERRADO = 1 Then
        MsgBox "No se puede registrar, el mes al que hace referencia la fecha del documento " & Chr(13) & _
                   "se encuentra cerrado", vbExclamation, "Emision de Documento"
        Exit Sub
    End If
          
    ' *********************************************
   
         
   ' Hay que pasar los Datos del Resumen de tmp_ar_sales, tmp_ar_salesdet
   ' al Temporal de OP_salesdet
      
   If txtncredito.Enabled = True Then
      IntNcredito = 1
   Else
      IntNcredito = 0
   End If
   
   If txtfactura.Enabled = True Then
      IntFactura = 1
   Else
      IntFactura = 0
   End If
      
   If SSTab1.Tab = 0 Then
      MsgBox "Debe Procesar los Datos Seleccionados", vbDefaultButton1 + vbExclamation, "Mensaje"
      Exit Sub
   End If
   
   If optResumido.Value = True Then
      If LrsResumenArticulos.EOF Then
         MsgBox "No existen Datos para Generar los Documentos ", vbDefaultButton1 + vbExclamation, "Mensaje"
         Exit Sub
      End If
   Else
      If LrsDocumentosporCobrar.EOF Then
         MsgBox "No existen Datos para Generar los Documentos ", vbDefaultButton1 + vbExclamation, "Mensaje"
         Exit Sub
      End If
   End If
      
   
   Screen.MousePointer = 11
   
   Dim LARRAYFECHAS(1, 1) As Variant
   LARRAYFECHAS(1, 1) = DTPFechaDocu.Value
   
   
   If optResumido.Value = True Then
                               
      ' Hay que Verificar que los Documentos Tengan la Misma Fecha de Vencimiento
        
      IntFechaVencimiento = MobjCobranzas.ValidarFechaVencimiento(MdblCorrelativo, 0)
      If IntFechaVencimiento = 0 Then
         Screen.MousePointer = 0
         MsgBox "No se han Seleccionado Documentos", vbDefaultButton1 + vbExclamation, "Advertencia"
         Exit Sub
      End If
      'Comentad Pablo N. 09/04/2008, Es un prolema q salga este error.
      If IntFechaVencimiento = 2 Then
         Screen.MousePointer = 0
         MsgBox "Los Documentos que contiene a estos Artículos deben tener la misma Fecha de Vencimiento", vbDefaultButton1 + vbExclamation, "Advetencia"
         Exit Sub
      End If
                                                        
      ' Hay que pasar el Resumen Obtenido en TMP_AR_RESUMEN
      
      MobjCobranzas.GrabarResumenenTmp_Ar_resumen MdblCorrelativo, 1, dtcmoneda.BoundText, GCUSERID
      ' Se procede a Emitir
      DblMontoTipoCambio = MobjVentasGeneral.ObtenerMontoTipodeCambio(GstrCodMonedaBase, GstrMonedaExtranjeraModgen, DTPEmision.Value, LblTipoCambio.Caption)
                                                                                                                                                                                                                                                 
      ' Veririficar los Totales
                                                                                                                                                                                                                                                 
      VerificarTotales (0)
      
      Screen.MousePointer = 11
      Dim A As Double
      
      'MobjCobranzas
      MobjCobranzas.GenerarDocumentosCtaCte 1, IntFactura, IntNcredito, Val(Mid(txtfacturaproce.Text, 1, 3)), Mid(txtfacturaproce.Text, 4, Len(txtfacturaproce.Text)), _
                                            Val(Mid(txtncreditoproce.Text, 1, 3)), Mid(txtncreditoproce.Text, 4, Len(txtncreditoproce.Text)), 0, MdblCorrelativo, dtcmoneda.BoundText, _
                                            "", GCUSERID, "", "", Val(lbltotalBase.Caption), Val(lbltotalext.Caption), Val(lblsubtotalBase.Caption), Val(lblsubtotalExt.Caption), Val(lbligvBase.Caption), _
                                            Val(lbligvext.Caption), _
                                            0, 0, Val(lblnoafectoBase.Caption), Val(lblnoafectoExt.Caption), 0, 0, 0, 0, 0, 0, 0, 0, lblcodcliente.Caption, _
                                            TxtRuc.Text, lblrazonsocialpro.Caption, "", LblTipoCambio.Caption, DblMontoTipoCambio, 0, 0, "", 0, "", "", 0, txtdireccion.Text, "", _
                                            "", "", "", LARRAYFECHAS
      Screen.MousePointer = 0
      
   Else
        
      ' Hay que Verificar que los Documentos Tengan la Misma Fecha de Vencimiento
        
      IntFechaVencimiento = MobjCobranzas.ValidarFechaVencimiento(MdblCorrelativo, 1)
      If IntFechaVencimiento = 0 Then
         Screen.MousePointer = 0
         MsgBox "No se han Seleccionado Documentos", vbDefaultButton1 + vbExclamation, "Advertencia"
         Exit Sub
      End If
      'Pablo N., No quieren esta condicion
'      If IntFechaVencimiento = 2 Then
'         Screen.MousePointer = 0
'         MsgBox "Los Documentos Seleccionados deben tener la misma Fecha de Vencimiento", vbDefaultButton1 + vbExclamation, "Advetencia"
'         Exit Sub
'      End If
      
      ' Hay que llenar TMP_AR_SALESDET con los Documentos Seleccionados
                  
      MobjCobranzas.CargarDatosResumenSeleccion MdblCorrelativo, lblcodcliente.Caption, DTPDel.Value, DTPAL.Value, _
                                                dtcmoneda.BoundText, LblTipoCambio.Caption, GintDecPrecio
                                                                                                                                                              
      ' Hay que pasar el Resumen Obtenido en TMP_AR_RESUMEN
      
      MobjCobranzas.GrabarResumenenTmp_Ar_resumen MdblCorrelativo, 1, dtcmoneda.BoundText, GCUSERID
      
      ' Se procede a Emitir
                           
      DblMontoTipoCambio = MobjVentasGeneral.ObtenerMontoTipodeCambio(GstrCodMonedaBase, GstrMonedaExtranjeraModgen, DTPEmision.Value, LblTipoCambio.Caption)
                                                      
                        
      ' Verificar los Totales
        
      VerificarTotales (1)
            
      ' Fin de Verificar Totales
      Screen.MousePointer = 11
      MobjCobranzas.GenerarDocumentosCtaCte 0, IntFactura, IntNcredito, Val(Mid(txtfacturaproce.Text, 1, 3)), Mid(txtfacturaproce.Text, 4, Len(txtfacturaproce.Text)), _
                                            Val(Mid(txtncreditoproce.Text, 1, 3)), Mid(txtncreditoproce.Text, 4, Len(txtfacturaproce.Text)), 0, MdblCorrelativo, dtcmoneda.BoundText, _
                                            "", GCUSERID, "", "", Val(lbltotalBase.Caption), Val(lbltotalext.Caption), Val(lblsubtotalBase.Caption), Val(lblsubtotalExt.Caption), Val(lbligvBase.Caption), _
                                            Val(lbligvext.Caption), _
                                            0, 0, Val(lblnoafectoBase.Caption), Val(lblnoafectoExt.Caption), 0, 0, 0, 0, 0, 0, 0, 0, lblcodcliente.Caption, _
                                            TxtRuc.Text, lblrazonsocialpro.Caption, "", LblTipoCambio.Caption, DblMontoTipoCambio, 0, 0, "", 0, "", "", 0, txtdireccion.Text, "", _
                                            "", "", "", LARRAYFECHAS
      Screen.MousePointer = 0
   End If
   
   Screen.MousePointer = 0
   MsgBox "Documentos Fueron Generados", vbDefaultButton1 + vbInformation, "Mensaje"
   BlnDocumentosgenerados = True
   cmdGenerar.Enabled = False
   
Exit Sub
errhandler:
   MsgBox Err.Description, vbCritical + vbExclamation, "Advertencia"

End Sub

Sub VerificarTotales(IntSeleccionTodos As Integer)

     Dim LdblTotalBase As Double
     Dim LdblTotalExt As Double
     Dim LdblSubtotalPen As Double
     Dim LdblSubtotalUsd As Double
     Dim LdblIGVPen As Double
     Dim LdblIGVUsd As Double
     Dim LdblDiferenciaPen As Double
     Dim LdblDiferenciaUsd As Double
     
     Dim LrsTotales As ADODB.Recordset
     Dim LrsTotalesResumen As ADODB.Recordset
          
          
     ' IntSeleccionTodos = 1 ==> entonces el Monto de la Factura y Nota de Credito es
     ' Igual
     ' IntSeleccionTodos = 0 ==> entonces el Monto de la Factura no es Igual Necesariamente
     ' porque puede Haber descuentos
               
     If IntSeleccionTodos = 1 Then
        If lblnoafecto.Caption <> 0 Then
           ' Existe algún no Afecto
           Exit Sub
        End If

        ' El Total se Obtiene de la Tabla tmp_ar_sales donde selected = 1
        ' pero el Program internamente guarda esta suma en las etiquetas
        ' lbltotalBase.Caption / lbltotalext.Caption
        
        LdblTotalBase = lbltotalBase.Caption
        LdblTotalExt = lbltotalext.Caption
                   
        ' Calculo el SubTotal en Base a el Total
        
        LdblSubtotalPen = GFormatodeNumero(LdblTotalBase / (1 + (GdblIGV / 100)), GintDecResultado)
        LdblSubtotalUsd = GFormatodeNumero(LdblTotalExt / (1 + (GdblIGV / 100)), GintDecResultado)
                   
        LdblIGVPen = GFormatodeNumero(LdblTotalBase - LdblSubtotalPen, GintDecResultado)
        LdblIGVUsd = GFormatodeNumero(LdblTotalExt - LdblSubtotalUsd, GintDecResultado)
                   
        ' Se Obtiene de la Tabla Final TMP_AR_RESUMEN los montos Originales (SUBTOTALES)
        ' Se procede a Comparar
                                              
        Set LrsTotales = MobjVentasGeneral.ObtenerTotales_TMP_AR_RESUMEN(MdblCorrelativo, IntSeleccionTodos)
                            
        If LrsTotales!SUBTOTALPENCAL <> LdblSubtotalPen Then
           ' Hay que insertar el Item de Redondeo
           
           If LrsTotales!SUBTOTALPENCAL > LdblSubtotalPen Then
              LdblDiferenciaPen = LrsTotales!SUBTOTALPENCAL - LdblSubtotalPen
           Else
              LdblDiferenciaPen = LdblSubtotalPen - LrsTotales!SUBTOTALPENCAL
           End If
              
           If LrsTotales!SUBTOTALUSDCAL > LdblSubtotalUsd Then
              LdblDiferenciaUsd = LrsTotales!SUBTOTALUSDCAL - LdblSubtotalUsd
           Else
              LdblDiferenciaUsd = LdblSubtotalUsd - LrsTotales!SUBTOTALUSDCAL
           End If
           
           ' Hay que Grabar en TMP_AR_RESUMEN el Item de Redondeo
           ' Para la Factura y para la Nota de Crédito
                                   
           'MobjVentasGeneral.GrabarItemdeRedondeo "", MDblCorrelativo, "", 0, GStrArticuloRedondeo, dtcMoneda.BoundText, _
                                                   0, 0, 0, "", 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, LdblDiferenciaUsd, _
                                                   LdblDiferenciaPen, LdblDiferenciaUsd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, _
                                                   LdblDiferenciaPen, 0, 0, "", "REDONDEO", 1, GCUSERID, 0, 0, "", "", "FC"
            
           'MobjVentasGeneral.GrabarItemdeRedondeo "", MDblCorrelativo, "", 0, GStrArticuloRedondeo, dtcMoneda.BoundText, _
                                                   0, 0, 0, "", 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, LdblDiferenciaUsd, _
                                                   LdblDiferenciaPen, LdblDiferenciaUsd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, _
                                                   LdblDiferenciaPen, 0, 0, "", "REDONDEO", 1, GCUSERID, 0, 0, "", "", "NC"
           
           'Hay que Refrescar los Totales que se graban en la Cabecera
        
           lblsubtotalBase.Caption = LdblSubtotalPen
           lblnoafectoBase.Caption = 0
           lbligvBase.Caption = LdblIGVPen
           lbltotalBase.Caption = LdblTotalBase
           lblsubtotalExt.Caption = LdblSubtotalUsd
           lblnoafectoExt.Caption = 0
           lbligvext.Caption = LdblIGVUsd
           lbltotalext.Caption = LdblTotalExt

        Else
        
          ' ***************************************************
          ' *************** No hay Diferencias ****************
          ' ***************************************************
          
           lblsubtotalBase.Caption = LdblSubtotalPen
           lblnoafectoBase.Caption = 0
           lbligvBase.Caption = LdblIGVPen
           lbltotalBase.Caption = LdblTotalBase
           lblsubtotalExt.Caption = LdblSubtotalUsd
           lblnoafectoExt.Caption = 0
           lbligvext.Caption = LdblIGVUsd
           lbltotalext.Caption = LdblTotalExt
          
        End If
                               
     Else
     
        '**********************************************************
        ' Hay que Verificar si la Nota de Credito Necesita Redondeo
        '**********************************************************
           If MobjVentasGeneral.ExistenNoafectos_TMP_AR_RESUMEN(MdblCorrelativo) = True Then
              Exit Sub
           End If
           
           ' El Total se Obtiene de la Tabla tmp_ar_sales donde selected = 0 o =1
           ' Para la Nota de Credito son Todos los Registros
                          
           Set LrsTotales = MobjVentasGeneral.ObtenerTotales_TMP_AR_SALES(MdblCorrelativo)
                              
           LdblTotalBase = LrsTotales!SUMTOTALPEN
           LdblTotalExt = LrsTotales!SUMTOTALUSD
                      
           LdblSubtotalPen = GFormatodeNumero(LdblTotalBase / (1 + (GdblIGV / 100)), GintDecResultado)
           LdblSubtotalUsd = GFormatodeNumero(LdblTotalExt / (1 + (GdblIGV / 100)), GintDecResultado)
                      
           LdblIGVPen = LdblTotalBase - LdblSubtotalPen
           LdblIGVUsd = LdblTotalExt - LdblSubtotalUsd
                                            
           Set LrsTotales = MobjVentasGeneral.ObtenerTotales_TMP_AR_RESUMEN(MdblCorrelativo, IntSeleccionTodos)
                               
           If LrsTotales!SUBTOTALPENCAL <> LdblSubtotalPen Then
              ' Hay que insertar el Item de Redondeo
              If LrsTotales!SUBTOTALPENCAL > LdblSubtotalPen Then
                LdblDiferenciaPen = LrsTotales!SUBTOTALPENCAL - LdblSubtotalPen
              Else
                 LdblDiferenciaPen = LdblSubtotalPen - LrsTotales!SUBTOTALPENCAL
              End If
                 
              If LrsTotales!SUBTOTALUSDCAL > LdblSubtotalUsd Then
                 LdblDiferenciaUsd = LrsTotales!SUBTOTALUSDCAL - LdblSubtotalUsd
              Else
                 LdblDiferenciaUsd = LdblSubtotalUsd - LrsTotales!SUBTOTALUSDCAL
              End If
              ' Hay que Grabar en TMP_AR_RESUMEN el Item de Redondeo
              ' Para la Nota de Credito
           
              'MobjVentasGeneral.GrabarItemdeRedondeo "", MDblCorrelativo, "", 0, GStrArticuloRedondeo, dtcMoneda.BoundText, _
                                                     0, 0, 0, "", 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, LdblDiferenciaUsd, _
                                                     LdblDiferenciaPen, LdblDiferenciaUsd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, _
                                                     LdblDiferenciaPen, 0, 0, "", "REDONDEO", 1, GCUSERID, 0, 0, "", "", "NC"
              'Hay que Refrescar los Totales que se graban en la Cabecera
        
              lblsubtotalBase.Caption = LdblSubtotalPen
              lblnoafectoBase.Caption = 0
              lbligvBase.Caption = LdblIGVPen
              lbltotalBase.Caption = LdblTotalBase
              lblsubtotalExt.Caption = LdblSubtotalUsd
              lblnoafectoExt.Caption = 0
              lbligvext.Caption = LdblIGVUsd
              lbltotalext.Caption = LdblTotalExt
           Else
              
              ' *************************************************************************
              ' *************** No hay Diferencias en la Nota de Crédito ****************
              ' *************************************************************************
              lblsubtotalBase.Caption = LdblSubtotalPen
              lblnoafectoBase.Caption = 0
              lbligvBase.Caption = LdblIGVPen
              lbltotalBase.Caption = LdblTotalBase
              lblsubtotalExt.Caption = LdblSubtotalUsd
              lblnoafectoExt.Caption = 0
              lbligvext.Caption = LdblIGVUsd
              lbltotalext.Caption = LdblTotalExt
           End If
                          
         '**********************************************************
         ' Hay que Verificar si la Factura Necesita Redondeo
         '**********************************************************
           
          'lbltotal.Caption contiene el Total del Resumen
          'Incluyendo los descuentos
           
           ' Con el Parámetro 2 recibe Totales y ya no SubTotales
           ' el total que se va ha grabar se puede Obtener
           ' del monto que varia (los no originales) de TMP_AR_RESUMEN
           
           Set LrsTotales = MobjVentasGeneral.ObtenerTotales_TMP_AR_RESUMEN(MdblCorrelativo, 2)
           
           LdblTotalBase = LrsTotales!TOTALPENCAL
           LdblTotalExt = LrsTotales!TOTALUSDCAL
            
           LdblSubtotalPen = GFormatodeNumero(LdblTotalBase / (1 + (GdblIGV / 100)), GintDecResultado)
           LdblSubtotalUsd = GFormatodeNumero(LdblTotalExt / (1 + (GdblIGV / 100)), GintDecResultado)
                      
           LdblIGVPen = LdblTotalBase - LdblSubtotalPen
           LdblIGVUsd = LdblTotalExt - LdblSubtotalUsd
            
           ' Validar si los SUBTotales que varian (LOS NO ORIGINALES)
           ' de tmp_ar_resumen son iguales
           
           Set LrsTotales = MobjVentasGeneral.ObtenerTotales_TMP_AR_RESUMEN(MdblCorrelativo, 3)
              
           If LrsTotales!SUBTOTALPENCAL <> LdblSubtotalPen Then
              ' Hay que insertar el Item de Redondeo
              If LrsTotales!SUBTOTALPENCAL > LdblSubtotalPen Then
                LdblDiferenciaPen = LrsTotales!SUBTOTALPENCAL - LdblSubtotalPen
              Else
                 LdblDiferenciaPen = LdblSubtotalPen - LrsTotales!SUBTOTALPENCAL
              End If
                 
              If LrsTotales!SUBTOTALUSDCAL > LdblSubtotalUsd Then
                 LdblDiferenciaUsd = LrsTotales!SUBTOTALUSDCAL - LdblSubtotalUsd
              Else
                 LdblDiferenciaUsd = LdblSubtotalUsd - LrsTotales!SUBTOTALUSDCAL
              End If
              'MobjVentasGeneral.GrabarItemdeRedondeo "", MDblCorrelativo, "", 0, GStrArticuloRedondeo, dtcMoneda.BoundText, _
                                                     0, 0, 0, "", 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, LdblDiferenciaUsd, _
                                                     LdblDiferenciaPen, LdblDiferenciaUsd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, LdblDiferenciaPen, _
                                                     LdblDiferenciaPen, 0, 0, "", "REDONDEO", 1, GCUSERID, 0, 0, "", "", "FC"
           Else
              ' *************************************************************************
              ' *************** No hay Diferencias en la Factura  ***********************
              ' *************************************************************************
           End If
                      
     End If
     
     Set LrsTotales = Nothing
     Set LrsTotalesResumen = Nothing
     
End Sub

Private Sub cmdNuevo_Click()

   HabilitarControles (True)
   cdmbuscararticulo.Enabled = True
   TxtRuc.SetFocus
   
   ' Hay que Obtener un Correlativo
     
   MdblCorrelativo = MobjCorrelativo.ObtenerCorrelativo(GCUSERID)
     
     
End Sub

Private Sub cmdpreciopromed_Click()
   If MsgBox("Seguro que desea Actulizar los precios al Precio Promedio", vbQuestion + vbYesNo, "Advertencia") = vbYes Then
      MobjCobranzas.ActualizarPrecioPromedio MdblCorrelativo, dtcmoneda.BoundText, GintDecPrecio
      RefrescarGrilla
      ActulizaTotalesResumen
   End If
      
End Sub

Private Sub cmdReimprimir_Click()
        Call imprimir
End Sub

Private Sub cmdsalir_Click()
   Unload Me
End Sub

Private Sub DbDocumentos_HeadClick(ByVal ColIndex As Integer)
On Error GoTo TrataError

  'strSQL = " Select SITEID,NAME,DOCTYPEID,TIPODOCUMENTO,NBRDOCUMENT," & _
             " DATEPROCESALES,DUEDATE,PLACA,TOTALPEN,TOTALUSD," & _
             " SUBTOTALPEN , SUBTOTALUSD, TAXIGVPEN, TAXIGVUSD," & _
             " TOTALNOTAFFECTPEN, TOTALNOTAFFECTUSD,CASE SELECTED WHEN 1 THEN 'Sí' WHEN 0 THEN 'No' END " & _
             " FROM TMP_AR_SALES where CORRNBR=" & dblCORRELATIVO
     
    Select Case ColIndex
        Case 0
            LrsDocumentosporCobrar.Sort = "SITEID" & " " & MstrOrden
        Case 1
            LrsDocumentosporCobrar.Sort = "NAME" & " " & MstrOrden
        Case 2
            LrsDocumentosporCobrar.Sort = "DOCTYPEID" & " " & MstrOrden
        Case 3
            LrsDocumentosporCobrar.Sort = "TIPODOCUMENTO" & " " & MstrOrden
        Case 4
            LrsDocumentosporCobrar.Sort = "NBRDOCUMENT" & " " & MstrOrden
        Case 5
            LrsDocumentosporCobrar.Sort = "DATEPROCESALES" & " " & MstrOrden
        Case 6
            LrsDocumentosporCobrar.Sort = "DUEDATE" & " " & MstrOrden
        Case 7
            LrsDocumentosporCobrar.Sort = "PLACA" & " " & MstrOrden
        Case 8
            LrsDocumentosporCobrar.Sort = "TOTALPEN" & " " & MstrOrden
        Case 9
            LrsDocumentosporCobrar.Sort = "TOTALUSD" & " " & MstrOrden
        Case 16
            LrsDocumentosporCobrar.Sort = "SELECTED" & " " & MstrOrden
            
    End Select
        
    If MstrOrden = "ASC" Then
       MstrOrden = "DESC"
    Else
       MstrOrden = "ASC"
    End If
    
TrataError:
End Sub

Private Sub DbDocumentos_KeyDown(KeyCode As Integer, Shift As Integer)

    '" Select SITEID,NAME,DOCTYPEID,TIPODOCUMENTO,NBRDOCUMENT," & _
    '         " DATEPROCESALES,PLACA,TOTALPEN,TOTALUSD," & _
    '         " SUBTOTALPEN , SUBTOTALUSD, TAXIGVPEN, TAXIGVUSD," & _
    '         " TOTALNOTAFFECTPEN, TOTALNOTAFFECTUSD,SELECTED " & _

    If KeyCode = 32 Then
       Dim varBmk As Variant
       Dim LintEstado As Integer
           varBmk = DbDocumentos.Bookmark
           If DbDocumentos.Columns(16).Value = "Sí" Then
              LintEstado = 0
           Else
              LintEstado = 1
           End If
           MobjCobranzas.ActualizarSeleccion MdblCorrelativo, DbDocumentos.Columns(2), _
                                             DbDocumentos.Columns(0), DbDocumentos.Columns(4), LintEstado
           Set DbDocumentos.DataSource = MobjCobranzas.ObtenerDocumentosCtaCte(MdblCorrelativo)
           DbDocumentos.Refresh
           FormatoGrillaDocumentos
           DbDocumentos.Bookmark = varBmk
           ActulizarTotales
    End If
    
End Sub

Public Sub MostrarControles(IntFormato As Integer)
   ' 1 es Detallado / 0 es Resumido
    
    If IntFormato = 1 Then
       DbDocumentos.Visible = True
       DbArticulos.Visible = True
       DbVales.Visible = True
       Dbresumenarticulos.Visible = False
       'Etiquetas de lo Totales
       
       lblsubtotalmon.Visible = True
       lblsubtotal.Visible = True
       lblnoafectomon.Visible = True
       lblnoafecto.Visible = True
       lbligvmon.Visible = True
       lbligv.Visible = True
    Else
       DbDocumentos.Visible = False
       DbArticulos.Visible = False
       DbVales.Visible = False
       Dbresumenarticulos.Visible = True
       
       'Etiqueta de los Totales
       lblsubtotalmon.Visible = False
       lblsubtotal.Visible = False
       lblnoafectomon.Visible = False
       lblnoafecto.Visible = False
       lbligvmon.Visible = False
       lbligv.Visible = False
              
    End If
    
End Sub
Public Sub ActulizaTotalesResumen()

  'strsql = " Select sum(TOTALPEN) AS SUMTOTALPEN,sum(TOTALUSD) AS SUMTOTALUSD, " & _
  '         " sum(TAXPEN) AS SUMTAXPEN,sum(TAXUSD) AS SUMTAXUSD " & _
  '         " from tmp_ar_salesdet where CORRNBR =" & DblCorrelativo
  
  Dim LrsTotalesResumen As ADODB.Recordset
  Set LrsTotalesResumen = MobjCobranzas.ObtenerTotalesResumen(MdblCorrelativo)
  
  If dtcmoneda.BoundText = GstrCodMonedaBase Then
     If IsNull(LrsTotalesResumen!SUMTOTALPEN) Then
        lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
     Else
        lbltotal.Caption = GFormatodeNumero(LrsTotalesResumen!SUMTOTALPEN, GintDecResultado)
     End If
  Else
     If IsNull(LrsTotalesResumen!SUMTOTALUSD) Then
        lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
     Else
        lbltotal.Caption = GFormatodeNumero(LrsTotalesResumen!SUMTOTALUSD, GintDecResultado)
     End If
  End If
          
  Set LrsTotalesResumen = Nothing
          
End Sub
Public Sub ActulizarTotales()

 'select sum(TOTALPEN) as SUMTOTALPEN,sum(TOTALUSD) as SUMTOTALUSD,
 'sum(SUBTOTALPEN) as SUMSUBTOTALPEN,sum(SUBTOTALUSD) as SUMSUBTOTALUSD,
 'sum(TAXIGVPEN) as SUMTAXIGVPEN,sum(TAXIGVUSD) as SUMTAXIGVUSD,
 'sum(TOTALNOTAFFECTPEN) as SUMTOTALNOTAFFECTPEN,SUM(TOTALNOTAFFECTUSD) as SUMTOTALNOTAFFECTUSD
 'from tmp_ar_sales where CORRNBR='' and selected=1
       
  Dim LrsTotales As ADODB.Recordset

  Set LrsTotales = MobjCobranzas.ObtenerTotales(MdblCorrelativo)
   
   If dtcmoneda.BoundText = GstrCodMonedaBase Then
      If Not IsNull(LrsTotales!SUMTOTALPEN) Then
         lbltotal.Caption = GFormatodeNumero(LrsTotales!SUMTOTALPEN, GintDecResultado)
      Else
         lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
      End If
      If Not IsNull(LrsTotales!SUMTOTALNOTAFFECTPEN) Then
         lblnoafecto.Caption = GFormatodeNumero(LrsTotales!SUMTOTALNOTAFFECTPEN, GintDecResultado)
      Else
         lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
      End If
      
      If lblnoafecto.Caption = 0 Then
         lblsubtotal.Caption = GFormatodeNumero((lbltotal.Caption / (1 + (GdblIGV / 100))), GintDecResultado)
         '@TOTALPEN * (1+ (@TAXVALUEIGV/100)
         lbligv.Caption = GFormatodeNumero(lbltotal.Caption - lblsubtotal.Caption, GintDecResultado)
      Else
          If Not IsNull(LrsTotales!SUMSUBTOTALPEN) Then
             lblsubtotal.Caption = GFormatodeNumero(LrsTotales!SUMSUBTOTALPEN, GintDecResultado)
          Else
             lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
          End If
          If Not IsNull(LrsTotales!SUMTAXIGVPEN) Then
             lbligv.Caption = GFormatodeNumero(LrsTotales!SUMTAXIGVPEN, GintDecResultado)
          Else
             lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
          End If
       End If
   Else
      If Not IsNull(LrsTotales!SUMTOTALUSD) Then
         lbltotal.Caption = GFormatodeNumero(LrsTotales!SUMTOTALUSD, GintDecResultado)
      Else
         lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
      End If
      If Not IsNull(LrsTotales!SUMTOTALNOTAFFECTUSD) Then
         lblnoafecto.Caption = GFormatodeNumero(LrsTotales!SUMTOTALNOTAFFECTUSD, GintDecResultado)
      Else
         lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
      End If
       
      If lblnoafecto.Caption = 0 Then
          lblsubtotal.Caption = GFormatodeNumero((lbltotal.Caption / (1 + (GdblIGV / 100))), GintDecResultado)
          '@TOTALPEN * (1+ (@TAXVALUEIGV/100)
          lbligv.Caption = GFormatodeNumero(lbltotal.Caption - lblsubtotal.Caption, GintDecResultado)
      Else
            If Not IsNull(LrsTotales!SUMSUBTOTALUSD) Then
               lblsubtotal.Caption = GFormatodeNumero(LrsTotales!SUMSUBTOTALUSD, GintDecResultado)
            Else
               lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
            End If
            If Not IsNull(LrsTotales!SUMTAXIGVUSD) Then
               lbligv.Caption = GFormatodeNumero(LrsTotales!SUMTAXIGVUSD, GintDecResultado)
            Else
               lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
            End If
       End If
   End If
  
  ' Actualizar Etiquetas en MonedaBase y MonedaExtranjera
   
  If IsNull(LrsTotales!SUMSUBTOTALPEN) Then
   lblsubtotalBase.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
   lblsubtotalBase.Caption = GFormatodeNumero(LrsTotales!SUMSUBTOTALPEN, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTOTALNOTAFFECTPEN) Then
   lblnoafectoBase.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
   lblnoafectoBase.Caption = GFormatodeNumero(LrsTotales!SUMTOTALNOTAFFECTPEN, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTAXIGVPEN) Then
   lbligvBase.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
   lbligvBase.Caption = GFormatodeNumero(LrsTotales!SUMTAXIGVPEN, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTOTALPEN) Then
    lbltotalBase.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
    lbltotalBase.Caption = GFormatodeNumero(LrsTotales!SUMTOTALPEN, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMSUBTOTALUSD) Then
   lblsubtotalExt.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
   lblsubtotalExt.Caption = GFormatodeNumero(LrsTotales!SUMSUBTOTALUSD, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTOTALNOTAFFECTUSD) Then
   lblnoafectoExt.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
   lblnoafectoExt.Caption = GFormatodeNumero(LrsTotales!SUMTOTALNOTAFFECTUSD, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTAXIGVUSD) Then
    lbligvext.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
    lbligvext.Caption = GFormatodeNumero(LrsTotales!SUMTAXIGVUSD, GintDecResultado)
  End If
  
  If IsNull(LrsTotales!SUMTOTALUSD) Then
    lbltotalext.Caption = GFormatodeNumero(0, GintDecResultado)
  Else
    lbltotalext.Caption = GFormatodeNumero(LrsTotales!SUMTOTALUSD, GintDecResultado)
  End If
  Set LrsTotales = Nothing
  
End Sub

Public Sub FormatoGrillaDocumentos()
   
  '" Select SITEID,NAME,DOCTYPEID,TIPODOCUMENTO,NBRDOCUMENT," & _
  '         " DATEPROCESALES,PLACA,TOTALPEN,TOTALUSD," & _
  '         " SUBTOTALPEN,SUBTOTALUSD, TAXIGVPEN, TAXIGVUSD," & _
  '         " TOTALNOTAFFECTPEN, TOTALNOTAFFECTUSD,SELECTED " & _

   DbDocumentos.Columns(0).Visible = False
   DbDocumentos.Columns(1).Caption = "Almacén"
   DbDocumentos.Columns(1).Width = 1500
   DbDocumentos.Columns(2).Visible = False
   DbDocumentos.Columns(3).Caption = "Documento"
   DbDocumentos.Columns(3).Width = 1000
   DbDocumentos.Columns(4).Caption = "Nro._Documento"
   DbDocumentos.Columns(4).Width = 1200
   DbDocumentos.Columns(5).Caption = "Fec._Proceso"
   DbDocumentos.Columns(5).Width = 1050
   DbDocumentos.Columns(6).Caption = "Vencimiento"
   DbDocumentos.Columns(6).Width = 1050
   
   'DE AQUI
   DbDocumentos.Columns(7).Caption = "Placa"
   DbDocumentos.Columns(8).Caption = "Total"
   
   If dtcmoneda.BoundText = GstrCodMonedaBase Then
      DbDocumentos.Columns(8).Width = 1000
      DbDocumentos.Columns(8).Visible = True
      DbDocumentos.Columns(8).NumberFormat = GMascara(GintDecResultado)
      DbDocumentos.Columns(8).Alignment = dbgRight
      DbDocumentos.Columns(9).Visible = False
      DbDocumentos.Columns(10).Visible = False
      DbDocumentos.Columns(11).Visible = False
      DbDocumentos.Columns(12).Visible = False
      DbDocumentos.Columns(13).Visible = False
      DbDocumentos.Columns(14).Visible = False
      DbDocumentos.Columns(15).Visible = False
      DbDocumentos.Columns(16).Visible = True
   Else
      DbDocumentos.Columns(8).Visible = False
      DbDocumentos.Columns(9).Visible = True
      DbDocumentos.Columns(9).NumberFormat = GMascara(GintDecResultado)
      DbDocumentos.Columns(9).Alignment = dbgRight
      DbDocumentos.Columns(10).Visible = False
      DbDocumentos.Columns(11).Visible = False
      DbDocumentos.Columns(12).Visible = False
      DbDocumentos.Columns(13).Visible = False
      DbDocumentos.Columns(14).Visible = False
      DbDocumentos.Columns(15).Visible = False
      DbDocumentos.Columns(16).Visible = True
   End If
   DbDocumentos.Columns(16).Width = 650
   DbDocumentos.Columns(16).Alignment = dbgCenter
   DbDocumentos.Columns(16).Caption = "Selec."
      
End Sub
Public Sub FormatoGrillaArticulosResumen()
  '  strsql = " select siteid,[name],INVTIDSKU,DESCR, " & _
  '  " QTY,SLSPRICESALE,TOTALPEN,TOTALUSD, " & _
  '  " TAXPEN,TAXUSD  from tmp_ar_salesdet where CORRNBR =" & DblCorrelativo
   
  Dbresumenarticulos.Columns(0).Visible = False
  Dbresumenarticulos.Columns(1).Caption = "Almacén"
  Dbresumenarticulos.Columns(1).Width = 1400
  Dbresumenarticulos.Columns(2).Caption = "Código"
  Dbresumenarticulos.Columns(2).Width = 1000
  Dbresumenarticulos.Columns(3).Caption = "Descripción"
  Dbresumenarticulos.Columns(3).Width = 3350
  Dbresumenarticulos.Columns(4).Caption = "Cantidad"
  Dbresumenarticulos.Columns(4).Width = 940
  Dbresumenarticulos.Columns(4).Alignment = dbgRight
  Dbresumenarticulos.Columns(4).NumberFormat = GMascara(GintDecStock)
  Dbresumenarticulos.Columns(5).Width = 940
  Dbresumenarticulos.Columns(5).Caption = "Precio_Venta"
  Dbresumenarticulos.Columns(5).Alignment = dbgRight
  Dbresumenarticulos.Columns(5).NumberFormat = GMascara(GintDecPrecio)
  
  If dtcmoneda.BoundText = GstrCodMonedaBase Then
     Dbresumenarticulos.Columns(6).Caption = "Total"
     Dbresumenarticulos.Columns(6).Visible = True
     Dbresumenarticulos.Columns(6).Alignment = dbgRight
     Dbresumenarticulos.Columns(6).Width = 980
     Dbresumenarticulos.Columns(6).NumberFormat = GMascara(GintDecResultado)
     Dbresumenarticulos.Columns(7).Visible = False
  Else
     Dbresumenarticulos.Columns(7).Caption = "Total"
     Dbresumenarticulos.Columns(7).Visible = True
     Dbresumenarticulos.Columns(7).Alignment = dbgRight
     Dbresumenarticulos.Columns(7).Width = 980
     Dbresumenarticulos.Columns(7).NumberFormat = GMascara(GintDecResultado)
     
     Dbresumenarticulos.Columns(6).Visible = False
  End If
  Dbresumenarticulos.Columns(8).Visible = False
  Dbresumenarticulos.Columns(9).Visible = False
  
  
End Sub


Public Sub FormatoGrillaArticulos()
  ' " Select SITEID,DOCTYPEID,NBRDOCUMENT,TYPEPAYMENTID,INVTIDSKU,DESCR from VW_OP_SALESCABDET " & _
  ' " WHERE DATEPROCESALES BETWEEN '" & DatFechaDesde & "' AND '" & DatFechaHasta & "'" & _
  ' " AND custidss='" & StrCodCliente & "' AND SITEID IN " & _
  ' " (SELECT SITEID FROM TMP_AR_ALMACENES WHERE CORRNBR=" & DblCorrelativo & ")"
             
  DbArticulos.Columns(0).Visible = False
  DbArticulos.Columns(1).Visible = False
  DbArticulos.Columns(2).Visible = False
  DbArticulos.Columns(3).Visible = False
  DbArticulos.Columns(4).Caption = "Código"
  DbArticulos.Columns(5).Caption = "Descripción"
  DbArticulos.Columns(5).Width = 4000
             
End Sub

Public Sub FormatoGrillaVales()
  ' " select SITEID,DOCTYPEID,DATEPROCESALES,NBRDOCUMENT,NBRBONUS from VW_OP_SALESCABONUS " & _
  ' " WHERE DATEPROCESALES BETWEEN '" & DatFechaDesde & "' AND '" & DatFechaHasta & "'" & _
  ' " AND custidss='" & StrCodCliente & "' AND SITEID IN " & _
  ' " (SELECT SITEID FROM TMP_AR_ALMACENES WHERE CORRNBR=" & DblCorrelativo & ")"
  
  DbVales.Columns(0).Visible = False
  DbVales.Columns(1).Visible = False
  DbVales.Columns(2).Visible = False
  DbVales.Columns(3).Visible = False
  DbVales.Columns(4).Caption = "Número_de _Vale"
  DbVales.Columns(4).Width = 2200
  
  
End Sub

Private Sub DbDocumentos_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
'SITEID,DOCTYPEID,NBRDOCUMENT,TYPEPAYMENTID
On Error Resume Next
   If Not LrsArticulos Is Nothing Then
      If Not LrsArticulos.EOF Then
         LrsArticulos.Filter = " NBRDOCUMENT ='" & DbDocumentos.Columns(4).Text & "' and " & _
                               " DOCTYPEID='" & DbDocumentos.Columns(2).Text & "' and " & _
                               " SITEID='" & DbDocumentos.Columns(0).Text & "'"
      End If
    End If
    
   If Not LrsVales Is Nothing Then
      If Not LrsVales.EOF Then
         LrsVales.Filter = " NBRDOCUMENT ='" & DbDocumentos.Columns(4).Text & "' and " & _
                           " DOCTYPEID='" & DbDocumentos.Columns(2).Text & "' and " & _
                           " SITEID='" & DbDocumentos.Columns(0).Text & "'"
      End If
   End If

End Sub

Private Sub Dtcfactura_Change()
  txtfactura.Text = MobjVentasGeneral.obtenernrodocumento(lblfactura.Caption, Dtcfactura.BoundText, GstrSiteProce)
End Sub

Private Sub Dtcfactura_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     txtfactura.SetFocus
  End If
End Sub

Private Sub Dtcmoneda_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     DTPDel.SetFocus
  End If
End Sub

Private Sub dtcncredito_Change()
  txtncredito.Text = MobjVentasGeneral.obtenernrodocumento(lblncredito.Caption, dtcncredito.BoundText, GstrSiteProce)
End Sub

Private Sub dtcncredito_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     txtncredito.SetFocus
  End If
End Sub

Private Sub DTPAL_Keydown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
     optResumido.SetFocus
  End If
End Sub

Private Sub DTPDel_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
     DTPAL.SetFocus
  End If
End Sub

Private Sub DTPEmision_Change()
   
'   If DTPEmision.Value > GDatFechaProcesoVentas Then
'      MsgBox "Fecha de Emisión Tiene que ser Menor o Igual a Fecha de Proceso de Ventas ", vbDefaultButton1 + vbExclamation, "Advertencia"
'      DTPEmision.Value = GDatFechaProcesoVentas
'      'lblfechavenci.Caption = MobjCobranzas.ObtenerFechaVencimiento(lblcodcliente.Caption, lblterms.Caption, DTPEmision.Value)
'      Exit Sub
'   End If
'
'   If DTPEmision.Value < GDatFechaProceso Then
'      MsgBox "Fecha de Emisión Tiene que ser Mayor o Igual a " & GDatFechaProceso, vbDefaultButton1 + vbExclamation, "Advertencia"
'      DTPEmision.Value = GDatFechaProceso
'      'lblfechavenci.Caption = MobjCobranzas.ObtenerFechaVencimiento(lblcodcliente.Caption, lblterms.Caption, DTPEmision.Value)
'      Exit Sub
'   End If
    
   'Si es que Pasa se Calcula la Fecha de Vencimiento
   'lblfechavenci.Caption = MobjCobranzas.ObtenerFechaVencimiento(lblcodcliente.Caption, lblterms.Caption, DTPEmision.Value)
           
End Sub

Private Sub DTPEmision_KeyDown(KeyCode As Integer, Shift As Integer)
'  If KeyCode = 13 Then
'     'lblfechavenci.Caption = MobjCobranzas.ObtenerFechaVencimiento(lblcodcliente.Caption, lblterms.Caption, DTPEmision.Value)
'     dtcmoneda.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_Load()
           
   Call gseguridad(Me)
    
   If pbderecho_consultar Then
        Call obtener_datos
        Call asigna_campos
        pb_primerregistro = True
        'lineas nuevas
               Me.Left = (MDIFCcobrar.Width - Me.Width) / 2
               Me.Top = 100
                            
               ' Hay que Cargar los Tipos de Factura y de Nota de Credito
                  
               BlnClienteCargado = False
                     
               ' Crear Instancias
                     
               Set MobjVentasGeneral = New DB_OP_FACTURACION.C_VENTASGENERAL
               Set MobjCobranzas = New DB_AR_CUENTASCOBRAR.C_COBRANZAS
               Set MobjMoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
               Set MobjAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
               Set MobjCorrelativo = New DB_CORRELATIVO.C_Correlativos
               Set MobjDocumento = New DB_MA_MANTENIMIENTOS.C_DOCUMENTO
                  
               lblfactura.Caption = MobjVentasGeneral.obtenertipofactura
               lblncredito.Caption = MobjVentasGeneral.obtenertiponc
                
               Call CargaDataCombo(Dtcfactura, MobjVentasGeneral.obtenerseriesdoc(lblfactura.Caption, GstrSiteProce), "nbrseries", "nbrseries")
               Call CargaDataCombo(dtcncredito, MobjVentasGeneral.obtenerseriesdoc(lblncredito.Caption, GstrSiteProce), "nbrseries", "nbrseries")
            
                      
               Set MrsListadoMoneda = MobjMoneda.ListarMonedas
               
               Set dtcmoneda.DataSource = MrsListadoMoneda
               dtcmoneda.DataField = "descr"
               Set dtcmoneda.RowSource = MrsListadoMoneda
               dtcmoneda.ListField = "descr"
               dtcmoneda.BoundColumn = "curyid"
               If Not MrsListadoMoneda.EOF Then
                 dtcmoneda.BoundText = MrsListadoMoneda.Fields("descr")
               End If
                        
               ListRAlmacenes.llena_lista Nothing, MobjAlmacen.ListarAlmacenesPorStatus(1)
               ListRAlmacenes.Size (24)
                        
               txtfactura.Text = Empty
               txtncredito.Text = Empty
                   
               DTPDel.Value = "1/" & Month(Now) & "/" & Year(Now)
               DTPAL.Value = Day(Now) & "/" & Month(Now) & "/" & Year(Now)
               DTPEmision.Value = GDatFechaProceso
               HabilitarControles (False)
               HabilitaDatosIngreso (False)
                          
               SSTab1.Tab = 0
               BlnDocumentosgenerados = False
               DTPFechaDocu.Value = Now
               MstrOrden = "ASC"
        ' fin nuevas lineas
        ' Hay que Cargar el Combo de Tipo de Documento
                               
          Call CargaDataCombo(DtcTipoDocument, MobjCobranzas.ListarDocumentosCredito, "DOCTYPEID", "DESCR")
          Call CargaDataCombo(DtcAlmacenes, MobjAlmacen.ListarAlmacenesPorStatus(1), "SITEID", "NAME")
                                    
          DtcAlmacenes.BoundText = GstrSiteProce
          DtcTipoDocument.BoundText = lblncredito.Caption
                                    
        ' ---------------------------------------------------------------
   Else
        'Unload Me
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
   End If
              
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If Me.pb_editar Then
        If MsgBox("Desea Cancelar los Cambios", vbYesNo + vbQuestion, "Esta Modificando un registro") = vbNo Then
            Cancel = True
        Else
            Me.pb_agregar = False
            Me.pb_editar = False
            Call gdesactiva_barra
        End If
    Else
        Me.pb_agregar = False
        Me.pb_editar = False
        Call gdesactiva_barra
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
  MobjCobranzas.EliminarTmpAlmacenes MdblCorrelativo
  MobjCobranzas.EliminarTmpCtacte MdblCorrelativo
    
  Set MobjVentasGeneral = Nothing
  Set MobjCobranzas = Nothing
  Set MobjMoneda = Nothing
  Set MobjAlmacen = Nothing
  Set MobjCorrelativo = Nothing
  Set LrsArticulos = Nothing
  Set LrsVales = Nothing
  
End Sub

Sub LimpiaDatos()
  
  lblcodcliente.Caption = Empty
  lblrazonsocial.Caption = Empty
  txtdireccion.Text = Empty
  lblclascliente.Caption = Empty
  lblterms.Caption = Empty
  txtfactura.Text = Empty
  txtncredito.Text = Empty
  LblTipoCambio.Caption = Empty
  lblcodmonedabase.Caption = Empty
  
  
  BlnClienteCargado = False
  HabilitaDatosIngreso (BlnClienteCargado)
End Sub



Private Sub Optdetallado_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
    
   End If
End Sub

Private Sub Optresumido_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then

  End If
End Sub

Public Function ProcesarInformacion() As Boolean
    
    Dim LArrayAlmacenes()
    Dim LintFilas As Integer
    Dim i As Integer
    
   ' Primero Hay que Eliminar los Almacenes
     
        MobjCobranzas.EliminarTmpAlmacenes (MdblCorrelativo)
          
   ' Hay que Insertar en el Temporal de Almacenes
        
         LArrayAlmacenes = ListRAlmacenes.llenar_matriz
         LintFilas = UBound(LArrayAlmacenes)
          
         If LintFilas = 0 Then
            MsgBox "Debe seleccionar un Almacen", vbDefaultButton1 + vbExclamation, "Mensaje"
            ProcesarInformacion = False
            Exit Function
         End If
        
         For i = 1 To LintFilas
             MobjCobranzas.GrabarTmpAlmacenes MdblCorrelativo, LArrayAlmacenes(i, 1)
         Next
                
   ' Hay que Elimiar los Datos de las Tablas TMP_AR_SALES / TMP_AR_SALESDET
         
         Screen.MousePointer = 11
         
         MobjCobranzas.EliminarDatosResumen MdblCorrelativo
                
   ' Hay que Llenar las Tablas TMP_AR_SALES / TMP_AR_SALESDET
    'Carlos
'    MsgBox CStr(GintDecPrecio), vbQuestion, "Redondeo?"
             
         MobjCobranzas.CargarDatosResumen MdblCorrelativo, lblcodcliente.Caption, DTPDel.Value, DTPAL.Value, _
                                          dtcmoneda.BoundText, LblTipoCambio.Caption, GintDecPrecio
              
   ' Hay que Llenar la Grilla de Documentos
                       
         Set LrsDocumentosporCobrar = MobjCobranzas.ObtenerDocumentosCtaCte(MdblCorrelativo)
         Set DbDocumentos.DataSource = LrsDocumentosporCobrar
         DbDocumentos.Refresh
         'FormatoGrillaDocumentos
         
   ' Hay que Llenar la Grila de Resumen de Artículos
                         
         Set LrsArticulos = MobjCobranzas.ObtenerDetalleDocumentCtaCte(MdblCorrelativo, lblcodcliente.Caption, _
                                                                       DTPDel.Value, DTPAL.Value).Clone
                                                                                          
         Set DbArticulos.DataSource = LrsArticulos
         DbArticulos.Refresh
         'FormatoGrillaArticulos
    ' Hay que llenar la Grilla de Vales
                
         Set LrsVales = MobjCobranzas.ObtenerValesCtaCte(MdblCorrelativo, lblcodcliente.Caption, _
                                                         DTPDel.Value, DTPAL.Value).Clone

         Set DbVales.DataSource = LrsVales
         DbVales.Refresh
         'FormatoGrillaVales
         
         FormatoGrillaDocumentos
         FormatoGrillaArticulos
         FormatoGrillaVales
         
         'DbDocumentos.Visible = True
         'DbArticulos.Visible = True
         'DbVales.Visible = True
         
    ' Hay que Actualizar las Etiquetas
    
         If dtcmoneda.BoundText = GstrCodMonedaBase Then
            lblsubtotalmon.Caption = "SubTotal " & GstrSimboloMonedaBaseModGen
            lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
            lblnoafectomon.Caption = "No Afecto " & GstrSimboloMonedaBaseModGen
            lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
            lbligvmon.Caption = "IGV " & GstrSimboloMonedaBaseModGen
            lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
            lbltotalmon.Caption = "Total " & GstrSimboloMonedaBaseModGen
            lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
         Else
            lblsubtotalmon.Caption = "SubTotal " & GstrSimboloMonedaExtModGen
            lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
            lblnoafectomon.Caption = "No Afecto " & GstrSimboloMonedaExtModGen
            lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
            lbligvmon.Caption = "IGV " & GstrSimboloMonedaExtModGen
            lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
            lbltotalmon.Caption = "Total " & GstrSimboloMonedaExtModGen
            lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
         End If
         cmdacumulaart.Enabled = True
         cmdcambioprecio.Enabled = False
         cmdpreciopromed.Enabled = False
         Screen.MousePointer = 0
         
End Function
Public Function ProcesarInformacionResumida() As Boolean
    
    Dim LArrayAlmacenes()
    Dim LintFilas As Integer
    Dim i As Integer
    
   ' Primero Hay que Eliminar los Almacenes
     
         MobjCobranzas.EliminarTmpAlmacenes (MdblCorrelativo)
          
   ' Hay que Insertar en el Temporal de Almacenes
        
         LArrayAlmacenes = ListRAlmacenes.llenar_matriz
         LintFilas = UBound(LArrayAlmacenes)
          
         If LintFilas = 0 Then
            MsgBox "Debe seleccionar un Almacen", vbDefaultButton1 + vbExclamation, "Mensaje"
            ProcesarInformacionResumida = False
            Exit Function
         End If
        
         For i = 1 To LintFilas
             MobjCobranzas.GrabarTmpAlmacenes MdblCorrelativo, LArrayAlmacenes(i, 1)
         Next
                
   ' Hay que Elimiar los Datos de las Tablas TMP_AR_SALES / TMP_AR_SALESDET
         
         Screen.MousePointer = 11
         
      MobjCobranzas.EliminarDatosResumen MdblCorrelativo
                
   ' Hay que Llenar las Tablas TMP_AR_SALES / TMP_AR_SALESDET
      'MobjCobranzas
      MobjCobranzas.CargarDatosResumen MdblCorrelativo, lblcodcliente.Caption, DTPDel.Value, DTPAL.Value, _
                                       dtcmoneda.BoundText, LblTipoCambio.Caption, GintDecPrecio
                                                                                                         
    ' Hay que Llenar la Grila de Resumen de Artículos General
                                     
      Set LrsResumenArticulos = MobjCobranzas.ObtenerResumendeArticulos(MdblCorrelativo)
      Set Dbresumenarticulos.DataSource = LrsResumenArticulos
      Dbresumenarticulos.Refresh
         
         
    ' Hay que Actualizar las Etiquetas
    
         If dtcmoneda.BoundText = GstrCodMonedaBase Then
            lblsubtotalmon.Caption = "SubTotal " & GstrSimboloMonedaBaseModGen
            lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
            lblnoafectomon.Caption = "No Afecto " & GstrSimboloMonedaBaseModGen
            lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
            lbligvmon.Caption = "IGV " & GstrSimboloMonedaBaseModGen
            lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
            lbltotalmon.Caption = "Total " & GstrSimboloMonedaBaseModGen
            lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
         Else
            lblsubtotalmon.Caption = "SubTotal " & GstrSimboloMonedaExtModGen
            lblsubtotal.Caption = GFormatodeNumero(0, GintDecResultado)
            lblnoafectomon.Caption = "No Afecto " & GstrSimboloMonedaExtModGen
            lblnoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
            lbligvmon.Caption = "IGV " & GstrSimboloMonedaExtModGen
            lbligv.Caption = GFormatodeNumero(0, GintDecResultado)
            lbltotalmon.Caption = "Total " & GstrSimboloMonedaExtModGen
            lbltotal.Caption = GFormatodeNumero(0, GintDecResultado)
         End If
                           
      ' Hay que Actualizar los Totales
        FormatoGrillaArticulosResumen
        ActulizaTotalesResumen
      ' Hay que Cargar los Datos Originales en las Etiquetas
      
        Dim LrsTotalesResumen As ADODB.Recordset
        
        Set LrsTotalesResumen = MobjCobranzas.ObtenerTotalesGenerales(MdblCorrelativo)
          
        lblsubtotalBase.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMSUBTOTALPEN), 0, LrsTotalesResumen!SUMSUBTOTALPEN), GintDecResultado)
        lblnoafectoBase.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTOTALNOTAFFECTPEN), 0, LrsTotalesResumen!SUMTOTALNOTAFFECTPEN), GintDecResultado)
        lbligvBase.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTAXIGVPEN), 0, LrsTotalesResumen!SUMTAXIGVPEN), GintDecResultado)
        lbltotalBase.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTOTALPEN), 0, LrsTotalesResumen!SUMTOTALPEN), GintDecResultado)
  
        lblsubtotalExt.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMSUBTOTALUSD), 0, LrsTotalesResumen!SUMSUBTOTALUSD), GintDecResultado)
        lblnoafectoExt.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTOTALNOTAFFECTUSD), 0, LrsTotalesResumen!SUMTOTALNOTAFFECTUSD), GintDecResultado)
        lbligvext.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTAXIGVUSD), 0, LrsTotalesResumen!SUMTAXIGVUSD), GintDecResultado)
        lbltotalext.Caption = GFormatodeNumero(IIf(IsNull(LrsTotalesResumen!SUMTOTALUSD), 0, LrsTotalesResumen!SUMTOTALUSD), GintDecResultado)
                  
        Set LrsTotalesResumen = Nothing
        
      ' ------------------------------------
        cmdacumulaart.Enabled = False
        cmdcambioprecio.Enabled = True
        cmdpreciopromed.Enabled = True
        Screen.MousePointer = 0
         
End Function

Public Sub RefrescarGrilla()
  Set Dbresumenarticulos.DataSource = MobjCobranzas.ObtenerResumendeArticulos(MdblCorrelativo)
  Dbresumenarticulos.Refresh
  FormatoGrillaArticulosResumen
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
  If SSTab1.Tab = 1 Then
      Dim LArrayAlmacenes()
      Dim LintFilas As Integer
     ' Hay que Validar los Datos de Entrada
       
       If Trim(TxtRuc.Text) = Empty Then
          MsgBox "Debe Ingresar RUC del Cliente", vbDefaultButton1 + vbExclamation, "Advertencia"
          SSTab1.Tab = 0
          TxtRuc.SetFocus
          Exit Sub
       End If
       
       'If Trim(lblfechavenci.Caption) = Empty Then
       '   MsgBox "Debe Calcularse la Fecha de Vencimiento ", vbDefaultButton1 + vbExclamation, "Advertencia"
       '   SSTab1.Tab = 0
       '   DTPEmision.SetFocus
       '   Exit Sub
       'End If
          
       If txtfactura.Enabled = True Then
         If Trim(txtfactura.Text) = Empty Then
            MsgBox "Debe Ingresar el Número de la Factura ", vbDefaultButton1 + vbExclamation, "Advertencia"
            SSTab1.Tab = 0
            txtfactura.SetFocus
            Exit Sub
         End If
       End If
       
       If txtncredito.Enabled = True Then
         If Trim(txtncredito.Text) = Empty Then
            MsgBox "Debe Ingresar el Número de la Nota de Crédito ", vbDefaultButton1 + vbExclamation, "Advertencia"
            SSTab1.Tab = 0
            txtncredito.SetFocus
            Exit Sub
         End If
       End If
       
       LArrayAlmacenes = ListRAlmacenes.llenar_matriz
       LintFilas = UBound(LArrayAlmacenes)
    
       If LintFilas = 0 Then
            MsgBox "Debe seleccionar un Almacen", vbDefaultButton1 + vbExclamation, "Mensaje"
            SSTab1.Tab = 0
            ListRAlmacenes.SetFocus
            Exit Sub
       End If
       
     ' Hay que cargar los datos Principales en la ficha Procesar
        
       lblcodclientepro.Caption = lblcodcliente.Caption
       lblrucpro = TxtRuc.Text
       lblrazonsocialpro = lblrazonsocial.Caption
       lblfechaemi.Caption = DTPEmision.Value
               
       'lblvencipro.Caption = lblfechavenci.Caption
       
       txtfacturaproce.Text = Dtcfactura.BoundText & txtfactura.Text
       txtncreditoproce.Text = dtcncredito.BoundText & txtncredito.Text
        
     ' *************************************
     ' Hay que Cargar las Grillas
     ' *************************************
       'DbDocumentos.Visible = False
       'DbArticulos.Visible = False
       'DbVales.Visible = False
       
       If optDetallado.Value = True Then
          MostrarControles (1)
          ProcesarInformacion
          
          'Hay que Refrescar las Grillas
          
          If Not LrsArticulos Is Nothing Then
             If Not LrsArticulos.EOF Then
                LrsArticulos.Filter = " NBRDOCUMENT ='" & DbDocumentos.Columns(4).Text & "' and " & _
                                      " DOCTYPEID='" & DbDocumentos.Columns(2).Text & "' and " & _
                                      " SITEID='" & DbDocumentos.Columns(0).Text & "'"
             End If
          End If
    
          If Not LrsVales Is Nothing Then
             If Not LrsVales.EOF Then
                LrsVales.Filter = " NBRDOCUMENT ='" & DbDocumentos.Columns(4).Text & "' and " & _
                                  " DOCTYPEID='" & DbDocumentos.Columns(2).Text & "' and " & _
                                  " SITEID='" & DbDocumentos.Columns(0).Text & "'"
             End If
          End If
          
          'Fin de Refrescar las Grillas
       Else
          MostrarControles (0)
          ProcesarInformacionResumida
       End If
       cmdGenerar.Enabled = True
  End If
  
End Sub
Private Sub txtdireccion_KeyPress(KeyAscii As Integer)
   KeyAscii = GBloqueaCaracter(KeyAscii)
   If KeyAscii = 13 Then
      If Dtcfactura.Enabled = True Then
         Dtcfactura.SetFocus
      Else
         dtcncredito.SetFocus
      End If
   End If
End Sub

Private Sub txtfactura_KeyPress(KeyAscii As Integer)
  
  KeyAscii = GBloqueaCaracter(KeyAscii)
  
  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then
         dtcncredito.SetFocus
      End If
    Else
       KeyAscii = 0
    End If
  End If

End Sub

Private Sub txtncredito_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
  
  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then
         dtcmoneda.SetFocus
      End If
    Else
       KeyAscii = 0
    End If
  End If

End Sub

Private Sub FormatodeGrilla()
  If Not MrsdetalleDocumento.EOF Then
   If MrsdetalleDocumento!CURYID = GstrCodMonedaBase Then
      lbldescafecto.Caption = "Subtotal (Afecto) " & GstrSimboloMonedaBaseModGen
      lblSubtotalafecto.Caption = GFormatodeNumero(MrsdetalleDocumento!SUBTOTALPEN, GintDecResultado)
      lbldescNoafecto.Caption = "No Afecto " & GstrSimboloMonedaBaseModGen
      lblSubtotalNoafecto.Caption = GFormatodeNumero(MrsdetalleDocumento!TOTALNOTAFFECTPEN, GintDecResultado)
      lbldesIgv.Caption = "IGV " & GstrSimboloMonedaBaseModGen
      lbligvcons.Caption = GFormatodeNumero(MrsdetalleDocumento!TAXIGVPEN, GintDecResultado)
      lbldesTotal.Caption = "Total " & GstrSimboloMonedaBaseModGen
      lbltotalcons.Caption = GFormatodeNumero(MrsdetalleDocumento!TOTALPEN, GintDecResultado)
   Else
      lbldescafecto.Caption = "Subtotal (Afecto) " & GstrSimboloMonedaExtModGen
      lblSubtotalafecto.Caption = GFormatodeNumero(MrsdetalleDocumento!SUBTOTALUSD, GintDecResultado)
      lbldescNoafecto.Caption = "No Afecto " & GstrSimboloMonedaExtModGen
      lblSubtotalNoafecto.Caption = GFormatodeNumero(MrsdetalleDocumento!TOTALNOTAFFECTUSD, GintDecResultado)
      lbldesIgv.Caption = "IGV " & GstrSimboloMonedaExtModGen
      lbligvcons.Caption = GFormatodeNumero(MrsdetalleDocumento!TAXIGVUSD, GintDecResultado)
      lbldesTotal.Caption = "Total " & GstrSimboloMonedaExtModGen
      lbltotalcons.Caption = GFormatodeNumero(MrsdetalleDocumento!TOTALUSD, GintDecResultado)
   End If
  End If
   dbDetalle.Columns(0).Visible = False
   dbDetalle.Columns(1).Visible = False
   dbDetalle.Columns(2).Visible = False
   dbDetalle.Columns(3).Visible = False ' Moneda
   dbDetalle.Columns(4).Visible = False ' Placa
   dbDetalle.Columns(5).Visible = False ' cliente
   dbDetalle.Columns(6).Visible = False
   dbDetalle.Columns(7).Visible = False
   dbDetalle.Columns(8).Visible = False
   dbDetalle.Columns(9).Visible = False
   dbDetalle.Columns(10).Visible = False
   dbDetalle.Columns(11).Visible = False
   dbDetalle.Columns(12).Visible = False
   dbDetalle.Columns(13).Visible = False
   
   ' Parte de la Grilla que se Mostrará
   dbDetalle.Columns(14).Caption = "Nro"
   dbDetalle.Columns(14).Width = 500
   dbDetalle.Columns(15).Caption = "Código"
   dbDetalle.Columns(15).Width = 1500
   dbDetalle.Columns(16).Caption = "Descripción"
   dbDetalle.Columns(16).Width = 3500
   dbDetalle.Columns(17).Caption = "Precio"
   dbDetalle.Columns(17).Alignment = dbgRight
   dbDetalle.Columns(17).NumberFormat = GMascara(GintDecPrecio)
   dbDetalle.Columns(17).Width = 1000
   dbDetalle.Columns(18).Caption = "Cantidad"
   dbDetalle.Columns(18).Alignment = dbgRight
   dbDetalle.Columns(18).NumberFormat = GMascara(GintDecStock)
   dbDetalle.Columns(18).Width = 1000
      
   dbDetalle.Columns(19).Caption = "Total"
   dbDetalle.Columns(19).Alignment = dbgRight
   dbDetalle.Columns(19).NumberFormat = GMascara(GintDecResultado)
   dbDetalle.Columns(19).Width = 1000
   dbDetalle.Columns(20).Visible = False
   
           
   If Not MrsdetalleDocumento.EOF Then
     If MrsdetalleDocumento!CURYID = GstrCodMonedaBase Then
        dbDetalle.Columns(19).Caption = "Total"
        dbDetalle.Columns(19).Alignment = dbgRight
        dbDetalle.Columns(19).NumberFormat = GMascara(GintDecResultado)
        dbDetalle.Columns(19).Width = 1000
        dbDetalle.Columns(20).Visible = False
     Else
        dbDetalle.Columns(20).Caption = "Total"
        dbDetalle.Columns(20).Alignment = dbgRight
        dbDetalle.Columns(20).NumberFormat = GMascara(GintDecResultado)
        dbDetalle.Columns(20).Width = 1000
        dbDetalle.Columns(19).Visible = False
     End If
   End If
   
   dbDetalle.Columns(21).Visible = False
   dbDetalle.Columns(22).Visible = False
   dbDetalle.Columns(23).Visible = False
   dbDetalle.Columns(24).Visible = False
   dbDetalle.Columns(25).Visible = False
   dbDetalle.Columns(26).Visible = False
   
End Sub

Private Sub MostrarDatos()
    
  ' Cargar Datos de la Cabecera
    
    lblcodclientecons.Caption = MrsdetalleDocumento!CUSTIDSS
    lblRuc.Caption = MrsdetalleDocumento!TAXREGNBR
    lblrazonsocialcons.Caption = MrsdetalleDocumento!custname
    lblfechadocu.Caption = MrsdetalleDocumento!DATEDOC
    lblfechaproceso.Caption = MrsdetalleDocumento!DATEPROCESALES
    lblMoneda.Caption = MrsdetalleDocumento!DESRCMONEDA
    lblcodstatus.Caption = MrsdetalleDocumento!DOCSTATUSID
    
    If lblcodstatus.Caption = "PE" Then
       lblEstado.Caption = "Pendiente"
    End If
    If lblcodstatus.Caption = "CA" Then
       lblEstado.Caption = "Cancelado"
    End If
       
    If lblcodstatus.Caption = "AN" Then
       lblEstado.Caption = "ANULADO"
    End If
  ' ****************************

    Set dbDetalle.DataSource = MrsdetalleDocumento
    FormatodeGrilla
    dbDetalle.Refresh
       
    BlnDatosCargados = True
       
End Sub

Private Sub LimpiarDatos()

  'txtnumero.Text = Empty
  lblcodclientecons.Caption = Empty
  lblRuc.Caption = Empty
  lblrazonsocialcons.Caption = Empty
  lblfechadocu.Caption = Empty
  lblfechaproceso.Caption = Empty
  lblMoneda.Caption = Empty
  lblEstado.Caption = Empty
  lblSubtotalafecto.Caption = GFormatodeNumero(0, GintDecResultado)
  lblSubtotalNoafecto.Caption = GFormatodeNumero(0, GintDecResultado)
  lbligvcons.Caption = GFormatodeNumero(0, GintDecResultado)
  lbltotalcons.Caption = GFormatodeNumero(0, GintDecResultado)
  
  Set MrsdetalleDocumento = MobjCobranzas.ListarDocumento(DtcAlmacenes.BoundText, DtcTipoDocument.BoundText, 0)
  Set dbDetalle.DataSource = MrsdetalleDocumento
  FormatodeGrilla
  dbDetalle.Refresh
End Sub


Private Sub txtnumero_Change()
  If BlnDatosCargados = True Then
     LimpiarDatos
     BlnDatosCargados = False
  End If
End Sub

Private Sub txtnumero_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyF2 Then
    FBuscarDoc.Show vbModal
 End If
End Sub

Private Sub txtnumero_KeyPress(KeyAscii As Integer)

  KeyAscii = GBloqueaCaracter(KeyAscii)
  
  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then
         ' Parte en que se Busca el Documento
           Set MrsdetalleDocumento = MobjCobranzas.ListarDocumento(DtcAlmacenes.BoundText, DtcTipoDocument.BoundText, _
                                                                   txtnumero.Text)
           If MrsdetalleDocumento.EOF Then
              LimpiarDatos
              BlnDatosCargados = False
              MsgBox "Número de Documento no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
           Else
              MostrarDatos
           End If
      End If
    Else
       KeyAscii = 0
    End If
  End If

End Sub

Private Sub TxtRuc_Change()
   If BlnClienteCargado = True Then
      LimpiaDatos
   End If
End Sub

Private Sub TxtRuc_KeyDown(KeyCode As Integer, Shift As Integer)
  
  If KeyCode = vbKeyF2 Then
       Dim LArrayBusqueda(1 To 3, 1 To 3) As Variant
       Dim LrsClientesAyuda As ADODB.Recordset
       
       
       Set LrsClientesAyuda = MobjVentasGeneral.ListarClientesCtacteAyuda(1)
              
       LArrayBusqueda(1, 1) = "CUSTIDSS"
       LArrayBusqueda(1, 2) = "Código"
       LArrayBusqueda(1, 3) = 1200
       LArrayBusqueda(2, 1) = "CUSTNAME"
       LArrayBusqueda(2, 2) = "Descripción"
       LArrayBusqueda(2, 3) = 4500
       LArrayBusqueda(3, 1) = "TAXREGNBR"
       LArrayBusqueda(3, 2) = "RUC"
       LArrayBusqueda(3, 3) = 1200
      
       GrecibeUbicacion = 0
       GrecibeColumnaID = Empty
       GrecibeColumnaOpcional = Empty
  
       FBusquedaCCobrar.GObtenerRegistros LrsClientesAyuda, LArrayBusqueda, 3, 2
       FBusquedaCCobrar.Show vbModal
       If GrecibeUbicacion <> 0 Then
           lblcodcliente.Caption = GrecibeColumnaID
           TxtRuc.Text = GrecibeColumnaOpcional2
           TxtRuc_KeyPress (13)
       End If
       Set LrsClientesAyuda = Nothing
   End If

End Sub

Private Sub TxtRuc_KeyPress(KeyAscii As Integer)
  
  KeyAscii = GBloqueaCaracter(KeyAscii)
  
  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then
         If MostrarDatosCliente(TxtRuc.Text) = True Then
            txtdireccion.SetFocus
            HabilitaDatosIngreso (True)
         Else
            MsgBox "Cliente no puede ser registrado", vbDefaultButton1 + vbExclamation, "Advertencia"
            TxtRuc.Text = Empty
            lblcodcliente.Caption = Empty
            Exit Sub
         End If
       End If
    Else
       KeyAscii = 0
    End If
  End If
  
End Sub

Private Function MostrarDatosCliente(StrRucCliente As String) As Boolean
 Dim LrsDatosCliente As ADODB.Recordset
 
  Set LrsDatosCliente = MobjVentasGeneral.ListarClientesCtacteAyuda(0, StrRucCliente)
 
  If Not LrsDatosCliente.EOF Then
     
     lblcodcliente.Caption = LrsDatosCliente!CUSTIDSS
     TxtRuc.Text = LrsDatosCliente!TAXREGNBR
     lblrazonsocial.Caption = LrsDatosCliente!custname
     txtdireccion.Text = LrsDatosCliente!ADDR1
     lblclascliente.Caption = LrsDatosCliente!CUSTCLASSID
     lblterms.Caption = LrsDatosCliente!TERMIDSUM
     LblTipoCambio.Caption = LrsDatosCliente!CURYTYPEID
     
     If IsNull(LrsDatosCliente!CURYID) Then
      lblcodmonedabase.Caption = GstrCodMonedaBase
     Else
      lblcodmonedabase.Caption = LrsDatosCliente!CURYID
     End If
     
     If Trim(lblcodmonedabase.Caption) <> Empty Then
        dtcmoneda.BoundText = lblcodmonedabase.Caption
     Else
        dtcmoneda.BoundText = GstrCodMonedaBase
     End If
                
     MostrarDatosCliente = True
     
     BlnClienteCargado = True
     
     ' Hay que recargar los Correlativos de Factura y Nota de Credito
     If lblclascliente = "03" Then
        txtfactura.Text = MobjVentasGeneral.obtenernrodocumento(lblfactura.Caption, Dtcfactura.BoundText, GstrSiteProce)
     End If
     txtncredito.Text = MobjVentasGeneral.obtenernrodocumento(lblncredito.Caption, dtcncredito.BoundText, GstrSiteProce)
     lblfechavenci.Caption = MobjCobranzas.ObtenerFechaVencimiento(lblcodcliente.Caption, lblterms.Caption, DTPEmision.Value)
  Else
     MostrarDatosCliente = False
     BlnClienteCargado = False
  End If
  
  Set LrsDatosCliente = Nothing
 
End Function

Public Sub HabilitaDatosIngreso(BlnHabilita As Boolean)
            
      If lblclascliente.Caption = "03" Then
         Dtcfactura.Enabled = True
         txtfactura.Enabled = True
      Else
         Dtcfactura.Enabled = False
         txtfactura.Enabled = False
      End If
            
            
    ' *****************
    
      dtcncredito.Enabled = BlnHabilita
      txtncredito.Enabled = BlnHabilita
      'DTPEmision.Enabled = BlnHabilita
      dtcmoneda.Enabled = BlnHabilita
      
    ' *****************
      
      DbDocumentos.Enabled = BlnHabilita
      DbVales.Enabled = BlnHabilita
      DbArticulos.Enabled = BlnHabilita
      FraFiltrar.Enabled = BlnHabilita
      FraFormato.Enabled = BlnHabilita
      

End Sub

Public Sub HabilitarControles(BlnHabilita As Boolean)

      FraClientes.Enabled = BlnHabilita
           
    ' *****************
      FraAlmacenes.Enabled = BlnHabilita
               
    ' *****************
      SSTab1.TabEnabled(1) = BlnHabilita
      
End Sub

Private Sub TxtRuc_LostFocus()
On Error Resume Next
     If Trim(TxtRuc.Text) <> Empty Then
       If Len(Trim(TxtRuc.Text)) <> 11 Then
          MsgBox "EL RUC debe tener 11 Dígitos", vbDefaultButton1 + vbExclamation, "Advertencia"
          TxtRuc.SetFocus
          Exit Sub
       End If
     End If
End Sub
Public Sub primer_registro()
End Sub

Public Sub ultimo_registro()
End Sub

Public Sub registro_anterior()
End Sub
Public Sub registro_siguiente()
End Sub

Function valida_datos() As Boolean
  valida_datos = True
End Function

Public Sub grabar_registro()

On Error GoTo errhandler
    
    If valida_datos() = True Then
        ' llamada al proc de grabacion
        If pb_agregar Then
           If SSTab1.Tab = 0 Then
              SSTab1.Tab = 1
           End If
           If cmdGenerar.Enabled = True Then
                 
              If MsgBox("Seguro que desea Generar los Documentos", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
                Screen.MousePointer = 11
                cmdGenerar_Click
                Screen.MousePointer = 0
                If BlnDocumentosgenerados = False Then
                   Screen.MousePointer = 0
                   Exit Sub
                End If
              Else
                Screen.MousePointer = 0
                Exit Sub
              End If
           Else
                Screen.MousePointer = 0
                Exit Sub
           End If
        Else
                   
        End If
        
        Me.pb_agregar = False
        Me.pb_editar = False
        Call gactualiza_barra(Me)
        'Call gHabilitarReg(frm, frm.pb_editar)
        Call gactualizaopcion(Me.pbderecho_agregar, Me.pbderecho_editar, Me.pbderecho_borrar, Me.pbderecho_imprimir)
        LimpiaFormulario
        Actualizar_Registro
        
    End If
    Screen.MousePointer = 0
Exit Sub
errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error"
    
End Sub
Public Sub Actualizar_Registro()
    'llamar al procedimiento de carga
    Call obtener_datos
    Call asigna_campos
    'MsgBox ("Registros Actualizados")
End Sub
Public Sub agregar_registro()
    'Call gagregar_registro(Me, TxtRuc)
    
    cmdNuevo_Click
    
    Me.pb_agregar = True
    Me.pb_editar = True
    'gHabilitarReg Me, Me.pb_editar
    Call gactualiza_barra(Me)
    
    
End Sub
Public Sub modificar_registro()
    'Call gmodificar_registro(Me, txtCodigo)
End Sub
Public Sub descartar_registro()
    'Revertir cambios
    'adodc1.Recordset.CancelUpdate
    
    LimpiaFormulario
    
    'Call gdescartar_registro(Me)
    
    Me.pb_agregar = False
    Me.pb_editar = False
    
    'Call gHabilitarReg(frm, frm.pb_editar)
    
    Call gactualiza_barra(Me)
    Call gactualizaopcion(Me.pbderecho_agregar, Me.pbderecho_editar, Me.pbderecho_borrar, Me.pbderecho_imprimir)
    MsgBox ("Cambios Descartados"), vbInformation + vbDefaultButton1, "Mensaje"
    'Call asigna_campos
End Sub
Sub obtener_datos()
End Sub

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

Sub asigna_campos() ' falta decidir si va ha ser public o private
End Sub

Sub LimpiaFormulario()
    
    TxtRuc.Text = Empty
    lblcodcliente.Caption = Empty
    lblrazonsocial.Caption = Empty
    txtdireccion.Text = Empty
    
    BlnClienteCargado = False
    txtfactura.Text = Empty
    txtncredito.Text = Empty
               
    DTPDel.Value = "1/" & Month(Now) & "/" & Year(Now)
    DTPAL.Value = Day(Now) & "/" & Month(Now) & "/" & Year(Now)
    'DTPEmision.Value = GDatFechaProcesoVentas
    DTPEmision.Value = GDatFechaProceso
    HabilitarControles (False)
    HabilitaDatosIngreso (False)
    SSTab1.Tab = 0
    BlnDocumentosgenerados = False
    
    MobjCobranzas.EliminarTmpAlmacenes MdblCorrelativo
    MobjCobranzas.EliminarTmpCtacte MdblCorrelativo
    
End Sub



Public Sub CargaDatos(StrAlmacen As String, strTipoDoc As String, strDoc As String, dblNroDoc As Double)
'On Error GoTo TrataError
        
    txtnumero.Text = dblNroDoc
    DtcAlmacenes.BoundText = StrAlmacen
    DtcTipoDocument.BoundText = strTipoDoc
    txtnumero_KeyPress (13)
                   
'    Exit Sub
    
'TrataError:
    
'    MsgBox Err.Description, vbDefaultButton1 + vbCritical, "Error"

End Sub

Private Sub FormatoGrilla()
    dbDetalle.Columns(0).Width = 600
    dbDetalle.Columns(1).Width = 1000
    dbDetalle.Columns(1).Width = 1700
    dbDetalle.Columns(3).Alignment = dbgRight
    dbDetalle.Columns(3).NumberFormat = GMascara(GintDecStock)
    dbDetalle.Columns(3).Width = 1200
    dbDetalle.Columns(4).Alignment = dbgRight
    dbDetalle.Columns(4).NumberFormat = GMascara(GintDecCosto)
    dbDetalle.Columns(4).Width = 1200
    dbDetalle.Columns(5).Width = 1200
    dbDetalle.Columns(5).NumberFormat = GMascara(GintDecCosto)
    dbDetalle.Columns(5).Alignment = dbgRight
End Sub

Public Sub imprimir()
'On Error GoTo TrataError
Dim numero As String
Dim Letras As String
Dim MontoLetras As String
Dim acumNumGuia As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
   Set cn = New ADODB.Connection
   'cn.ConnectionString = "FILEDSN=CONEXIONSIES"
   cn.Open "FILEDSN=CONEXIONSIES"
   sql = "SELECT OP_BONUS.NBRBONUS FROM OP_BONUS WHERE NBRDOCUMENT IN (SELECT NBRDOCUMENTREF FROM OP_DOCREFERENCE WHERE NBRDOCUMENT='" & txtnumero.Text & "')"
Set rs = cn.Execute(sql)
If rs.State = adStateOpen Then
   Do While Not rs.EOF
      acumNumGuia = acumNumGuia & " " & rs(0)
      rs.MoveNext
   Loop
   'lblnnumguias.Caption = Trim(acumNumGuia)
End If
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing

'    If GVDATO(dtcAlmacen.BoundText) = Empty Then
'        MsgBox "Seleccione algún registro que desee Imprimir", vbExclamation, "Imprimir"
'        Exit Sub
'    End If
'    MontoLetras = InputBox("Ingrese el monto factura en letras...", "Factura", "")
    Screen.MousePointer = 11
    Dim bytValor As Byte
    If Trim(MobjVentasGeneral.obtenertipofactura) = Trim(DtcTipoDocument.BoundText) Then
        bytValor = 0
'crReporte.ReportFileName = GstrReportesVta + "rpt_Reporte_Factura.rpt"
        crReporte.ReportFileName = GstrReportesVta + "rpt_Factura_MM_3.rpt"
        crReporte.WindowTitle = "Factura Generada"
'        crReporte.ReportFileName = GstrReportesVta + "rpt_Reporte_NtaCreditoGenerada.rpt"
'        crReporte.WindowTitle = "NOTA DE CREDITO GENERADA"
'---------------------------------------------------------------------------------
    Dim SITEID As String
    Dim TIPODOC As String
    Dim RSFact As ADODB.Recordset
    Set RSFact = New ADODB.Recordset
    Dim sql1 As String
    Dim DBc As ADODB.Connection
    Set DBc = New ADODB.Connection
    DBc.Open "FILEDSN=conexionsies"
    RSFact.CursorLocation = adUseClient
   ' SITEID = MobjVentasGeneral.obtenerSITEID
    TIPODOC = Trim(DtcTipoDocument.BoundText)
    sql1 = "SELECT TOTALPEN FROM OP_SALES WHERE NBRDOCUMENT = '" & txtnumero.Text & "' and SITEID = '" & Trim(DtcAlmacenes.BoundText) & "' AND DOCTYPEID= '" & TIPODOC & "'"
    RSFact.Open sql1, DBc, adOpenDynamic ', DBBEG, adOpenDynamic, adLockReadOnly
    If RSFact.EOF Then
        RSFact.Close
        sql1 = "SELECT TOTALPEN FROM OP_SALES WHERE NBRDOCUMENT = '" & txtnumero.Text & "' and SITEID = '" & Trim(DtcAlmacenes.BoundText) & "'"
        RSFact.Open sql1, DBc, adOpenDynamic
        If rs.EOF Then
            MsgBox "No existe Documento", "Error"
            RSFact.Close
        Else
            RSFact.MoveFirst
            numero = RSFact.Fields(0)
        End If
    Else
        RSFact.MoveFirst
        numero = RSFact.Fields(0)
    End If
    RSFact.Close
    DBc.Close
'---------------------------------------------------------------------------------
        'numero = CStr(MrsEmision!TOTALBASE) 'GintDecResultado) 'GintDecResultado
        Letras = Numero2Letra(numero, , "Nuevos Soles" & " ", "Centimos" & " ")
          
        crReporte.Formulas(1) = "formTotLetras= stringvar totletras; totletras:='" & UCase(Letras) & "'"
    Else
'        bytValor = 0
        crReporte.ReportFileName = GstrReportesVta + "rpt_Reporte_NtaCreditoGenerada.rpt"
        crReporte.WindowTitle = "FACTURA GENERADA"
        'Copiado, Descomentado: Pablo N.
        crReporte.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
        crReporte.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='08.010.00'"
        crReporte.Formulas(3) = "formNDStock=" & GintDecStock
        crReporte.Formulas(4) = "formNDCosto=" & GintDecCosto
        crReporte.Formulas(5) = "formNDMonto=" & GintDecResultado
        crReporte.Formulas(6) = "formNDPrecio=" & GintDecPrecio
    End If
'Comentado: Pablo N.
'        crReporte.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
'        crReporte.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='08.010.00'"
'        crReporte.Formulas(3) = "formNDStock=" & GintDecStock
'        crReporte.Formulas(4) = "formNDCosto=" & GintDecCosto
'        crReporte.Formulas(5) = "formNDMonto=" & GintDecResultado
'        crReporte.Formulas(6) = "formNDPrecio=" & GintDecPrecio
                
'    crReporte.Formulas(1) = "formst='" & lblSubtotalafecto.Caption & "'"
'    crReporte.Formulas(2) = "formigv='" & lbligvcons.Caption & "'"
'    crReporte.Formulas(3) = "formtot='" & lbltotalcons.Caption & "'"
'    crReporte.Formulas(4) = "formletras='" & MontoLetras & "'"
'    crReporte.Formulas(5) = "formtv='CREDITO'"
'    crReporte.Formulas(6) = "formng='" & CStr(acumNumGuia) & "'"
    
    crReporte.StoredProcParam(0) = IIf(txtnumero.Text = "", 0, txtnumero.Text) 'codigo de factura
    crReporte.StoredProcParam(1) = Trim(DtcAlmacenes.BoundText) 'numero de estacion de venta
    
    If Trim(DtcTipoDocument.BoundText) = "01" Then  'FACTURA
       crReporte.StoredProcParam(2) = "01"
    Else
    If Trim(DtcTipoDocument.BoundText) = "07" Then  'NOTA DE CREDITO
       crReporte.StoredProcParam(2) = 0
    End If
    End If
    
   
        
    crReporte.WindowState = crptMaximized
    crReporte.WindowShowPrintSetupBtn = True
    crReporte.Action = 1
    crReporte.Reset
        
    Screen.MousePointer = 0
    Exit Sub

TrataError:
    Screen.MousePointer = 0
    MsgBox "Error Generando reporte", vbExclamation, "Error"
End Sub
