VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmConfiguraBotonProducto 
   Caption         =   "Configurar Botones y Productos"
   ClientHeight    =   7050
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7320
   Icon            =   "frmConfiguraBotonProducto.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   7050
   ScaleWidth      =   7320
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdSalir 
      Caption         =   "Salir"
      Height          =   465
      Left            =   3090
      TabIndex        =   27
      Top             =   6570
      Width           =   1290
   End
   Begin VB.Frame Frame1 
      Height          =   1545
      Left            =   600
      TabIndex        =   24
      Top             =   4920
      Width           =   5985
      Begin VB.TextBox txtCodigoProducto 
         Height          =   315
         Left            =   135
         TabIndex        =   35
         Top             =   1035
         Visible         =   0   'False
         Width           =   945
      End
      Begin VB.TextBox txtNombreProducto 
         BackColor       =   &H00C0FFFF&
         Height          =   315
         Left            =   870
         Locked          =   -1  'True
         TabIndex        =   34
         Top             =   645
         Width           =   4470
      End
      Begin VB.CommandButton txtBuscaProductos 
         Caption         =   "..."
         Height          =   315
         Left            =   5400
         TabIndex        =   33
         Top             =   660
         Width           =   435
      End
      Begin VB.CommandButton cmdEliminar 
         Caption         =   "Quitar Producto"
         Height          =   360
         Left            =   1440
         TabIndex        =   25
         Top             =   1080
         Width           =   1365
      End
      Begin VB.CommandButton cmdGrabar 
         Caption         =   "Grabar"
         Height          =   360
         Left            =   3285
         TabIndex        =   26
         Top             =   1095
         Width           =   1230
      End
      Begin VB.TextBox txtTecla 
         BackColor       =   &H00C0FFFF&
         Height          =   315
         Left            =   4410
         Locked          =   -1  'True
         TabIndex        =   32
         TabStop         =   0   'False
         Top             =   225
         Width           =   930
      End
      Begin VB.TextBox txtBoton 
         BackColor       =   &H00C0FFFF&
         Height          =   315
         Left            =   870
         Locked          =   -1  'True
         TabIndex        =   30
         TabStop         =   0   'False
         Top             =   225
         Width           =   1680
      End
      Begin MSAdodcLib.Adodc adoProducto 
         Height          =   360
         Left            =   2655
         Top             =   195
         Visible         =   0   'False
         Width           =   1200
         _ExtentX        =   2117
         _ExtentY        =   635
         ConnectMode     =   0
         CursorLocation  =   3
         IsolationLevel  =   -1
         ConnectionTimeout=   15
         CommandTimeout  =   30
         CursorType      =   3
         LockType        =   3
         CommandType     =   8
         CursorOptions   =   0
         CacheSize       =   50
         MaxRecords      =   0
         BOFAction       =   0
         EOFAction       =   0
         ConnectStringType=   1
         Appearance      =   1
         BackColor       =   -2147483643
         ForeColor       =   -2147483640
         Orientation     =   0
         Enabled         =   -1
         Connect         =   ""
         OLEDBString     =   ""
         OLEDBFile       =   ""
         DataSourceName  =   ""
         OtherAttributes =   ""
         UserName        =   ""
         Password        =   ""
         RecordSource    =   ""
         Caption         =   "Adodc1"
         BeginProperty Font {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
         _Version        =   393216
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Tecla:"
         Height          =   195
         Left            =   3885
         TabIndex        =   31
         Top             =   285
         Width           =   450
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Botón:"
         Height          =   195
         Left            =   330
         TabIndex        =   29
         Top             =   285
         Width           =   465
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Producto:"
         Height          =   195
         Left            =   105
         TabIndex        =   28
         Top             =   675
         Width           =   690
      End
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto2"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   2
      Left            =   1320
      TabIndex        =   1
      Top             =   195
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto3"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   3
      Left            =   2475
      TabIndex        =   2
      Top             =   195
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto4"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   4
      Left            =   3645
      TabIndex        =   3
      Top             =   195
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto5"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   5
      Left            =   4800
      TabIndex        =   4
      Top             =   195
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto6"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   6
      Left            =   5970
      TabIndex        =   5
      Top             =   195
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto7"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   7
      Left            =   165
      TabIndex        =   6
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto8"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   8
      Left            =   1320
      TabIndex        =   7
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto9"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   9
      Left            =   2475
      TabIndex        =   8
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto10"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   10
      Left            =   3645
      TabIndex        =   9
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto11"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   11
      Left            =   4800
      TabIndex        =   10
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto12"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   12
      Left            =   5970
      TabIndex        =   11
      Top             =   1350
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto13"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   13
      Left            =   165
      TabIndex        =   12
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto14"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   14
      Left            =   1320
      TabIndex        =   13
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto15"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   15
      Left            =   2475
      TabIndex        =   14
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto16"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   16
      Left            =   3645
      TabIndex        =   15
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto17"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   17
      Left            =   4800
      TabIndex        =   16
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto18"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   18
      Left            =   5970
      TabIndex        =   17
      Top             =   2505
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto19"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   19
      Left            =   165
      TabIndex        =   18
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto20"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   20
      Left            =   1320
      TabIndex        =   23
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto21"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   21
      Left            =   2475
      TabIndex        =   19
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto22"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   22
      Left            =   3645
      TabIndex        =   20
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto23"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   23
      Left            =   4800
      TabIndex        =   21
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto24"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   24
      Left            =   5970
      TabIndex        =   22
      Top             =   3660
      Width           =   1155
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "Producto1"
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1155
      Index           =   1
      Left            =   165
      TabIndex        =   0
      Top             =   195
      Width           =   1155
   End
End
Attribute VB_Name = "frmConfiguraBotonProducto"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim iBoton As Integer

Private Sub cmdEliminar_Click()
   'dcbProducto.BoundText = ""
   Me.txtNombreProducto = ""
   Me.txtCodigoProducto = ""
   Call cmdGrabar_Click
End Sub

Private Sub cmdGrabar_Click()
  On Error GoTo LineaError

  Dim sSql As String
  Dim sProducto As String
  Dim adoRS As ADODB.Recordset
  
  If iBoton < 1 Then Exit Sub
   
'  If dcbProducto.BoundText = "" Then
'    sProducto = "0"
'  Else
'    sProducto = CStr(dcbProducto.BoundText)
'  End If

  If Me.txtCodigoProducto.Text = "" Then
    sProducto = "0"
  Else
    sProducto = Me.txtCodigoProducto.Text
  End If
  
    
  sSql = "UPDATE ConfiguracionTeclado SET cProdCode = $, cTeclFlagAsig = '1' " + _
         "WHERE cTeclCode = $ "
  sSql = VBsprintf(sSql, sProducto, _
         CStr(iBoton))

  If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSql) Then GoTo Salir
  
  If Me.txtCodigoProducto.Text = "" Then
     cmdTecla(iBoton).BackColor = &HE0E0E0          'No tiene producto asignado
     cmdTecla(iBoton).Caption = "Producto" & iBoton
     cmdTecla(iBoton).Font.Size = 8
  Else
    sSql = " SELECT cProdCode, sProdDescCrta" & _
           "   FROM Producto WHERE cProdCode = " + sProducto + _
           "    AND cAlmaCode ='" & kPAR_ALMACEN & "'"

    If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSql, adoRS) Then GoTo Salir
    If adoRS.RecordCount = 0 Then
            sSql = "UPDATE PRODUCTO set cAlmaCode='" & kPAR_ALMACEN & "' WHERE cProdCode=" + sProducto
            
            If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSql) Then GoTo Salir
    Else
            Do While Not adoRS.EOF
              cmdTecla(iBoton).BackColor = &HFFFFC0       'Tiene producto asignado
              If Len(adoRS("sProdDescCrta")) > 25 Then
              cmdTecla(iBoton).Caption = Left(LeerCampo(adoRS("sProdDescCrta")), 25) + ".."
              Else
              cmdTecla(iBoton).Caption = LeerCampo(adoRS("sProdDescCrta"))
              End If
              adoRS.MoveNext
            Loop
    End If
  End If
  
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
Salir:
  Set adoRS = Nothing
