VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form FFechaProceso 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Fecha de Proceso (95.100.00)"
   ClientHeight    =   4005
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5700
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4005
   ScaleWidth      =   5700
   Begin VB.CommandButton cmdSalir 
      Caption         =   "&Salir"
      Height          =   420
      Left            =   3000
      TabIndex        =   2
      Top             =   3525
      Width           =   1365
   End
   Begin VB.CommandButton cmdGrabar 
      Caption         =   "&Grabar"
      Height          =   420
      Left            =   1560
      TabIndex        =   1
      Top             =   3525
      Width           =   1365
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   3285
      Left            =   0
      TabIndex        =   4
      Top             =   30
      Width           =   5625
      _ExtentX        =   9922
      _ExtentY        =   5794
      _Version        =   393216
      Tabs            =   6
      Tab             =   5
      TabsPerRow      =   6
      TabHeight       =   520
      MouseIcon       =   "9510000.frx":0000
      TabCaption(0)   =   "&Ventas"
      TabPicture(0)   =   "9510000.frx":001C
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "mvwVentas"
      Tab(0).ControlCount=   1
      TabCaption(1)   =   "&Inventario"
      TabPicture(1)   =   "9510000.frx":0038
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "mvwInvent"
      Tab(1).ControlCount=   1
      TabCaption(2)   =   "Turno"
      TabPicture(2)   =   "9510000.frx":0054
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "Shape1"
      Tab(2).Control(1)=   "lblTurnos"
      Tab(2).Control(2)=   "cmbTurnos"
      Tab(2).ControlCount=   3
      TabCaption(3)   =   "Confirmar"
      TabPicture(3)   =   "9510000.frx":0070
      Tab(3).ControlEnabled=   0   'False
      Tab(3).Control(0)=   "Shape2"
      Tab(3).Control(1)=   "Label1"
      Tab(3).Control(2)=   "Label2"
      Tab(3).Control(3)=   "Label3"
      Tab(3).Control(4)=   "cmbCTurnos"
      Tab(3).Control(5)=   "dtpFecha"
      Tab(3).Control(6)=   "cmdConfirmar"
      Tab(3).ControlCount=   7
      TabCaption(4)   =   "P. Diario"
      TabPicture(4)   =   "9510000.frx":008C
      Tab(4).ControlEnabled=   0   'False
      Tab(4).Control(0)=   "Frame1"
      Tab(4).Control(1)=   "cmdaceptarpd"
      Tab(4).ControlCount=   2
      TabCaption(5)   =   "*.DBF"
      TabPicture(5)   =   "9510000.frx":00A8
      Tab(5).ControlEnabled=   -1  'True
      Tab(5).Control(0)=   "Label5"
      Tab(5).Control(0).Enabled=   0   'False
      Tab(5).Control(1)=   "lbldestino"
      Tab(5).Control(1).Enabled=   0   'False
      Tab(5).Control(2)=   "lblorigen"
      Tab(5).Control(2).Enabled=   0   'False
      Tab(5).Control(3)=   "Label7"
      Tab(5).Control(3).Enabled=   0   'False
      Tab(5).Control(4)=   "Label6"
      Tab(5).Control(4).Enabled=   0   'False
      Tab(5).Control(5)=   "cmdreemplaza"
      Tab(5).Control(5).Enabled=   0   'False
      Tab(5).ControlCount=   6
      Begin VB.CommandButton cmdreemplaza 
         Caption         =   "Reemplazar"
         Height          =   975
         Left            =   1560
         TabIndex        =   19
         Top             =   1440
         Width           =   2415
      End
      Begin VB.Frame Frame1 
         Height          =   1575
         Left            =   -74760
         TabIndex        =   14
         Top             =   480
         Width           =   4455
         Begin MSDataListLib.DataCombo DtcAlmacen 
            Height          =   315
            Left            =   960
            TabIndex        =   18
            Top             =   240
            Width           =   3375
            _ExtentX        =   5953
            _ExtentY        =   556
            _Version        =   393216
            Style           =   2
            Text            =   "DataCombo1"
         End
         Begin MSComCtl2.DTPicker DTPFechaPD 
            Height          =   375
            Left            =   1560
            TabIndex        =   15
            Top             =   960
            Width           =   1455
            _ExtentX        =   2566
            _ExtentY        =   661
            _Version        =   393216
            Format          =   16449537
            CurrentDate     =   37896
         End
         Begin VB.Label lblestacion 
            Caption         =   "Estación"
            Height          =   375
            Left            =   120
            TabIndex        =   17
            Top             =   240
            Width           =   1215
         End
         Begin VB.Label Label4 
            Caption         =   "Abrir Parte Diario del "
            Height          =   375
            Left            =   120
            TabIndex        =   16
            Top             =   720
            Width           =   1455
         End
      End
      Begin VB.CommandButton cmdaceptarpd 
         Caption         =   "Aceptar"
         Height          =   735
         Left            =   -71640
         Picture         =   "9510000.frx":00C4
         Style           =   1  'Graphical
         TabIndex        =   13
         Top             =   2280
         Width           =   1335
      End
      Begin VB.CommandButton cmdConfirmar 
         Caption         =   "Confirmar"
         Height          =   855
         Left            =   -72120
         Picture         =   "9510000.frx":03CE
         Style           =   1  'Graphical
         TabIndex        =   11
         ToolTipText     =   "Confirmar Turno"
         Top             =   1320
         Width           =   1215
      End
      Begin MSComCtl2.DTPicker dtpFecha 
         Height          =   345
         Left            =   -73680
         TabIndex        =   8
         Top             =   1830
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   609
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         CalendarBackColor=   16777152
         CalendarForeColor=   -2147483635
         CalendarTitleForeColor=   -2147483635
         Format          =   16449537
         CurrentDate     =   37662
      End
      Begin VB.ComboBox cmbCTurnos 
         BackColor       =   &H00FFFFC0&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000006&
         Height          =   360
         Left            =   -73680
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Top             =   1320
         Width           =   1455
      End
      Begin VB.ComboBox cmbTurnos 
         BackColor       =   &H00FFFFC0&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000002&
         Height          =   360
         Left            =   -73620
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   1470
         Width           =   2175
      End
      Begin MSComCtl2.MonthView mvwInvent 
         CausesValidation=   0   'False
         Height          =   2370
         Left            =   -73800
         TabIndex        =   3
         Top             =   480
         Width           =   2595
         _ExtentX        =   4577
         _ExtentY        =   4180
         _Version        =   393216
         ForeColor       =   -2147483630
         BackColor       =   -2147483633
         Appearance      =   1
         MonthBackColor  =   16777152
         StartOfWeek     =   16449538
         CurrentDate     =   37630
      End
      Begin MSComCtl2.MonthView mvwVentas 
         CausesValidation=   0   'False
         Height          =   2370
         Left            =   -73800
         TabIndex        =   0
         Top             =   480
         Width           =   2595
         _ExtentX        =   4577
         _ExtentY        =   4180
         _Version        =   393216
         ForeColor       =   -2147483630
         BackColor       =   -2147483633
         Appearance      =   1
         MonthBackColor  =   16777152
         StartOfWeek     =   16449538
         CurrentDate     =   37630
      End
      Begin VB.Label Label6 
         Caption         =   "Ruta Origen :"
         Height          =   255
         Left            =   240
         TabIndex        =   24
         Top             =   2520
         Width           =   1095
      End
      Begin VB.Label Label7 
         Caption         =   "Ruta Destino"
         Height          =   255
         Left            =   240
         TabIndex        =   23
         Top             =   2880
         Width           =   1095
      End
      Begin VB.Label lblorigen 
         BackColor       =   &H8000000E&
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   1320
         TabIndex        =   22
         Top             =   2520
         Width           =   3855
      End
      Begin VB.Label lbldestino 
         BackColor       =   &H8000000E&
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   1320
         TabIndex        =   21
         Top             =   2880
         Width           =   3855
      End
      Begin VB.Label Label5 
         Caption         =   $"9510000.frx":06D8
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   360
         TabIndex        =   20
         Top             =   720
         Width           =   5055
      End
      Begin VB.Label Label3 
         Caption         =   " Confirmar Turno"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   -74400
         TabIndex        =   12
         Top             =   750
         Width           =   1785
      End
      Begin VB.Label Label2 
         Caption         =   "Fecha"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   -74400
         TabIndex        =   10
         Top             =   1860
         Width           =   735
      End
      Begin VB.Label Label1 
         Caption         =   "Turno"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   225
         Left            =   -74430
         TabIndex        =   9
         Top             =   1350
         Width           =   675
      End
      Begin VB.Shape Shape2 
         Height          =   1845
         Left            =   -74580
         Top             =   870
         Width           =   3825
      End
      Begin VB.Label lblTurnos 
         Caption         =   "Turnos"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   -73680
         TabIndex        =   6
         Top             =   1080
         Width           =   1230
      End
      Begin VB.Shape Shape1 
         Height          =   1680
         Left            =   -73980
         Top             =   885
         Width           =   2850
      End
   End
