VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{CDF3B183-D408-11CE-AE2C-0080C786E37D}#2.1#0"; "Edt32x20.ocx"
Begin VB.Form FCO3040 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Actualizar Variable"
   ClientHeight    =   3915
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3330
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Actualizar variable.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3915
   ScaleWidth      =   3330
   Begin EditLib.fpLongInteger txtAño 
      Height          =   315
      Left            =   1560
      TabIndex        =   2
      Top             =   465
      Width           =   975
      _Version        =   131072
      _ExtentX        =   1720
      _ExtentY        =   556
      _StockProps     =   68
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      ThreeDInsideStyle=   1
      ThreeDInsideHighlightColor=   -2147483633
      ThreeDInsideShadowColor=   -2147483642
      ThreeDInsideWidth=   1
      ThreeDOutsideStyle=   1
      ThreeDOutsideHighlightColor=   16777215
      ThreeDOutsideShadowColor=   -2147483632
      ThreeDOutsideWidth=   1
      ThreeDFrameWidth=   0
      BorderStyle     =   0
      BorderColor     =   -2147483642
      BorderWidth     =   1
      ButtonDisable   =   0   'False
      ButtonHide      =   0   'False
      ButtonIncrement =   1
      ButtonMin       =   1
      ButtonMax       =   100
      ButtonStyle     =   1
      ButtonWidth     =   0
      ButtonWrap      =   -1  'True
      ButtonDefaultAction=   -1  'True
      ThreeDText      =   0
      ThreeDTextHighlightColor=   -2147483633
      ThreeDTextShadowColor=   -2147483632
      ThreeDTextOffset=   1
      AlignTextH      =   2
      AlignTextV      =   1
      AllowNull       =   0   'False
      NoSpecialKeys   =   3
      AutoAdvance     =   0   'False
      AutoBeep        =   0   'False
      CaretInsert     =   0
      CaretOverWrite  =   3
      UserEntry       =   0
      HideSelection   =   -1  'True
      InvalidColor    =   -2147483637
      InvalidOption   =   0
      MarginLeft      =   3
      MarginTop       =   3
      MarginRight     =   3
      MarginBottom    =   3
      NullColor       =   -2147483637
      OnFocusAlignH   =   0
      OnFocusAlignV   =   0
      OnFocusNoSelect =   0   'False
      OnFocusPosition =   0
      ControlType     =   0
      Text            =   "0"
      MaxValue        =   "2078"
      MinValue        =   "2002"
      NegFormat       =   1
      NegToggle       =   0   'False
      Separator       =   ""
      UseSeparator    =   0   'False
      IncInt          =   1
      BorderGrayAreaColor=   -2147483637
      ThreeDOnFocusInvert=   0   'False
      ThreeDFrameColor=   -2147483633
      Appearance      =   0
      BorderDropShadow=   0
      BorderDropShadowColor=   -2147483632
      BorderDropShadowWidth=   3
      MouseIcon       =   "Actualizar variable.frx":030A
   End
   Begin VB.TextBox txtVar2 
      Enabled         =   0   'False
      Height          =   285
      Left            =   2040
      MaxLength       =   2
      TabIndex        =   13
      Top             =   2880
      Width           =   495
   End
   Begin VB.CheckBox chkActProc 
      Caption         =   "Actualizar procedimiento de &retención a 2"
      Height          =   375
      Left            =   240
      TabIndex        =   11
      Top             =   2400
      Width           =   2895
   End
   Begin VB.OptionButton optTiempo 
      Caption         =   "&Tiempo"
      Height          =   255
      Left            =   1920
      TabIndex        =   8
      Top             =   1560
      Value           =   -1  'True
      Width           =   1215
   End
   Begin VB.OptionButton optImporte 
      Caption         =   "&Importe"
      Height          =   255
      Left            =   720
      TabIndex        =   7
      Top             =   1560
      Width           =   1215
   End
   Begin VB.TextBox txtVariable 
      Height          =   285
      Left            =   2040
      MaxLength       =   2
      TabIndex        =   10
      Top             =   1920
      Width           =   495
   End
   Begin VB.TextBox txtConcepto 
      Height          =   285
      Left            =   1560
      MaxLength       =   5
      TabIndex        =   6
      Top             =   1200
      Width           =   975
   End
   Begin VB.TextBox txtPeriodo 
      Height          =   285
      Left            =   1560
      MaxLength       =   2
      TabIndex        =   4
      Top             =   840
      Width           =   975
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Varia&ble:"
      Enabled         =   0   'False
      Height          =   210
      Index           =   5
      Left            =   1200
      TabIndex        =   12
      Top             =   2880
      Width           =   645
   End
   Begin VB.Image imgListaVar2 
      Enabled         =   0   'False
      Height          =   480
      Left            =   2640
      Picture         =   "Actualizar variable.frx":0326
      Top             =   2880
      Width           =   480
   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           =   "Actualizar variable.frx":0630
   End
   Begin VB.Image imgListaVar 
      Height          =   480
      Left            =   2640
      Picture         =   "Actualizar variable.frx":16FE
      Top             =   1920
      Width           =   480
   End
   Begin VB.Image imgListaCon 
      Height          =   480
      Left            =   2640
      Picture         =   "Actualizar variable.frx":1A08
      Top             =   1200
      Width           =   480
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Actualizar la &variable:"
      Height          =   210
      Index           =   4
      Left            =   360
      TabIndex        =   9
      Top             =   1920
      Width           =   1560
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Concepto"
      Height          =   210
      Index           =   3
      Left            =   720
      TabIndex        =   5
      Top             =   1200
      Width           =   690
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Periodo"
      Height          =   210
      Index           =   2
      Left            =   720
      TabIndex        =   3
      Top             =   840
      Width           =   540
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Año"
      Height          =   210
      Index           =   1
      Left            =   720
      TabIndex        =   0
      Top             =   480
      Width           =   300
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Con los datos de:"
      Height          =   210
      Index           =   0
      Left            =   360
      TabIndex        =   1
      Top             =   120
      Width           =   1260
   End
