VERSION 5.00
Begin VB.Form FbuscarVendedor 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Búsqueda de Vendedores"
   ClientHeight    =   2115
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7140
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2115
   ScaleWidth      =   7140
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Height          =   2055
      Left            =   0
      TabIndex        =   4
      Top             =   0
      Width           =   7095
      Begin VB.CommandButton cmdCancelar 
         Caption         =   "&Cancelar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   765
         Left            =   5400
         Picture         =   "FbuscarVendedor.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   1080
         Width           =   1515
      End
      Begin VB.CommandButton cmdAceptar 
         Caption         =   "&Aceptar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   765
         Left            =   3840
         Picture         =   "FbuscarVendedor.frx":030A
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   1080
         Width           =   1515
      End
      Begin VB.TextBox txtcodigo 
         Height          =   315
         Left            =   120
         MaxLength       =   20
         TabIndex        =   0
         Top             =   480
         Width           =   2055
      End
      Begin VB.CommandButton cmdBuscar 
         Height          =   375
         Left            =   2160
         Picture         =   "FbuscarVendedor.frx":0614
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   480
         Width           =   375
      End
      Begin VB.Label lbldescripcion 
         BorderStyle     =   1  'Fixed Single
         Height          =   315
         Left            =   2640
         TabIndex        =   6
         Top             =   480
         Width           =   4095
      End
      Begin VB.Label Label1 
         Caption         =   "Vendedor"
         Height          =   375
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   1455
      End
   End
End
Attribute VB_Name = "FbuscarVendedor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String
Private MBlnDatosCargados As Boolean
Public objVendedor As DB_OP_MANTENIMIENTOS.C_VENDEDOR

Private Sub cmdAceptar_Click()
  
  If Trim(txtcodigo.Text) <> Empty Then
    FCierreX_Playa.lblvendedor = Trim(txtcodigo.Text)
    FCierreX_Playa.Lbldesvendedor = Trim(lbldescripcion.Caption)
    FCierreX_Playa.MintAceptarCancelar = 1
    Unload Me
  Else
    MsgBox "Ingrese Código de Vendedor", vbDefaultButton1 + vbExclamation, "Mensaje"
    txtcodigo.SetFocus
  End If
    
End Sub

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

Private Sub cmdBuscar_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "SALESPERID"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1200
    ArrayBusqueda(2, 1) = "SALESPERNAME"
    ArrayBusqueda(2, 2) = "Nombre "
    ArrayBusqueda(2, 3) = 4000
      
    fAyudaVendedor.GObtenerRegistros objVendedor.ListarVendedoresAyuda, ArrayBusqueda, 2, 2
    fAyudaVendedor.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
       txtcodigo.Text = GrecibeColumnaID
       lbldescripcion.Caption = GrecibeColumnaOpcional
       MBlnDatosCargados = True
    End If
    
End Sub

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

Private Sub cmdCancelar_Click()
   Unload Me
End Sub

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

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyF2 Then
      cmdBuscar_Click
   End If
End Sub

Private Sub Form_Load()

   Set objVendedor = New DB_OP_MANTENIMIENTOS.C_VENDEDOR
   MBlnDatosCargados = False
   'Me.KeyPreview = True
   
   Me.Left = (Screen.Width - Me.Width) / 2
   Me.Top = (Screen.Height - Me.Height) / 2
      
End Sub

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

Private Sub txtcodigo_Change()
   If MBlnDatosCargados = True Then
      lbldescripcion.Caption = Empty
   End If
End Sub

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

Private Sub txtcodigo_KeyPress(KeyAscii As Integer)

   If KeyAscii = 13 Then
       Dim LrsVendedor As ADODB.Recordset
       
       Set LrsVendedor = objVendedor.ListarPorVendedorID(txtcodigo.Text)
       If Not LrsVendedor.EOF Then
          lbldescripcion.Caption = LrsVendedor!salespername
          MBlnDatosCargados = True
          cmdAceptar.SetFocus
       Else
          MsgBox "Código de Vendedor no existe", vbDefaultButton1 + vbExclamation, "Mensaje"
          MBlnDatosCargados = False
          lbldescripcion.Caption = Empty
          txtcodigo.SetFocus
          Exit Sub
       End If
       Set LrsVendedor = Nothing
   
   End If

End Sub
