VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmTablas 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   4380
   ClientLeft      =   300
   ClientTop       =   1635
   ClientWidth     =   7170
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4380
   ScaleWidth      =   7170
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdAdicionar 
      Height          =   540
      Left            =   120
      Picture         =   "FrmTablas.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   11
      ToolTipText     =   "Nuevo"
      Top             =   3765
      Width           =   555
   End
   Begin VB.CommandButton cmdModificar 
      Height          =   540
      Left            =   735
      Picture         =   "FrmTablas.frx":038A
      Style           =   1  'Graphical
      TabIndex        =   10
      ToolTipText     =   "Modifica"
      Top             =   3765
      Width           =   555
   End
   Begin VB.CommandButton cmdEliminar 
      Enabled         =   0   'False
      Height          =   540
      Left            =   1947
      Picture         =   "FrmTablas.frx":0C54
      Style           =   1  'Graphical
      TabIndex        =   9
      ToolTipText     =   "Elimina"
      Top             =   3765
      Width           =   555
   End
   Begin VB.CommandButton cmdSalir 
      Cancel          =   -1  'True
      Height          =   540
      Left            =   2556
      Picture         =   "FrmTablas.frx":1096
      Style           =   1  'Graphical
      TabIndex        =   8
      ToolTipText     =   "Salir"
      Top             =   3765
      Width           =   555
   End
   Begin VB.CommandButton CmdVer 
      Height          =   540
      Left            =   1338
      Picture         =   "FrmTablas.frx":20D8
      Style           =   1  'Graphical
      TabIndex        =   7
      ToolTipText     =   "Consulta"
      Top             =   3765
      Width           =   555
   End
   Begin VB.TextBox txtfind 
      Height          =   315
      Left            =   120
      TabIndex        =   0
      Top             =   3225
      Visible         =   0   'False
      Width           =   6915
   End
   Begin VB.TextBox txtbuscar 
      BackColor       =   &H00FFFFFF&
      Height          =   300
      Left            =   120
      TabIndex        =   1
      Top             =   3240
      Visible         =   0   'False
      Width           =   6705
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   3345
      Style           =   2  'Dropdown List
      TabIndex        =   4
      ToolTipText     =   "Seleccione Un Programa"
      Top             =   210
      Visible         =   0   'False
      Width           =   3765
   End
   Begin MSDataGridLib.DataGrid grddatos 
      Height          =   3015
      Left            =   75
      TabIndex        =   3
      Top             =   570
      Width           =   7005
      _ExtentX        =   12356
      _ExtentY        =   5318
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      RowDividerStyle =   3
      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            =   8.25
         Charset         =   0
         Weight          =   400
         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            =   2058
            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            =   2058
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         MarqueeStyle    =   4
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label txtOpcion 
      Height          =   285
      Left            =   7395
      TabIndex        =   6
      Top             =   3435
      Visible         =   0   'False
      Width           =   420
   End
   Begin VB.Label lbltit3 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Almacenes:"
      BeginProperty Font 
         Name            =   "Comic Sans MS"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   315
      Left            =   2940
      TabIndex        =   5
      Top             =   3030
      Visible         =   0   'False
      Width           =   1230
   End
   Begin VB.Label lblTit2 
      BackStyle       =   0  'Transparent
      Caption         =   "TABLA DE GRUPOS"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   345
      Left            =   90
      TabIndex        =   2
      Top             =   60
      Width           =   6990
   End
End
Attribute VB_Name = "FrmTablas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rsTempT As ADODB.Recordset

Private Sub cmdEliminar_Click()
Dim mBook As Variant
Dim strsqlchange As String
Dim SW As Boolean
On Error GoTo ElimErr

