VERSION 5.00
Begin VB.Form FCierrex 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cierre X                                           Fecha Proceso"
   ClientHeight    =   4260
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6645
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4260
   ScaleWidth      =   6645
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton CMD_ACEPTAR 
      Caption         =   "Aceptar"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   4710
      Picture         =   "FCierrexPlaya.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   11
      Tag             =   "R ASDASD"
      Top             =   2310
      Width           =   1860
   End
   Begin VB.CommandButton CMD_CANCELAR 
      Cancel          =   -1  'True
      Caption         =   "Cancelar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   4710
      Picture         =   "FCierrexPlaya.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   10
      Top             =   3270
      Width           =   1860
   End
   Begin VB.Frame Frame2 
      Caption         =   "Imprimir Por"
      Height          =   1830
      Left            =   135
      TabIndex        =   7
      Top             =   2250
      Width           =   4155
      Begin VB.OptionButton optimpresora 
         Caption         =   "Impresora"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   885
         Left            =   285
         Picture         =   "FCierrexPlaya.frx":0614
         TabIndex        =   9
         Top             =   870
         Width           =   1605
      End
      Begin VB.OptionButton optpantalla 
         Caption         =   "Pantalla"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   315
         TabIndex        =   8
         Top             =   390
         Width           =   1860
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   5670
      Top             =   420
   End
   Begin VB.Frame Frame1 
      Caption         =   "Datos"
      Height          =   1980
      Left            =   135
      TabIndex        =   0
      Top             =   120
      Width           =   6420
      Begin VB.Label lblturno 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   375
         Left            =   1440
         TabIndex        =   6
         Top             =   1380
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "Turno"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   120
         TabIndex        =   5
         Top             =   1350
         Width           =   1110
      End
      Begin VB.Label lblfechaactual 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   375
         Left            =   1440
         TabIndex        =   4
         Top             =   855
         Width           =   3360
      End
      Begin VB.Label Label2 
         Caption         =   "Fecha Actual"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   150
         TabIndex        =   3
         Top             =   855
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "Caja"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   195
         TabIndex        =   2
         Top             =   330
         Width           =   645
      End
      Begin VB.Label lblcaja 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   345
         Left            =   1440
         TabIndex        =   1
         Top             =   345
         Width           =   3345
      End
   End
End
Attribute VB_Name = "FCierrex"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MobjVentaPlaya As DB_OP_FACTURACION.C_VENTASPLAYA
Private MobjDispensador As DB_UT_MANTENIMIENTOS.C_DISPENSADORES
Private MrsDispensador As ADODB.Recordset

Private MobjCierrex As DB_OP_FACTURACION.C_CIERRES

' variables de cabecera de cierre
'Dim StrSerieMaqReg As String
'Dim StrFecha As String
'Dim DblTipoCambio As Double
'Dim IntNroTransacciones As Integer
'Dim DblTicketBolIni As Double
'Dim dblTicketFacIni As Double
'Dim DblValorVta As Double
'Dim DblVtaNoAfecta As Double
'Dim DblIGV As Double
'Dim DblVtaTotal As Double
'Dim IntNroTicketAnul As Integer
'Dim DblTotalTicketAnul As Double
'Dim DblGranTotal As Double
'Dim IntNroZeta As Integer
'Dim StrNroPtoVta As String
'Dim IntTurno As Integer
'
'' variables de resumen de ventas
'Dim DblTotalTicketBol As Double
'Dim DblTotalTicketFac As Double
'Dim DblTotalGral As Double
'
'' variables de resumen de tipos de pago
'Dim DblEfectivo As Double
'Dim DblVueltoEfectivo As Double
'Dim DblNetoEfectivo As Double
'
'Dim DblTarjeta As Double
'Dim DblVueltoTarjeta As Double
'Dim DblNetoTarjeta As Double
'
'Dim DblVale As Double
'Dim DblVueltoVale As Double
'Dim DblNetoVale As Double

