VERSION 5.00
Begin VB.Form FReimpTickets 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Reimpresión de Tickets"
   ClientHeight    =   3135
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4965
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   3135
   ScaleWidth      =   4965
   Begin VB.ComboBox CmbPuerto 
      Height          =   315
      Left            =   960
      TabIndex        =   13
      Top             =   1320
      Width           =   1725
   End
   Begin VB.CheckBox chk 
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   2040
      Width           =   255
   End
   Begin VB.TextBox txtNumero 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1020
      MaxLength       =   10
      TabIndex        =   2
      Top             =   840
      Width           =   1665
   End
   Begin VB.Frame Frame2 
      Appearance      =   0  'Flat
      BackColor       =   &H80000004&
      Caption         =   "Negocio"
      ForeColor       =   &H80000008&
      Height          =   735
      Left            =   180
      TabIndex        =   11
      Top             =   0
      Width           =   2745
      Begin VB.OptionButton optPlaya 
         Caption         =   "Playa"
         Height          =   285
         Left            =   1650
         TabIndex        =   1
         Top             =   330
         Width           =   915
      End
      Begin VB.OptionButton optTienda 
         Caption         =   "Tienda"
         Height          =   345
         Left            =   420
         TabIndex        =   0
         Top             =   300
         Value           =   -1  'True
         Width           =   1065
      End
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000004&
      Caption         =   "        Rango de Tickets"
      Enabled         =   0   'False
      ForeColor       =   &H80000008&
      Height          =   1215
      Left            =   180
      TabIndex        =   8
      Top             =   1800
      Width           =   2745
      Begin VB.TextBox txtNumeroIni 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   840
         MaxLength       =   10
         TabIndex        =   4
         Top             =   300
         Width           =   1665
      End
      Begin VB.TextBox txtNumeroFin 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   840
         MaxLength       =   10
         TabIndex        =   5
         Top             =   720
         Width           =   1665
      End
      Begin VB.Label lblNumeroIni 
         Caption         =   "Inicial :"
         Height          =   315
         Left            =   240
         TabIndex        =   10
         Top             =   330
         Width           =   525
      End
      Begin VB.Label Label1 
         Caption         =   "Final :"
         Height          =   375
         Left            =   210
         TabIndex        =   9
         Top             =   720
         Width           =   585
      End
   End
   Begin VB.CommandButton cmdCancelar 
      Caption         =   "&Cancelar"
      Height          =   795
      Left            =   3120
      Picture         =   "FReimpTickets.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   2160
      Width           =   1590
   End
   Begin VB.CommandButton cmdReimp 
      Caption         =   "&Reimprimir"
      Height          =   795
      Left            =   3120
      Picture         =   "FReimpTickets.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   1320
      Width           =   1590
   End
   Begin VB.Label Label3 
      Caption         =   "Puerto"
      Height          =   255
      Left            =   240
      TabIndex        =   14
      Top             =   1320
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "Número"
      Height          =   315
      Left            =   210
      TabIndex        =   12
      Top             =   960
      Width           =   705
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   3660
      Picture         =   "FReimpTickets.frx":0614
      Top             =   240
      Width           =   480
   End
End
Attribute VB_Name = "FReimpTickets"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' EDGAR MARTIN CANCHO RUIZ

Option Explicit
Public pb_editar As Boolean
Public pb_agregar As Boolean
Public pb_primerregistro As Boolean
Public pb_ultimoregistro As Boolean
Public pbderecho_agregar As Boolean
Public pbderecho_consultar As Boolean
Public pbderecho_editar As Boolean
Public pbderecho_borrar As Boolean
Public pbderecho_imprimir As Boolean
Public pbderecho_anular As Boolean
Public pbderecho_emitir As Boolean
Public pb_tiposcreen As String
 
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String

Public objImpresion As DB_UT_MANTENIMIENTOS.C_REIMPRE
Public sDispositivo As String
Private Sub CargarP()
Dim TPrinter As Printer
    CmbPuerto.Clear
    For Each TPrinter In Printers
        CmbPuerto.AddItem UCase(TPrinter.Port) & " " & TPrinter.DeviceName
    Next
End Sub

Public Sub salir_formulario()
Unload Me
End Sub

