VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form FApro_CarasVendedor 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Confirmar Caras-Vendedor"
   ClientHeight    =   6045
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7770
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6045
   ScaleWidth      =   7770
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdsalir 
      Caption         =   "&Salir"
      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            =   5775
      Picture         =   "FApro_CarasVendedor.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   4980
      Width           =   1815
   End
   Begin VB.CommandButton cmdcancelar 
      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            =   3720
      Picture         =   "FApro_CarasVendedor.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   4980
      Width           =   1815
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "Aceptar"
      Enabled         =   0   'False
      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            =   1620
      Picture         =   "FApro_CarasVendedor.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   16
      Tag             =   "R ASDASD"
      Top             =   4980
      Width           =   1815
   End
   Begin VB.TextBox txtClaveR 
      Enabled         =   0   'False
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   5400
      PasswordChar    =   "*"
      TabIndex        =   15
      Top             =   4320
      Width           =   1935
   End
   Begin MSDataListLib.DataCombo dtcVendedorR 
      Height          =   315
      Left            =   1680
      TabIndex        =   12
      Top             =   4320
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   556
      _Version        =   393216
      Enabled         =   0   'False
      Style           =   2
      Text            =   ""
   End
   Begin VB.CommandButton cmdReemplazar 
      Caption         =   "Reemplazar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   4920
      TabIndex        =   2
      Top             =   3120
      Width           =   1935
   End
   Begin VB.TextBox txtClave 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   5400
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1920
      Width           =   2175
   End
   Begin MSDataGridLib.DataGrid dbDetalle 
      Height          =   1335
      Left            =   240
      TabIndex        =   10
      TabStop         =   0   'False
      Top             =   2400
      Width           =   3615
      _ExtentX        =   6376
      _ExtentY        =   2355
      _Version        =   393216
      ForeColor       =   192
      HeadLines       =   1
      RowHeight       =   19
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      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
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSDataListLib.DataCombo dtcVendedor 
      Height          =   315
      Left            =   240
      TabIndex        =   0
      Top             =   1920
      Width           =   3615
      _ExtentX        =   6376
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   ""
   End
   Begin VB.Image Image2 
      Height          =   600
      Left            =   3990
      Picture         =   "FApro_CarasVendedor.frx":091E
      Stretch         =   -1  'True
      Top             =   2715
      Width           =   570
   End
   Begin VB.Image Imgaceptar 
      Height          =   480
      Left            =   6960
      Picture         =   "FApro_CarasVendedor.frx":0C28
      Top             =   3120
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Line Line3 
      BorderColor     =   &H80000002&
      X1              =   120
      X2              =   7680
      Y1              =   4800
      Y2              =   4800
   End
   Begin VB.Label Label2 
      Caption         =   "Clave"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4680
      TabIndex        =   14
      Top             =   4320
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "Vendedor Remplazante"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   240
      TabIndex        =   13
      Top             =   4200
      Width           =   1335
   End
   Begin VB.Label lblClave 
      Caption         =   "Clave"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4200
      TabIndex        =   11
      Top             =   1920
      Width           =   855
   End
   Begin VB.Line Line2 
      BorderColor     =   &H80000002&
      X1              =   120
      X2              =   7680
      Y1              =   3960
      Y2              =   3960
   End
   Begin VB.Line Line1 
      BorderColor     =   &H80000002&
      X1              =   120
      X2              =   7680
      Y1              =   240
      Y2              =   240
   End
   Begin VB.Label lblAlmacen1 
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   1440
      TabIndex        =   9
      Top             =   360
      Width           =   6135
   End
   Begin VB.Label lblTurno1 
      AutoSize        =   -1  'True
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   3840
      TabIndex        =   8
      Top             =   840
      Width           =   135
   End
   Begin VB.Label lblFechaproc 
      AutoSize        =   -1  'True
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   1440
      TabIndex        =   7
      Top             =   840
      Width           =   135
   End
   Begin VB.Label lblAlmacen 
      AutoSize        =   -1  'True
      Caption         =   "Almacen"
      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            =   240
      TabIndex        =   6
      Top             =   360
      Width           =   915
   End
   Begin VB.Label lblFecha 
      Caption         =   "Fecha de Proceso"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   240
      TabIndex        =   5
      Top             =   840
      Width           =   1095
   End
   Begin VB.Label lblTurno 
      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          =   255
      Left            =   3000
      TabIndex        =   4
      Top             =   840
      Width           =   615
   End
   Begin VB.Label lblVendecor 
      AutoSize        =   -1  'True
      Caption         =   "Vendedor"
      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            =   240
      TabIndex        =   3
      Top             =   1560
      Width           =   1035
   End