End
Attribute VB_Name = "FCO3040"
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 Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlejecuta": Actualizar
        Case "tlsalida": Unload Me
    End Select
End Sub

Private Sub chkActProc_Click()
    lblLabels(5).Enabled = (chkActProc.Value)
    txtVar2.Enabled = lblLabels(5).Enabled
    imgListaVar2.Enabled = lblLabels(5).Enabled
End Sub

Private Sub chkActProc_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then
      SendEnter
  End If
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
         Case vbKeyF11: Actualizar
    End Select

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then
        Select Case LCase(ActiveControl.Name)
            Case "txtconcepto": imgListaCon_Click
            Case "txtvariable": imgListaVar_Click
            Case "txtvar2": imgListaVar2_Click
        End Select
    End If
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)
    
    'Checa nivel de seguridad
    Gven(Val(Me.Tag)).iNivSeguridad = iObtenNivSeguridad(GsOper, GsUid, Micx)
    If Gven(Val(Me.Tag)).iNivSeguridad = 0 Then
        Screen.MousePointer = vbDefault
        Me.Top = -10000
        GbAError = True
        Exit Sub
    End If
        
    If Not MDIChild Then
        WindowState = 0
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        Screen.MousePointer = vbDefault
    End If
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 3420
        MiY = 4290
        Me.Width = MiX
        Me.Height = MiY
    End If

    txtAño = Year(Date)
    AsignaIconos abToolbar, 3, LEJECUTA, LSALIDA
End Sub

Private Sub Actualizar()
    On Error GoTo ErrAct

    If Val(txtAño) = 0 Then clsMsgbox.Mensaje "Año no valido", mAceptar, mAdvierte, GsTitMsg: Exit Sub
    If Val(txtPeriodo) = 0 Then clsMsgbox.Mensaje "Periodo no valido", mAceptar, mAdvierte, GsTitMsg: Exit Sub
    If Val(txtConcepto) = 0 Then clsMsgbox.Mensaje "Concepto no valido", mAceptar, mAdvierte, GsTitMsg: Exit Sub
    If Val(txtVariable) = 0 Then clsMsgbox.Mensaje "Variable no valida", mAceptar, mAdvierte, GsTitMsg: Exit Sub
    If chkActProc.Value = vbChecked And Val(txtVar2) = 0 Then
        clsMsgbox.Mensaje "Variable no valida", mAceptar, mAdvierte, GsTitMsg
        txtVar2.SetFocus
        Exit Sub
    End If
    
    Screen.MousePointer = vbHourglass
        
    MAdo.Sql = "sp_fco_upd_var_trabajador " & _
    "'" & GsCveCia & "'," & Val(txtAño) & "," & _
    Val(txtPeriodo) & "," & txtVariable & "," & txtConcepto & "," & _
    IIf(optTiempo.Value = True, 1, 0) & "," & IIf(chkActProc.Value = vbChecked, 1, 0) & _
    "," & Val(txtVar2)

    If MAdo.ExecSQL = -1 Then GoTo ErrAct
    
    Screen.MousePointer = vbDefault
    clsMsgbox.Mensaje "Proceso terminado normalmente", mAceptar, mAdvierte, GsTitMsg
    
    Unload Me
    Exit Sub
ErrAct:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set MAdo = Nothing
    Gtc(Micx).ihijas = Gtc(Micx).ihijas - 1
    Set FCO3040 = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
    If GbExterno Then End
End Sub

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

Private Sub imgListaVar_Click()
    MostrarListaVar
    If Trim(GsParamOUT(0)) <> "" Then txtVariable = Val(GsParamOUT(0))
End Sub

Private Sub imgListaVar2_Click()
    MostrarListaVar
    If Trim(GsParamOUT(0)) <> "" Then txtVar2 = Val(GsParamOUT(0))
End Sub

Private Sub optImporte_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then
      SendEnter
  End If
End Sub

Private Sub optTiempo_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then
      SendEnter
  End If

End Sub

Private Sub txtAño_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtConcepto_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtPeriodo_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtVar2_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If

End Sub

Private Sub txtVariable_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub MostrarListaVar()
    Screen.MousePointer = vbHourglass
    
    If Left(UCase(GsDsn), 3) = "ORA" Then
        GsParamIN(0) = "SELECT To_Number(Substr(variable,9,2)) variable, descripcion_var" & _
        " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
        " variable like 'var_tra_%' And descripcion_var not like 'Variable_Trabajador%'"
        GsParamIN(1) = "To_Number(Substr(variable,9,2))"
    Else
        GsParamIN(0) = "SELECT convert(numeric,substring(variable,9,2)) variable, descripcion_var" & _
        " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
        " variable like 'var_tra_%' And descripcion_var not like 'Variable_Trabajador%'"
        GsParamIN(1) = "convert(numeric,substring(variable,9,2))"
    End If
    GsParamIN(2) = "descripcion_var"
    GsParamIN(3) = "Variable"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Variables del Trabajador"
    GsParamIN(6) = ""
    frmLista.Show 1
End Sub