Private Sub chk_Click()
If chk.Value = 1 Then
    Frame1.Enabled = True
    txtNumero.Enabled = False
Else
    Frame1.Enabled = False
    txtNumero.Enabled = True
End If
End Sub

Private Sub CmbPuerto_Change()
CmbPuerto.Text = Left(CmbPuerto.Text, 10)
End Sub

Private Sub CmbPuerto_Click()
'CmbPuerto.Text = Left(CmbPuerto.Text, 10)
End Sub

Private Sub CmbPuerto_LostFocus()
CmbPuerto.Text = Left(CmbPuerto.Text, 10)
End Sub

Private Sub cmdCancelar_Click()
    Unload Me
End Sub

Private Sub cmdReimp_Click()
    Dim rsTickets As ADODB.Recordset

    
If chk.Value = 1 Then
    If Len(Trim(txtNumeroIni.Text)) < 10 Or Len(Trim(txtNumeroFin.Text)) < 10 Then
        MsgBox "Número Inicial y Número final deben contener 10 caracteres", vbExclamation, "Error de Ingreso"
        Exit Sub
    End If
    
    If Val(txtNumeroIni.Text) > Val(txtNumeroFin.Text) Then
        MsgBox "Número Inicial noi puede ser mayor que Número final", vbExclamation, "Error de Ingreso"
        Exit Sub
    End If
    
    If (Val(txtNumeroFin.Text) - Val(txtNumeroIni.Text)) > 50 Then
        MsgBox "Solo se permite un Rango de tickets no mayor a 50", vbExclamation, "Error de Ingreso"
        Exit Sub
    End If
    
Else
    If Len(Trim(txtNumero.Text)) < 10 Then
        MsgBox "Número debe contener 10 caracteres", vbExclamation, "Error de Ingreso"
        Exit Sub
    End If
End If

sDispositivo = Empty
If Len(Trim(CmbPuerto.Text)) < 1 Then
    MsgBox "Especifique el puerto de impresora", vbExclamation + 0
    CmbPuerto.SetFocus
    Exit Sub
End If

sDispositivo = Trim(CmbPuerto.Text)

    Screen.MousePointer = 11
    
If chk.Value = 1 Then
    Set rsTickets = objImpresion.ListarTickets(GstrSiteProce, CDbl(txtNumeroIni.Text), CDbl(txtNumeroFin.Text))
Else
    Set rsTickets = objImpresion.ListarTickets(GstrSiteProce, CDbl(txtNumero.Text), CDbl(txtNumero.Text))
End If

    While Not rsTickets.EOF
        
        Call ImprimeTicket(rsTickets!NBRDOCUMENT)
        rsTickets.MoveNext
    Wend
    Set rsTickets = Nothing

If chk.Value = 1 Then
    txtNumeroIni.SetFocus
Else
    txtNumero.SetFocus
End If

Screen.MousePointer = 0
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

Private Sub Form_Activate()
 txtNumero.SetFocus
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_Load()
    
    'seguridad
    Call gseguridad(Me)
    Call CargarP
   ' If pbderecho_consultar Then

        Set objImpresion = New DB_UT_MANTENIMIENTOS.C_REIMPRE
        pb_primerregistro = True
        'lineas nuevas
        Me.Top = 1300
        Me.Left = (Screen.Width - Me.Width) / 2
    'Else
        'Unload Me
     '   MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    'End If
    
