VERSION 5.00
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"; "MiControl.ocx"
Begin VB.Form FDocFree 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Documentos Libres (08.055.00)"
   ClientHeight    =   5490
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6105
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5490
   ScaleWidth      =   6105
   Begin VB.CommandButton cmdbuscarFp6 
      Caption         =   "Buscar FP6"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3720
      TabIndex        =   15
      Top             =   480
      Width           =   1455
   End
   Begin VB.Frame FraRangoFp6 
      Caption         =   "Rango [Fecha de Proceso]"
      Height          =   1095
      Left            =   360
      TabIndex        =   10
      Top             =   1440
      Width           =   2655
      Begin MSComCtl2.DTPicker dtpFechaProc2 
         Height          =   315
         Left            =   1140
         TabIndex        =   14
         Top             =   600
         Width           =   1365
         _ExtentX        =   2408
         _ExtentY        =   556
         _Version        =   393216
         Format          =   46530561
         CurrentDate     =   37852
      End
      Begin MSComCtl2.DTPicker dtpFechaProc1 
         Height          =   315
         Left            =   1140
         TabIndex        =   11
         Top             =   240
         Width           =   1365
         _ExtentX        =   2408
         _ExtentY        =   556
         _Version        =   393216
         Format          =   46530561
         CurrentDate     =   37693
      End
      Begin VB.Label Label1 
         Caption         =   "Fecha Fin"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   600
         Width           =   975
      End
      Begin VB.Label lblFechaProc 
         Caption         =   "Fecha Inicio"
         Height          =   465
         Left            =   120
         TabIndex        =   12
         Top             =   240
         Width           =   975
      End
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   2655
      Left            =   120
      TabIndex        =   9
      Top             =   2760
      Width           =   5895
      _ExtentX        =   10398
      _ExtentY        =   4683
      _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         =   "Tickets Procesados"
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            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            =   10250
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton cmddetalle 
      Caption         =   "<< Detalle"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4200
      TabIndex        =   8
      Top             =   2160
      Width           =   1815
   End
   Begin MiControl.CtrlNumber ctnMonto 
      Height          =   375
      Left            =   4290
      TabIndex        =   4
      Top             =   1590
      Width           =   1605
      _ExtentX        =   2831
      _ExtentY        =   661
      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 cmdBusCliente 
      Height          =   375
      Left            =   5520
      MousePointer    =   99  'Custom
      Picture         =   "0805500.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   3
      ToolTipText     =   "Buscar Tipo de Ingreso"
      Top             =   1050
      Width           =   375
   End
   Begin VB.CommandButton cmdBuscar 
      Enabled         =   0   'False
      Height          =   375
      Left            =   3120
      Picture         =   "0805500.frx":0532
      Style           =   1  'Graphical
      TabIndex        =   1
      ToolTipText     =   "Buscar"
      Top             =   480
      Width           =   375
   End
   Begin VB.TextBox txtCodigo 
      Height          =   285
      Left            =   1440
      MaxLength       =   10
      TabIndex        =   0
      Top             =   510
      Width           =   1575
   End
   Begin Crystal.CrystalReport crDocFree 
      Left            =   5640
      Top             =   360
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin MSDataListLib.DataCombo dtcCliente 
      Height          =   315
      Left            =   1440
      TabIndex        =   2
      Top             =   1050
      Width           =   3975
      _ExtentX        =   7011
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   ""
   End
   Begin VB.Line Line1 
      X1              =   120
      X2              =   6000
      Y1              =   2640
      Y2              =   2640
   End
   Begin VB.Image Image1 
      Height          =   630
      Left            =   5280
      Picture         =   "0805500.frx":0A64
      Stretch         =   -1  'True
      Top             =   120
      Width           =   585
   End
   Begin VB.Label lblMonto 
      Caption         =   "Monto"
      Height          =   285
      Left            =   3420
      TabIndex        =   7
      Top             =   1650
      Width           =   675
   End
   Begin VB.Label lblDescripcion 
      AutoSize        =   -1  'True
      Caption         =   "Cliente :"
      Height          =   195
      Left            =   390
      TabIndex        =   6
      Top             =   1110
      Width           =   570
   End
   Begin VB.Label lblCodigo 
      AutoSize        =   -1  'True
      Caption         =   "Código :"
      Height          =   195
      Left            =   390
      TabIndex        =   5
      Top             =   540
      Width           =   585
   End
