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 = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#50.0#0"; "pry_list.ocx"
Begin VB.Form FCarasDispensadores 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Configuracion de Caras para Punto de Venta (95.190.00)"
   ClientHeight    =   6195
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6420
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   6195
   ScaleWidth      =   6420
   Begin VB.CommandButton cmdactivar 
      Caption         =   "Activar  Punto de Venta"
      Height          =   960
      Left            =   2700
      Picture         =   "9519000.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   5160
      Width           =   1785
   End
   Begin VB.CommandButton cmdsalir 
      Caption         =   "&Salir"
      Height          =   975
      Left            =   4560
      Picture         =   "9519000.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   5130
      Width           =   1770
   End
   Begin VB.CommandButton cmddesactivar 
      Caption         =   "Desactivar Punto de Venta"
      Height          =   960
      Left            =   2700
      Picture         =   "9519000.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   5160
      Width           =   1785
   End
   Begin MSComCtl2.DTPicker DTPicker1 
      Height          =   255
      Left            =   4110
      TabIndex        =   9
      Top             =   6840
      Visible         =   0   'False
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   450
      _Version        =   393216
      Enabled         =   0   'False
      Format          =   71041025
      CurrentDate     =   37579
   End
   Begin VB.TextBox TXTCODIGO 
      Enabled         =   0   'False
      Height          =   375
      Left            =   4110
      TabIndex        =   6
      TabStop         =   0   'False
      Text            =   "Text1"
      Top             =   7110
      Visible         =   0   'False
      Width           =   2295
   End
   Begin MSDataListLib.DataCombo Dtcptovta 
      Height          =   315
      Left            =   1440
      TabIndex        =   0
      Top             =   240
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   "DataCombo1"
   End
   Begin VB.Frame FraCaras 
      Caption         =   "Seleccionar Caras"
      Height          =   3825
      Left            =   90
      TabIndex        =   1
      Top             =   1245
      Width           =   6255
      Begin pry_list.ctrl_listarray ListRCaras 
         Height          =   2895
         Left            =   360
         TabIndex        =   13
         Top             =   720
         Width           =   5655
         _ExtentX        =   9975
         _ExtentY        =   5106
      End
      Begin VB.Label Label3 
         Caption         =   "Caras Asignadas"
         Height          =   255
         Left            =   3525
         TabIndex        =   8
         Top             =   300
         Width           =   1935
      End
      Begin VB.Label Label2 
         Caption         =   "Caras Disponibles"
         Height          =   255
         Left            =   315
         TabIndex        =   7
         Top             =   330
         Width           =   1815
      End
   End
   Begin VB.Image Image1 
      Height          =   600
      Left            =   5025
      Picture         =   "9519000.frx":091E
      Stretch         =   -1  'True
      Top             =   315
      Width           =   570
   End
   Begin VB.Label lbltiponegocio 
      Height          =   345
      Left            =   4140
      TabIndex        =   12
      Top             =   675
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Label Label4 
      Caption         =   "Estado"
      Height          =   285
      Left            =   120
      TabIndex        =   11
      Top             =   675
      Width           =   1170
   End
   Begin VB.Label lbltipo 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   330
      Left            =   1455
      TabIndex        =   10
      Top             =   645
      Width           =   2295
   End
   Begin VB.Label Label1 
      Caption         =   "Punto de Venta"
      Height          =   255
      Left            =   120
      TabIndex        =   5
      Top             =   240
      Width           =   1335
   End
End
Attribute VB_Name = "FCarasDispensadores"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 MrsTipoNegocio As ADODB.Recordset
Public Mrsptovta As ADODB.Recordset
Public MobjPtoVta As DB_UT_MANTENIMIENTOS.C_PUNTODEVENTA
Public MrsDisponibles As ADODB.Recordset
Public MrsAsignados As ADODB.Recordset
Public MobjDispensador As DB_UT_MANTENIMIENTOS.C_DISPENSADORES