End Sub
Private Sub ImprimeTicket(dblNumeroTiket As Double)
    Dim rsCabeceraVenta As ADODB.Recordset
    Dim rsDetalleVenta As ADODB.Recordset
    Dim rsTarjetasVenta As ADODB.Recordset
    Dim rsValesVenta As ADODB.Recordset
    Dim IntTurno As Integer
    Dim strCARA As String
    Dim strMonedaTarjeta As String
    Dim strNombreTarjeta As String
    Dim StrNumeroTarjeta As String
    Dim strTipoDoc As String
    Dim strDescTipoDoc As String
    
    Set rsCabeceraVenta = objImpresion.ObtenerDatosCabecera(GstrSiteProce, dblNumeroTiket)
    GStrMaquinaReg = rsCabeceraVenta!serialnumber
    GstrPuntodeVenta = rsCabeceraVenta!SALESPOINT
    strTipoDoc = rsCabeceraVenta!DOCTYPEID
    strDescTipoDoc = rsCabeceraVenta!DESCDOC
    
    Call ObtenerConfiguracionTicket
    
    Set rsDetalleVenta = objImpresion.ObtenerDatosDetalle(GstrSiteProce, dblNumeroTiket, 2)
    IntTurno = rsDetalleVenta!NBRTURN
    
    strCARA = Empty
    While Not rsDetalleVenta.EOF
        If Not IsNull(rsDetalleVenta!NBRSIDE) Then
            strCARA = rsDetalleVenta!NBRSIDE
        End If
        rsDetalleVenta.MoveNext
    Wend
    rsDetalleVenta.MoveFirst
    
    Set rsValesVenta = objImpresion.obtenervalesventa(dblNumeroTiket, GstrSiteProce)
    Set rsTarjetasVenta = objImpresion.obtenertarjetasventa(strTipoDoc, dblNumeroTiket, GstrSiteProce)
    
    If Not rsTarjetasVenta.EOF Then
        strMonedaTarjeta = rsTarjetasVenta!curyid
        strNombreTarjeta = rsTarjetasVenta!DESCR
        StrNumeroTarjeta = rsTarjetasVenta!NBRCARD
    Else
        strMonedaTarjeta = Empty
        strNombreTarjeta = Empty
        StrNumeroTarjeta = Empty
    
    End If
    
    
    If optPlaya.Value = True Then
        ' se llama a la rutina de impresion de kike
        Call Imprimir_Ticket(rsCabeceraVenta!PLACA, CStr(dblNumeroTiket), 40, IIf(IsNull(rsCabeceraVenta!CUSTNAME), Empty, rsCabeceraVenta!CUSTNAME), _
                            IIf(IsNull(rsCabeceraVenta!taxregnbr), Empty, rsCabeceraVenta!taxregnbr), IIf(IsNull(rsCabeceraVenta!ADDR1), Empty, rsCabeceraVenta!ADDR1), _
                            rsCabeceraVenta!curyid, 0, rsCabeceraVenta!SUBTOTALPEN, rsCabeceraVenta!SUBTOTALUSD, rsCabeceraVenta!TAXIGVPEN, _
                            rsCabeceraVenta!TAXIGVUSD, rsCabeceraVenta!TOTALPEN, rsCabeceraVenta!TOTALUSD, _
                            rsCabeceraVenta!TOTALNOTAFFECTPEN, rsCabeceraVenta!TOTALNOTAFFECTUSD, rsDetalleVenta, rsCabeceraVenta!TYPEPAYMENTID, strMonedaTarjeta, _
                            IntTurno, strCARA, rsCabeceraVenta!SALESPERNAME, rsCabeceraVenta!PORCENTDISCOUNT1, rsCabeceraVenta!TOTDISCOUNTPEN, "", strNombreTarjeta, StrNumeroTarjeta, rsValesVenta, IIf(IsNull(rsCabeceraVenta!PLACA), Empty, rsCabeceraVenta!PLACA), 1, rsCabeceraVenta!DATEDOC, CmbPuerto.Text)
        
    Else
        ' se llama a la rutina de impresion de Gus
    
        'Call Imprimir_Ticketcstore(strDescTipoDoc, CStr(dblNumeroTiket), 40, IIf(IsNull(rsCabeceraVenta!CUSTNAME), Empty, rsCabeceraVenta!CUSTNAME), _
                                    IIf(IsNull(rsCabeceraVenta!taxregnbr), Empty, rsCabeceraVenta!taxregnbr), IIf(IsNull(rsCabeceraVenta!ADDR1), Empty, rsCabeceraVenta!ADDR1), _
                                    rsCabeceraVenta!curyid, 0, rsCabeceraVenta!SUBTOTALPEN, rsCabeceraVenta!SUBTOTALUSD, rsCabeceraVenta!TAXIGVPEN, _
                                    rsCabeceraVenta!TAXIGVUSD, rsCabeceraVenta!TOTALPEN, rsCabeceraVenta!TOTALUSD, _
                                    rsCabeceraVenta!TOTALNOTAFFECTPEN, rsCabeceraVenta!TOTALNOTAFFECTUSD, rsCabeceraVenta!TOTCASHPEN, _
                                    rsCabeceraVenta!TOTCASHUSD, rsCabeceraVenta!TOTRETURNEDPEN, rsCabeceraVenta!TOTRETURNEDUSD, _
                                    rsDetalleVenta, rsCabeceraVenta!TYPEPAYMENTID, IntTurno, _
                                    rsCabeceraVenta!SALESPERNAME, 0, IIf(IsNull(rsCabeceraVenta!PLACA), Empty, rsCabeceraVenta!PLACA), rsTarjetasVenta, 1, rsCabeceraVenta!DATEDOC)
    If Trim(strDescTipoDoc) = "TICKET" Then strDescTipoDoc = "Ticket"
    Call Imprimir_Ticketcstore_PantImpre(strDescTipoDoc, CStr(dblNumeroTiket), 40, IIf(IsNull(rsCabeceraVenta!CUSTNAME), Empty, rsCabeceraVenta!CUSTNAME), _
                                    IIf(IsNull(rsCabeceraVenta!taxregnbr), Empty, rsCabeceraVenta!taxregnbr), IIf(IsNull(rsCabeceraVenta!ADDR1), Empty, rsCabeceraVenta!ADDR1), _
                                    rsCabeceraVenta!curyid, 0, rsCabeceraVenta!SUBTOTALPEN, rsCabeceraVenta!SUBTOTALUSD, rsCabeceraVenta!TAXIGVPEN, _
                                    rsCabeceraVenta!TAXIGVUSD, rsCabeceraVenta!TOTALPEN, rsCabeceraVenta!TOTALUSD, _
                                    rsCabeceraVenta!TOTALNOTAFFECTPEN, rsCabeceraVenta!TOTALNOTAFFECTUSD, rsCabeceraVenta!TOTCASHPEN, _
                                    rsCabeceraVenta!TOTCASHUSD, rsCabeceraVenta!TOTRETURNEDPEN, rsCabeceraVenta!TOTRETURNEDUSD, _
                                    rsDetalleVenta, rsCabeceraVenta!TYPEPAYMENTID, IntTurno, _
                                    rsCabeceraVenta!SALESPERNAME, 0, IIf(IsNull(rsCabeceraVenta!PLACA), Empty, rsCabeceraVenta!PLACA), rsTarjetasVenta, 1, rsCabeceraVenta!DATEDOC, rsValesVenta, sDispositivo)
    End If
                                    
    Set rsCabeceraVenta = Nothing
    Set rsDetalleVenta = Nothing
    Set rsTarjetasVenta = Nothing
    Set rsValesVenta = Nothing

