VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form FrmTablas_sub 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   2595
   ClientLeft      =   3360
   ClientTop       =   3000
   ClientWidth     =   6195
   LinkTopic       =   "Form2"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2595
   ScaleWidth      =   6195
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame frmTipoConvenio 
      Height          =   780
      Left            =   0
      TabIndex        =   10
      Top             =   1800
      Width           =   6165
      Begin VB.CommandButton cmdSalir 
         Appearance      =   0  'Flat
         Cancel          =   -1  'True
         Height          =   495
         Left            =   670
         Picture         =   "FrmTablas_sub.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   180
         Width           =   500
      End
      Begin VB.CommandButton cmdGrabar 
         Appearance      =   0  'Flat
         Height          =   495
         Left            =   150
         Picture         =   "FrmTablas_sub.frx":0CCA
         Style           =   1  'Graphical
         TabIndex        =   4
         ToolTipText     =   "Adicionar datos"
         Top             =   180
         Width           =   500
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1815
      Left            =   0
      TabIndex        =   6
      Top             =   0
      Width           =   6180
      Begin VB.TextBox txtAbr1 
         Height          =   285
         Left            =   1770
         TabIndex        =   3
         Top             =   1380
         Visible         =   0   'False
         Width           =   2000
      End
      Begin MSMask.MaskEdBox txtcod 
         Height          =   285
         Left            =   1770
         TabIndex        =   0
         Top             =   210
         Width           =   1245
         _ExtentX        =   2196
         _ExtentY        =   503
         _Version        =   393216
         MaxLength       =   12
         PromptChar      =   "_"
      End
      Begin VB.TextBox txtAbr 
         Height          =   285
         Left            =   1770
         MaxLength       =   20
         TabIndex        =   2
         Top             =   945
         Width           =   2000
      End
      Begin VB.TextBox txtDes 
         Height          =   285
         Left            =   1770
         MaxLength       =   50
         TabIndex        =   1
         Top             =   555
         Width           =   3870
      End
      Begin VB.Label Label9 
         Alignment       =   1  'Right Justify
         Caption         =   "Label9"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   150
         TabIndex        =   15
         Top             =   1410
         Visible         =   0   'False
         Width           =   1440
      End
      Begin VB.Label lblCiu 
         Caption         =   "ciu"
         Height          =   420
         Left            =   60
         TabIndex        =   16
         Top             =   1305
         Visible         =   0   'False
         Width           =   6030
      End
      Begin VB.Label Label8 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   3840
         TabIndex        =   14
         Top             =   960
         Width           =   2175
      End
      Begin VB.Label Label6 
         BackColor       =   &H00404040&
         Caption         =   "Label4"
         Height          =   315
         Left            =   1770
         TabIndex        =   12
         Top             =   960
         Width           =   2000
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "Abreviatura   :"
         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          =   195
         Left            =   360
         TabIndex        =   9
         Top             =   975
         Width           =   1230
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "Código          :"
         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          =   195
         Left            =   330
         TabIndex        =   8
         Top             =   180
         Width           =   1260
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "Descripcion   :"
         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          =   195
         Left            =   330
         TabIndex        =   7
         Top             =   540
         Width           =   1260
      End
      Begin VB.Label Label5 
         BackColor       =   &H00404040&
         Caption         =   "Label4"
         Height          =   315
         Left            =   1770
         TabIndex        =   11
         Top             =   570
         Width           =   3870
      End
   End
   Begin VB.Label Label7 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "Abreviatura   :"
      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          =   195
      Left            =   0
      TabIndex        =   13
      Top             =   0
      Width           =   1230
   End
End
Attribute VB_Name = "FrmTablas_sub"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim atxtcod As String
Dim Tabla As String
Dim tipban As String
Dim rsTempT As New ADODB.Recordset


Private Function ValidaDatos(sQLL As String) As Boolean
Dim ltxtabr As String
Dim lBUSCA As Recordset
Dim sql1 As String
ValidaDatos = False
If sQLL <> "" Then
   If pAction = "A" Then
      If validcampo(sQLL, "", "Se Registro Anteriormente") Then
         txtcod.SetFocus
         Exit Function
      End If
   End If
End If

If txtDes = "" Then
    MsgBox "Debe ingresar Descripcion", vbInformation, "Atención"
    txtDes.SetFocus
    Exit Function
End If

ValidaDatos = True

End Function

Private Sub cmdGrabar_Click()
Dim Vsql As String
Dim gtxtabr As String
Dim strsqlchange As String
Dim rsUltimo As New ADODB.Recordset
On Error GoTo GraErr
tipban = "A"
Screen.MousePointer = vbHourglass

Select Case xTabla  'FrmTablas.grddatos.Columns(0)
    Case 9
        Vsql = "select * from " & Tabla & " Where cod_tar = '" & Me.txtcod.Text & "'"
  End Select

If ValidaDatos(Vsql) Then
    
    If pAction = "A" Then
        Select Case xTabla
            Case 9
                strsqlchange = "INSERT INTO " & Tabla & " (cod_tar, Descrip)" & _
                " VALUES('" & txtcod & "','" & txtDes & "')"
        End Select
    ElseIf pAction = "M" Then
        Select Case xTabla
            Case 9
                strsqlchange = "UPDATE " & Tabla & " SET  Descrip = '" & txtDes & "'  WHERE cod_tar = '" & txtcod & "'"
        End Select
    End If
    ADOCnn.Execute strsqlchange
    cmdSalir_Click
Else
    If xTabla = 11 Then txtcod = ""
End If
Screen.MousePointer = vbDefault
SWP = True
Exit Sub

GraErr:
  MsgBox Err.Description
  Screen.MousePointer = vbDefault
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
 KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Form_Load()
Dim sSql3 As String
Dim snumsolo As String
Dim max As String
Dim Vsql As String
DoEvents
Tabla = ""
atxtcod = ""
Label3.Caption = "P.Presupuestal:"

If pAction = "A" Then
    Caption = "Crear Nuevo"
    txtcod.Enabled = True
ElseIf pAction = "M" Then
    Caption = "Modificar"
    txtcod.Enabled = False
ElseIf pAction = "C" Then
    Caption = "Consulta"
    txtcod.Enabled = False
    cmdGrabar.Enabled = False
End If

Select Case xTabla
                            
       Case 9   'Servicios
            Tabla = "tipo_tarjeta"
            Label3.Visible = False
            Label6.Visible = False
            txtAbr.Visible = False
            txtcod.MaxLength = 5
            txtDes.MaxLength = 50
            Vsql = "select max(cod_TAR) as cod from " & Tabla & ""
            
            If rsTempT.state = adStateOpen Then rsTempT.Close
            'rsTempT.CursorLocation = adUseClient
            rsTempT.CursorLocation = adUseServer
            rsTempT.Open Vsql, ADOCnn, adOpenStatic, adLockReadOnly, adCmdText
            rsTempT.MoveFirst
            max = IIf(IsNull(rsTempT!cod), "", rsTempT!cod)
            rsTempT.Close
            Me.txtcod = Right("000" & Trim(Str(Val(max) + 1)), 3)
            
            If pAction <> "A" Then
                txtcod = FrmTablas.grddatos.Columns(0)
                txtDes = FrmTablas.grddatos.Columns(1)
            End If
End Select
End Sub