' cargar las variables que detallan la cabecera del cierre
'Sub Cabecera_Cierre()
'    ' serie de maquina registradora
'    StrSerieMaqReg = MobjCierrex.Obtener_Serie_Maq_Reg(lblcaja.Caption)
'    ' fecha de proceso (jalada del servidor)
'    StrFecha = MobjCierrex.Obtener_Fecha_Cierre
'    ' tipo de cambio actual
'    DblTipoCambio = MobjCierrex.Obtener_Tipo_Cambio(lblcaja.Caption)
'    ' cantidad de transacciones realizadas
'    IntNroTransacciones = MobjCierrex.Obtener_NroTransacciones(lblcaja.Caption, lblturno.Caption)
'    ' numero del ticket boleta inicial
'    DblTicketBolIni = MobjCierrex.Obtener_NroNroTicketBolIni(lblcaja.Caption, lblturno.Caption)
'    ' numero del ticket factura inicial
'    dblTicketFacIni = MobjCierrex.Obtener_NroNroTicketFacIni(lblcaja.Caption, lblturno.Caption)
'    ' total de la venta (sin IGV)
'    DblValorVta = MobjCierrex.Obtener_ValorVenta(lblcaja.Caption, lblturno.Caption)
'    ' total de la venta no afecta al IGV
'    DblVtaNoAfecta = MobjCierrex.Obtener_ValorVentaNoAfecto(lblcaja.Caption, lblturno.Caption)
'    ' total de IGV
'    DblIGV = MobjCierrex.Obtener_IGV(lblcaja.Caption, lblturno.Caption)
'    ' total de la venta + IGV
'    DblVtaTotal = MobjCierrex.Obtener_VentaTotal(lblcaja.Caption, lblturno.Caption)
'    ' numero de transacciones anuladas
'    IntNroTicketAnul = MobjCierrex.Obtener_NumTicketsAnulados(lblcaja.Caption, lblturno.Caption)
'    ' total de las transacciones anuladas
'    DblTotalTicketAnul = MobjCierrex.Obtener_TotalAnulados(lblcaja.Caption, lblturno.Caption)
'    ' el total zeta acumulado
'    DblGranTotal = MobjCierrex.Obtener_GranTotal(lblcaja.Caption, lblturno.Caption)
'    ' el numero de zeta correspondiente
'    IntNroZeta = MobjCierrex.Obtener_NroZetas(lblcaja.Caption)
'End Sub

'Sub ResumenVentas()
'    Dim rs As ADODB.Recordset
'
'    Set rs = New ADODB.Recordset
'
'    Set rs = MobjCierrex.Obtener_Resumen_Ventas(lblcaja.Caption, GCUSERID)
'
'    If Not rs.EOF Then
'        DblTotalTicketBol = IIf(IsNull(rs!TOTALBOLPENAUT), 0, rs!TOTALBOLPENAUT) + _
'                            IIf(IsNull(rs!TOTALBOLPENMAN), 0, rs!TOTALBOLPENMAN)
'        DblTotalTicketFac = IIf(IsNull(rs!TOTALFACPENAUT), 0, rs!TOTALFACPENAUT) + _
'                            IIf(IsNull(rs!TOTALFACPENMAN), 0, rs!TOTALFACPENMAN)
'        DblTotalGral = DblTotalTicketBol + DblTotalTicketFac
'    Else
'        DblTotalTicketBol = 0
'        DblTotalTicketFac = 0
'        DblTotalGral = DblTotalTicketBol + DblTotalTicketFac
'    End If
'End Sub

'Sub ResumenTipoPagos()
'    Dim rs As ADODB.Recordset
'
'    Set rs = New ADODB.Recordset
'
'    Set rs = MobjCierrex.Obtener_Resumen_Tipos_pagos(lblcaja.Caption, GCUSERID)
'
'    If Not rs.EOF Then
'        DblEfectivo = IIf(IsNull(rs!EFECTIVOPEN), 0, rs!EFECTIVOPEN)
'        DblVueltoEfectivo = IIf(IsNull(rs!VUELTOPEN), 0, rs!VUELTOPEN)
'        DblNetoEfectivo = DblEfectivo - DblVueltoEfectivo
'
'        DblTarjeta = IIf(IsNull(rs!TARJETAPEN), 0, rs!TARJETAPEN)
'        DblVueltoTarjeta = 0
'        DblNetoTarjeta = DblTarjeta - DblVueltoTarjeta
'
'        DblVale = IIf(IsNull(rs!VALEPEN), 0, rs!VALEPEN)
'        DblVueltoVale = 0
'        DblNetoVale = DblVale - DblVueltoVale
'    Else
'        DblEfectivo = 0
'        DblVueltoEfectivo = 0
'        DblNetoEfectivo = DblEfectivo - DblVueltoEfectivo
'
'        DblTarjeta = 0
'        DblVueltoTarjeta = 0
'        DblNetoTarjeta = DblTarjeta - DblVueltoTarjeta
'
'        DblVale = 0
'        DblVueltoVale = 0
'        DblNetoVale = DblVale - DblVueltoVale
'    End If
'End Sub

'Sub Detalle_CierreX()
'    Dim rs As ADODB.Recordset
'
'    Set rs = New ADODB.Recordset
'
'    Set rs = MobjCierrex.Obtener_Detalle_Cierre(lblcaja.Caption, GCUSERID)
'End Sub