End
Attribute VB_Name = "FFechaProceso"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' EDGAR MARTIN CANCHO RUIZ
' CONFIGURACION DE FECHA DE PROCESO DE VENTAS Y DE INVENTARIO

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 MobjSetup As UTIL_SETUP.C_SETUP
Public MobjAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Public MintResultadoLogin As Integer
Public MstrUsuario As String

Dim MrsListadoAlmacen As ADODB.Recordset
Dim MrsTemp As ADODB.Recordset

Private Sub cmdaceptarpd_Click()

   If SSTab1.Tab = 4 Then
       If MsgBox("Seguro que Desea Abrir el Parte Diario ?", vbYesNo + vbExclamation, "Advertencia") = vbNo Then
          Exit Sub
       Else
        
            MintResultadoLogin = -1
            FIngresoClave.GintPantalla = 2
            FIngresoClave.Show vbModal
            If MintResultadoLogin <> 0 Then
               Exit Sub
            End If
       End If
                    
       ' Se Abre el Parte Diario
       Dim LArrayAperturaPD(1, 3) As Variant
       
       LArrayAperturaPD(1, 1) = DTPFechaPD.Value
       LArrayAperturaPD(1, 2) = DtcAlmacen.BoundText
       LArrayAperturaPD(1, 3) = MstrUsuario
       
                     
       MobjSetup.Auxiliar1 LArrayAperturaPD
                    
       MsgBox "Parte Diario Abierto", vbDefaultButton1 + vbInformation, "Mensaje"
                                        
    End If

