VERSION 5.00
Begin VB.Form FCierreXCStore 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cierre X C-Store"
   ClientHeight    =   4140
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6495
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4140
   ScaleWidth      =   6495
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "Datos"
      Height          =   1980
      Left            =   45
      TabIndex        =   5
      Top             =   45
      Width           =   6420
      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            =   1755
         TabIndex        =   11
         Top             =   345
         Width           =   3345
      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            =   285
         TabIndex        =   10
         Top             =   330
         Width           =   645
      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            =   240
         TabIndex        =   9
         Top             =   855
         Width           =   1245
      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            =   1755
         TabIndex        =   8
         Top             =   855
         Width           =   3360
      End
      Begin VB.Label Label3 
         Caption         =   "Vendedor "
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   210
         TabIndex        =   7
         Top             =   1350
         Width           =   1335
      End
      Begin VB.Label lblvendedor 
         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            =   1755
         TabIndex        =   6
         Top             =   1380
         Width           =   3360
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   5580
      Top             =   345
   End
   Begin VB.Frame Frame2 
      Caption         =   "Imprimir Por"
      Height          =   1830
      Left            =   45
      TabIndex        =   2
      Top             =   2175
      Width           =   4155
      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        =   4
         Top             =   390
         Value           =   -1  'True
         Width           =   1860
      End
      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         =   "FCierreXCStore.frx":0000
         TabIndex        =   3
         Top             =   870
         Width           =   1605
      End
   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            =   4575
      Picture         =   "FCierreXCStore.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   3195
      Width           =   1860
   End
   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            =   4590
      Picture         =   "FCierreXCStore.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   0
      Tag             =   "R ASDASD"
      Top             =   2235
      Width           =   1860
   End
End
Attribute VB_Name = "FCierreXCStore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' VARIABLE PARA SABER SI ES CIERREX O CIERREZ
' 1 : CierreX
' 2 : CierreZ
Dim IntTipoCierre As Integer

' VARIABLE PARA SABER SI ES TIENDA O PLAYA
' 1 : Tienda
' 2 : Playa
Dim IntLugar As Integer

' VARIABLES DE PUNTO DE VENTA,VENDEDOR y FECHA DE CIERRE (FECHA DE PROCESO)
Dim StrNroPtoVta As String
Dim StrSalesPerID As String
Dim StrFechaCierre As String
Dim IntTurno As Integer

' DATOS DE IMPRESORA
Dim IntNroSaltosLineas As Integer
Dim StrCodCorte As String
Dim IntAnchoTicket As Integer

' LINEA DE SEPARACION
Dim StrLineaSeparacion As String

' 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 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

Dim DblFondoCajaPEN As Double
Dim DblFondoCajaUSD As Double

' variables para monedas
Dim StrMdaBase As String
Dim StrMdaCaja As String
Dim StrSimbMdaCaja As String
Dim StrSimbMdaExt As String

' cabeceras de ticket
Dim StrCab1 As String, StrCab2 As String, StrCab3 As String, StrCab4 As String, _
    StrCab5 As String

' variable de comprobacion de error
Dim BlnOK As Boolean