End Sub

Private Sub cmdsalir_Click()
   Unload Me
End Sub

Private Sub cmdTecla_Click(Index As Integer)
  On Error GoTo LineaError

  Screen.MousePointer = vbHourglass
  
  Dim sSql As String
  Dim adoRS As ADODB.Recordset
  
  iBoton = Index
  
  txtBoton.Text = "DEP " + CStr(Index)
  If Index > 0 And Index < 13 Then
    txtTecla.Text = "F" + CStr(Index)
  Else
    If Index > 12 And Index < 25 Then
      txtTecla.Text = "SHFT+F" + CStr(Index - 12)
    Else
          txtTecla.Text = ""
    End If
  End If
  
  sSql = " SELECT c.cProdCode, p.sProdDesc" & _
         "   FROM ConfiguracionTeclado c," + _
         "        Producto p" + _
         "  WHERE cTeclCode =" + CStr(Index) & _
         "    AND c.cProdCode = p.cProdCode" & _
         "    AND p.cAlmaCode = '" & kPAR_ALMACEN & "'"

  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSql, adoRS) Then GoTo Salir
  If adoRS.EOF Then
      Me.txtCodigoProducto.Text = ""
      Me.txtNombreProducto.Text = ""
  Else
  
    If LeerCampo(adoRS("cProdCode")) = "" Then
      'dcbProducto.BoundText = ""
      Me.txtCodigoProducto.Text = ""
      Me.txtNombreProducto.Text = ""
    Else
      'dcbProducto.BoundText = LeerCampo(ADORS("cProdCode"))
      Me.txtCodigoProducto.Text = LeerCampo(adoRS("cProdCode"))
      Me.txtNombreProducto.Text = LeerCampo(adoRS("sProdDesc"))
  
    End If
    
  End If
  
  
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