End
Attribute VB_Name = "FDocFree"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Private LarrayDFest(1, 1) As Variant

Public pb_editar As Boolean
Public pb_agregar As Boolean
Public pb_primerregistro As Boolean
Public pb_ultimoregistro As Boolean

Public pbderecho_agregar As Boolean
Public pbderecho_consultar As Boolean
Public pbderecho_editar As Boolean
Public pbderecho_borrar As Boolean
Public pbderecho_imprimir As Boolean
Public pb_tiposcreen As String

Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String
Public GrecibeColumnaOpcional4 As String
Public GrecibeColumnaOpcional5 As String


Public rs_Docfree As ADODB.Recordset
Public rs_DocfreeH As ADODB.Recordset

Public objDocFree As DB_OP_MANTENIMIENTOS.C_DOCFREE
Public objDocFreeH As DB_OP_MANTENIMIENTOS.C_DOCFREEHEAD
Public objCliente As DB_MA_MANTENIMIENTOS.C_CLIENTE

Private Sub cmdBuscar_Click()
    'Lineas que llaman al Formulario de Búsqueda
                
    'SELECT D.DOCUMENTFREEID,C.CUSTNAME,D.CUSTIDSS,D.DATEPROCEINI,
    'D.DATEPROCEFIN,D.FREETOTAL FROM OP_DOCUMENTFREE AS D JOIN CUSTOMER AS C
    'ON D.CUSTIDSS=C.CUSTIDSS WHERE D.SITEID='" & strSITEID & "'"
            
    Dim ArrayBusqueda(1 To 5, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "DOCUMENTFREEID"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1200
    ArrayBusqueda(2, 1) = "CUSTNAME"
    ArrayBusqueda(2, 2) = "Cliente "
    ArrayBusqueda(2, 3) = 2650
    ArrayBusqueda(3, 1) = "DATEPROCEINI"
    ArrayBusqueda(3, 2) = "Fecha_Ini."
    ArrayBusqueda(3, 3) = 1150
    ArrayBusqueda(4, 1) = "DATEPROCEFIN"
    ArrayBusqueda(4, 2) = "Fecha_Fin."
    ArrayBusqueda(4, 3) = 1150
    ArrayBusqueda(5, 1) = "FREETOTAL"
    ArrayBusqueda(5, 2) = "Total"
    ArrayBusqueda(5, 3) = 1000
    
                      
    FBusquedaCCobrar.GObtenerRegistros rs_Docfree, ArrayBusqueda, 5, 2
    FBusquedaCCobrar.Show vbModal
    If GrecibeUbicacion <> 0 And GrecibeUbicacion <= rs_Docfree.RecordCount Then
          rs_Docfree.AbsolutePosition = GrecibeUbicacion
          asigna_campos
          Call gestadoactualrs(Me, rs_Docfree)
          Call gactualiza_barra(Me)
    End If
  
End Sub

Private Sub cmdbuscarFp6_Click()
    'Lineas que llaman al Formulario de Búsqueda
                                                
    Dim ArrayBusqueda(1 To 6, 1 To 3) As Variant
    
    ' SELECT D.DOCUMENTFREEID,C.CUSTNAME,SITE.NAME," & _
    " D.DATEPROCEINI , D.DATEPROCEFIN, D.FREETOTAL, D.SITEID, D.CUSTIDSS " & _

    ArrayBusqueda(1, 1) = "DOCUMENTFREEID"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "CUSTNAME"
    ArrayBusqueda(2, 2) = "Cliente "
    ArrayBusqueda(2, 3) = 2000
    ArrayBusqueda(3, 1) = "NAME"
    ArrayBusqueda(3, 2) = "Estación "
    ArrayBusqueda(3, 3) = 1300
    ArrayBusqueda(4, 1) = "DATEPROCEINI"
    ArrayBusqueda(4, 2) = "Fecha_Ini."
    ArrayBusqueda(4, 3) = 1000
    ArrayBusqueda(5, 1) = "DATEPROCEFIN"
    ArrayBusqueda(5, 2) = "Fecha_Fin."
    ArrayBusqueda(5, 3) = 1000
    ArrayBusqueda(6, 1) = "Freetotal"
    ArrayBusqueda(6, 2) = "Total "
    ArrayBusqueda(6, 3) = 1000
      
          
    FBusquedaCCobrar.GObtenerRegistros rs_DocfreeH, ArrayBusqueda, 6, 2
    FBusquedaCCobrar.Show vbModal
    If GrecibeUbicacion <> 0 And GrecibeUbicacion <= rs_DocfreeH.RecordCount Then
          rs_DocfreeH.AbsolutePosition = GrecibeUbicacion
          asigna_Campos_Head
          Call gestadoactualrs(Me, rs_Docfree)
          Call gactualiza_barra(Me)
    End If

End Sub

Private Sub cmddetalle_Click()

   Me.Height = 5955
   
   If cmddetalle.Caption = "<< Detalle" Then
      cmddetalle.Caption = "<< Ocultar"
      Me.Height = 5865
   Else
      cmddetalle.Caption = "<< Detalle"
      Me.Height = 3015
   End If
   
End Sub

Private Sub Command1_Click()

End Sub

Private Sub dtcCliente_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then
    cmdBusCliente_Click
End If
End Sub

Private Sub dtcCliente_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        'dtpFechaProc1.SetFocus
    End If
End Sub

Private Sub dtpFechaProc_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    'ctnMonto.SetFocus
End If
End Sub
Private Sub dtpFechaProc2_LostFocus()

   If dtpFechaProc2.Value < dtpFechaProc1.Value Then
      MsgBox "Fecha Final no puede ser Menor a la Fecha Inicial", vbDefaultButton1 + vbExclamation, "Mensaje"
      dtpFechaProc2.Value = dtpFechaProc1.Value
      Exit Sub
   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
    Else
       cmddetalle.Enabled = True
    End If
    
End Sub

Public Sub primer_registro()
    Call Gprimer_registro(Me, rs_Docfree)
    Call asigna_campos
End Sub

Public Sub ultimo_registro()
    Call Gultimo_registro(Me, rs_Docfree)
    Call asigna_campos
End Sub

Public Sub registro_anterior()
    Call Gregistro_anterior(Me, rs_Docfree)
    Call asigna_campos
End Sub
Public Sub registro_siguiente()
    Call Gregistro_siguiente(Me, rs_Docfree)
    Call asigna_campos
End Sub
Private Sub Form_Initialize()
    Call gHabilitarReg(Me, False)
End Sub

Private Sub Form_Load()
    'seguridad
    Call gseguridad(Me)
    
    If pbderecho_consultar Then
        Dim numreg As Long
        
        Me.Height = 3015
        Me.Top = 1300
        Me.Left = (Screen.Width - Me.Width) / 2
                
        ctnMonto.Enteros = 7
        ctnMonto.Decimales = GintDecResultado
        ctnMonto.ValorPorDefecto
        
        
        Set objDocFree = New DB_OP_MANTENIMIENTOS.C_DOCFREE
        Set objDocFreeH = New DB_OP_MANTENIMIENTOS.C_DOCFREEHEAD
        
        Set objCliente = New DB_MA_MANTENIMIENTOS.C_CLIENTE
                
        Call obtener_datos
                        
        Call CargaDataCombo(dtcCliente, objCliente.ListarClientesAyudaTPC, "CUSTIDSS", "CUSTNAME")
        Call asigna_campos
        
        pb_primerregistro = True
        cmddetalle.Enabled = True
        
    Else
    
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
        'Unload Me
        'Exit Sub
        
    End If
    
End Sub
Public Sub borrar_registro()

On Error GoTo errhandler

If GVDATO(txtCodigo.Text) <> Empty Then
    
    If Not objDocFree.ListarDocumentosLiberados(GstrSiteProce, txtCodigo.Text, dtpFechaProc1.Value, dtpFechaProc2.Value).EOF Then
       MsgBox "No se puede Eliminar FP6, Tiene registros procesados ", vbDefaultButton1 + vbExclamation, "Advertencia"
       Exit Sub
    End If
    
    objDocFree.EliminarDocFree GstrSiteProce, txtCodigo.Text
    Call gborrar_Registro(Me, rs_Docfree, txtCodigo)
End If

Exit Sub

errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error"

End Sub

Function valida_datos()

    If GVDATO(txtCodigo.Text) = Empty Then
        valida_datos = False
        MsgBox "Ingrese Código de Documento", vbInformation, "Error"
        txtCodigo.SetFocus
        Exit Function
    End If
   
    '**********************************************************************************************
    
    Dim rsFreeHeadVal As ADODB.Recordset
    Set rsFreeHeadVal = objDocFreeH.ListarPorDocFreeHeadID(GstrSiteProce, txtCodigo.Text)
    If rsFreeHeadVal.EOF Then
        valida_datos = False
        MsgBox "Código Fp6 no existe", vbDefaultButton1 + vbExclamation, "Mensaje"
        txtCodigo.SetFocus
        Exit Function
    Else
       Screen.MousePointer = 11
       txtCodigo.Text = rsFreeHeadVal!DOCUMENTFREEID
       dtcCliente.BoundText = rsFreeHeadVal!CUSTIDSS
       dtpFechaProc1.Value = rsFreeHeadVal!DATEPROCEINI
       dtpFechaProc2.Value = rsFreeHeadVal!DATEPROCEFIN
       ctnMonto.Text = rsFreeHeadVal!FREETOTAL
       Screen.MousePointer = 0
    End If
   
   '**********************************************************************************************
   
   
    If GVDATO(dtcCliente.BoundText) = Empty Then
        valida_datos = False
        MsgBox "Ingrese Cliente", vbInformation, "Error"
        'dtcCliente.SetFocus
        Exit Function
    End If
        
    If dtpFechaProc1.Value < GDatFechaProcesoVentas Then
        valida_datos = False
        MsgBox "No se puede registrar un Documento con una fecha inferior a la fecha de Proceso de Ventas", vbInformation, "Error"
        'dtpFechaProc1.SetFocus
        Exit Function
    End If
        
    If GVDATO(ctnMonto.Text) = Empty Or GVDATO(ctnMonto.Text) <= 0 Then
        valida_datos = False
        MsgBox "Ingrese Monto", vbInformation, "Error"
        'ctnMonto.SetFocus
        Exit Function
    End If
        
    If dtpFechaProc2.Value < dtpFechaProc1.Value Then
        valida_datos = False
        MsgBox "Fecha Final no puede ser Menor a la Fecha Inicial", vbDefaultButton1 + vbExclamation, "Mensaje"
        dtpFechaProc2.Value = dtpFechaProc1.Value
        Exit Function
    End If
                                                
    valida_datos = True
    
End Function
Public Sub grabar_registro()

On Error GoTo errhandler
    If valida_datos() = True Then
        ' llamada al proc de grabacion
        
        If MsgBox("Seguro que desea grabar el registro", vbYesNo + vbQuestion, "Mensaje") = vbYes Then
            LarrayDFest(1, 1) = dtpFechaProc2.Value
                            
            If pb_agregar Then
                objDocFree.AgregarDocFree GstrSiteProce, Trim(txtCodigo.Text), dtcCliente.BoundText, dtpFechaProc1.Value, GFormatodeNumero(CDbl(ctnMonto.Text), GintDecResultado), GCUSERID, LarrayDFest
            Else
                objDocFree.ActualizarDocFree GstrSiteProce, Trim(txtCodigo.Text), dtcCliente.BoundText, dtpFechaProc1.Value, GFormatodeNumero(CDbl(ctnMonto.Text), GintDecResultado), GCUSERID, LarrayDFest
            End If
            
            Call ggrabar_registro(Me)
            Actualizar_Registro
        End If
    End If
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, txtCodigo)
        
        
    'FraRangoFp6.Enabled = True
    'dtpFechaProc1.Enabled = True
    'dtpFechaProc1.Value = GDatFechaProcesoVentas
    'dtpFechaProc2.Enabled = True
    'dtpFechaProc2.Value = GDatFechaProcesoVentas
        
    dtcCliente.Enabled = False
    cmdBusCliente.Enabled = False
    ctnMonto.Enabled = False
        
    Set DataGrid1.DataSource = objDocFree.ListarDocumentosLiberados(GstrSiteProce, txtCodigo.Text, dtpFechaProc1.Value, dtpFechaProc2.Value)
    DataGrid1.Refresh