SW = False
If xTabla = 2 Or xTabla = 3 Then
    mBook = rsTempT.Bookmark
    Me.cmdEliminar.Enabled = False
    If vbNo = MsgBox("En este Proceso 1º Verificara Si se puede Eliminar este Articulo..." & Chr(13) & "en Caso de Poderse se Eliminara Automaticamente..." & Chr(13) & "ESPERE UNOS Segundos...", vbYesNo + vbInformation, "Mensaje") Then Exit Sub
    Screen.MousePointer = vbHourglass
    xCod = grddatos.Columns(xTabla)
    Set rsTempT = New ADODB.Recordset
    If Left(xCod, 1) = "B" Then
        rsTempT.Open "SELECT CODART FROM DETSOL WHERE CODART = '" & xCod & "' ORDER BY CODART ", db1, adOpenStatic, adLockReadOnly, adCmdText
        If rsTempT.RecordCount = 0 Then
            rsTempT.Close
            If xTabla = 2 Then
                rsTempT.Open "SELECT COD_ART FROM KARDEX WHERE COD_ART = '" & xCod & "' ORDER BY COD_ART ", db1, adOpenStatic, adLockReadOnly, adCmdText
                If rsTempT.RecordCount = 0 Then
                    rsTempT.Close
                    rsTempT.Open "SELECT COD_ART FROM KARNOT WHERE COD_ART = '" & xCod & "' ORDER BY COD_ART ", db1, adOpenStatic, adLockReadOnly, adCmdText
                    If rsTempT.RecordCount = 0 Then
                            strsqlchange = "Delete FROM ARTINOTA WHERE COD_ART = '" & xCod & "'"
                            db1.Execute strsqlchange
                            strsqlchange = "Delete FROM CATAARTI WHERE CODBIEN = '" & xCod & "'"
                            db1.Execute strsqlchange
                            SW = True
                    End If
                End If
            Else
                rsTempT.Open "SELECT COD_ART FROM KARNOT WHERE COD_ART = '" & xCod & "' ORDER BY COD_ART ", db1, adOpenStatic, adLockReadOnly, adCmdText
                If rsTempT.RecordCount = 0 Then
                        strsqlchange = "Delete FROM ARTINOTA WHERE COD_ART = '" & xCod & "' AND COD_PRO = '" & Format(Combo1.ItemData(Combo1.ListIndex), "0000") & "'"
                        db1.Execute strsqlchange
                        SW = True
                End If
            End If
        End If
    Else
        rsTempT.Open "SELECT CODART FROM DETSOLS WHERE CODART = '" & xCod & "' ORDER BY CODART ", db1, adOpenStatic, adLockReadOnly, adCmdText
        If rsTempT.RecordCount = 0 Then
            rsTempT.Close
            rsTempT.Open "SELECT CODART FROM DETAORDS WHERE CODART = '" & xCod & "' ORDER BY CODART ", db1, adOpenStatic, adLockReadOnly, adCmdText
            If rsTempT.RecordCount = 0 Then
                If xTabla = 2 Then
                    strsqlchange = "Delete FROM ARTINOTA WHERE COD_ART = '" & xCod & "'"
                    db1.Execute strsqlchange
                    strsqlchange = "Delete FROM CATAARTI WHERE CODBIEN = '" & xCod & "'"
                    db1.Execute strsqlchange
                    SW = True
                Else
                    strsqlchange = "Delete FROM ARTINOTA WHERE COD_ART = '" & xCod & "' AND COD_PRO = '" & Format(Combo1.ItemData(Combo1.ListIndex), "0000") & "'"
                    db1.Execute strsqlchange
                    SW = True
                End If
            End If
        End If
    End If
    rsTempT.Close
    If SW Then
        MsgBox "El Articulo SI ha sido Eliminado ...", vbInformation, "Ok"
    Else
        MsgBox "El Articulo No se Puede Eliminar ...", vbExclamation, "No Eliminó"
    End If
    Pro_Servicios (xTabla)
    rsTempT.Bookmark = mBook
    cmdEliminar.Enabled = True
    Screen.MousePointer = vbDefault
End If

Exit Sub

ElimErr:
MsgBox Err.Description, vbExclamation
cmdEliminar.Enabled = True
Screen.MousePointer = vbDefault
End Sub


Private Sub cmdModificar_Click()
On Error GoTo Fatal
Dim mBook As Variant
pAction = "M"
SWP = False
If Me.grddatos.Row >= 0 Then
    mBook = rsTempT.Bookmark
    Select Case xTabla
    Case 9
        FrmTablas_sub.Show 1
        If SWP Then Pro_Servicios (xTabla)
    End Select
    On Error Resume Next
    rsTempT.Bookmark = mBook
    On Error GoTo Fatal
Else
    MsgBox "No Existen registros.....", vbInformation, "Mensaje"
End If
Exit Sub

Fatal:
MsgBox Err.Description, vbOKOnly + vbInformation

End Sub

Private Sub cmdAdicionar_Click()
pAction = "A"
SWP = False
Select Case xTabla
    Case 9
        FrmTablas_sub.Show 1
End Select
If SWP Then Pro_Servicios (xTabla)
withdatos
End Sub

Private Sub cmdSalir_Click()
Unload Me
End Sub

Private Sub cmdVer_Click()
Dim mBook As Variant
pAction = "C"
SWP = False
If Me.grddatos.Row >= 0 Then
    mBook = rsTempT.Bookmark
    Select Case xTabla
    Case 9
        FrmTablas_sub.Show 1
        If SWP Then Pro_Servicios (xTabla)
    End Select
    rsTempT.Bookmark = mBook
