VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Begin VB.Form FCO1010TA 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Alta de Concepto Relacionado"
   ClientHeight    =   1815
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4230
   Icon            =   "FCO1010TA Parametros Trabajar Con Alta.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1815
   ScaleWidth      =   4230
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtConcepto 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   1440
      TabIndex        =   0
      Top             =   480
      Width           =   975
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   0
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Bands           =   "FCO1010TA Parametros Trabajar Con Alta.frx":030A
   End
   Begin VB.Label lblTitulo 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Label1"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   3
      Top             =   120
      Width           =   4125
   End
   Begin VB.Label lblDescripcion 
      BackStyle       =   0  'Transparent
      Caption         =   "Nombre"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   2
      Top             =   960
      Width           =   3855
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "Concepto"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   240
      TabIndex        =   1
      Top             =   480
      Width           =   975
   End
   Begin VB.Image imgListaCon 
      Height          =   480
      Left            =   2640
      Picture         =   "FCO1010TA Parametros Trabajar Con Alta.frx":13D8
      Top             =   480
      Width           =   480
   End
End
Attribute VB_Name = "FCO1010TA"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private Micx As Integer 'Conexión
Private MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma
Private MbHuboCambio As Boolean

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlguarda": If bValidarDatos Then GuardaCambios: Unload Me
        Case "tlsalida": Unload Me
    End Select
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF4: imgListaCon_Click
        Case vbKeyF11: GuardaCambios
    End Select
End Sub

Private Sub Form_Load()
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    Micx = Gven(Val(Me.Tag)).icx
    Set MAdo = Gtc(Micx).Ado
    Me.Icon = LoadPicture(sIconoForma)
    
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Relacionar concepto"
    AsignaIconos abToolbar, 3, LGUARDA, LSALIDA
    lblDescripcion = ""
    MbHuboCambio = False
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 4320
        MiY = 2190
        Me.Width = MiX
        Me.Height = MiY
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim iResp As Integer
    If MbHuboCambio Then
        iResp = clsMsgbox.Mensaje("¿Desea guardar los cambios?", mSiNoCancelar, mConfirma, GsTitMsg)
        If iResp = vbYes Then GuardaCambios
        If iResp = vbCancel Then Cancel = True: Exit Sub
    End If
    Set MAdo = Nothing
End Sub

Private Sub Form_Resize()
    If Me.WindowState <> 1 Then
        GAdam.MaximizaControles Me, 1, 2, 4320, 2190, MiX, MiY, False, True, False, -1
    End If
End Sub

Private Sub imgListaCon_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = _
    " SELECT concepto, descripcion" & _
    " FROM conceptos_ns " & _
    " WHERE compania = '" & GsCveCia & "'"
    GsParamIN(1) = "concepto"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Concepto"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Conceptos"
    GsParamIN(6) = ""
    frmLista.Show 1
    txtConcepto = GsParamOUT(0)
    lblDescripcion = GsParamOUT(1)
    If Trim(txtConcepto) <> "" Then MbHuboCambio = True
End Sub

Private Sub txtConcepto_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        Screen.MousePointer = vbHourglass
        MAdo.Sql = _
        " SELECT concepto, descripcion" & _
        " FROM conceptos_ns" & _
        " WHERE compania = '" & GsCveCia & "'" & _
        " AND concepto = '" & Val(txtConcepto) & "'"
        If Not MAdo.SendSQL Then GoTo Salir
        If MAdo.EOF Then
            Screen.MousePointer = vbDefault
            clsMsgbox.Mensaje "No existe el concepto", mAceptar, mAdvierte, GsTitMsg
            Exit Sub
        Else
            txtConcepto = MAdo.GetFieldInt(1)
            lblDescripcion = MAdo.GetField(2)
        End If
        MbHuboCambio = True
        Screen.MousePointer = vbDefault
    End If
Salir:
    Screen.MousePointer = vbDefault
End Sub

Private Function bValidarDatos() As Boolean
    bValidarDatos = True
    If Trim(txtConcepto) = "" Then
        bValidarDatos = False
        clsMsgbox.Mensaje "Antes de guardar debe definir el Concepto", mAceptar, mAdvierte, GsTitMsg
    End If
End Function

Private Sub GuardaCambios()
    MAdo.Sql = "sp_alta_rel_conceptos_agr " & _
    "'" & GsDatoAux & "','" & GsCveCia & "','" & txtConcepto & "','+'"
    MAdo.ExecSQL
    MbHuboCambio = False
End Sub