'''***********************************************************
'Private Mcmd As ADODB.Command
'Private Mcon As ADODB.Connection
'Private Mrstranspend As ADODB.Recordset
'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

Private Sub CMD_ACEPTAR_Click()
On Error GoTo errhandler
    Dim MobjTipoCambio As DB_OP_FACTURACION.C_VENTASGENERAL
    Dim BlnOK As Boolean
    Dim StrCierre As String
    
    Dim StrDatEmpresa As String     ' datos de la empresa
    Dim StrDatCabecera As String    ' datos cabecera del cierre
    Dim StrResVenta As String       ' resumen de ventas
    Dim StrResTipoPago As String    ' resumene de tipo pago
    Dim StrResCategoria As String   ' resumen de producto
    Dim StrResProducto As String    ' resumen producto
    Dim StrResVendedor As String    ' resumen vendedor
    Dim StrResCara As String        ' resumen cara
    Dim StrSalto As String

    Dim DblMontoTipoCambio As Double

    Set MobjCierrex = New DB_OP_FACTURACION.C_CIERRES
    Set MobjTipoCambio = New DB_OP_FACTURACION.C_VENTASGENERAL
    
    Limpiar_Variables
    
    DblMontoTipoCambio = MobjTipoCambio.ObtenerMontoTipodeCambio(GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas)
                                        
    Screen.MousePointer = vbHourglass
    
    If optimpresora.Value = True Then
        ' 1 : por impresora  <------------------------------¸
        Call MobjCierrex.Imprimir_Cierre(IntTipoCierre, IntLugar, StrNroPtoVta, _
                    StrSalesPerID, StrFechaCierre, IntTurno, IntNroSaltosLineas, _
                    StrCodCorte, IntAnchoTicket, StrLineaSeparacion, StrSerieMaqReg, _
                    StrFecha, DblMontoTipoCambio, IntNroTransacciones, DblTicketBolIni, _
                    dblTicketFacIni, DblValorVta, DblVtaNoAfecta, DblIGV, DblVtaTotal, _
                    IntNroTicketAnul, DblTotalTicketAnul, DblGranTotal, IntNroZeta, _
                    DblTotalTicketBol, DblTotalTicketFac, DblTotalGral, _
                    DblEfectivo, DblVueltoEfectivo, DblNetoEfectivo, DblTarjeta, _
                    DblVueltoTarjeta, DblNetoTarjeta, DblVale, DblVueltoVale, _
                    DblNetoVale, StrMdaBase, StrMdaCaja, StrSimbMdaCaja, StrSimbMdaExt, _
                    StrCab1, StrCab2, StrCab3, StrCab4, StrCab5, BlnOK, GintDecResultado, GintDecStock, _
                    StrDatEmpresa, StrDatCabecera, StrResVenta, StrResTipoPago, StrResCategoria, StrResProducto, StrResVendedor, StrResCara, StrSalto, DblFondoCajaPEN, DblFondoCajaUSD)
        ' actualiza el campo STKCLOSEDX=1 si no hubo fallas
        'Printer.Print StrCierre
        If Trim(StrDatEmpresa) <> "" Then Printer.Print StrDatEmpresa
        If Trim(StrDatCabecera) <> "" Then Printer.Print StrDatCabecera
        If Trim(StrResVenta) <> "" Then Printer.Print StrResVenta
        If Trim(StrResTipoPago) <> "" Then Printer.Print StrResTipoPago
        If Trim(StrResCategoria) <> "" Then Printer.Print StrResCategoria
        If Trim(StrResProducto) <> "" Then Printer.Print StrResProducto
        If Trim(StrResVendedor) <> "" Then Printer.Print StrResVendedor
        If Trim(StrResCara) <> "" Then Printer.Print StrResCara
        If Trim(StrSalto) <> "" Then Printer.Print StrSalto
        
        Printer.EndDoc
                
        BlnOK = MobjCierrex.MensajeOK
                
        If BlnOK Then
            ' actualiza el campo STKCLOSEDX=1 si no hubo fallas
            Call MobjCierrex.Actualizar_Datos_LuegodeCierreX(StrNroPtoVta, IntLugar, IntTurno, _
            StrFechaCierre, DblGranTotal, IntNroZeta, StrSalesPerID)
                    
            MsgBox "Proceso de Cierre X realizado", vbInformation, "Mensaje"
            End
        Else
            MsgBox "Proceso de Cierre X fallido", vbInformation, "Mensaje"
        End If

    Else
        ' 2 : por pantalla  <-------------------------------¸
        Call MobjCierrex.Imprimir_Cierre(IntTipoCierre, IntLugar, StrNroPtoVta, _
                    StrSalesPerID, StrFechaCierre, IntTurno, IntNroSaltosLineas, _
                    StrCodCorte, IntAnchoTicket, StrLineaSeparacion, StrSerieMaqReg, _
                    StrFecha, DblMontoTipoCambio, IntNroTransacciones, DblTicketBolIni, _
                    dblTicketFacIni, DblValorVta, DblVtaNoAfecta, DblIGV, DblVtaTotal, _
                    IntNroTicketAnul, DblTotalTicketAnul, DblGranTotal, IntNroZeta, _
                    DblTotalTicketBol, DblTotalTicketFac, DblTotalGral, _
                    DblEfectivo, DblVueltoEfectivo, DblNetoEfectivo, DblTarjeta, _
                    DblVueltoTarjeta, DblNetoTarjeta, DblVale, DblVueltoVale, _
                    DblNetoVale, StrMdaBase, StrMdaCaja, StrSimbMdaCaja, StrSimbMdaExt, _
                    StrCab1, StrCab2, StrCab3, StrCab4, StrCab5, BlnOK, GintDecResultado, GintDecStock, _
                    StrDatEmpresa, StrDatCabecera, StrResVenta, StrResTipoPago, StrResCategoria, StrResProducto, StrResVendedor, StrResCara, StrSalto, DblFondoCajaPEN, DblFondoCajaUSD)
                
        Open "temp.txt" For Output As #1
            If Trim(StrDatEmpresa) <> "" Then Print #1, StrDatEmpresa
            If Trim(StrDatCabecera) <> "" Then Print #1, StrDatCabecera
            If Trim(StrResVenta) <> "" Then Print #1, StrResVenta
            If Trim(StrResTipoPago) <> "" Then Print #1, StrResTipoPago
            If Trim(StrResCategoria) <> "" Then Print #1, StrResCategoria
            If Trim(StrResProducto) <> "" Then Print #1, StrResProducto
            If Trim(StrResVendedor) <> "" Then Print #1, StrResVendedor
            If Trim(StrResCara) <> "" Then Print #1, StrResCara
            If Trim(StrSalto) <> "" Then Print #1, StrSalto
            'Print #1, StrCierre
        Close #1
                
        Shell "notepad.exe temp.txt", vbMaximizedFocus
        
        BlnOK = MobjCierrex.MensajeOK
                
        If BlnOK Then
            MsgBox "Proceso de Cierre X realizado", vbInformation, "Mensaje"
        Else
            MsgBox "Proceso de Cierre X fallido", vbInformation, "Mensaje"
        End If
    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 C-Store                                    Fecha Proceso [" & GDatFechaProcesoVentas & "]"
   lblfechaactual.Caption = Date & " " & Time
   lblcaja.Caption = GstrPuntodeVenta
 
   lblvendedor.Caption = GstrCodigoVENDEDOR
    
  
   'Set Mcon = New ADODB.Connection
   
   'Mcon.Provider = "MSDASQL"
   'Mcon.ConnectionString = "Driver={Microsoft Visual FoxPro Driver (*.dbf)};UID=;SourceDB=" & GstrRutaTran & ";SourceType=DBF;Exclusive=No;BackgroundFetch=Sí;Collate=Machine;Null=Sí;Deleted=Sí;"
   'Mcon.ConnectionString = "FILEDSN=GASBOY"
   'Mcon.Open
   ';SourceType=DBF;Exclusive=No;BackgroundFetch=Sí;Collate=Machine;Null=Sí;Deleted=Sí;"
   'Set Mrstranspend = New ADODB.Recordset
   'Mrstranspend.CursorLocation = adUseClient
   
   'Set Mcmd = New ADODB.Command
   'Mcmd.ActiveConnection = Mcon
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

Sub Limpiar_Variables()

    IntTipoCierre = 1 ' cierre x
    
    ' VARIABLE PARA SABER SI ES TIENDA O PLAYA
    ' 1 : Tienda
    ' 2 : Playa
    IntLugar = 1 ' Tienda
    
'    2, lblcaja.Caption, Val(lblTurno.Caption), GCUSERID, Str(GDatFechaProcesoVentas), 1
    
    StrNroPtoVta = lblcaja.Caption
    StrSalesPerID = GstrCodigoVENDEDOR
    StrFechaCierre = Str(GDatFechaProcesoVentas)
    IntTurno = 0 ' para tiendas no importa el turno
    'DblTipoCambio = DblTipoCambioActual
    BlnOK = True ' inicialmente todo bien
    
    ' VARIABLES DE PUNTO DE VENTA,VENDEDOR y FECHA DE CIERRE (FECHA DE PROCESO)
    'StrNroPtoVta = ""
    'StrSalesPerID = ""
    'StrFechaCierre = ""
    'IntTurno = 0
    
    ' DATOS DE IMPRESORA
    IntNroSaltosLineas = 0
    StrCodCorte = ""
    IntAnchoTicket = 0
    
    ' LINEA DE SEPARACION
    StrLineaSeparacion = ""
    
    ' variables de cabecera de cierre
    StrSerieMaqReg = ""
    StrFecha = ""
    DblTipoCambio = 0
    IntNroTransacciones = 0
    DblTicketBolIni = 0
    dblTicketFacIni = 0
    DblValorVta = 0
    DblVtaNoAfecta = 0
    DblIGV = 0
    DblVtaTotal = 0
    IntNroTicketAnul = 0
    DblTotalTicketAnul = 0
    DblGranTotal = 0
    IntNroZeta = 0
    'dim IntTurno As Integer
    
    ' variables de resumen de ventas
    DblTotalTicketBol = 0
    DblTotalTicketFac = 0
    DblTotalGral = 0
    
    ' variables de resumen de tipos de pago
    DblEfectivo = 0
    DblVueltoEfectivo = 0
    DblNetoEfectivo = 0
    
    DblTarjeta = 0
    DblVueltoTarjeta = 0
    DblNetoTarjeta = 0
    
    DblVale = 0
    DblVueltoVale = 0
    DblNetoVale = 0
    
    DblFondoCajaPEN = 0
    DblFondoCajaUSD = 0
    
    ' variables para monedas
    StrMdaBase = ""
    StrMdaCaja = ""
    StrSimbMdaCaja = ""
    StrSimbMdaExt = ""
    
    ' cabeceras de ticket
    StrCab1 = ""
    StrCab2 = ""
    StrCab3 = ""
    StrCab4 = ""
    StrCab5 = ""
    
    ' variable de comprobacion de error
    'BlnOK =
End Sub