End Sub

Private Sub txtNumero_GotFocus()
    txtNumero.BackColor = GC_ColorEnfoque
End Sub

Private Sub txtNumero_KeyPress(KeyAscii As Integer)
KeyAscii = ValidaNumeros(KeyAscii)
    If KeyAscii = 13 Then
        cmdReimp_Click
    End If
End Sub

Private Sub txtNumero_LostFocus()
txtNumero.BackColor = GC_ColorDefecto
End Sub

Private Sub txtNumeroFin_GotFocus()
    txtNumeroFin.BackColor = GC_ColorEnfoque
End Sub

Private Sub txtNumeroFin_KeyPress(KeyAscii As Integer)
KeyAscii = ValidaNumeros(KeyAscii)
    If KeyAscii = 13 Then
        cmdReimp.SetFocus
    End If
End Sub

Private Sub txtNumeroFin_LostFocus()
    txtNumeroFin.BackColor = GC_ColorDefecto
End Sub

Private Sub txtNumeroIni_GotFocus()
    txtNumeroIni.BackColor = GC_ColorEnfoque
End Sub

Private Sub txtNumeroIni_KeyPress(KeyAscii As Integer)
KeyAscii = ValidaNumeros(KeyAscii)
    If KeyAscii = 13 Then
        txtNumeroFin.SetFocus
    End If
End Sub

Private Sub txtNumeroIni_LostFocus()
    txtNumeroIni.BackColor = GC_ColorDefecto
End Sub

Private Function ValidaNumeros(KeyAscii As Integer) As Integer
    If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 13 Or KeyAscii = 8 Then
        ValidaNumeros = KeyAscii
    Else
        ValidaNumeros = 0
    End If
End Function

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As ADODB.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