End
Attribute VB_Name = "FApro_CarasVendedor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Programador: Edgar Cancho Ruiz
' Empresa Texaco
' Modulo de Caras-Vendedor (playa)
' Fecha : 08/11/2002

Public MintTurno As Integer

Public objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Public objCarasVendedor As DB_OP_MANTENIMIENTOS.C_CARAS_VENDEDOR
Public MobjVentasPlaya As DB_OP_FACTURACION.C_VENTASPLAYA
Dim rs_temporal As ADODB.Recordset
Dim MblnReemplazo As Boolean

Public Sub CargaDataCombo(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
    objDataCombo.BoundText = rsSource.Fields(istrCampo2)
End Sub

Private Sub cmdAceptar_Click()
On Error GoTo TrataError

If MblnReemplazo Then
    If MsgBox("Desea Confirmar el Reemplazo? ", vbQuestion + vbYesNo, "Confirmar") = vbNo Then
        Exit Sub
    Else
        objCarasVendedor.ReemplazarTurno GstrSiteProce, GDatFechaProcesoVentas, MintTurno, dtcVendedor.BoundText, dtcVendedorR.BoundText
        MsgBox "Actualización exitosa", vbInformation, "Mensaje"
                
        Set rs_temporal = objCarasVendedor.CargaVendedores(GstrSiteProce, GDatFechaProcesoVentas, MintTurno)
        
        If rs_temporal.EOF Then
           ' Si ya no hay vendedores a Confirmar entonces se cambia el Turno
           'MobjVentasPlaya.ActualizarTurno
           Unload Me
           MsgBox "Confirmación de Turnos fue Completada,el Sistema se cerrará", vbDefaultButton1 + vbInformation, "Mensaje"
           End
        End If
        
        Call CargaDataCombo(dtcVendedor, rs_temporal, "SALESPERID", "SALESPERNAME")
        dtcVendedor.BoundText = rs_temporal!SALESPERID
    
        Call CargaDataCombo(dtcVendedorR, objCarasVendedor.CargaVendedoresR(GstrSiteProce, GDatFechaProcesoVentas, MintTurno), "SALESPERID", "SALESPERNAME")
        
        dtcVendedorR.BoundText = Empty
        dtcVendedorR.Enabled = False
        txtClaveR.Text = Empty
        txtClaveR.Enabled = False
        
        MblnReemplazo = False
        cmdReemplazar.Enabled = True
        dtcVendedor.Enabled = True
        txtClave.Text = Empty
        txtClave.Enabled = True
        
        cmdAceptar.Enabled = False
        
        dtcVendedor.SetFocus
    End If

Else

    If MsgBox("Desea Confirmar Turno? ", vbQuestion + vbYesNo, "Confirmar") = vbNo Then
        Exit Sub
    Else
        objCarasVendedor.ConfirmarTurno GstrSiteProce, GDatFechaProcesoVentas, MintTurno, dtcVendedor.BoundText
        MsgBox "Actualización exitosa", vbInformation, "Mensaje"
                
        Set rs_temporal = objCarasVendedor.CargaVendedores(GstrSiteProce, GDatFechaProcesoVentas, MintTurno)
        
        If rs_temporal.EOF Then
           ' Si ya no hay vendedores a Confirmar entonces se cambia el Turno
           'MobjVentasPlaya.ActualizarTurno
           Unload Me
           MsgBox "Confirmación de Turnos fue Completada,el Sistema se cerrará", vbDefaultButton1 + vbInformation, "Mensaje"
           End
        End If
                        
        Call CargaDataCombo(dtcVendedor, rs_temporal, "SALESPERID", "SALESPERNAME")
        dtcVendedor.BoundText = rs_temporal!SALESPERID
    
        Call CargaDataCombo(dtcVendedorR, objCarasVendedor.CargaVendedoresR(GstrSiteProce, GDatFechaProcesoVentas, MintTurno), "SALESPERID", "SALESPERNAME")
                
        txtClave.Text = Empty
        
        cmdAceptar.Enabled = False
        
        dtcVendedor.SetFocus
    End If
    
End If

Exit Sub
TrataError:

End Sub

Private Sub cmdcancelar_Click()

    dtcVendedorR.BoundText = Empty
    dtcVendedorR.Enabled = False
    txtClaveR.Text = Empty
    txtClaveR.Enabled = False
    MblnReemplazo = False
    cmdReemplazar.Enabled = True
    dtcVendedor.Enabled = True
    txtClave.Text = Empty
    txtClave.Enabled = True
    cmdAceptar.Enabled = False
    dtcVendedor.SetFocus
End Sub

Private Sub cmdReemplazar_Click()

    If GVDATO(dtcVendedor.BoundText) = Empty Then
           MsgBox "No ha seleccionado Vendedor a Reemplazar", vbExclamation, "Mensaje"
           Exit Sub
    End If
    
    dtcVendedorR.Enabled = True
    txtClaveR.Enabled = True
    MblnReemplazo = True
    cmdReemplazar.Enabled = False
    dtcVendedor.Enabled = False
    txtClave.Text = Empty
    txtClave.Enabled = False
    dtcVendedorR.SetFocus

End Sub

Private Sub cmdReemplazar_GotFocus()
  Imgaceptar.Visible = True
End Sub

Private Sub cmdReemplazar_LostFocus()
  Imgaceptar.Visible = False
End Sub

Private Sub Command1_Click()
   
End Sub

Private Sub cmdsalir_Click()
  Unload Me
End Sub

Private Sub dtcVendedor_Change()
    Set DBDETALLE.DataSource = objCarasVendedor.SeleccionTemporal(GstrSiteProce, GDatFechaProcesoVentas, MintTurno, dtcVendedor.BoundText)
    DBDETALLE.Refresh
End Sub

Private Sub dtcVendedor_Click(Area As Integer)
    Set DBDETALLE.DataSource = objCarasVendedor.SeleccionTemporal(GstrSiteProce, GDatFechaProcesoVentas, MintTurno, dtcVendedor.BoundText)
    DBDETALLE.Refresh
End Sub

Private Sub dtcVendedor_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        txtClave.SetFocus
    End If
End Sub

Private Sub dtcVendedorR_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        txtClaveR.SetFocus
    End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = 27 Then
        Unload Me
    End If
End Sub

Private Sub Form_Load()
On Error Resume Next
    
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objCarasVendedor = New DB_OP_MANTENIMIENTOS.C_CARAS_VENDEDOR
    Set MobjVentasPlaya = New DB_OP_FACTURACION.C_VENTASPLAYA
    
    Set rs_temporal = objCarasVendedor.CargaVendedores(GstrSiteProce, GDatFechaProcesoVentas, MintTurno)
    
    lblAlmacen1.Caption = objAlmacen.ObtenerDescripcionAlmacen(GstrSiteProce)
    lblFechaproc.Caption = GDatFechaProcesoVentas
    lblTurno1.Caption = "Turno " & MintTurno
    
    Call CargaDataCombo(dtcVendedor, rs_temporal, "SALESPERID", "SALESPERNAME")
    dtcVendedor.BoundText = rs_temporal!SALESPERID

    
    Call CargaDataCombo(dtcVendedorR, objCarasVendedor.CargaVendedoresR(GstrSiteProce, GDatFechaProcesoVentas, MintTurno), "SALESPERID", "SALESPERNAME")
    
    'KeyPreview = True
    MblnReemplazo = False
    
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  If Not rs_temporal.EOF Then
     MsgBox "Debe Configurar Todos los Vendedores", vbDefaultButton1 + vbExclamation, "Advertencia"
     dtcVendedor.SetFocus
     Cancel = 1
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)

  Set objAlmacen = Nothing
  Set objCarasVendedor = Nothing
  Set MobjVentasPlaya = Nothing
  
End Sub

Private Sub txtClave_Change()
On Error GoTo TrataError
    If Trim(objCarasVendedor.ObtienePassWordVendedor(dtcVendedor.BoundText)) = Trim(txtClave) Then
        cmdAceptar.Enabled = True
        cmdAceptar.SetFocus
    Else
        cmdAceptar.Enabled = False
    End If
TrataError:
End Sub

Private Sub txtClave_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 And cmdAceptar.Enabled Then
        cmdAceptar.SetFocus
    End If
End Sub

Private Sub txtClaveR_Change()
On Error GoTo TrataError
    If Trim(objCarasVendedor.ObtienePassWordVendedor(dtcVendedorR.BoundText)) = Trim(txtClaveR) Then
        cmdAceptar.Enabled = True
        cmdAceptar.SetFocus
    Else
        cmdAceptar.Enabled = False
    End If
TrataError:
End Sub

Private Sub txtClaveR_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 And cmdAceptar.Enabled Then
        cmdAceptar.SetFocus
    End If
End Sub