End Sub

Private Sub cmdConfirmar_Click()
On Error GoTo errhandler
    MobjSetup.ConfirmarTurno cmbCTurnos.ListIndex + 1, dtpFecha.Value
    MsgBox "Actualización exitosa", vbInformation, "Confirmar"
Exit Sub
errhandler:
    Screen.MousePointer = 0
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error"
End Sub

Private Sub cmdgrabar_Click()
On Error GoTo errhandler
                        
    If SSTab1.Tab = 0 Then
       If MsgBox("Las Ventas serán registradas para esta nueva fecha de proceso " & Chr(13) & Chr(13) & _
                 "Está Seguro ?", vbYesNo + vbExclamation, "Advertencia") = vbNo Then
          Exit Sub
       Else
          MintResultadoLogin = -1
          FIngresoClave.GintPantalla = 1
          FIngresoClave.Show vbModal
          
          If MintResultadoLogin <> 0 Then
             Exit Sub
          End If
          
       End If
    End If
    
    Screen.MousePointer = 11
                
    Dim LArrActualiza(1, 2) As Variant

    LArrActualiza(1, 1) = SSTab1.Tab
    LArrActualiza(1, 2) = MstrUsuario
    
    MobjSetup.ActualizarFechasDeProceso mvwVentas.Value, mvwInvent.Value, cmbTurnos.ListIndex + 1, LArrActualiza
        
        
    GDatFechaProcesoVentas = MobjSetup.ObtenerFechaProcesoVentas
    GDatFechaProceso = MobjSetup.ObtenerFechaProcesoInventarios
    'Unload Me
    Screen.MousePointer = 0
    
    If SSTab1.Tab = 0 Then
       MsgBox "Fechas de Proceso de Ventas Actualizada. ", vbInformation, "Mensaje"
    End If
    If SSTab1.Tab = 1 Then
       MsgBox "Fechas de Proceso de Inventarios Actualizada. ", vbInformation, "Mensaje"
    End If
    If SSTab1.Tab = 2 Then
       MsgBox "Turno Actualizado. ", vbInformation, "Mensaje"
    End If
        
    
Exit Sub
errhandler:
    Screen.MousePointer = 0
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error grabando"
    
End Sub

Private Sub cmdgrabar_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 1 Then
    cmdgrabar_Click
End If
End Sub

Private Sub cmdreemplaza_Click()

Dim strCARA As String
Dim i As Integer
Dim fso, txtfile