End Sub
Public Sub modificar_registro()
    
    If Not objDocFree.ListarDocumentosLiberados(GstrSiteProce, txtCodigo.Text, dtpFechaProc1.Value, dtpFechaProc2.Value).EOF Then
       MsgBox "No se puede Modificar FP6, Tiene registros procesados ", vbDefaultButton1 + vbExclamation, "Advertencia"
       Exit Sub
    End If
    Call gmodificar_registro(Me, txtCodigo)
    
    FraRangoFp6.Enabled = True
    dtpFechaProc1.Enabled = True
    dtpFechaProc2.Enabled = True
    
End Sub
Public Sub descartar_registro()
    ' Revertir cambios
    'adodc1.Recordset.CancelUpdate
    Call gdescartar_registro(Me)
    Call asigna_campos
End Sub

Sub obtener_datos()
    Set rs_Docfree = objDocFree.ListarDocFrees(GstrSiteProce)
    'Set rs_DocfreeH = objDocFreeH.ListarDocFreesHead(GstrSiteProce)
    
    Dim strsql As String
    
    strsql = " SELECT D.DOCUMENTFREEID,C.CUSTNAME,SITE.NAME," & _
             " D.DATEPROCEINI , D.DATEPROCEFIN, D.FREETOTAL, D.SITEID, D.CUSTIDSS " & _
             " FROM (OP_DOCUMENTFREE_HEAD AS D JOIN CUSTOMER AS C " & _
             " ON D.CUSTIDSS=C.CUSTIDSS) INNER JOIN SITE " & _
             " ON D.SITEID=SITE.SITEID " & _
             " Where STKDEL = 0 and DOCUMENTFREEID " & _
             " NOT IN (SELECT DOCUMENTFREEID  FROM OP_DOCUMENTFREE)"
                 
    Set rs_DocfreeH = objDocFreeH.Auxiliar1(strsql)
            
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_Head()
    
    If rs_DocfreeH.RecordCount <> 0 Then
       txtCodigo.Text = rs_DocfreeH!DOCUMENTFREEID
       dtcCliente.BoundText = rs_DocfreeH!CUSTIDSS
       dtpFechaProc1.Value = rs_DocfreeH!DATEPROCEINI
       dtpFechaProc2.Value = rs_DocfreeH!DATEPROCEFIN
       ctnMonto.Text = GFormatodeNumero(rs_DocfreeH!FREETOTAL, GintDecResultado)
    End If
        