Sub CierreX(StrPtoVta As String, StrSalesPerID As String)
    Dim fp As Integer
    
    
End Sub

Private Sub CMD_ACEPTAR_Click()
On Error GoTo errhandler
    Dim IntVerificacionTrans As Integer
'    Dim BlnCierrexPend As Boolean
    
'    BlnCierrexPend = False
    Set MobjCierrex = New DB_OP_FACTURACION.C_CIERRES
    
    'Call MobjCierrex.Cargar_Datos_Cierre("PTOVTA01", "VENDEDOR2")
    'Call MobjCierrex.Imprimir_CierreX(GintDecResultado, 2)
    
                                        '¸------> Lugar(2=Playa)
    Call MobjCierrex.Cargar_Datos_Cierre(2, lblcaja.Caption, Val(lblturno.Caption), GCUSERID, Str(GDatFechaProcesoVentas), 1)
                                                    'Turno Actual <-----'               Tipo de Cierre (1=Equis - X)<------'

    'Call MobjCierrex.Cargar_Datos_Cierre(lblcaja.Caption, GCUSERID, Str(GDatFechaProcesoVentas), 1)
    'Call MobjCierrex.Cargar_Datos_Cierre(2, "PTOVTA02", Int(lblturno.Caption), "GUS", "27/12/2002", 1)
    
    ' Obteniendo turno
    
    Screen.MousePointer = vbHourglass
    
    IntVerificacionTrans = MobjCierrex.Ver_Transacciones_Pendientes
    Select Case IntVerificacionTrans
        Case 0: ' no puede realizarse cierre(ni pantalla , ni impresora)
        Case 1: ' existen transacciones pendiente
                ' 2 : por pantalla  <-------------------------------¸
                Call MobjCierrex.Imprimir_CierreX(GintDecResultado, 2)
                Call MobjCierrex.MensajeOK
        Case 2: ' no hay transacciones pendientes ==> OK !
            If optimpresora.Value = True Then
                ' 1 : por impresora  <------------------------------¸
                Call MobjCierrex.Imprimir_CierreX(GintDecResultado, 1)
                ' actualiza el campo STKCLOSEDX=1 si no hubo fallas
                Call MobjCierrex.Actualizar_Datos_LuegodeCierreX
                Call MobjCierrex.MensajeOK
            Else
                ' 2 : por pantalla  <-------------------------------¸
                Call MobjCierrex.Imprimir_CierreX(GintDecResultado, 2)
                Call MobjCierrex.MensajeOK
            End If
    End Select
'        Set MrsDispensador = MobjDispensador.ListarCarasAsignadasaPtoVta(GstrPuntodeVenta)
'        MrsDispensador.MoveFirst
'        Do While Not MrsDispensador.EOF
'          If Not MobjDispensador.ListarTransacdeCara(MrsDispensador!side).EOF Then
'             BlnCierrexPend = True
'          End If
'          MrsDispensador.MoveNext
'        Loop
'        ' -----------------------------------------
'        If BlnCierrexPend = True Then
'           MsgBox "Existen Transaciones Pendientes", vbDefaultButton1 + vbExclamation, "No se Puede realizar el Cambio de Turno"
'           Exit Sub
'        Else
'
'        End If
'    Else
       ' Es por Pantalla
       
'    End If
    Screen.MousePointer = vbDefault
    
    Exit Sub
errhandler:
    Screen.MousePointer = vbDefault
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error"
End Sub

Private Sub CMD_CANCELAR_Click()
 Unload Me
End Sub

Private Sub Form_Load()
  
  Me.Left = (Screen.Width - Me.Width) / 2
  Me.Top = (Screen.Height - Me.Height) / 2
  
  Set MobjVentaPlaya = New DB_OP_FACTURACION.C_VENTASPLAYA
  Set MobjDispensador = New DB_UT_MANTENIMIENTOS.C_DISPENSADORES
  Me.Caption = "Cierre X                                                Fecha Proceso [" & GDatFechaProcesoVentas & "]"
  lblfechaactual.Caption = Date & " " & Time
  lblcaja.Caption = GstrPuntodeVenta
 
 'Hay que Obtener el Turno Actual
  lblturno.Caption = MobjVentaPlaya.ObtenerTurnoActual

End Sub

Private Sub Form_Unload(Cancel As Integer)
  
  Set MobjVentaPlaya = Nothing
  Set MobjDispensador = Nothing
  
End Sub

Private Sub Timer1_Timer()
  lblfechaactual.Caption = Date & " " & Time
End Sub