Private Sub cmdActivar_Click()
  If MsgBox("Está seguro de Activar el Punto de Venta", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
     
     Screen.MousePointer = 11
     MobjPtoVta.ActivarDesactivarPtovta 1, Dtcptovta.BoundText
     asigna_campos
     Screen.MousePointer = 0
      
     MsgBox "Punto de Venta Activado ", vbDefaultButton1 + vbInformation, "Mensaje"
     
  End If

End Sub

Private Sub cmddesactivar_Click()
  If MsgBox("Está seguro de Desactivar el Punto de Venta", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
     Screen.MousePointer = 11
     MobjPtoVta.ActivarDesactivarPtovta 0, Dtcptovta.BoundText
     asigna_campos
     Screen.MousePointer = 0
     
     MsgBox "Punto de Venta Desactivado ", vbDefaultButton1 + vbInformation, "Mensaje"
         
  End If
End Sub

Private Sub cmdSalir_Click()
  Unload Me
End Sub

Private Sub Dtcptovta_Click(Area As Integer)
   asigna_campos
End Sub

Private Sub Form_Activate()
    Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
    Call gactualiza_barra(Me)
    cmdsalir.Enabled = True
    '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_Initialize()
    Call gHabilitarReg(Me, False)
End Sub

Private Sub Form_Load()
    'seguridad
    Call gseguridad(Me)
    
    If pbderecho_consultar Then
        Dim numreg As Long
        Set MobjPtoVta = New DB_UT_MANTENIMIENTOS.C_PUNTODEVENTA
        Set MobjDispensador = New DB_UT_MANTENIMIENTOS.C_DISPENSADORES
        Call obtener_datos
        Call GCargaDataCombo(Dtcptovta, Mrsptovta, "SALESPOINT", "SALESPOINT")
        ListRCaras.Size (18)
        Call asigna_campos
        pb_primerregistro = True
      
    'lineas nuevas
    Else
        'Unload Me
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    End If
    
    Me.Top = 1300
    Me.Left = (Screen.Width - Me.Width) / 2
     
    
End Sub
Public Sub GCargaDataCombo(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

Public Sub borrar_registro()
    
End Sub
Function valida_datos()
    valida_datos = True
End Function
Public Sub grabar_registro()

Dim LArrayCarasAsignadas()
Dim lintfilas As Integer
Dim i As Integer
On Error GoTo errhandler
    If lbltipo.Caption = "Desactivado" Then
       MsgBox "Punto de Venta está Desactivado ", vbDefaultButton1 + vbExclamation, "Advertencia"
       Exit Sub
    End If
    Screen.MousePointer = vbHourglass
    If valida_datos() = True Then
        ' llamada al proc de grabacion
        If pb_agregar Then
          'Si se quiere agregar
        Else
          'si se está modificando
          MobjDispensador.EliminarCarasdePtoVenta (Dtcptovta.BoundText)
          LArrayCarasAsignadas = ListRCaras.llenar_matriz
          lintfilas = UBound(LArrayCarasAsignadas)
  
          'If lintfilas = 0 Then
          '   MsgBox "Debe seleccionar al menos un Cara", vbDefaultButton1 + vbExclamation, "Advertencia"
          '   Screen.MousePointer = 0
          '   Exit Sub
          'End If
           
          For i = 1 To lintfilas
             MobjDispensador.AsignarCaraaPtoVenta Dtcptovta.BoundText, LArrayCarasAsignadas(i, 1)
          Next
          
          MsgBox "Deben salir del sistema todos los Puntos de Venta de Playa ", vbDefaultButton1 + vbInformation, "Mensaje"
          
        End If
        Screen.MousePointer = 0
        Call ggrabar_registro(Me)
    End If
    
Exit Sub

errhandler:
    Screen.MousePointer = 0
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"
End Sub
Public Sub actualizar_registro()
  asigna_campos
End Sub
Public Sub agregar_registro()
End Sub
Public Sub modificar_registro()
    Call gmodificar_registro(Me, TXTCODIGO)
    If cmdactivar.Visible = True Then
       cmdactivar.Enabled = True
       cmdsalir.Enabled = True
    End If
    If cmddesactivar.Visible = True Then
       cmddesactivar.Enabled = True
       cmdsalir.Enabled = True
    End If
      
End Sub
Public Sub descartar_registro()
    ' Revertir cambios
    'adodc1.Recordset.CancelUpdate
    Call gdescartar_registro(Me)
    Call asigna_campos
End Sub
Sub obtener_datos()
    Set Mrsptovta = MobjPtoVta.ListarPuntodeVentaAyuda
End Sub
Sub salir_formulario()
    ' validar que no haya procesos pendientes
    ' si no hay problemas
    MDIFUtilitarios.Toolbar1.Buttons(18).Caption = "Salir"    ' boton salir
    Unload Me
End Sub

Sub asigna_campos() ' falta decidir si va ha ser public o private
    Set MrsTipoNegocio = MobjPtoVta.ObtenerTipoPtoVta(Dtcptovta.BoundText)
    Set MrsDisponibles = MobjDispensador.ListarCarasDisponibles
    ListRCaras.llena_lista MrsDisponibles, MobjDispensador.ListarCarasAsignadasaPtoVta(Dtcptovta.BoundText)
        
    ' El valor cero es Desactivado
    If Trim(MrsTipoNegocio!tiponegocio) = "0" Then
      lbltipo.Caption = "Desactivado"
      cmdactivar.Visible = True
      cmddesactivar.Visible = False
    Else
      ' El valor 1 es Acivado
      lbltipo.Caption = "Activado"
      cmdactivar.Visible = False
      cmddesactivar.Visible = True
    End If
    
    Set MrsTipoNegocio = Nothing
    
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 MobjPtoVta = Nothing
    Set MobjDispensador = Nothing
    Set Mrsptovta = Nothing
    Set MrsDisponibles = Nothing
    Set MrsAsignados = Nothing
End Sub
Sub imprimir()

End Sub