Salir:
  Set adoRS = Nothing
  Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Load()
  On Error GoTo LineaError

  Screen.MousePointer = vbHourglass
  
  Dim sSql As String
  Dim adoRS As ADODB.Recordset
  Dim i As Long, j As Long
  i = 1
  
  iBoton = 0
  
  sSql = " SELECT C.cTeclCode, C.sTeclDesc, C.sTeclRapd, C.cTeclFlagAsig, C.cProdCode, P.sProdDescCrta" & _
         " FROM ConfiguracionTeclado AS C LEFT JOIN Producto AS P ON C.cProdCode = P.cProdCode" & _
         " WHERE C.cTeclCode between 1 and 24 AND P.cAlmaCode ='" & kPAR_ALMACEN & "' ORDER BY cTeclCode"

  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSql, adoRS) Then GoTo Salir
  
  Do While Not adoRS.EOF ' And i < 41
      
    If LeerCampo(adoRS("cProdCode")) = "" Then
      cmdTecla(adoRS("cTeclCode")).BackColor = &HE0E0E0          'No tiene producto asignado
      cmdTecla(adoRS("cTeclCode")).Caption = ""
    Else
      cmdTecla(adoRS("cTeclCode")).BackColor = &HFFFFC0       'Tiene producto asignado
      If Len(adoRS("sProdDescCrta")) > 25 Then
      cmdTecla(adoRS("cTeclCode")).Caption = Left(LeerCampo(adoRS("sProdDescCrta")), 25) + ".."
      Else
      cmdTecla(adoRS("cTeclCode")).Caption = LeerCampo(adoRS("sProdDescCrta"))
      End If
      
    End If
    
    i = i + 1
    adoRS.MoveNext
  Loop
  
  'LlenaProducto

  Screen.MousePointer = vbDefault
  
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  Screen.MousePointer = vbDefault

Salir:
  Set adoRS = Nothing
End Sub

'Sub LlenaProducto()
'  'Carga combo Departamento
'  Dim sSQL As String
'  On Error GoTo LineaError
'
'  With adoProducto
'    .ConnectionString = kCONNECT_STRING + psRutaMdb
'    sSQL = " SELECT * FROM Producto " & _
'           "  WHERE nActivo = 1" & _
'           "  ORDER BY sProdDesc"
'    .RecordSource = sSQL
'    .Refresh
'  End With
'
'  If Not adoProducto.Recordset.EOF Then
'    dcbProducto.BoundText = ""
'  End If
'
'  Exit Sub
'
'LineaError:
'  Screen.MousePointer = vbDefault
'
'End Sub


Private Sub txtBuscaProductos_Click()
    frmBusquedaArticulos.frmPadre = "frmConfiguraBotonProducto"
    frmBusquedaArticulos.pOpcion = "Producto"
    frmBusquedaArticulos.inicio
    frmBusquedaArticulos.Show vbModal
End Sub
