VERSION 5.00
Begin VB.Form Form_DesaPerSoc_Add_Item 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Agregar un Nuevo Item de Evaluación Personal y Social"
   ClientHeight    =   3435
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5580
   Icon            =   "Form_DesaPerSoc_Add_Item.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3435
   ScaleWidth      =   5580
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command2 
      Caption         =   "&Cancelar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2880
      TabIndex        =   7
      Top             =   2760
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "&Aceptar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1080
      TabIndex        =   6
      Top             =   2760
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Caption         =   "Datos Nuevos"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2535
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5295
      Begin VB.TextBox nuevoitem 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   2
         Left            =   1320
         MaxLength       =   150
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   8
         ToolTipText     =   "Debe ingresar el nuevo detalle del item a evaluar"
         Top             =   1320
         Width           =   3735
      End
      Begin VB.TextBox nuevoitem 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   1320
         TabIndex        =   4
         Top             =   840
         Width           =   1575
      End
      Begin VB.TextBox nuevoitem 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   1320
         TabIndex        =   3
         Top             =   360
         Width           =   3735
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Nº Item :"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   240
         TabIndex        =   5
         Top             =   840
         Width           =   600
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Item:"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   240
         TabIndex        =   2
         Top             =   1320
         Width           =   330
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Tipo de Item :"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   945
      End
   End
End
Attribute VB_Name = "Form_DesaPerSoc_Add_Item"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private cualitem As String
Private Sub Command1_Click()
    Dim grabaritem As ADODB.Recordset
    Dim nitem, des As String
    nitem = nuevoitem(1).Text
    des = nuevoitem(2).Text
    des = Trim(des)
    If des = "" Or des = " " Then
        MsgBox "No ha ingresado datos, por lo tanto se cancelará el ingreso", , "Advertencia"
        Command2_Click
    Else
        Set grabaritem = New ADODB.Recordset
        grabaritem.Open "INSERT INTO desaper_item_des (T_ITEM,N_ITEM,DESCRIPCION) VALUES ('" + cualitem + "','" + nitem + "','" + des + "')", conn
        Form_Load
        nuevoitem(2).SetFocus
    End If
End Sub

Private Sub Command2_Click()
    Form_Desa_Persoc_Def.Enabled = True
    Unload Form_DesaPerSoc_Add_Item
End Sub

Private Sub Form_Load()
    Dim cualcuantos As Integer
    Dim consultaitem As ADODB.Recordset
    
    
    cualitem = Form_Desa_Persoc_Def.Tipo_Item

    Set consultaitem = New ADODB.Recordset
    'MsgBox (cualitem)
    consultaitem.Open "Select count(*) as ULTIMO From desaper_item_des where T_ITEM='" + cualitem + "'", conn
    cualcuantos = consultaitem!ULTIMO + 1
    nuevoitem(1).Text = str(cualcuantos)
    nuevoitem(2).Text = ""
    consultaitem.Close
    
    If cualitem = "FE" Then
        nuevoitem(0).Text = "FORMACION ETICA"
    ElseIf cualitem = "ACP" Then
        nuevoitem(0).Text = "AUTOAFIRMACION Y CRECIMIENTO PERSONAL"
    ElseIf cualitem = "DP" Then
        nuevoitem(0).Text = "DESARROLLO DEL PENSAMIENTO"
    ElseIf cualitem = "RPE" Then
        nuevoitem(0).Text = "RELACION DE LA PERSONA Y SU ENTORNO"
    ElseIf cualitem = "CFC" Then
        nuevoitem(0).Text = "COMPROMISO FAMILIA Y COMUNIDAD"
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Form_Desa_Persoc_Def.Enabled = True
    Form_Desa_Persoc_Def.SetFocus
End Sub

Private Sub nuevoitem_KeyPress(Index As Integer, KeyAscii As Integer)
    If KeyAscii = 13 Or KeyAscii = 10 Then
        SendKeys "{BACKSPACE}"
        Command1.SetFocus
    ElseIf KeyAscii = 10 Then
            SendKeys "{BACKSPACE}{BACKSPACE}"
    End If
    
End Sub