Else
    MsgBox "No Existen registros.....", vbInformation, "Mensaje"
End If
End Sub

Private Sub Combo1_Click()
Dim lText As String
Dim conxprg As ADODB.Recordset
    lText = Combo1.Text
    If Len(lText) > 0 Then
        cmdAdicionar.Enabled = True
        cmdModificar.Enabled = True
    Else
        cmdAdicionar.Enabled = False
        cmdModificar.Enabled = False
    End If
    Screen.MousePointer = vbHourglass
    Pro_Servicios (xTabla)
    Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Load()


Dim rProg As ADODB.Recordset
'CenterMe Me
xTabla = kMNU_MANTENIMIENTO_TIPO_TARJETA
Screen.MousePointer = vbHourglass
DoEvents
Set rsTempT = New ADODB.Recordset
Select Case xTabla
    Case 9
        lblTit2 = "TIPOS DE TARJETA"
End Select
lblTit2 = lblTit2
Pro_Servicios (xTabla)
Screen.MousePointer = vbDefault
End Sub

Private Sub withdatos()
Select Case xTabla
    Case 9
        grddatos.Columns(0).Width = 800
        grddatos.Columns(0).Caption = "Codigo"
        grddatos.Columns(1).Width = 4000
        grddatos.Columns(1).Caption = "Descripción"
End Select

End Sub

Private Sub Form_LostFocus()
 xtop = Me.Top
 xLeft = Me.Left
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set rsTempT = Nothing
lbltit3.Visible = False
Combo1.Visible = False
End Sub

Private Sub grdDatos_DblClick()
If rsTempT.state = adStateOpen Then
  If Not (rsTempT.EOF And rsTempT.BOF) Then
   xCod = grddatos.Columns(0).Text
   xDes = grddatos.Columns(1).Text
    cmdVer_Click
  End If
End If

End Sub

Private Sub grddatos_KeyDown(KeyCode As Integer, Shift As Integer)
Dim sCar As String * 1
Select Case KeyCode
    Case 96
        sCar = "0"
    Case 97
        sCar = "1"
    Case 98
        sCar = "2"
    Case 99
        sCar = "3"
    Case 100
        sCar = "4"
    Case 101
        sCar = "5"
    Case 102
        sCar = "6"
    Case 103
        sCar = "7"
    Case 104
        sCar = "8"
    Case 105
        sCar = "9"
    Case Else
        sCar = UCase$(Chr$(KeyCode))
End Select
If (sCar >= "A" And sCar <= "Z") Or (sCar >= "0" And sCar <= "9") Then
  If xTabla = 222 Or xTabla = 9 Then
    txtfind.Text = sCar
    txtfind.SelStart = 1
    txtfind.Visible = True
    txtfind.SetFocus
  Else
    txtbuscar.Text = sCar
    txtbuscar.SelStart = 1
    txtbuscar.Visible = True
    txtbuscar.SetFocus
  End If
End If
End Sub

Private Sub grddatos_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then grdDatos_DblClick
End Sub

Private Sub txtBuscar_KeyPress(KeyAscii As Integer)
Dim lBUSCA As String
Dim lbook As Variant
If KeyAscii = 13 And txtbuscar <> "" And Not IsNull(txtbuscar.Text) Then
   Screen.MousePointer = vbHourglass
   If grddatos.Row >= 0 Then
        lBUSCA = txtbuscar & "%"
        lbook = rsTempT.Bookmark
        Select Case xTabla
            Case 9
                    rsTempT.Find "descrip LIKE '" & lBUSCA & "'", , , 1
        End Select
        If rsTempT.EOF Then
            MsgBox "El dato no fue encontrado", vbInformation, "Búsqueda finalizada"
            txtbuscar.SelStart = 0
            txtbuscar.SelLength = Len(txtbuscar.Text)
            rsTempT.Bookmark = lbook
        End If
    End If
    Screen.MousePointer = vbDefault
    grddatos.SetFocus
End If
End Sub
Private Sub txtbuscar_LostFocus()
txtbuscar.Text = ""
txtbuscar.Visible = False
End Sub

Private Sub Pro_Servicios(OP As Integer)
Dim sSQLT1 As String
Select Case OP
    Case 9
        sSQLT1 = "SELECT cod_tar,descrip From tipo_tarjeta"
End Select
 If rsTempT.state = adStateOpen Then rsTempT.Close
 'rsTempT.CursorLocation = adUseClient
 rsTempT.CursorLocation = adUseServer
 rsTempT.Open sSQLT1, ADOCnn, adOpenStatic, adLockReadOnly, adCmdText
 Set grddatos.DataSource = rsTempT
 withdatos
End Sub









