diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 4ab276bd8..2d1764be0 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -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 diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 029a45413..7395a49c5 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -7899,88 +7899,95 @@ 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 + ' If day_of_week = diaDescanso Then + ' DiasNolavorales = DiasNolavorales + 1 + ' End If + + ' FechaTemp = FechaTemp.AddDays(1) + + ' 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 + + ' TxtVacDiasPago.Text = diasVacaciones.ToString + + '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 + + ' End If + ' Contador = Contador + 1 + 'Next + + + + 'Dim UltimoDiamasUno As Integer = CType(FechaFin.AddDays(1).DayOfWeek, Integer) + 1 + + 'If UltimoDiamasUno = diaDescanso Then + ' FechaFin = FechaFin.AddDays(1) + ' DiasAgregados = DiasAgregados + 1 + 'End If + 'TxtFechaFinVac.Text = FechaFin.ToString + 'Txtdiasinabiles.Text = DiasAgregados.ToString + Using onom As New ClsNominas + If onom.CalculaDiasFeriados(fechaInicioParametro.ToDateTime().ToString("yyyy-MM-dd"), "", diasVacaciones, 0, UsuarioActual.CveEmpresa, UsuarioActual.CvePersonal) Then + If Not IsNothing(onom.DtResultados) AndAlso onom.DtResultados.Rows.Count > 0 Then + Dim drow As DataRow = onom.DtResultados.Rows(0) + TxtFechaFinVac.Text = String.Format("{0:dd/MM/yyyy}", drow("FechaInicio")) + Txtdiasinabiles.Text = String.Format("{0}", drow("DiaFeriadoB")) End If - - FechaTemp = FechaTemp.AddDays(1) - - 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 - - TxtVacDiasPago.Text = diasVacaciones.ToString - - 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 - - End If - Contador = Contador + 1 - Next - - - - Dim UltimoDiamasUno As Integer = CType(FechaFin.AddDays(1).DayOfWeek, Integer) + 1 - - If UltimoDiamasUno = diaDescanso Then - FechaFin = FechaFin.AddDays(1) - DiasAgregados = DiasAgregados + 1 - End If - - TxtFechaFinVac.Text = FechaFin.ToString - Txtdiasinabiles.Text = DiasAgregados.ToString - + End Using UpSolicitarVacaciones.Update() End Sub