End Sub


Sub asigna_campos() ' falta decidir si va ha ser public o private
    
    If rs_Docfree.RecordCount <> 0 Then
                
        txtCodigo.Text = rs_Docfree!DOCUMENTFREEID
        dtcCliente.BoundText = rs_Docfree!CUSTIDSS
        dtpFechaProc1.Value = rs_Docfree!DATEPROCEINI
        dtpFechaProc2.Value = rs_Docfree!DATEPROCEFIN
        ctnMonto.Text = GFormatodeNumero(rs_Docfree!FREETOTAL, GintDecResultado)
        Set DataGrid1.DataSource = objDocFree.ListarDocumentosLiberados(GstrSiteProce, txtCodigo.Text, dtpFechaProc1.Value, dtpFechaProc2.Value)
        DataGrid1.Refresh
        
    End If
    
    
End Sub

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

Private Sub Form_Unload(Cancel As Integer)
    Set objDocFree = Nothing
    Set objDocFreeH = Nothing
    Set rs_Docfree = Nothing
    Set rs_DocfreeH = Nothing
End Sub


Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then
         
        If Trim(txtCodigo.Text) = Empty Then
           MsgBox "Ingrese código de la FP6", vbDefaultButton1 + vbExclamation, "Mensaje"
           txtCodigo.SetFocus
           Exit Sub
        End If
    
        Dim rsFreeHead As ADODB.Recordset
        Set rsFreeHead = objDocFreeH.ListarPorDocFreeHeadID(GstrSiteProce, txtCodigo.Text)
         
        If Not rsFreeHead.EOF Then
           txtCodigo.Text = rsFreeHead!DOCUMENTFREEID
           dtcCliente.BoundText = rsFreeHead!CUSTIDSS
           dtpFechaProc1.Value = rsFreeHead!DATEPROCEINI
           dtpFechaProc2.Value = rsFreeHead!DATEPROCEFIN
           ctnMonto.Text = rsFreeHead!FREETOTAL
        Else
           MsgBox "Código Fp6 no existe ", vbDefaultButton1 + vbExclamation, "Mensaje"
           txtCodigo.Text = Empty
           txtCodigo.SetFocus
           Exit Sub
        End If
        
        'dtcCliente.SetFocus
    End If
