This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2023-11-28 07:36:09 -07:00
parent f599c7a3fb
commit 603c57a8e3
2 changed files with 73 additions and 61 deletions

View File

@@ -3712,6 +3712,18 @@ Public Class ClsNominas
End Function
Public Function CalculaDiasFeriados(fechaInicio As String, fechaFin As String, DiasPagos As Int32, DiasFeriados As Int32, cveEmpresa As Int32, cveUsuario As Int32) As Boolean
Dim retorno As Boolean = False
DataAdapter("PA_Nom_CalculaDiasFeriados", CommandType.StoredProcedure)
addParameters("@FechaFin", SqlDbType.VarChar, fechaFin)
addParameters("@FechaInicio", SqlDbType.VarChar, fechaInicio)
addParameters("@DiasPagos", SqlDbType.Int, DiasPagos)
addParameters("@DiasFeriados", SqlDbType.Int, DiasFeriados)
addParameters("@CveEmpresa", SqlDbType.Int, cveEmpresa)
addParameters("@CveUsuario", SqlDbType.Int, cveUsuario)
retorno = RunQuery("Ocurrió un error al realizar la carga de periodos.")
Return retorno
End Function

View File

@@ -7899,87 +7899,87 @@ Partial Class RH_Personal
Private Sub CalculaDiasVacaciones(fechaInicioParametro As Date, diasVacaciones As Integer, Optional fechaFinParametro As Date = Nothing)
Dim diaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {DdlTurno.SelectedValue.ToEntero}").ToEntero
diaDescanso = If(diaDescanso <= 0, 1, diaDescanso)
'Dim diaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {DdlTurno.SelectedValue.ToEntero}").ToEntero
'diaDescanso = If(diaDescanso <= 0, 1, diaDescanso)
If fechaFinParametro <> Nothing Then
If fechaInicioParametro > fechaFinParametro Then
Alert("La fecha fin no puede ser mayor a la fecha inicial", TipoMensaje.MsgAdvertencia)
fechaFinParametro = Nothing
TxtVacDiasPago.Text = DiasDisponibles.ToString
End If
End If
'If fechaFinParametro <> Nothing Then
' If fechaInicioParametro > fechaFinParametro Then
' Alert("La fecha fin no puede ser mayor a la fecha inicial", TipoMensaje.MsgAdvertencia)
' fechaFinParametro = Nothing
' TxtVacDiasPago.Text = DiasDisponibles.ToString
' End If
'End If
If fechaFinParametro <> Nothing Then
'If fechaFinParametro <> Nothing Then
Dim DiferenciaEntreFechas As Integer = (fechaFinParametro - fechaInicioParametro).Days + 1
Dim DiasNolavorales As Integer = 0
Dim FechaTemp As Date = fechaInicioParametro
' Dim DiferenciaEntreFechas As Integer = (fechaFinParametro - fechaInicioParametro).Days + 1
' Dim DiasNolavorales As Integer = 0
' Dim FechaTemp As Date = fechaInicioParametro
For x As Integer = 1 To DiferenciaEntreFechas
Dim day_of_week As Integer = CType(FechaTemp.DayOfWeek, Integer) + 1
' For x As Integer = 1 To DiferenciaEntreFechas
' Dim day_of_week As Integer = CType(FechaTemp.DayOfWeek, Integer) + 1
If day_of_week = diaDescanso Then
DiasNolavorales = DiasNolavorales + 1
End If
' If day_of_week = diaDescanso Then
' DiasNolavorales = DiasNolavorales + 1
' End If
FechaTemp = FechaTemp.AddDays(1)
' FechaTemp = FechaTemp.AddDays(1)
If 1 = DiferenciaEntreFechas Then
If day_of_week = diaDescanso Then
DiasNolavorales = DiasNolavorales + 1
End If
End If
Next x
' If 1 = DiferenciaEntreFechas Then
' If day_of_week = diaDescanso Then
' DiasNolavorales = DiasNolavorales + 1
' End If
' End If
' Next x
If (DiferenciaEntreFechas - DiasNolavorales) >= DiasDisponibles Then
diasVacaciones = DiasDisponibles
Else
diasVacaciones = DiferenciaEntreFechas - DiasNolavorales
End If
' If (DiferenciaEntreFechas - DiasNolavorales) >= DiasDisponibles Then
' diasVacaciones = DiasDisponibles
' Else
' diasVacaciones = DiferenciaEntreFechas - DiasNolavorales
' End If
TxtVacDiasPago.Text = diasVacaciones.ToString
' TxtVacDiasPago.Text = diasVacaciones.ToString
End If
'End If
If TxtVacDiasPago.Text.ToEntero > DiasDisponibles Then
TxtVacDiasPago.Text = DiasDisponibles.ToString
diasVacaciones = DiasDisponibles
End If
'If TxtVacDiasPago.Text.ToEntero > DiasDisponibles Then
' TxtVacDiasPago.Text = DiasDisponibles.ToString
' diasVacaciones = DiasDisponibles
'End If
Dim DiasAgregados As Integer = 0
Dim FechaFin As Date = fechaInicioParametro
Dim Contador As Integer = 0
For x As Integer = 2 To diasVacaciones
Dim day_of_week As Integer = CType(FechaFin.DayOfWeek, Integer) + 1
If day_of_week = diaDescanso Then
FechaFin = FechaFin.AddDays(2)
DiasAgregados = DiasAgregados + 1
Else
FechaFin = FechaFin.AddDays(1)
day_of_week = CType(FechaFin.DayOfWeek, Integer) + 1
If (diasVacaciones = Contador + 2) AndAlso day_of_week = diaDescanso Then
FechaFin = FechaFin.AddDays(1)
DiasAgregados = DiasAgregados + 1
End If
'Dim DiasAgregados As Integer = 0
'Dim FechaFin As Date = fechaInicioParametro
'Dim Contador As Integer = 0
'For x As Integer = 2 To diasVacaciones
' Dim day_of_week As Integer = CType(FechaFin.DayOfWeek, Integer) + 1
' If day_of_week = diaDescanso Then
' FechaFin = FechaFin.AddDays(2)
' DiasAgregados = DiasAgregados + 1
' Else
' FechaFin = FechaFin.AddDays(1)
' day_of_week = CType(FechaFin.DayOfWeek, Integer) + 1
' If (diasVacaciones = Contador + 2) AndAlso day_of_week = diaDescanso Then
' FechaFin = FechaFin.AddDays(1)
' DiasAgregados = DiasAgregados + 1
' End If
End If
Contador = Contador + 1
Next
' End If
' Contador = Contador + 1
'Next
Dim UltimoDiamasUno As Integer = CType(FechaFin.AddDays(1).DayOfWeek, Integer) + 1
'Dim UltimoDiamasUno As Integer = CType(FechaFin.AddDays(1).DayOfWeek, Integer) + 1
If UltimoDiamasUno = diaDescanso Then
FechaFin = FechaFin.AddDays(1)
DiasAgregados = DiasAgregados + 1
End If
'If UltimoDiamasUno = diaDescanso Then
' FechaFin = FechaFin.AddDays(1)
' DiasAgregados = DiasAgregados + 1
'End If
TxtFechaFinVac.Text = FechaFin.ToString
Txtdiasinabiles.Text = DiasAgregados.ToString
'TxtFechaFinVac.Text = FechaFin.ToString
'Txtdiasinabiles.Text = DiasAgregados.ToString
UpSolicitarVacaciones.Update()