On Error GoTo errhandler


    If MsgBox("Seguro que desea reemplazar los archivos *.DBF", vbQuestion + vbYesNo, "Mensaje") = vbNo Then
       Exit Sub
    End If


    For i = 1 To GintCantidadCaras
            
            strCARA = Mid("0" & i, Len("0" & i) - 1, 2)

            If Trim(Dir(GstrRutaTran & "tran" & Trim(strCARA) & ".DBF")) <> "" Then
               Set fso = CreateObject("Scripting.FileSystemObject")
               fso.deletefile Trim(GstrRutaTran & "tran" & Trim(strCARA) & ".DBF")
            End If
            
            If Trim(Dir(GstrRutaTranError & "tran" & Trim(strCARA) & ".DBF")) <> "" Then
               Set fso = CreateObject("Scripting.FileSystemObject")
               fso.copyfile Trim(GstrRutaTranError & "tran" & Trim(strCARA)) & ".dbf", Trim(GstrRutaTran & "tran" & Trim(strCARA) & ".dbf")
            End If
                                                                
          ' Fin de reemplazar los Trans
                        
          ' Reemplazar los Jtrans
            
            If GintTipoControlador = 1 Then
               If Trim(Dir(GstrRutaJtran & "jtran" & Trim(strCARA) & ".dbf")) <> "" Then
                  Set fso = CreateObject("Scripting.FileSystemObject")
                  fso.deletefile Trim(GstrRutaJtran & "jtran" & Trim(strCARA) & ".dbf")
               End If
            
               If Trim(Dir(GstrRutaTranError & "jtran" & Trim(strCARA) & ".dbf")) <> "" Then
                  Set fso = CreateObject("Scripting.FileSystemObject")
                  fso.copyfile Trim(GstrRutaTranError & "jtran" & Trim(strCARA)) & ".dbf", Trim(GstrRutaJtran & "jtran" & Trim(strCARA) & ".dbf")
               End If

            End If
                            
          ' Fin de Reemplazar los Jtrans
          
      Next i
      
      MsgBox "Reemplazo de archivos realizado con éxito", vbDefaultButton1 + vbInformation, "Mensaje"
      
 Exit Sub
      
errhandler:
      
  MsgBox Err.Description, vbDefaultButton1 + vbExclamation, "Mensaje"

End Sub

Private Sub cmdSalir_Click()
    Unload Me
End Sub

Private Sub cmdsalir_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 1 Then
    cmdSalir_Click
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
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_Load()
    'seguridad
    Call gseguridad(Me)
    
    If pbderecho_consultar Then

        Set MobjSetup = New UTIL_SETUP.C_SETUP
        CargaTurnos
        Set MrsTemp = MobjSetup.ObtenerSetupGeneral
        
        mvwVentas.Value = MobjSetup.ObtenerFechaProcesoVentas
        mvwInvent.Value = MobjSetup.ObtenerFechaProcesoInventarios
        dtpFecha.Value = MobjSetup.ObtenerFechaProcesoVentas
        cmbTurnos.ListIndex = MrsTemp!SALESPERSONTURN - 1
        cmbCTurnos.ListIndex = MrsTemp!SALESPERSONTURN - 1
        
        Set MobjAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
     
        'Carga el DataCombo con Almacenes
  
        Set MrsListadoAlmacen = MobjAlmacen.ListarAlmacenesAyuda
     
        Set DtcAlmacen.DataSource = MrsListadoAlmacen
        DtcAlmacen.DataField = "name"
        Set DtcAlmacen.RowSource = MrsListadoAlmacen
        DtcAlmacen.ListField = "name"
        DtcAlmacen.BoundColumn = "siteid"
        If Not MrsListadoAlmacen.EOF Then
         DtcAlmacen.BoundText = MrsListadoAlmacen.Fields("name")
        End If
                
        lblorigen.Caption = GstrRutaTranError
        lbldestino.Caption = GstrRutaTran
        
        pb_primerregistro = True
        
        
    'lineas nuevas
    Else
        'Unload Me
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    End If
    
    SSTab1.Tab = 1
    Me.Top = 1300
    Me.Left = (Screen.Width - Me.Width) / 2
    
     
End Sub

Private Sub Salir()
    Unload Me
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 MobjSetup = Nothing
End Sub

Public Sub salir_formulario()
    Unload Me
End Sub

Private Sub CargaTurnos()
    Dim i As Integer
    For i = 1 To GintCantidadTurnos
        cmbTurnos.AddItem "Turno " & i
        cmbCTurnos.AddItem "Turno " & i
    Next
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
    
     If SSTab1.Tab = 3 Or SSTab1.Tab = 4 Then
        cmdgrabar.Enabled = False
     Else
        cmdgrabar.Enabled = True
     End If
    
'    If SSTab1.Tab = 0 Then
       
'       If MsgBox("El Cambio de la fecha de Proceso de Ventas influye en la emisión de los documentos de Ventas " & Chr(13) & Chr(13) & " Desea Continuar ? ", vbYesNo + vbQuestion, "Advertencia") = vbNo Then
'          SSTab1.Tab = PreviousTab
'       End If
             
'    End If

End Sub