End Sub

Sub imprimir()
    crDocFree.ReportFileName = GstrReportesVta + "rpt_DocumentoLibre.rpt"
    crDocFree.WindowTitle = "Reporte de Documento Libre"
    crDocFree.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
    crDocFree.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='01.117.00'"
    crDocFree.Formulas(3) = "formNDMonto=" & GintDecResultado
    
    crDocFree.StoredProcParam(0) = GstrSiteProce
    crDocFree.StoredProcParam(1) = txtCodigo.Text
    
    crDocFree.WindowState = crptMaximized
    crDocFree.WindowShowPrintSetupBtn = True
    crDocFree.Action = 1
    
End Sub

Private Sub txtDescripcion_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As Recordset, istrCampo1 As String, istrCampo2 As String)

    Set objDataCombo.DataSource = rsSource
    objDataCombo.DataField = istrCampo2
    Set objDataCombo.RowSource = rsSource
    objDataCombo.ListField = istrCampo2
    objDataCombo.BoundColumn = istrCampo1
    
    If Not rsSource.EOF Then
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If

End Sub

Private Sub cmdBusCliente_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "CUSTIDSS"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1500
    ArrayBusqueda(2, 1) = "CUSTNAME"
    ArrayBusqueda(2, 2) = "Nombre "
    ArrayBusqueda(2, 3) = 4000
      
    FBusquedaCCobrar.GObtenerRegistros objCliente.ListarClientesAyudaTPC, ArrayBusqueda, 2, 2
    FBusquedaCCobrar.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
        dtcCliente.BoundText = GrecibeColumnaID
    End If
    
End Sub

Private Sub txtCodigo_LostFocus()
    
    'Dim rsFreeHeadlF As ADODB.Recordset
    'Set rsFreeHeadlF = objDocFreeH.ListarPorDocFreeHeadID(GstrSiteProce, txtCodigo.Text)
    'Screen.MousePointer = 11
    'If Not rsFreeHeadlF.EOF Then
    '   txtCodigo.Text = rsFreeHeadlF!DOCUMENTFREEID
    '   dtcCliente.BoundText = rsFreeHeadlF!CUSTIDSS
    '   dtpFechaProc1.Value = rsFreeHeadlF!DATEPROCEINI
    '   dtpFechaProc2.Value = rsFreeHeadlF!DATEPROCEFIN
    '   ctnMonto.Text = rsFreeHeadlF!FREETOTAL
    'Else
    '   MsgBox "Código Fp6 no existe ", vbDefaultButton1 + vbExclamation, "Mensaje"
    '   txtCodigo.Text = Empty
    '   txtCodigo.SetFocus
    '   Exit Sub
    'End If
    'Screen.MousePointer = 0
    'Set rsFreeHeadlF = Nothing
    
End Sub
