Files
SIG/Nomina/Finiquito.aspx.vb
JORGE LUIS CAUDILLO ESPARZA 98d5139425
2019-12-16 19:52:52 -07:00

447 lines
17 KiB
VB.net

Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Nomina_Finiquito
Inherits ClsPaginas
Private Class ConceptosPersonal
Public Sub New()
Concepto = ""
ConceptoD = ""
CveConcepto = 0
CveConceptoD = 0
Estatus = 0
Estatus = 0
End Sub
Public Property Concepto As String
Public Property CveConcepto As Integer
Public Property Importe As Decimal
Public Property Estatus As Integer
Public Property ConceptoD As String
Public Property CveConceptoD As Integer
Public Property ImporteD As Decimal
Public Property EstatusD As Integer
End Class
#Region "Propiedades"
Private Property CvePersonal As Integer
Get
If Not IsNothing(ViewState("CvePersonal")) Then
Return ViewState("CvePersonal").ToString().ToEntero()
Else
Return 0
End If
End Get
Set(value As Integer)
ViewState("CvePersonal") = value
End Set
End Property
Private Property CveTipoPeriodo As Integer
Get
If Not IsNothing(ViewState("CveTipoPeriodo")) Then
Return ViewState("CveTipoPeriodo").ToString().ToEntero()
Else
Return 0
End If
End Get
Set(value As Integer)
ViewState("CveTipoPeriodo") = value
End Set
End Property
Private Property CvePeriodoFiniquito As Integer
Get
If Not IsNothing(ViewState("CvePeriodoFiniquito")) Then
Return ViewState("CvePeriodoFiniquito").ToString().ToEntero()
Else
Return 0
End If
End Get
Set(value As Integer)
ViewState("CvePeriodoFiniquito") = value
End Set
End Property
Private Property GCEstatus As Integer
Get
If Not IsNothing(ViewState("GCEstatus")) Then
Return ViewState("GCEstatus").ToString().ToEntero()
Else
Return 0
End If
End Get
Set
ViewState("GCEstatus") = Value
End Set
End Property
Private Property GCCveConcepto As Integer
Get
If Not IsNothing(ViewState("GCCveConcepto")) Then
Return ViewState("GCCveConcepto").ToString().ToEntero()
Else
Return 0
End If
End Get
Set
ViewState("GCCveConcepto") = Value
End Set
End Property
Private Property GCImporte As Decimal
Get
If Not IsNothing(ViewState("GCImporte")) Then
Return ViewState("GCImporte").ToString().ToDecimal()
Else
Return 0
End If
End Get
Set
ViewState("GCImporte") = Value
End Set
End Property
Private ReadOnly Property ConceptsPersonas As List(Of ConceptosPersonal)
Get
Dim listaconceptos As New List(Of ConceptosPersonal)
Dim TotalP As Decimal = 0
Dim TotalD As Decimal = 0
If (Not IsNothing(DTConceptosPersonal) AndAlso DTConceptosPersonal.Rows.Count > 0) Then
Dim dtP As DataTable = DTConceptosPersonal.FiltraParametros("Tipo=1")
Dim dtD As DataTable = DTConceptosPersonal.FiltraParametros("Tipo=2")
Dim noP = dtP.Rows.Count()
Dim noD = dtD.Rows.Count()
Dim max = If(noP > noD, noP, noD)
TotalP = dtP.SUM("Importe").ToString().ToDecimal()
TotalD = dtD.SUM("Importe").ToString().ToDecimal()
For index = 0 To max
Dim obj As New ConceptosPersonal()
If index < noP Then
obj.Importe = dtP.Rows(index)("Importe").ToString().ToDecimal()
obj.CveConcepto = dtP.Rows(index)("CveConcepto").ToString().ToEntero()
obj.Concepto = dtP.Rows(index)("Concepto").ToString()
obj.Estatus = dtP.Rows(index)("Estatus").ToString().ToEntero()
ElseIf index = noP Then
obj.Estatus = -1
obj.Concepto = "Agregar"
End If
If index < noD Then
obj.ImporteD = dtD.Rows(index)("Importe").ToString().ToDecimal()
obj.CveConceptoD = dtD.Rows(index)("CveConcepto").ToString().ToEntero()
obj.ConceptoD = dtD.Rows(index)("Concepto").ToString()
obj.EstatusD = dtD.Rows(index)("Estatus").ToString().ToEntero()
ElseIf index = noD Then
obj.EstatusD = -1
obj.ConceptoD = "Agregar"
End If
listaconceptos.Add(obj)
Next
End If
listaconceptos.Add(New ConceptosPersonal())
Dim objST As New ConceptosPersonal()
objST.Importe = TotalP
objST.CveConcepto = 0
objST.Concepto = "Total Percepciones"
objST.Estatus = -2
objST.ImporteD = TotalD
objST.CveConceptoD = 0
objST.ConceptoD = "Total Deducciones"
objST.EstatusD = -2
listaconceptos.Add(objST)
Dim objT As New ConceptosPersonal()
objT.CveConcepto = 0
objT.Concepto = ""
objT.Estatus = -3
objT.ImporteD = objST.Importe + objST.ImporteD
objT.CveConceptoD = 0
objT.ConceptoD = "Total"
objT.EstatusD = -3
listaconceptos.Add(objT)
Return listaconceptos
End Get
End Property
Private Property DTConceptosPersonal As DataTable
Get
If Not IsNothing(ViewState("DTConceptosPersonal")) Then
Return DirectCast(ViewState("DTConceptosPersonal"), DataTable)
Else
Return Nothing
End If
End Get
Set
ViewState("DTConceptosPersonal") = Value
End Set
End Property
Private Property DTConceptos As DataTable
Get
If Not IsNothing(ViewState("DTConceptos")) Then
Return DirectCast(ViewState("DTConceptos"), DataTable)
Else
Return Nothing
End If
End Get
Set
ViewState("DTConceptos") = Value
End Set
End Property
Private Property esLiquidacion As Boolean
Get
If Not IsNothing(ViewState("esLiquidacion")) Then
Return CBool(ViewState("esLiquidacion"))
Else
Return False
End If
End Get
Set
ViewState("esLiquidacion") = Value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaDdlPersonal()
CargaMotivoBaja()
CvePeriodoFiniquito = 0
If Request("CvePersonal") IsNot Nothing AndAlso IsNumeric(Request("CvePersonal")) AndAlso Request("CvePersonal").ToEntero > 0 Then
ViewState("CvePersonal") = Request("CvePersonal")
Else
CvePersonal = -1
End If
If Not CargaDatosFiniquito() Then
RegistraScript("$('#ModalEmpleados').modal();")
End If
End If
If CvePersonal > 0 And CvePeriodoFiniquito > 0 Then
LtlEmpleadoCancelar.Visible = True
End If
End Sub
Private Sub CargaMotivoBaja()
DdlMotivoBaja.DataSource = GlobalDTMotivoBaja.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlMotivoBaja.DataBind()
End Sub
Private Sub CargaDdlPersonal()
Dim ObjPersonal As New ClsRH
If ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa) Then
DdlPersonal.DataSource = ObjPersonal.DtResultados
DdlPersonal.DataBind()
End If
ObjPersonal.Dispose()
End Sub
Private Function CargaDatosFiniquito() As Boolean
Dim retorno As Boolean = True
If CvePersonal > 0 Then
DdlPersonal.SelectedValueExist(CvePersonal.ToString())
Dim Nombre As String = ""
Dim FechaBaja As String = ""
Dim EstatusPersonal As String = ""
CvePeriodoFiniquito = 0
CveTipoPeriodo = 0
esLiquidacion = False
pnlupValoresFiniquito.Visible = False
DdlMotivoBaja.SelectedValue = "-1"
Using ObjPersonal As New ClsRH()
If ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) AndAlso ObjPersonal.DtResultados.Rows.Count > 0 Then
Nombre = ObjPersonal.DtResultados.Rows(0)("Nombre").ToString()
FechaBaja = String.Format("{0:dd/MM/yyyy}", ObjPersonal.FechaBaja)
EstatusPersonal = String.Format("{0}", ObjPersonal.DtResultados.Rows(0)("EstatusPersonal"))
CveTipoPeriodo = ObjPersonal.DtResultados.Rows(0)("CveTipoPeriodo").ToString().ToEntero()
End If
If ObjPersonal.GetPersonalAltas(CvePersonal) AndAlso ObjPersonal.DtResultados.Rows.Count > 0 Then
CvePeriodoFiniquito = ObjPersonal.DtResultados.Rows(0)("CvePeriodoFiniquito").ToString().ToEntero()
FechaBaja = String.Format("{0:dd/MM/yyyy}", ObjPersonal.DtResultados.Rows(0)("FechaFin"))
DdlMotivoBaja.SelectedValueExist(ObjPersonal.DtResultados.Rows(0)("CveMotivoBaja").ToString().ToEntero())
Dim stringesliquidacion = ObjPersonal.DtResultados.Rows(0)("esLiquidacion").ToString()
esLiquidacion = (stringesliquidacion = "True" OrElse stringesliquidacion = "1")
End If
End Using
If DdlMotivoBaja.SelectedValue.ToEntero() > 0 Then
LblMotivoBaja.Text = DdlMotivoBaja.SelectedItem.Text
Else
LblMotivoBaja.Text = ""
End If
HypEmpleado.Text = Nombre
HypEmpleado.NavigateUrl = String.Format("/RH/Personal.aspx?CvePersonal={0}", CvePersonal)
LblFechaBaja.Text = FechaBaja
LblEstatus.Text = EstatusPersonal
TxtFechaBaja.Text = FechaBaja
If CvePeriodoFiniquito <= 0 Then
DdlTipoPeriodo_SelectedIndexChanged(Nothing, Nothing)
retorno = False
pnlupValoresFiniquito.Visible = True
End If
Using ObjNom As New ClsNominas()
'If ObjNom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa) Then
' DTConceptosPersonal = ObjNom.DtResultados
'Autoriza nomina
'Finiquita Liquidación
'Rep Nomina
'RepInversion de nomina
'Alertas Altas /Bajas
'
'End If
End Using
GvConceptos.DataSource = ConceptsPersonas
GvConceptos.DataBind()
Else
retorno = False
End If
Return retorno
End Function
Protected Sub LnkCampiarEmpleado_Click(sender As Object, e As EventArgs)
CvePersonal = DdlPersonal.SelectedValue.ToEntero()
Using ObjPersonal As New ClsRH()
If ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), DdlPeriodo.SelectedValue.ToEntero(), DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked) AndAlso ObjPersonal.DtResultados.Rows.Count > 0 Then
End If
End Using
If pnlupValoresFiniquito.Visible Then
End If
If Not CargaDatosFiniquito() Then
RegistraScript("$('#ModalEmpleados').modal('hide');")
End If
upDatos.Update()
End Sub
Protected Sub LnkCalcular_Click(sender As Object, e As EventArgs)
End Sub
Protected Sub LnkAutorizar_Click(sender As Object, e As EventArgs)
End Sub
Protected Sub LnkTimbrar_Click(sender As Object, e As EventArgs)
End Sub
Protected Sub LnkFormatoRenuncia_Click(sender As Object, e As EventArgs)
End Sub
Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs)
Response.Redirect($"/Nomina/Finiquito.aspx?CvePersonal={DdlPersonal.SelectedValue}")
'Alert($"insertParam('CvePersonal','{DdlPersonal.SelectedValue}')")
'RegistraScript($"insertParam('CvePersonal','{DdlPersonal.SelectedValue}')")
End Sub
Protected Sub DdlTipoPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim CveTipoPeriodoactual As Integer = If(DdlTipoPeriodo.SelectedValue.ToEntero() > 0, DdlTipoPeriodo.SelectedValue.ToEntero(), CveTipoPeriodo)
Dim fechabaja As String = TxtFechaBaja.Text
Dim dtperiodos As New DataTable
Dim ObjPeriodos As New ClsNominas
If ObjPeriodos.GetPeriodos(CveTipoPeriodoactual, UsuarioActual.CveEmpresa, -1, -1, -1) Then
dtperiodos = ObjPeriodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4)")
'FechaInicio, P.FechaFin
DdlPeriodo.DataSource = dtperiodos
Else
DdlPeriodo.DataSource = Nothing
End If
ObjPeriodos.Dispose()
DdlPeriodo.DataBind()
If fechabaja.Length > 0 AndAlso dtperiodos.Rows.Count > 0 Then
Dim row As DataRow = dtperiodos.FiltroPrimero(String.Format("FechaInicio<='{0:yyyy/MM/dd}' AND FechaFin>='{0:yyyy/MM/dd}'", fechabaja.ToDate()))
If Not IsNothing(row) Then
DdlPeriodo.SelectedValueExist(row("CvePeriodo"))
End If
End If
End Sub
#Region "Conceptos"
Protected Sub GvConceptos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'Datakeys
'Concepto,CveConcepto,Importe,Estatus,ConceptoD,CveConceptoD,ImporteD,EstatusD
Dim CveConcepto As Integer = e.Row.DataKey("CveConcepto").ToEntero()
Dim CveConceptoD As Integer = e.Row.DataKey("CveConceptoD").ToEntero()
'Dim Importe As Decimal = e.Row.DataKey("Importe").ToDecimal()
'Dim ImporteD As Decimal = e.Row.DataKey("ImporteD").ToDecimal()
Dim Estatus As Integer = e.Row.DataKey("Estatus").ToEntero()
Dim EstatusD As Integer = e.Row.DataKey("EstatusD").ToEntero()
'Controles
Dim LtlConcepto As Label = e.Row.FCLabel("LtlConcepto")
Dim LnkConcepto As LinkButton = e.Row.FCLinkButton("LnkConcepto")
Dim LtlConceptoD As Label = e.Row.FCLabel("LtlConceptoD")
Dim LnkConceptoD As LinkButton = e.Row.FCLinkButton("LnkConceptod")
Dim LtlImporte As Label = e.Row.FCLabel("LtlImporte")
Dim LnkImporte As LinkButton = e.Row.FCLinkButton("LnkImporte")
Dim LtlImporteD As Label = e.Row.FCLabel("LtlImporteD")
Dim LnkImporteD As LinkButton = e.Row.FCLinkButton("LnkImporteD")
If Estatus < -1 Or EstatusD < -1 Then
e.Row.CssClass = "ConceptosTotales"
End If
If CveConcepto = 0 AndAlso (Estatus = 0 OrElse Estatus = -1 OrElse Estatus = -3) Then
LtlImporte.Text = ""
End If
If CveConceptoD = 0 AndAlso (EstatusD = 0 OrElse EstatusD = -1) Then
LtlImporteD.Text = ""
End If
If Estatus = -1 Then
LtlConcepto.Visible = False
ElseIf Estatus > 0 Then
LtlImporte.Visible = False
End If
If EstatusD = -1 Then
LtlConceptoD.Visible = False
ElseIf EstatusD > 0 Then
LtlImporteD.Visible = False
End If
LnkConcepto.Visible = Not LtlConcepto.Visible
LnkConceptoD.Visible = Not LtlConceptoD.Visible
LnkImporte.Visible = Not LtlImporte.Visible
LnkImporteD.Visible = Not LtlImporteD.Visible
End If
End Sub
Protected Sub LnkConcepto_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
GCEstatus = gvRow.DataKey("Estatus").ToEntero()
GCCveConcepto = gvRow.DataKey("CveConcepto").ToEntero()
GCImporte = gvRow.DataKey("Importe").ToDecimal()
OpenModalConceptos(1)
End Sub
Protected Sub LnkConceptoD_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
GCEstatus = gvRow.DataKey("Estatus").ToEntero()
GCCveConcepto = gvRow.DataKey("CveConcepto").ToEntero()
GCImporte = gvRow.DataKey("Importe").ToDecimal()
OpenModalConceptos(2)
End Sub
Private Sub OpenModalConceptos(Tipo As Integer)
If GCEstatus = -1 Then
Else
End If
RegistraScript("$('#ModalConceptos').modal();")
End Sub
Protected Sub LnkAceptarConceptos_Click(sender As Object, e As EventArgs)
RegistraScript("$('#ModalConceptos').modal('hide');")
End Sub
#End Region
End Class