3304 lines
148 KiB
VB.net
3304 lines
148 KiB
VB.net
Option Strict On
|
||
Imports Extensiones
|
||
Imports System.Data
|
||
|
||
|
||
|
||
|
||
Partial Class RH_RepChecadorPreAsistencia
|
||
Inherits ClsPaginas
|
||
#Region "Propiedades"
|
||
|
||
Private Property FiltroAplicado As String
|
||
Get
|
||
If ViewState("CveRegistroDetalle") Is Nothing Then
|
||
Return "-1"
|
||
Else
|
||
Return ViewState("CveRegistroDetalle").ToString()
|
||
End If
|
||
End Get
|
||
Set(value As String)
|
||
ViewState("CveRegistroDetalle") = value
|
||
End Set
|
||
End Property
|
||
|
||
|
||
Private Property DtDatosTabla As DataTable
|
||
Get
|
||
If ViewState("DtDatosTabla") Is Nothing Then
|
||
Return New DataTable
|
||
Else
|
||
Return DirectCast(ViewState("DtDatosTabla"), DataTable)
|
||
End If
|
||
End Get
|
||
Set(value As DataTable)
|
||
ViewState("DtDatosTabla") = value
|
||
End Set
|
||
End Property
|
||
|
||
|
||
Private Property DtResultados As DataTable
|
||
Get
|
||
If ViewState("DtResultados") Is Nothing Then
|
||
Return New DataTable
|
||
Else
|
||
Return DirectCast(ViewState("DtResultados"), DataTable)
|
||
End If
|
||
End Get
|
||
Set(value As DataTable)
|
||
ViewState("DtResultados") = value
|
||
End Set
|
||
End Property
|
||
|
||
Private Property DTTipoPeriodoDatos As DataTable
|
||
Get
|
||
If ViewState("DTTipoPeriodoDatos") Is Nothing Then
|
||
Return New DataTable
|
||
Else
|
||
Return DirectCast(ViewState("DTTipoPeriodoDatos"), DataTable)
|
||
End If
|
||
End Get
|
||
Set(value As DataTable)
|
||
ViewState("DTTipoPeriodoDatos") = value
|
||
End Set
|
||
End Property
|
||
|
||
Private Property DTPeriodos As DataTable
|
||
Get
|
||
If ViewState("DTPeriodos") Is Nothing Then
|
||
Return New DataTable
|
||
Else
|
||
Return DirectCast(ViewState("DTPeriodos"), DataTable)
|
||
End If
|
||
End Get
|
||
Set(value As DataTable)
|
||
ViewState("DTPeriodos") = value
|
||
End Set
|
||
End Property
|
||
|
||
Private Property FechaInicioPeriodo As Date
|
||
Get
|
||
If ViewState("FechaInicioPeriodo") Is Nothing Then
|
||
Return Nothing
|
||
Else
|
||
Return DirectCast(ViewState("FechaInicioPeriodo"), Date)
|
||
End If
|
||
End Get
|
||
Set(value As Date)
|
||
ViewState("FechaInicioPeriodo") = value
|
||
End Set
|
||
End Property
|
||
|
||
Private Property FechaFinPeriodo As Date
|
||
Get
|
||
If ViewState("FechaFinPeriodo") Is Nothing Then
|
||
Return Nothing
|
||
Else
|
||
Return DirectCast(ViewState("FechaFinPeriodo"), Date)
|
||
End If
|
||
End Get
|
||
Set(value As Date)
|
||
ViewState("FechaFinPeriodo") = value
|
||
End Set
|
||
End Property
|
||
|
||
|
||
Private Property DiasPeriodo As Integer
|
||
Get
|
||
If ViewState("DiasPeriodo") Is Nothing Then
|
||
Return -1
|
||
Else
|
||
Return DirectCast(ViewState("DiasPeriodo"), Integer)
|
||
End If
|
||
End Get
|
||
Set(value As Integer)
|
||
ViewState("DiasPeriodo") = value
|
||
End Set
|
||
End Property
|
||
|
||
Private Property CveTipoPeriodo As Integer
|
||
Get
|
||
If ViewState("CveTipoPeriodo") Is Nothing Then
|
||
Return -1
|
||
Else
|
||
Return DirectCast(ViewState("CveTipoPeriodo"), Integer)
|
||
End If
|
||
End Get
|
||
Set(value As Integer)
|
||
ViewState("CveTipoPeriodo") = value
|
||
End Set
|
||
End Property
|
||
|
||
|
||
|
||
Private Property CvePersonalSeleccionado As Integer
|
||
Get
|
||
If ViewState("CvePersonalSeleccionado") Is Nothing Then
|
||
ViewState("CvePersonalSeleccionado") = -1
|
||
End If
|
||
Return ViewState("CvePersonalSeleccionado").ToString.ToEntero
|
||
End Get
|
||
Set(value As Integer)
|
||
ViewState("CvePersonalSeleccionado") = value
|
||
End Set
|
||
End Property
|
||
|
||
Public Property FechaSeleccionada As Date
|
||
Get
|
||
If ViewState("FechaSeleccionada") Is Nothing Then
|
||
ViewState("FechaSeleccionada") = MinFecha
|
||
End If
|
||
Return ViewState("FechaSeleccionada").ToString.ToDate
|
||
End Get
|
||
Set(value As Date)
|
||
ViewState("FechaSeleccionada") = value
|
||
End Set
|
||
End Property
|
||
|
||
|
||
Public Property VerChkSeleccionPersonal As Boolean
|
||
Get
|
||
If ViewState("VerChkSeleccionPersonal") Is Nothing Then
|
||
ViewState("VerChkSeleccionPersonal") = False
|
||
End If
|
||
Return Boolean.Parse(ViewState("VerChkSeleccionPersonal").ToString)
|
||
End Get
|
||
Set(value As Boolean)
|
||
ViewState("VerChkSeleccionPersonal") = value
|
||
End Set
|
||
End Property
|
||
|
||
'Private Property dtPeriodos As DataTable
|
||
' Get
|
||
' If ViewState("dtPeriodos") Is Nothing Then
|
||
' Return Nothing
|
||
' Else
|
||
' Return DirectCast(ViewState("dtPeriodos"), DataTable)
|
||
' End If
|
||
' End Get
|
||
' Set(value As DataTable)
|
||
' ViewState("dtPeriodos") = value
|
||
' End Set
|
||
'End Property
|
||
|
||
|
||
#End Region
|
||
|
||
Private Sub RH_RepChecadorIncidencias_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||
|
||
If Not Page.IsPostBack Then
|
||
cargaEjercicios()
|
||
CargaCombos()
|
||
End If
|
||
|
||
' GvBind()
|
||
|
||
End Sub
|
||
|
||
|
||
Private Sub cargaEjercicios()
|
||
Dim EjercicioActual As Integer = UsuarioActual.Empresa.EjercicioActual
|
||
If EjercicioActual = 0 Then
|
||
EjercicioActual = Now.Year
|
||
End If
|
||
|
||
Dim dtejercicio As DataTable = Nothing
|
||
Using objnom As New ClsNominas()
|
||
If objnom.GetEjercicios(UsuarioActual.CveEmpresa) Then
|
||
dtejercicio = objnom.DtResultados
|
||
End If
|
||
End Using
|
||
|
||
DdlEjercicios.DataSource = dtejercicio
|
||
DdlEjercicios.DataBind()
|
||
|
||
Dim litem As ListItem = Nothing
|
||
If dtejercicio IsNot Nothing AndAlso dtejercicio.Rows.Count > 0 Then
|
||
If dtejercicio.Compute("COUNT(Ejercicio)", String.Format("Ejercicio={0}", EjercicioActual)).ToString.ToEntero = 0 Then
|
||
litem = New ListItem(EjercicioActual.ToString(), EjercicioActual.ToString())
|
||
DdlEjercicios.Items.Insert(0, litem)
|
||
End If
|
||
If dtejercicio.Compute("COUNT(Ejercicio)", String.Format("Ejercicio={0}", EjercicioActual - 1)).ToString.ToEntero = 0 Then
|
||
litem = New ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString())
|
||
DdlEjercicios.Items.Insert(1, litem)
|
||
' DdlEjerciciosCM.Items.Insert(1, litem)
|
||
End If
|
||
Else
|
||
litem = New ListItem(EjercicioActual.ToString(), EjercicioActual.ToString())
|
||
DdlEjercicios.Items.Insert(0, litem)
|
||
'DdlEjerciciosCM.Items.Insert(0, litem)
|
||
litem = New ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString())
|
||
DdlEjercicios.Items.Insert(1, litem)
|
||
'DdlEjerciciosCM.Items.Insert(1, litem)
|
||
End If
|
||
|
||
If DdlEjercicios.Items.Count > 0 Then
|
||
DdlEjercicios.SelectedIndex = 0
|
||
End If
|
||
|
||
' Additional method to check if selected value exists, and set it if it does
|
||
DdlEjercicios.SelectedValueExist(Now.Year.ToString())
|
||
End Sub
|
||
|
||
Protected Sub DdlEjercicios_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||
cargaPeriodos()
|
||
End Sub
|
||
|
||
Private Sub cargaPeriodos()
|
||
BtnConsultar.Enabled = False
|
||
Dim tipoPeriodo As Integer = DdlTipoPeriodo.SelectedValue.ToEntero()
|
||
Dim ejercicio As Integer = DdlEjercicios.SelectedValue.ToEntero()
|
||
DTPeriodos = Nothing
|
||
|
||
If DdlTipoPeriodo.SelectedValue.ToEntero() > 0 Then
|
||
Using objPeriodos As New ClsNominas()
|
||
If objPeriodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1) Then
|
||
If objPeriodos.DtResultados.Rows.Count = 0 Then
|
||
Alert("No existen periodos registrados en este año y tipo de periodo, ¿desea registrarlos masivamente?", TipoMensaje.MsgConfirmacion, "$(""#divCargaMasiva"").modal(""show"");", TextoConfirmacion:="Aceptar", TextoSegundoBoton:="No")
|
||
End If
|
||
DTPeriodos = objPeriodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4,5)")
|
||
End If
|
||
End Using
|
||
|
||
BtnConsultar.Enabled = True
|
||
End If
|
||
|
||
DdlPeriodo.DataSource = DTPeriodos
|
||
DdlPeriodo.DataBind()
|
||
DdlPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||
UPFiltros.Update()
|
||
'muestraPeriodo()
|
||
End Sub
|
||
|
||
Private Sub CargaCombos()
|
||
|
||
|
||
DdlAsistenciaInacistencia.DataSource = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltraParametros(" CveAsistenciasInasistencias <> 6")
|
||
DdlAsistenciaInacistencia.DataBind()
|
||
DdlAsistenciaInacistencia.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
||
|
||
DdlAsistenciaInacistenciaCarga.DataSource = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa)
|
||
DdlAsistenciaInacistenciaCarga.DataBind()
|
||
DdlAsistenciaInacistenciaCarga.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
||
|
||
DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras(UsuarioActual.CveEmpresa)
|
||
DdlMotivoHoraExtra.DataBind()
|
||
DdlMotivoHoraExtra.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
||
|
||
DdlMotivoHoraExtraModal.DataSource = GlobalDTMotivosHorasExtras(UsuarioActual.CveEmpresa)
|
||
DdlMotivoHoraExtraModal.DataBind()
|
||
DdlMotivoHoraExtraModal.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
||
|
||
Dim objNom As New ClsNominas
|
||
|
||
If objNom.GetTiposPeriodos() Then
|
||
DdlTipoPeriodo.DataSource = objNom.DtResultados.FiltraParametros(" CveTipoPeriodo <> 6 ")
|
||
DTTipoPeriodoDatos = objNom.DtResultados
|
||
End If
|
||
|
||
objNom.Dispose()
|
||
|
||
DdlTipoPeriodo.DataBind()
|
||
DdlTipoPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||
|
||
DdlTurno.DataSource = GlobalDTTurno(UsuarioActual.CveEmpresa)
|
||
DdlTurno.DataBind()
|
||
' DdlTurno.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
||
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)
|
||
DdlSubProyecto.DataBind()
|
||
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
||
DdlTurno.Items.Insert(0, New ListItem("Todos", "-1"))
|
||
DdlTurno.SelectedValue = "-1"
|
||
|
||
CargaDepartamento()
|
||
End Sub
|
||
Private Sub CargaDepartamento()
|
||
DdlDepartamento.DataSource = GlobalDTDepartamentos(UsuarioActual.CveEmpresa)
|
||
DdlDepartamento.DataBind()
|
||
End Sub
|
||
|
||
Private Sub CargaDdlAsistencia()
|
||
|
||
|
||
|
||
|
||
End Sub
|
||
|
||
Private Sub GeneraFechasInicioFinPerdiodo()
|
||
|
||
lblTituloPagina.Text = ""
|
||
|
||
If DdlPeriodo.SelectedIndex > 0 Then
|
||
lblTituloPagina.Text = DdlPeriodo.SelectedItem.Text
|
||
|
||
Dim DtTemp As DataTable = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue.ToEntero)
|
||
FechaInicioPeriodo = DtTemp(0)("FechaInicio").ToString().ToDate
|
||
FechaFinPeriodo = DtTemp(0)("FechaFin").ToString().ToDate
|
||
End If
|
||
|
||
UpTituloPagina.Update()
|
||
|
||
End Sub
|
||
|
||
Protected Sub DdlTipoPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoPeriodo.SelectedIndexChanged
|
||
|
||
DdlPeriodo.Items.Clear()
|
||
DTPeriodos = Nothing
|
||
|
||
Dim objRh As New ClsRH
|
||
|
||
If DdlTipoPeriodo.SelectedIndex <> 0 Then
|
||
|
||
CveTipoPeriodo = DdlTipoPeriodo.SelectedValue.ToEntero
|
||
DiasPeriodo = DTTipoPeriodoDatos.FiltraParametros(" CveTipoPeriodo = " & DdlTipoPeriodo.SelectedValue)(0)("DiasPeriodo").ToString().ToEntero
|
||
|
||
|
||
cargaPeriodos()
|
||
|
||
Dim objNomina As New ClsNominas
|
||
|
||
If objNomina.GetPeriodos(DdlTipoPeriodo.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, -1, -1, -1) Then
|
||
|
||
' TxtFechaModal.Text = ""
|
||
' lblTituloPagina.Text = ""
|
||
' UpTituloPagina.Update()
|
||
' UpModalFechaBody.Update()
|
||
|
||
If objNomina.DtResultados.Rows.Count > 0 Then
|
||
' BtnConsultar.Enabled = True
|
||
DTPeriodos = objNomina.DtResultados
|
||
' Dim DTPeridosView As DataView = DTPeriodos.DefaultView
|
||
' DTPeridosView.Sort = " FechaInicio desc "
|
||
' DTPeriodos = DTPeridosView.ToTable
|
||
' DdlPeriodo.DataSource = objNomina.DtResultados
|
||
|
||
' ' LblPeriodo.Visible = True
|
||
' 'DdlRango.Visible = True
|
||
Else
|
||
' ' RegistraScript("$('#ModalModalFecha').modal({ backdrop: 'static', keyboard: false});")
|
||
' Alert("No se encontraron periodos disponibles.", TipoMensaje.MsgAdvertencia)
|
||
DTPeriodos = Nothing
|
||
' DdlPeriodo.DataSource = Nothing
|
||
End If
|
||
'Else
|
||
' DTPeriodos = Nothing
|
||
' DdlPeriodo.DataSource = Nothing
|
||
End If
|
||
|
||
objNomina.Dispose()
|
||
|
||
Dim DtTempFechaInicial As DataTable = DTPeriodos.FiltraParametros("Estatus = 1")
|
||
|
||
|
||
DdlPeriodo.DataBind()
|
||
|
||
If DtTempFechaInicial.Rows.Count > 0 Then
|
||
Dim temCvePeriodoNomi As Integer = DtTempFechaInicial(0)("CvePeriodo").ToString().ToEntero
|
||
DdlPeriodo.SelectedValueExist(temCvePeriodoNomi)
|
||
End If
|
||
|
||
DdlPeriodo.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
||
UPFiltros.Update()
|
||
' BtnConsultar.Enabled = True
|
||
Else
|
||
|
||
DTPeriodos = Nothing
|
||
DdlPeriodo.DataSource = Nothing
|
||
|
||
'DdlRango.Visible = False
|
||
' LblPeriodo.Visible = Fale
|
||
lblTituloPagina.Text = ""
|
||
UPFiltros.Update()
|
||
UpTituloPagina.Update()
|
||
BtnConsultar.Enabled = False
|
||
End If
|
||
|
||
GeneraFechasInicioFinPerdiodo()
|
||
|
||
DdlPeriodo_SelectedIndexChanged(Nothing, Nothing)
|
||
End Sub
|
||
|
||
Private Sub DdlRango_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPeriodo.SelectedIndexChanged
|
||
|
||
GeneraFechasInicioFinPerdiodo()
|
||
UpTituloPagina.Update()
|
||
|
||
End Sub
|
||
|
||
Private Sub CargaDatos()
|
||
|
||
DtDatosTabla = Nothing
|
||
Dim objRH As New ClsRH
|
||
Dim objGrales As New ClsGenerales
|
||
Dim DTDatos As New DataTable
|
||
Dim DtPersonal As New DataTable
|
||
Dim DTHorarioPersonal As DataTable
|
||
Dim DtVacaciones As New DataTable
|
||
|
||
Dim RetrasosMaximos As Integer = 3
|
||
Dim dt As New DataTable
|
||
|
||
Dim Retardos As Integer = 0
|
||
'Dim DTAsistenciasInasistencias As New DataTable
|
||
Dim DTPreAsistenciasInasistencias As New DataTable
|
||
Dim DTChecadorRegistros As New DataTable
|
||
Dim DTHorarios As New DataTable
|
||
Dim DTDiasInhabiles As New DataTable
|
||
Dim DTTipoPeriodo As New DataTable
|
||
Dim DTAsistenciasInasistenciasReg As New DataTable
|
||
|
||
Dim CveChecadorHorario As Integer = -1
|
||
Dim TolRetAcumulados As Integer = 0
|
||
Dim TolRetEntradaMin As Integer = 0
|
||
Dim TolFalEntradaMin As Integer = 0
|
||
Dim RetSalidaAntes As Boolean = True
|
||
Dim TolSalidaAntesMin As Integer = 0
|
||
|
||
Dim CveASistenciaInasistenciaAsistio As Integer = -1
|
||
Dim CveAsistenciaInasistenciaFalta As Integer = -1
|
||
Dim CveAsistenciaInasistenciaRetardo As Integer = -1
|
||
Dim CveAsistenciaInasistenciaDescanso As Integer = -1
|
||
|
||
Try
|
||
CveASistenciaInasistenciaAsistio = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'A'")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaFalta = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'F'")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaRetardo = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'R' ")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaDescanso = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'D' ")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
|
||
Catch ex As Exception
|
||
Alert("Se presento un error al obtener las claves de asistencia.", TipoMensaje.MsgError)
|
||
Exit Sub
|
||
End Try
|
||
|
||
GeneraFechasInicioFinPerdiodo()
|
||
|
||
DiasPeriodo = (FechaFinPeriodo - FechaInicioPeriodo).TotalDays.ToEntero + 1
|
||
Dim objNom As New ClsNominas
|
||
|
||
If objNom.GetTiposPeriodos() Then
|
||
DdlTipoPeriodo.DataSource = objNom.DtResultados
|
||
DTTipoPeriodo = objNom.DtResultados
|
||
End If
|
||
|
||
objNom.Dispose()
|
||
|
||
If objGrales.DiasInhabiles_Get(-1, 1, UsuarioActual.CveEmpresa) Then
|
||
DTDiasInhabiles = objGrales.DtResultados
|
||
End If
|
||
|
||
objGrales.Dispose()
|
||
|
||
Dim Resultados As New DataTable
|
||
|
||
Resultados.Columns.Add("CvePersonal")
|
||
Resultados.Columns.Add("NombreCompleto")
|
||
Resultados.Columns.Add("Codigo")
|
||
Resultados.Columns.Add("CveSubProyecto")
|
||
Resultados.Columns.Add("SalarioDiario")
|
||
Resultados.Columns.Add("CveAsistenciasInasistencias")
|
||
Resultados.Columns.Add("PorcentajePago")
|
||
Resultados.Columns.Add("Fecha")
|
||
Resultados.Columns.Add("Asistio")
|
||
Resultados.Columns.Add("Retraso")
|
||
Resultados.Columns.Add("Inconsistencia")
|
||
Resultados.Columns.Add("Descanso")
|
||
Resultados.Columns.Add("Entrada")
|
||
Resultados.Columns.Add("Salida")
|
||
Resultados.Columns.Add("FaltaRetraso")
|
||
Resultados.Columns.Add("DiaInhabil")
|
||
Resultados.Columns.Add("FaltaPorRetrasos")
|
||
Resultados.Columns.Add("Mensaje")
|
||
Resultados.Columns.Add("FaltaRetardosAcumulados")
|
||
Resultados.Columns.Add("DiaInhabilStr")
|
||
Resultados.Columns.Add("DiaVacacion")
|
||
Resultados.Columns.Add("TipoCorto")
|
||
Resultados.Columns.Add("Sancion")
|
||
|
||
Resultados.Columns.Add("HorasDobles", GetType(Decimal))
|
||
Resultados.Columns.Add("HorasTriples", GetType(Decimal))
|
||
Resultados.Columns.Add("CveMotivoHoraExtra", GetType(Integer))
|
||
Resultados.Columns.Add("Observacion")
|
||
|
||
|
||
If DdlTipoPeriodo.SelectedValue.ToEntero > 0 And DdlPeriodo.SelectedValue.ToEntero > 0 Then
|
||
|
||
Dim FiltroSubProyecto As String = ""
|
||
Dim filtroturno = If(DdlTurno.SelectedValue = "-1", "", $"AND CveTurno = { DdlTurno.SelectedValue}")
|
||
If DdlSubProyecto.SelectedIndex > 0 Then
|
||
FiltroSubProyecto = $" CveTipoPeriodo = {DdlTipoPeriodo.SelectedValue } {filtroturno} AND CveSubProyecto = { DdlSubProyecto.SelectedValue.ToEntero }"
|
||
Else
|
||
FiltroSubProyecto = $" CveTipoPeriodo = {DdlTipoPeriodo.SelectedValue } {filtroturno} "
|
||
End If
|
||
|
||
'DtPersonal = GlobalDTRHPersonal(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(FiltroSubProyecto)
|
||
|
||
Dim DtTempPeriodo As DataTable = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue.ToEntero)
|
||
Dim FechaInicioPeriodoFiltro = DtTempPeriodo(0)("FechaInicio").ToString().ToDate
|
||
|
||
|
||
|
||
Dim FilCveDepartamento As Integer = DdlDepartamento.SelectedValue.ToEntero
|
||
|
||
Dim FilasFiltradas = From fila In GlobalDTRHPersonal(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(FiltroSubProyecto).AsEnumerable()
|
||
Let Inicio = fila.Field(Of Date)("FechaInicio")
|
||
Let FechaFinOriginal = fila.Field(Of Date?)("FechaFin")
|
||
Let FechaFin = If(FechaFinOriginal.HasValue, FechaFinOriginal.Value, Now)
|
||
Where Inicio <= FechaInicioPeriodoFiltro AndAlso FechaInicioPeriodoFiltro <= FechaFin _
|
||
AndAlso (FilCveDepartamento = -1 OrElse fila.Field(Of Integer)("CveDepartamento") = FilCveDepartamento)
|
||
Select fila
|
||
|
||
DtPersonal = FilasFiltradas.CopyToDataTable()
|
||
|
||
|
||
|
||
If objRH.ChecadorHorariosGet(-1, 1, UsuarioActual.Empresa.CveEmpresa) Then
|
||
DTHorarios = objRH.DtResultados
|
||
|
||
If DdlTurno.SelectedIndex > 0 Then
|
||
Dim DTTemp As DataTable = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltraParametros("CveTurno = " & DdlTurno.SelectedValue)
|
||
Dim TMCveChecadorHorario As Integer = -1
|
||
|
||
If DTTemp.Rows.Count > 0 Then
|
||
TMCveChecadorHorario = DTTemp(0)("CveChecadorHorario").ToString().ToEntero
|
||
Dim DtHorarioTemp = DTHorarios.FiltraParametros("CveChecadorHorario = " & TMCveChecadorHorario)
|
||
|
||
If DtHorarioTemp.Rows.Count > 0 Then
|
||
TolRetAcumulados = DtHorarioTemp(0)("TolRetAcumulados").ToString().ToEntero
|
||
TolRetEntradaMin = DtHorarioTemp(0)("TolRetEntradaMin").ToString().ToEntero
|
||
TolFalEntradaMin = DtHorarioTemp(0)("TolFalEntradaMin").ToString().ToEntero
|
||
RetSalidaAntes = Boolean.Parse(DtHorarioTemp(0)("RetSalidaAntes").ToString())
|
||
TolSalidaAntesMin = DtHorarioTemp(0)("TolSalidaAntesMin").ToString().ToEntero
|
||
End If
|
||
End If
|
||
Else
|
||
If DTHorarios.Rows.Count > 0 Then
|
||
TolRetAcumulados = DTHorarios(0)("TolRetAcumulados").ToString().ToEntero
|
||
TolRetEntradaMin = DTHorarios(0)("TolRetEntradaMin").ToString().ToEntero
|
||
TolFalEntradaMin = DTHorarios(0)("TolFalEntradaMin").ToString().ToEntero
|
||
RetSalidaAntes = Boolean.Parse(DTHorarios(0)("RetSalidaAntes").ToString())
|
||
TolSalidaAntesMin = DTHorarios(0)("TolSalidaAntesMin").ToString().ToEntero
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
If objRH.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, False) Then
|
||
DTChecadorRegistros = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.VacacionesGet(-1, UsuarioActual.Empresa.CveEmpresa, FechaInicioPeriodo, FechaFinPeriodo) Then
|
||
DtVacaciones = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.GetPersonalPreAsistenciaRegistros(FechaInicioPeriodo, FechaFinPeriodo, UsuarioActual.CveEmpresa) Then
|
||
DTPreAsistenciasInasistencias = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.ChecadorPreAsistenciaRegistrosAsistenciasGet(CveTipoPeriodo, FechaInicioPeriodo, FechaFinPeriodo, UsuarioActual.Empresa.CveEmpresa) Then
|
||
DTAsistenciasInasistenciasReg = objRH.DtResultados
|
||
|
||
|
||
End If
|
||
|
||
objRH.Dispose()
|
||
|
||
|
||
If RdbChecador.Checked Then
|
||
'DtPersonal = DtPersonal.FiltraParametros("CvePersonal = 21271")
|
||
For Each dRow As DataRow In DtPersonal.Rows
|
||
|
||
Dim Fecha As Date = FechaInicioPeriodo
|
||
Dim ContadorFaltas As Integer = 0
|
||
|
||
objRH = New ClsRH
|
||
If objRH.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, True) Then
|
||
DTChecadorRegistros = objRH.DtResultados
|
||
End If
|
||
objRH.Dispose()
|
||
|
||
Dim registrosPersonal As DataTable = DTChecadorRegistros.FiltraParametros(" CvePersonal = " & dRow(0).ToString())
|
||
|
||
Dim CveTurno As Integer = dRow("CveTurno").ToString.ToEntero
|
||
Dim DiaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {CveTurno} ").ToEntero - 1 'El -1 es por que en .net el domingo empieza 0 y en la sql en 1
|
||
Dim Codigo As String = dRow("Codigo").ToString
|
||
|
||
If registrosPersonal.Rows.Count > 0 Then
|
||
DTHorarioPersonal = DTHorarios.FiltraParametros(" CveChecadorHorario = " & registrosPersonal(0)("CveHorario").ToString() & "")
|
||
Retardos = 0
|
||
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("PorcentajePago") = "0"
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("FaltaRetraso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
Dim diaSemana As Integer = Fecha.DayOfWeek
|
||
Dim Asistencia As Boolean = True
|
||
|
||
Dim Horario As DataTable = HorarioDiario(Fecha, DTHorarioPersonal, DiaDescanso)
|
||
Dim DiaLaboral As Boolean = Boolean.Parse(Horario(0)(0).ToString())
|
||
|
||
Dim HorarioEntrada As TimeSpan = TimeSpan.Parse(Horario(0)(1).ToString())
|
||
Dim HorarioSalidaComida As TimeSpan = TimeSpan.Parse(Horario(0)(2).ToString())
|
||
Dim HorarioEntradaComida As TimeSpan = TimeSpan.Parse(Horario(0)(3).ToString())
|
||
Dim HorarioSalida As TimeSpan = TimeSpan.Parse(Horario(0)(4).ToString())
|
||
|
||
Dim FechaHoraEntrada As DateTime
|
||
Dim FechahoraSalida As DateTime
|
||
Dim turnoNocturno As Boolean
|
||
|
||
Dim FechaHoraRegistroEntrada As DateTime
|
||
Dim FechaHoraRegistroSalida As DateTime
|
||
|
||
FechaHoraEntrada = Fecha + HorarioEntrada
|
||
If Not turnoNocturno Then
|
||
FechahoraSalida = Fecha + HorarioEntrada + (HorarioSalida - HorarioEntrada)
|
||
Else
|
||
FechahoraSalida = FechahoraSalida.AddDays(1) - HorarioEntrada + HorarioSalida
|
||
End If
|
||
|
||
Dim tempDatetime1 As DateTime = FechaHoraEntrada.AddHours(-2) 'la entrada se podra checar hasta dos horas antes de la hora de entrada
|
||
Dim tempDatetime2 As DateTime = FechahoraSalida.AddHours(4) 'Legalmente no se pueden hacer mas de 3 horas extras al día
|
||
|
||
Dim tabladelDia As DataTable = registrosPersonal.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND FechaRegistro >= '" & tempDatetime1.ToShortDateString & "' AND FechaRegistro <= '" & tempDatetime2.ToString() & "'")
|
||
|
||
|
||
If DTPreAsistenciasInasistencias.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND Fecha = '" & Fecha & "'").Rows.Count > 0 Then
|
||
|
||
Dim DTPreasistencia As DataTable = DTPreAsistenciasInasistencias.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND Fecha = '" & Fecha & "'")
|
||
|
||
If DTPreasistencia IsNot Nothing AndAlso DTPreasistencia.Rows.Count > 0 Then
|
||
ReRow("CveAsistenciasInasistencias") = DTPreasistencia.Rows(0)("CveAsistenciasInasistencias").ToString()
|
||
ReRow("HorasDobles") = DTPreasistencia.Rows(0)("HorasDobles").ToString.ToDecimal
|
||
ReRow("HorasTriples") = DTPreasistencia.Rows(0)("HorasTriples").ToString.ToDecimal
|
||
ReRow("CveMotivoHoraExtra") = DTPreasistencia.Rows(0)("CveMotivoHoraExtra").ToString.ToEntero
|
||
ReRow("Observacion") = DTPreasistencia.Rows(0)("Observacion").ToString
|
||
ReRow("PorcentajePago") = DTPreasistencia.Rows(0)("PorcentajePago").ToString.ToDecimal
|
||
|
||
|
||
End If
|
||
|
||
|
||
If ReRow("CveAsistenciasInasistencias").ToString.ToEntero > 0 Then
|
||
|
||
Dim drowAsistenciaInasistencia As DataRow = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltroPrimero($"CveAsistenciasInasistencias={ReRow("CveAsistenciasInasistencias").ToString.ToEntero}")
|
||
|
||
ReRow("Asistio") = drowAsistenciaInasistencia("AplicaAsistencia").ToString = "Aplica"
|
||
ReRow("PorcentajePago") = DTPreAsistenciasInasistencias(0)("PorcentajePago").ToString.ToDecimal
|
||
ReRow("Descanso") = drowAsistenciaInasistencia("AplicaVacacion").ToString = "Aplica"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaVacacion") = drowAsistenciaInasistencia("AplicaVacacion").ToString = "Aplica"
|
||
ReRow("FaltaRetardosAcumulados") = drowAsistenciaInasistencia("AplicaFalta").ToString = "Aplica"
|
||
ReRow("Retraso") = drowAsistenciaInasistencia("AplicaRetardo").ToString = "Aplica"
|
||
ReRow("FaltaRetraso") = False 'Not drowAsistenciaInasistencia("AplicaAsistencia").ToString = "Aplica"
|
||
ReRow("TipoCorto") = drowAsistenciaInasistencia("TipoCorto").ToString
|
||
|
||
End If
|
||
End If
|
||
|
||
If Not ReRow("CveAsistenciasInasistencias").ToString.ToEntero > 0 Then
|
||
|
||
'If tabladelDia.Rows.Count > 0 AndAlso tabladelDia.Rows.Count <> 4 And DiaLaboral = False Then
|
||
If tabladelDia.Rows.Count > 0 AndAlso tabladelDia.Rows.Count <> 4 Then
|
||
'Dim drowAsistenciaInasistencia As DataRow = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltroPrimero($"CveAsistenciasInasistencias={ReRow("CveAsistenciasInasistencias").ToString.ToEntero}")
|
||
|
||
ReRow("Asistio") = False
|
||
ReRow("PorcentajePago") = 0
|
||
ReRow("Descanso") = False
|
||
ReRow("DiaInhabil") = False
|
||
ReRow("DiaVacacion") = False
|
||
ReRow("FaltaRetardosAcumulados") = False
|
||
ReRow("Retraso") = False
|
||
ReRow("FaltaRetraso") = False
|
||
ReRow("TipoCorto") = "_ND"
|
||
|
||
Else
|
||
Dim CountRegistros As Integer = tabladelDia.Rows.Count
|
||
Dim Inconsistencia As Boolean = False
|
||
|
||
If Not DiaLaboral Then
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("Descanso") = "True"
|
||
End If
|
||
|
||
Dim TempDTValidaciones As DataTable = DTDiasInhabiles.FiltraParametros(" FechaInhabil = '" & Fecha.ToString() & "'")
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("DiaInhabil") = "True"
|
||
ReRow("DiaInhabilStr") = TempDTValidaciones(0)("DiaInhabil").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
End If
|
||
|
||
TempDTValidaciones = DtVacaciones.FiltraParametros(" Fecha = '" & Fecha.ToString() & "' AND CvePersonal = " & dRow(0).ToString())
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaVacacion") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
|
||
Else
|
||
ReRow("DiaVacacion") = "False"
|
||
End If
|
||
|
||
|
||
If Fecha >= NowADS() Then
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
|
||
If ReRow("DiaVacacion").ToString() <> "True" And ReRow("Descanso").ToString() <> "True" Then
|
||
|
||
If CountRegistros > 0 Then
|
||
|
||
FechaHoraRegistroEntrada = DateTime.Parse(tabladelDia(0)("FechaRegistro").ToString())
|
||
FechaHoraRegistroSalida = DateTime.Parse(tabladelDia(tabladelDia.Rows.Count - 1)("FechaRegistro").ToString())
|
||
|
||
If Not (FechaHoraRegistroEntrada - FechaHoraEntrada).TotalMinutes > TolFalEntradaMin Then
|
||
If (FechaHoraRegistroEntrada - FechaHoraEntrada).TotalMinutes > TolRetEntradaMin Then
|
||
|
||
Retardos = Retardos + 1
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Retardo"
|
||
|
||
If Retardos >= TolRetAcumulados Then
|
||
ReRow("Asistio") = "False"
|
||
ReRow("FaltaRetardosAcumulados") = "True"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & " Falta por " & TolRetAcumulados & " acumulados. "
|
||
Retardos = 0
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaRetardo
|
||
ReRow("PorcentajePago") = "100"
|
||
End If
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
End If
|
||
Else
|
||
Asistencia = False
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Falta por retardo."
|
||
ReRow("FaltaRetraso") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
If FechahoraSalida > FechaHoraRegistroSalida Then
|
||
|
||
Dim diferenciasalidaMinutos As Integer = (FechahoraSalida - FechaHoraRegistroSalida).TotalMinutes.ToString().ToEntero
|
||
|
||
If RetSalidaAntes Then
|
||
If diferenciasalidaMinutos > TolSalidaAntesMin Then
|
||
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "True"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Retraso por salida antes de tiempo (" & diferenciasalidaMinutos & " minutos)."
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaRetardo
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Salida antes de tiempo (" & diferenciasalidaMinutos & " minutos)."
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
|
||
End If
|
||
End If
|
||
End If
|
||
|
||
Else
|
||
ReRow("Asistio") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
If ReRow("Asistio").ToString() = "True" Then ReRow("PorcentajePago") = "100" Else ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
|
||
|
||
|
||
End If
|
||
|
||
|
||
|
||
'adasdasd
|
||
|
||
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next x
|
||
Else
|
||
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
If dRow("CveChecadorHorario").ToString().ToEntero > 0 Then
|
||
|
||
DTHorarioPersonal = DTHorarios.FiltraParametros(" CveChecadorHorario = " & dRow("CveChecadorHorario").ToString().ToEntero & "")
|
||
|
||
If Fecha >= NowADS() Then
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
Else
|
||
ReRow("Asistio") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
End If
|
||
|
||
Dim Horario As DataTable = HorarioDiario(Fecha, DTHorarioPersonal, DiaDescanso)
|
||
Dim DiaLaboral As Boolean = Boolean.Parse(Horario(0)(0).ToString())
|
||
|
||
If Not DiaLaboral Then
|
||
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("Descanso") = "True"
|
||
Else
|
||
|
||
Dim TempDTValidaciones As DataTable = DTDiasInhabiles.FiltraParametros(" FechaInhabil = '" & Fecha.ToString() & "'")
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaInhabil") = "True"
|
||
ReRow("DiaInhabilStr") = TempDTValidaciones(0)("DiaInhabil").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
TempDTValidaciones = DtVacaciones.FiltraParametros(" Fecha = '" & Fecha.ToString() & "' AND CvePersonal = " & dRow(0).ToString())
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaVacacion") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaVacacion") = "False"
|
||
End If
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
Else
|
||
|
||
BtnAgregar.Visible = False
|
||
|
||
For Each dRow As DataRow In DtPersonal.Rows
|
||
Dim Fecha As Date = FechaInicioPeriodo
|
||
Dim ContadorFaltas As Integer = 0
|
||
Dim registrosPersonal As DataTable = DTAsistenciasInasistenciasReg.FiltraParametros(" CvePersonal = " & dRow(0).ToString())
|
||
|
||
|
||
Dim Codigo As String = dRow("Codigo").ToString
|
||
If registrosPersonal.Rows.Count > 0 Then
|
||
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("PorcentajePago") = "0"
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("FaltaRetraso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
Dim diaSemana As Integer = Fecha.DayOfWeek
|
||
Dim Asistencia As Boolean = True
|
||
|
||
Dim tabladelDia As DataTable = registrosPersonal.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND Fecha = '" & Fecha.ToShortDateString & "'")
|
||
|
||
If tabladelDia.Rows.Count > 0 Then
|
||
ReRow("TipoCorto") = tabladelDia(0)("TipoCorto").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = tabladelDia(0)("CveAsistenciasInasistencias").ToString()
|
||
Else
|
||
ReRow("Asistio") = "False"
|
||
ReRow("TipoCorto") = "F"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
End If
|
||
|
||
If ReRow("Asistio").ToString() = "True" Then ReRow("PorcentajePago") = "100" Else ReRow("PorcentajePago") = "0"
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next x
|
||
Else
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
ReRow("Asistio") = "False"
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
|
||
If ReRow("Asistio").ToString() = "True" Then ReRow("PorcentajePago") = "100" Else ReRow("PorcentajePago") = "0"
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
'Primera parte del proceso terminada
|
||
|
||
DtResultados = Resultados
|
||
|
||
dt.Columns.Add("CvePersonal")
|
||
dt.Columns.Add("Codigo")
|
||
dt.Columns.Add("NombreCompleto")
|
||
dt.Columns.Add("Fecha1")
|
||
dt.Columns.Add("Fecha2")
|
||
dt.Columns.Add("Fecha3")
|
||
dt.Columns.Add("Fecha4")
|
||
dt.Columns.Add("Fecha5")
|
||
dt.Columns.Add("Fecha6")
|
||
dt.Columns.Add("Fecha7")
|
||
dt.Columns.Add("Fecha8")
|
||
dt.Columns.Add("Fecha9")
|
||
dt.Columns.Add("Fecha10")
|
||
dt.Columns.Add("Fecha11")
|
||
dt.Columns.Add("Fecha12")
|
||
dt.Columns.Add("Fecha13")
|
||
dt.Columns.Add("Fecha14")
|
||
dt.Columns.Add("Fecha15")
|
||
dt.Columns.Add("Fecha16")
|
||
dt.Columns.Add("Fecha17")
|
||
dt.Columns.Add("Fecha18")
|
||
dt.Columns.Add("Fecha19")
|
||
dt.Columns.Add("Fecha20")
|
||
dt.Columns.Add("Fecha21")
|
||
dt.Columns.Add("Fecha22")
|
||
dt.Columns.Add("Fecha23")
|
||
dt.Columns.Add("Fecha24")
|
||
dt.Columns.Add("Fecha25")
|
||
dt.Columns.Add("Fecha26")
|
||
dt.Columns.Add("Fecha27")
|
||
dt.Columns.Add("Fecha28")
|
||
dt.Columns.Add("Fecha29")
|
||
dt.Columns.Add("Fecha30")
|
||
dt.Columns.Add("Fecha31")
|
||
|
||
|
||
Dim DTFechas As DataTable
|
||
Dim DTUPersonal As DataTable
|
||
|
||
Dim DTVFechas As New DataView(DtResultados)
|
||
DTFechas = DTVFechas.ToTable(True, "Fecha")
|
||
DTUPersonal = DTVFechas.ToTable(True, {"CvePersonal", "NombreCompleto"})
|
||
|
||
Dim ColumN As Integer = (dt.Columns.Count) - 2
|
||
|
||
For x As Integer = 3 To dt.Columns.Count - 1
|
||
GVRegDatos.Columns(x).HeaderText = ""
|
||
GVRegDatos.Columns(x).Visible = False
|
||
Next
|
||
UpDatos.Update()
|
||
|
||
ColumN = 3
|
||
|
||
For Each drow As DataRow In DTFechas.Rows
|
||
GVRegDatos.Columns(ColumN).HeaderText = String.Format("<div class='Widthall' style='text-align:center;font-size:11px!important'>{1}</div><div class='Widthall' style='text-align:center'> {0} </div>", drow(0).ToString().ToDate.ToString("dd/MM/yyyy"), ObtenerDiaSemana(drow(0).ToString().ToDate))
|
||
GVRegDatos.Columns(ColumN).Visible = True
|
||
ColumN = ColumN + 1
|
||
Next
|
||
|
||
Dim medida As DateTime = NowADS()
|
||
|
||
For Each pRow As DataRow In DtPersonal.Rows
|
||
|
||
Dim RRow As DataRow = dt.NewRow
|
||
RRow("CvePersonal") = pRow("CvePersonal")
|
||
RRow("NombreCompleto") = pRow("NombreCompleto")
|
||
RRow("Codigo") = pRow("Codigo")
|
||
|
||
ColumN = 3
|
||
|
||
Dim ResumenDia As New DataTable
|
||
Dim DTTempAsistencias As New DataTable
|
||
Dim filtro As String
|
||
Dim TipoCorto As String = ""
|
||
|
||
For Each drow As DataRow In DTFechas.Rows
|
||
|
||
filtro = " CvePersonal = " & pRow("CvePersonal").ToString() & " AND Fecha ='" & drow(0).ToString() & $"'"
|
||
ResumenDia = DtResultados.FiltraParametros(filtro)
|
||
filtro = filtro & $"|{ResumenDia(0)("HorasDobles").ToString}|{ResumenDia(0)("HorasTriples").ToString}|{ResumenDia(0)("CveMotivoHoraExtra").ToString}|{ResumenDia(0)("Observacion").ToString}|{ResumenDia(0)("PorcentajePago").ToString}"
|
||
|
||
|
||
TipoCorto = ""
|
||
|
||
If RdbChecador.Checked Then
|
||
|
||
RRow(ColumN) = "-"
|
||
|
||
If ResumenDia(0)("TipoCorto").ToString().Length > 0 Then
|
||
|
||
RRow(ColumN) = $"{ResumenDia(0)("TipoCorto").ToString()}|" & filtro
|
||
|
||
Else
|
||
|
||
If ResumenDia(0)("Asistio").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "A" Then
|
||
RRow(ColumN) = "A|" & filtro
|
||
End If
|
||
|
||
|
||
If ResumenDia(0)("DiaVacacion").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "V" Then
|
||
RRow(ColumN) = "V|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Asistio").ToString() = "False" Or ResumenDia(0)("TipoCorto").ToString() = "F" Then
|
||
RRow(ColumN) = "F|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Retraso").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "R" Then
|
||
RRow(ColumN) = "R|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("FaltaRetraso").ToString() = "True" Or TipoCorto = "FR" Then
|
||
RRow(ColumN) = "FR|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Descanso").ToString() = "True" Or ResumenDia(0)("DiaInhabil").ToString() = "True" Then
|
||
RRow(ColumN) = "D|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Inconsistencia").ToString() = "True" Then
|
||
RRow(ColumN) = "IN|" & filtro
|
||
If ResumenDia(0)("Descanso").ToString() = "True" Then
|
||
RRow(ColumN) = "IND|" & filtro
|
||
End If
|
||
End If
|
||
|
||
|
||
End If
|
||
|
||
|
||
Else
|
||
|
||
DTTempAsistencias = DTAsistenciasInasistenciasReg.FiltraParametros(filtro)
|
||
If DTTempAsistencias.Rows.Count > 0 Then
|
||
TipoCorto = DTTempAsistencias(0)("TipoCorto").ToString()
|
||
Else
|
||
TipoCorto = "F"
|
||
End If
|
||
|
||
RRow(ColumN) = "" & TipoCorto & "|" & filtro
|
||
|
||
End If
|
||
|
||
ColumN = ColumN + 1
|
||
|
||
Next
|
||
|
||
ResumenDia.Dispose()
|
||
DTTempAsistencias.Dispose()
|
||
|
||
dt.Rows.Add(RRow)
|
||
|
||
Next
|
||
|
||
|
||
Dim SalidaTiempo As Integer = (NowADS() - medida).TotalSeconds.ToString().ToEntero
|
||
SalidaTiempo = SalidaTiempo
|
||
DtDatosTabla = dt
|
||
|
||
Else
|
||
DtDatosTabla = Nothing
|
||
objRH.Dispose()
|
||
End If
|
||
|
||
GvBind()
|
||
|
||
End Sub
|
||
|
||
Private Sub GvBind()
|
||
|
||
Dim Enviado As Boolean = PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero)
|
||
|
||
LnkEnviarAsistencia.Visible = False
|
||
LnkCargaMasiva.Visible = False
|
||
LnkDescargaExcel.Visible = False
|
||
|
||
If DtDatosTabla.Rows.Count > 0 Then
|
||
GVRegDatos.DataSource = DtDatosTabla
|
||
LnkEnviarAsistencia.Visible = True
|
||
LnkDescargaExcel.Visible = True
|
||
|
||
If Not Enviado Then
|
||
LnkCargaMasiva.Visible = True
|
||
End If
|
||
|
||
Else
|
||
GVRegDatos.DataSource = Nothing
|
||
End If
|
||
|
||
GVRegDatos.DataBind()
|
||
UpDatos.Update()
|
||
UpAcciones.Update()
|
||
|
||
End Sub
|
||
|
||
'Private Sub ReprocesarTabla()
|
||
|
||
|
||
|
||
' If DdlTipoPeriodo.SelectedValue.ToEntero > 0 And DdlPeriodo.SelectedValue.ToEntero > 0 Then
|
||
|
||
' Dim dt As New DataTable
|
||
' Dim DtPersonal As New DataTable
|
||
' Dim DTAsistenciasInasistencias As New DataTable
|
||
|
||
' Dim objRH As New ClsRH
|
||
|
||
' If objRH.GetPersonalAsistenciaRegistros(FechaInicioPeriodo, FechaFinPeriodo, UsuarioActual.CveEmpresa) Then
|
||
' DTAsistenciasInasistencias = objRH.DtResultados
|
||
' End If
|
||
|
||
' Dim DtTempPeriodo As DataTable = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue.ToEntero)
|
||
' Dim FechaInicioPeriodoFiltro = DtTempPeriodo(0)("FechaInicio").ToString().ToDate
|
||
|
||
' Dim FilasFiltradas = From fila In GlobalDTRHPersonal(UsuarioActual.Empresa.CveEmpresa).FiltraParametros($" CveTipoPeriodo = { DdlTipoPeriodo.SelectedValue} AND CveEstado = 1 " & If(DdlTurno.SelectedValue = "-1", "", $" AND CveTurno = {DdlTurno.SelectedValue}")).AsEnumerable()
|
||
' Let Inicio = fila.Field(Of Date)("FechaInicio")
|
||
' Let FechaFinOriginal = fila.Field(Of Date?)("FechaFin")
|
||
' Let FechaFin = If(FechaFinOriginal.HasValue, FechaFinOriginal.Value, Now)
|
||
' Where Inicio <= FechaInicioPeriodoFiltro AndAlso FechaInicioPeriodoFiltro <= FechaFin
|
||
' Select fila
|
||
|
||
' 'DtPersonal = FilasFiltradas.CopyToDataTable()
|
||
|
||
' DtPersonal = GlobalDTRHPersonal(UsuarioActual.Empresa.CveEmpresa).FiltraParametros($" CveTipoPeriodo = { DdlTipoPeriodo.SelectedValue} AND CveEstado = 1 " & If(DdlTurno.SelectedValue = "-1", "", $" AND CveTurno = {DdlTurno.SelectedValue}"))
|
||
|
||
' dt.Columns.Add("CvePersonal")
|
||
' dt.Columns.Add("NombreCompleto")
|
||
' 'dt.Columns.Add("Codigo")
|
||
' dt.Columns.Add("Fecha1")
|
||
' dt.Columns.Add("Fecha2")
|
||
' dt.Columns.Add("Fecha3")
|
||
' dt.Columns.Add("Fecha4")
|
||
' dt.Columns.Add("Fecha5")
|
||
' dt.Columns.Add("Fecha6")
|
||
' dt.Columns.Add("Fecha7")
|
||
' dt.Columns.Add("Fecha8")
|
||
' dt.Columns.Add("Fecha9")
|
||
' dt.Columns.Add("Fecha10")
|
||
' dt.Columns.Add("Fecha11")
|
||
' dt.Columns.Add("Fecha12")
|
||
' dt.Columns.Add("Fecha13")
|
||
' dt.Columns.Add("Fecha14")
|
||
' dt.Columns.Add("Fecha15")
|
||
' dt.Columns.Add("Fecha16")
|
||
' dt.Columns.Add("Fecha17")
|
||
' dt.Columns.Add("Fecha18")
|
||
' dt.Columns.Add("Fecha19")
|
||
' dt.Columns.Add("Fecha20")
|
||
' dt.Columns.Add("Fecha21")
|
||
' dt.Columns.Add("Fecha22")
|
||
' dt.Columns.Add("Fecha23")
|
||
' dt.Columns.Add("Fecha24")
|
||
' dt.Columns.Add("Fecha25")
|
||
' dt.Columns.Add("Fecha26")
|
||
' dt.Columns.Add("Fecha27")
|
||
' dt.Columns.Add("Fecha28")
|
||
' dt.Columns.Add("Fecha29")
|
||
' dt.Columns.Add("Fecha30")
|
||
' dt.Columns.Add("Fecha31")
|
||
|
||
' Dim DTFechas As DataTable
|
||
' Dim DTUPersonal As DataTable
|
||
' Dim DTVFechas As New DataView(DtResultados)
|
||
' DTFechas = DTVFechas.ToTable(True, "Fecha")
|
||
' DTUPersonal = DTVFechas.ToTable(True, {"CvePersonal", "NombreCompleto"})
|
||
|
||
' Dim ColumN As Integer = (dt.Columns.Count) - 2
|
||
|
||
' For x As Integer = 3 To ColumN - 1
|
||
' GVRegDatos.Columns(x).HeaderText = ""
|
||
' GVRegDatos.Columns(x).Visible = False
|
||
' Next
|
||
|
||
' ColumN = 3
|
||
' For Each drow As DataRow In DTFechas.Rows
|
||
' GVRegDatos.Columns(ColumN).HeaderText = String.Format("<div class='Widthall' style='text-align:center;font-size:11px!important'>{1}</div><div class='Widthall' style='text-align:center'> {0} </div>", drow(0).ToString().ToDate.ToString("dd/MM/yyyy"), ObtenerDiaSemana(drow(0).ToString().ToDate))
|
||
' GVRegDatos.Columns(ColumN).Visible = True
|
||
' ColumN = ColumN + 1
|
||
' Next
|
||
|
||
' For Each pRow As DataRow In DtPersonal.Rows
|
||
|
||
' Dim RRow As DataRow = dt.NewRow
|
||
' RRow("CvePersonal") = pRow("CvePersonal")
|
||
' RRow("NombreCompleto") = pRow("NombreCompleto")
|
||
' 'RRow("Codigo") = pRow("Codigo")
|
||
|
||
' ColumN = 2
|
||
' For Each drow As DataRow In DTFechas.Rows
|
||
|
||
' Dim filtro As String = " CvePersonal = " & pRow("CvePersonal").ToString() & " AND Fecha ='" & drow(0).ToString() & "' "
|
||
' Dim ResumenDia As DataTable = DtResultados.FiltraParametros(" CvePersonal = " & pRow("CvePersonal").ToString() & " AND Fecha ='" & drow(0).ToString() & "' ")
|
||
|
||
' Dim DTTempAsistencias As DataTable = DTAsistenciasInasistencias.FiltraParametros(" CvePersonal = " & pRow("CvePersonal").ToString() & " AND Fecha ='" & drow(0).ToString() & "' ")
|
||
' Dim TipoCorto As String = ""
|
||
|
||
' If DTTempAsistencias.Rows.Count > 1 Then
|
||
' TipoCorto = DTTempAsistencias(0)("TipoCorto").ToString()
|
||
' End If
|
||
|
||
' If TipoCorto <> "" Then
|
||
|
||
' If TipoCorto = "F" Then
|
||
' RRow(ColumN) = "F" & "|" & filtro
|
||
' End If
|
||
|
||
' If TipoCorto = "R" Then
|
||
' RRow(ColumN) = "R" & "|" & filtro
|
||
' Else
|
||
' If TipoCorto = "A" Then
|
||
' RRow(ColumN) = "A" & "|" & filtro
|
||
' Else
|
||
' If TipoCorto = "D" Then
|
||
' RRow(ColumN) = "D" & "|" & filtro
|
||
' Else
|
||
|
||
' If TipoCorto = "V" Then
|
||
' RRow(ColumN) = "V" & "|" & filtro
|
||
' Else
|
||
' If TipoCorto = "I" Then
|
||
' RRow(ColumN) = "I" & "|" & filtro
|
||
' Else
|
||
' If TipoCorto = "S" Then
|
||
' RRow(ColumN) = "S" & "|" & filtro
|
||
' End If
|
||
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
|
||
' Else
|
||
|
||
' RRow(ColumN) = "-"
|
||
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "" Then
|
||
|
||
' If ResumenDia(0)("Asistio").ToString() = "True" Then
|
||
' RRow(ColumN) = "A|" & filtro
|
||
' End If
|
||
|
||
' If ResumenDia(0)("DiaVacacion").ToString() = "True" Then
|
||
' RRow(ColumN) = "V" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("Asistio").ToString() = "False" Then
|
||
' RRow(ColumN) = "F" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("Retraso").ToString() = "True" Then
|
||
' RRow(ColumN) = "R" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("FaltaRetraso").ToString() = "True" Then
|
||
' RRow(ColumN) = "FR" & "|" & filtro
|
||
' lblModalMensaje.Text = "Falta por retardo"
|
||
' Else
|
||
' If ResumenDia(0)("Descanso").ToString() = "True" Then
|
||
' RRow(ColumN) = "D" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("Inconsistencia").ToString() = "True" Then
|
||
' RRow(ColumN) = "IN" & "|" & filtro
|
||
|
||
' If ResumenDia(0)("Descanso").ToString() = "True" Then
|
||
' RRow(ColumN) = "IND" & "|" & filtro
|
||
' Else
|
||
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "S" Then
|
||
' RRow(ColumN) = "S" & "|" & filtro
|
||
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "M" Then
|
||
' RRow(ColumN) = "M" & "|" & filtro
|
||
|
||
' End If
|
||
' End If
|
||
|
||
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' Else
|
||
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "A" Then
|
||
' RRow(ColumN) = "A" & "|" & filtro
|
||
' End If
|
||
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "V" Then
|
||
' RRow(ColumN) = "V" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "F" Then
|
||
' RRow(ColumN) = "F" & "|" & filtro
|
||
' Else
|
||
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "R" Then
|
||
' RRow(ColumN) = "R" & "|" & filtro
|
||
' Else
|
||
' If TipoCorto = "FR" Then
|
||
' RRow(ColumN) = "FR" & "|" & filtro
|
||
' lblModalMensaje.Text = "Falta por retardo"
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "D" Then
|
||
' RRow(ColumN) = "D" & "|" & filtro
|
||
|
||
' End If
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "I" Then
|
||
' RRow(ColumN) = "I" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "C" Then
|
||
' RRow(ColumN) = "C" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "S" Then
|
||
' RRow(ColumN) = "S" & "|" & filtro
|
||
' Else
|
||
' If ResumenDia(0)("TipoCorto").ToString() = "M" Then
|
||
' RRow(ColumN) = "M" & "|" & filtro
|
||
' End If
|
||
' End If
|
||
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
|
||
' End If
|
||
' ColumN = ColumN + 1
|
||
' Next
|
||
' dt.Rows.Add(RRow)
|
||
' Next
|
||
' Dim stopp As Integer = 0
|
||
' DtDatosTabla = dt
|
||
|
||
' End If
|
||
|
||
|
||
'End Sub
|
||
|
||
Private Function HorarioDiario(Fecha As Date, DTHorarioPersonal As DataTable, DiaDescanso As Integer) As DataTable
|
||
Dim respuesta As New DataTable
|
||
respuesta.Columns.Add("TRABAJO", System.Type.GetType("System.Boolean"))
|
||
|
||
respuesta.Columns.Add("ENTRADA", System.Type.GetType("System.TimeSpan"))
|
||
respuesta.Columns.Add("SALIDACOMIDA", System.Type.GetType("System.TimeSpan"))
|
||
respuesta.Columns.Add("ENTRADACOMIDA", System.Type.GetType("System.TimeSpan"))
|
||
respuesta.Columns.Add("SALIDA", System.Type.GetType("System.TimeSpan"))
|
||
Dim Drow As DataRow = respuesta.NewRow
|
||
Dim drp As DataRow = Nothing
|
||
If DTHorarioPersonal.Rows.Count > 0 Then
|
||
drp = DTHorarioPersonal(0)
|
||
End If
|
||
|
||
Dim diaSemana As Integer = Fecha.DayOfWeek
|
||
|
||
DiaDescanso = If(DiaDescanso > -1, DiaDescanso, 0)
|
||
|
||
Select Case diaSemana
|
||
Case 0
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Domingo").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Domingo").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("DomingoEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("DomingoSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("DomingoEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("DomingoSalida").ToString()))
|
||
|
||
Exit Select
|
||
Case 1
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Lunes").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Lunes").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("LunesEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("LunesSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("LunesEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("LunesSalida").ToString()))
|
||
Exit Select
|
||
Case 2
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Martes").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Martes").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MartesEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MartesSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MartesEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("MartesSalida").ToString()))
|
||
Exit Select
|
||
Case 3
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Miercoles").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Miercoles").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MiercolesEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MiercolesSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("MiercolesEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("MiercolesSalida").ToString()))
|
||
Exit Select
|
||
Case 4
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Jueves").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Jueves").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("JuevesEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("JuevesSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("JuevesEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("JuevesSalida").ToString()))
|
||
Exit Select
|
||
Case 5
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Viernes").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "true", drp("Viernes").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("ViernesEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("ViernesSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("ViernesEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("ViernesSalida").ToString()))
|
||
Exit Select
|
||
Case 6
|
||
Drow(0) = Boolean.Parse(If(IsNothing(drp), $"{(DiaDescanso <> diaSemana).ToString}", drp("Sabado").ToString()))
|
||
'Drow(0) = Boolean.Parse(If(IsNothing(drp), "False", drp("Sabado").ToString()))
|
||
Drow(1) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("SabadoEntrada").ToString()))
|
||
Drow(2) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("SabadoSalidaComida").ToString()))
|
||
Drow(3) = TimeSpan.Parse(If(IsNothing(drp), "00:00", drp("SabadoEntradaComida").ToString()))
|
||
Drow(4) = TimeSpan.Parse(If(IsNothing(drp), "09:00", drp("SabadoSalida").ToString()))
|
||
Exit Select
|
||
End Select
|
||
|
||
respuesta.Rows.Add(Drow)
|
||
|
||
Return respuesta
|
||
End Function
|
||
|
||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||
CargaDatos()
|
||
If PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero) Then
|
||
Alert($"La información del periodo {DdlPeriodo.SelectedItem.Text} ya fue enviada a la pre nómina, esta información ya está bloqueda y si hay ajustes estos se deberán de hacer en pre nóminas")
|
||
End If
|
||
End Sub
|
||
|
||
Private Sub BtnModalFecha_Click(sender As Object, e As EventArgs) Handles BtnModalFecha.Click
|
||
|
||
CalculaPeriodos(New DataTable, DiasPeriodo, CveTipoPeriodo, TxtFechaModal.Text.ToDate)
|
||
TxtFechaModal.Text = ""
|
||
lblTituloPagina.Text = ""
|
||
UpTituloPagina.Update()
|
||
UpModalFechaBody.Update()
|
||
|
||
RegistraScript("$('#ModalModalFecha').modal('hide');")
|
||
End Sub
|
||
|
||
Function CalculaPeriodos(DTNomPeriodos As DataTable, DiasPeriodo As Integer, CveTipoPeriodo As Integer, Optional FechaInicialPeriodos As Date = Nothing) As DataTable
|
||
|
||
Dim DTRespuesta As New DataTable
|
||
Dim FechaLoop As Date
|
||
Dim peridos As String = ""
|
||
Dim ContadorOrden As Integer = 0
|
||
|
||
|
||
DTRespuesta.Columns.Add("Valor")
|
||
DTRespuesta.Columns.Add("Texto")
|
||
DTRespuesta.Columns.Add("Numero")
|
||
DTRespuesta.Columns.Add("Orden")
|
||
|
||
|
||
|
||
If DTNomPeriodos.Rows.Count > 0 Then
|
||
|
||
FechaInicialPeriodos = DTNomPeriodos(DTNomPeriodos.Rows.Count - 1)("FechaFin").ToString().ToDate
|
||
|
||
For Each Row As DataRow In DTNomPeriodos.Rows
|
||
Dim Drow As DataRow = DTRespuesta.NewRow
|
||
Drow("Valor") = Row("FechaInicio").ToString().ToDate().ToString("dd/MM/yyyy") & "-" & Row("FechaFin").ToString().ToDate.ToString("dd/MM/yyyy") & "-" & Row("Numero").ToString()
|
||
Drow("Texto") = Row("FechaInicio").ToString().ToDate().ToString("dd/MM/yyyy") & " - " & Row("FechaFin").ToString().ToDate.ToString("dd/MM/yyyy") & " #" & Row("Numero").ToString() & " Cerrado"
|
||
Drow("Numero") = Row("Numero").ToString()
|
||
Drow("Orden") = ContadorOrden.ToString()
|
||
DTRespuesta.Rows.Add(Drow)
|
||
ContadorOrden += 1
|
||
Next
|
||
|
||
End If
|
||
|
||
'Dim DPI As Integer = DiasPeriodo + 1
|
||
'Dim DPF As Integer = DiasPeriodo
|
||
Dim DiasPerdiodoInicial As Integer = DiasPeriodo
|
||
Dim primeraBuelta As Boolean = True
|
||
Dim DiaDelMesInicial As Integer = FechaInicialPeriodos.Day
|
||
|
||
If Not FechaInicialPeriodos = Nothing And DiasPeriodo > 0 Then
|
||
|
||
FechaLoop = FechaInicialPeriodos
|
||
|
||
While FechaLoop <= NowADS()
|
||
Dim Drow As DataRow = DTRespuesta.NewRow
|
||
Drow("Orden") = ContadorOrden.ToString()
|
||
ContadorOrden += 1
|
||
|
||
'Quincenal
|
||
If CveTipoPeriodo = 4 Then
|
||
If FechaLoop.Day >= 15 Then
|
||
DiasPeriodo = DateTime.DaysInMonth(FechaLoop.Year, FechaLoop.Month) - FechaLoop.Day
|
||
If DiasPeriodo = 0 Then
|
||
DiasPeriodo = 15
|
||
End If
|
||
Else
|
||
DiasPeriodo = 15
|
||
End If
|
||
|
||
If primeraBuelta Then
|
||
peridos = FechaLoop.ToString("dd/MM/yyyy") & " - " & FechaLoop.AddDays(DiasPeriodo - 1).ToString("dd/MM/yyyy")
|
||
primeraBuelta = False
|
||
|
||
FechaLoop = FechaLoop.AddDays(DiasPeriodo - 1)
|
||
|
||
Else
|
||
peridos = FechaLoop.AddDays(1).ToString("dd/MM/yyyy") & " - " & FechaLoop.AddDays(DiasPeriodo).ToString("dd/MM/yyyy")
|
||
FechaLoop = FechaLoop.AddDays(DiasPeriodo)
|
||
End If
|
||
End If
|
||
|
||
'Mensual
|
||
If CveTipoPeriodo = 5 Then
|
||
|
||
DiasPeriodo = FechaLoop.LastDayOfMonth.Day
|
||
Dim diasMes = DateTime.DaysInMonth(FechaLoop.Year, FechaLoop.Month)
|
||
|
||
If DiaDelMesInicial > diasMes Then
|
||
FechaLoop = New Date(FechaLoop.Year, FechaLoop.Month, diasMes)
|
||
Else
|
||
FechaLoop = New Date(FechaLoop.Year, FechaLoop.Month, DiaDelMesInicial)
|
||
End If
|
||
|
||
|
||
peridos = FechaLoop.ToString("dd/MM/yyyy") & " - " & FechaLoop.AddMonths(1).AddDays(-1).ToString("dd/MM/yyyy")
|
||
|
||
|
||
|
||
FechaLoop = FechaLoop.AddMonths(1)
|
||
|
||
End If
|
||
|
||
If CveTipoPeriodo < 4 Then
|
||
|
||
Dim anioActual As Integer = FechaLoop.Year
|
||
Dim AnioDiasPeriodo As Integer = FechaLoop.AddDays(DiasPeriodo).Year
|
||
|
||
If anioActual <> AnioDiasPeriodo Then
|
||
DiasPeriodo = DateTime.DaysInMonth(FechaLoop.Year, FechaLoop.Month) - FechaLoop.Day
|
||
If DiasPeriodo = 0 Then
|
||
DiasPeriodo = DiasPerdiodoInicial
|
||
End If
|
||
End If
|
||
|
||
|
||
If primeraBuelta Then
|
||
peridos = FechaLoop.ToString("dd/MM/yyyy") & " - " & FechaLoop.AddDays(DiasPeriodo - 1).ToString("dd/MM/yyyy")
|
||
primeraBuelta = False
|
||
|
||
FechaLoop = FechaLoop.AddDays(DiasPeriodo - 1)
|
||
|
||
Else
|
||
peridos = FechaLoop.AddDays(1).ToString("dd/MM/yyyy") & " - " & FechaLoop.AddDays(DiasPeriodo).ToString("dd/MM/yyyy")
|
||
FechaLoop = FechaLoop.AddDays(DiasPeriodo)
|
||
End If
|
||
|
||
End If
|
||
|
||
Drow(0) = peridos
|
||
Drow(1) = peridos & " Abierto"
|
||
DTRespuesta.Rows.Add(Drow)
|
||
|
||
End While
|
||
End If
|
||
|
||
Dim DtRespuestaView As DataView = DTRespuesta.DefaultView
|
||
DtRespuestaView.Sort = "orden desc"
|
||
|
||
DTRespuesta = DtRespuestaView.ToTable
|
||
|
||
DdlPeriodo.DataSource = DTRespuesta
|
||
DdlPeriodo.DataBind()
|
||
DdlPeriodo.Items.Insert(0, New ListItem("Seleccionar uno", "-1"))
|
||
'DdlRango.Visible = True
|
||
'LblPeriodo.Visible = True
|
||
UPFiltros.Update()
|
||
|
||
Return DTRespuesta
|
||
|
||
End Function
|
||
|
||
Protected Sub GVRegDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVRegDatos.RowDataBound
|
||
|
||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||
|
||
Dim CountFecha As Integer = 1
|
||
Dim Instruccion As String = ""
|
||
Dim Filtro As String = ""
|
||
Dim lblFaltas As Label = e.Row.FCLabel("lblFaltas")
|
||
lblFaltas.Font.Bold = True
|
||
Dim ContadorFaltas As Integer = 0
|
||
|
||
Dim lnkLink As LinkButton
|
||
Dim NombreLink As String
|
||
Dim separador As Char()
|
||
Dim arrayComands As String()
|
||
|
||
Dim Fecha As Date = FechaInicioPeriodo
|
||
|
||
For x As Integer = 3 To 33
|
||
|
||
NombreLink = "LnkFecha" & CountFecha
|
||
|
||
lnkLink = e.Row.FCLinkButton(NombreLink)
|
||
separador = {"|"c}
|
||
arrayComands = lnkLink.Text.Split(separador)
|
||
Instruccion = arrayComands(0)
|
||
|
||
If Fecha >= NowADS() Then
|
||
lnkLink.Visible = False
|
||
End If
|
||
|
||
If arrayComands.Length > 1 Then Filtro = arrayComands(1) Else Filtro = ""
|
||
|
||
lnkLink.CommandArgument = $"{lnkLink.Text}|{e.Row.DataKey("CvePersonal")}|{e.Row.DataKey("NombreCompleto")}"
|
||
|
||
If Instruccion = "_ND" Then
|
||
lnkLink.Text = "<i class='fa fa-question' aria-hidden='True'></i>"
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
lnkLink.ToolTip = "Inconsistencia"
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
|
||
If Instruccion = "-" Then
|
||
lnkLink.Text = "<i class='fa fa-check-square' aria-hidden='true'></i>"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
lnkLink.ToolTip = "Asistencia"
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "A" Then
|
||
lnkLink.Text = "<i class='fa fa-check-square' aria-hidden='true'></i>"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
lnkLink.ToolTip = "Asistencia"
|
||
lnkLink.Font.Bold = True
|
||
|
||
End If
|
||
|
||
If Instruccion = "F" Then
|
||
lnkLink.Text = "<i class='fa fa-exclamation' aria-hidden='True'></i>"
|
||
lnkLink.ToolTip = "Falta"
|
||
lnkLink.ForeColor = Drawing.Color.Red
|
||
ContadorFaltas = ContadorFaltas + 1
|
||
End If
|
||
|
||
If Instruccion = "FR" Then
|
||
lnkLink.Text = "<i class='fa fa-clock-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Falta por (Retardo)"
|
||
lnkLink.ForeColor = Drawing.Color.Red
|
||
ContadorFaltas = ContadorFaltas + 1
|
||
End If
|
||
|
||
If Instruccion = "DDV" Then
|
||
lnkLink.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Dia de descanso."
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
End If
|
||
|
||
If Instruccion = "D" Or Instruccion = "V" Then
|
||
lnkLink.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Dia de descanso/no laboral/Vacación"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
End If
|
||
|
||
If Instruccion = "DI" Or Instruccion = "V" Then
|
||
lnkLink.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Dia de descanso/no laboral/Vacación"
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
End If
|
||
|
||
If Instruccion = "IN" Then
|
||
lnkLink.Text = "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Inconsistencia"
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "IND" Then
|
||
lnkLink.Text = "<i class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Asistencia en dia no laboral/Descanso"
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "R" Then
|
||
lnkLink.Text = "<i class='fa fa-clock-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Retardo"
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "D" Then
|
||
lnkLink.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Dia de descanso/no laboral"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
End If
|
||
|
||
|
||
If Instruccion = "V" Then
|
||
lnkLink.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Dia de descanso/no laboral"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
End If
|
||
|
||
If Instruccion = "I" Then
|
||
lnkLink.Text = "<i Class='fa fa-medkit' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Incapacidad"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "M" Then
|
||
lnkLink.Text = "<i Class='fa fa-medkit' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Medico"
|
||
lnkLink.ForeColor = Drawing.Color.Green
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "C" Then
|
||
lnkLink.Text = "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Castigo."
|
||
lnkLink.ForeColor = Drawing.Color.Red
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "S" Then
|
||
lnkLink.Text = "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Sanción."
|
||
lnkLink.ForeColor = Drawing.Color.Red
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
If Instruccion = "P" Then
|
||
lnkLink.Text = "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"
|
||
lnkLink.ToolTip = "Permiso."
|
||
lnkLink.ForeColor = Drawing.Color.DarkOrange
|
||
lnkLink.Font.Bold = True
|
||
End If
|
||
|
||
'If Filtro.Length > 0 Then
|
||
' AddHandler lnkLink.Click, AddressOf Me.DetalleDia_Click
|
||
'End If
|
||
CountFecha = CountFecha + 1
|
||
Fecha = Fecha.AddDays(1)
|
||
Next
|
||
|
||
If ContadorFaltas > 0 Then
|
||
lblFaltas.Text = "" & ContadorFaltas
|
||
Else
|
||
lblFaltas.Text = "-"
|
||
End If
|
||
|
||
|
||
If VerChkSeleccionPersonal Then
|
||
e.Row.FCCheckBox("Chk").Visible = True
|
||
End If
|
||
End If
|
||
|
||
If e.Row.RowType = DataControlRowType.Header Then
|
||
If VerChkSeleccionPersonal Then
|
||
e.Row.FCCheckBox("Chk").Visible = True
|
||
End If
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Public Sub DetalleDia_Click(sender As Object, e As EventArgs)
|
||
BtnGuardar.Visible = True
|
||
|
||
If PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero) Then
|
||
BtnGuardar.Visible = False
|
||
End If
|
||
|
||
CvePersonalSeleccionado = -1
|
||
|
||
Dim lnkLinkSender As LinkButton = DirectCast(sender, LinkButton)
|
||
Dim DTDatos As New DataTable
|
||
Dim DTTipoAsistenciaInasistencia As DataTable
|
||
|
||
Dim Instruccion As String = ""
|
||
Dim Filtro As String = ""
|
||
Dim CveEstado As Integer = -1
|
||
Dim DTChecadorRegistros As New DataTable
|
||
Dim separador() As Char = {"|"c}
|
||
Dim arrayComands As String() = lnkLinkSender.CommandArgument.Split(separador)
|
||
|
||
Dim objRH As New ClsRH
|
||
|
||
If objRH.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, False) Then
|
||
DTChecadorRegistros = objRH.DtResultados
|
||
End If
|
||
|
||
objRH.Dispose()
|
||
|
||
Instruccion = arrayComands(0)
|
||
CvePersonalSeleccionado = arrayComands(7).ToEntero
|
||
|
||
LtlAsistenciaHorariosModal.Text = arrayComands(8)
|
||
|
||
DTTipoAsistenciaInasistencia = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltraParametros(" TipoCorto = '" & Instruccion & "' ")
|
||
|
||
If DTTipoAsistenciaInasistencia.Rows.Count > 0 Then
|
||
CveEstado = DTTipoAsistenciaInasistencia(0)(0).ToString().ToEntero
|
||
Else
|
||
CveEstado = -1
|
||
End If
|
||
|
||
If arrayComands.Length > 1 Then Filtro = arrayComands(1) Else Filtro = ""
|
||
|
||
If Filtro.Length > 1 Then
|
||
FiltroAplicado = Filtro
|
||
DTDatos = DTChecadorRegistros.FiltraParametros(Filtro)
|
||
GvDetalleDias.DataSource = DTDatos
|
||
End If
|
||
|
||
GvDetalleDias.DataBind()
|
||
|
||
RegistraScript("$('#divDetallesDia').modal({ backdrop: 'static', keyboard: false});")
|
||
|
||
DTDatos = DtResultados.FiltraParametros(Filtro)
|
||
lblModalFecha.Text = DTDatos(0)("Fecha").ToString().ToDate.ToString("dd/MM/yyyy")
|
||
FechaSeleccionada = DTDatos(0)("Fecha").ToString().ToDate
|
||
|
||
lnkModalImg.Text = ""
|
||
|
||
If Instruccion = "_ND" Then
|
||
lnkModalImg.Text = "<i class='fa fa-question' aria-hidden='True'></i>"
|
||
lnkModalImg.ForeColor = Drawing.Color.DarkOrange
|
||
lnkModalImg.ToolTip = "Inconsistencia"
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Inconsistencia"
|
||
End If
|
||
|
||
If Instruccion = "-" Or Instruccion = "A" Then
|
||
lnkModalImg.Text = "<i class='fa fa-check-square fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ForeColor = Drawing.Color.Green
|
||
lnkModalImg.ToolTip = "Asistencia"
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Asistencia."
|
||
' CveEstado = CveAsistio
|
||
End If
|
||
|
||
If Instruccion = "F" Then
|
||
lnkModalImg.Text = "<i class='fa fa-exclamation fa-3x' aria-hidden='True'></i>"
|
||
lnkModalImg.ToolTip = "Falta"
|
||
lnkModalImg.ForeColor = Drawing.Color.Red
|
||
lblModalMensaje.Text = "Falta"
|
||
' CveEstado = CveFalto
|
||
End If
|
||
|
||
If Instruccion = "FR" Then
|
||
lnkModalImg.Text = "<i class='fa fa-clock-o fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Falta por (Retardo)"
|
||
lnkModalImg.ForeColor = Drawing.Color.Red
|
||
lblModalMensaje.Text = "Falta por retardo."
|
||
' CveEstado = CveFalto
|
||
|
||
End If
|
||
|
||
If Instruccion = "D" Then
|
||
lnkModalImg.Text = "<i Class='fa fa-sun-o fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Dia de descanso/no laboral"
|
||
lnkModalImg.ForeColor = Drawing.Color.Green
|
||
lblModalMensaje.Text = "Dia de descanso/dia no laboral."
|
||
'CveEstado = CveDescanso
|
||
End If
|
||
|
||
|
||
If Instruccion = "DDV" Then
|
||
lnkModalImg.Text = "<i Class='fa fa-sun-o fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Dia de descanso."
|
||
lnkModalImg.ForeColor = Drawing.Color.Green
|
||
lblModalMensaje.Text = "Dia de descanso."
|
||
'CveEstado = CveDescanso
|
||
End If
|
||
|
||
If Instruccion = "DI" Or Instruccion = "V" Then
|
||
lnkModalImg.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Dia de descanso/no laboral/Vacación"
|
||
lnkModalImg.ForeColor = Drawing.Color.DarkOrange
|
||
lblModalMensaje.Text = "Se asistio en dia de descanso."
|
||
End If
|
||
|
||
If Instruccion = "IN" Then
|
||
lnkModalImg.Text = "<i class='fa fa-exclamation-triangle fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Inconsistencia"
|
||
lnkModalImg.ForeColor = Drawing.Color.DarkOrange
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Inconsistencia."
|
||
End If
|
||
|
||
If Instruccion = "I" Then
|
||
lnkModalImg.Text = "<i Class='fa fa-medkit' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Incapacidad"
|
||
lnkModalImg.ForeColor = Drawing.Color.Green
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Incapacidad."
|
||
End If
|
||
|
||
If Instruccion = "V" Then
|
||
lnkModalImg.Text = "<i Class='fa fa-sun-o' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Vacación"
|
||
lnkModalImg.ForeColor = Drawing.Color.Green
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Vacación."
|
||
End If
|
||
|
||
If Instruccion = "IND" Then
|
||
lnkModalImg.Text = "<i class='fa fa-sun-o fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Asistencia en dia no laboral/Descanso"
|
||
lnkModalImg.ForeColor = Drawing.Color.DarkOrange
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Asistencia en día de descanso/día no laboral."
|
||
End If
|
||
|
||
If Instruccion = "R" Then
|
||
lnkModalImg.Text = "<i class='fa fa-clock-o fa-3x' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Retardo"
|
||
lnkModalImg.ForeColor = Drawing.Color.DarkOrange
|
||
lnkModalImg.Font.Bold = True
|
||
lblModalMensaje.Text = "Retardo."
|
||
' CveEstado = CveRetardo
|
||
End If
|
||
|
||
If Instruccion = "C" Then
|
||
lnkModalImg.Text = "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"
|
||
lnkModalImg.ToolTip = "Incapacidad"
|
||
lnkModalImg.ForeColor = Drawing.Color.Red
|
||
lblModalMensaje.Font.Bold = True
|
||
End If
|
||
|
||
|
||
DdlAsistenciaInacistencia.SelectedValueExist(CveEstado)
|
||
|
||
TxtHorasDoblesModal.Text = arrayComands(2)
|
||
TxtHorasTriplesModal.Text = arrayComands(3)
|
||
DdlMotivoHoraExtraModal.SelectedValueExist(arrayComands(4))
|
||
TxtObsModal.Text = arrayComands(5)
|
||
TxtPorcentajePagoModal.Text = arrayComands(6).ToDecimal.ToString("###.00")
|
||
|
||
UpDetallesDia.Update()
|
||
|
||
End Sub
|
||
|
||
Private Function ObtenerDiaSemana(Fecha As Date) As String
|
||
|
||
Dim DiaInt As Integer = Fecha.DayOfWeek
|
||
|
||
Select Case DiaInt
|
||
Case 0
|
||
Return "Domingo"
|
||
Case 1
|
||
Return "Lunes"
|
||
Case 2
|
||
Return "Martes"
|
||
Case 3
|
||
Return "Miercoles"
|
||
Case 4
|
||
Return "Jueves"
|
||
Case 5
|
||
Return "Viernes"
|
||
Case 6
|
||
Return "Sabado"
|
||
End Select
|
||
|
||
Return ""
|
||
|
||
End Function
|
||
|
||
Protected Sub BtnAgregar_Click(sender As Object, e As EventArgs) Handles BtnAgregar.Click
|
||
|
||
Dim objRh As New ClsRH()
|
||
Dim ErrorProceso = False
|
||
|
||
objRh.IniciaTransacSQL()
|
||
|
||
Try
|
||
For Each dRow As DataRow In DtResultados.Rows
|
||
'Dim DDROW As DataRow = dRow
|
||
|
||
Dim _CvePersonal As Integer = dRow("CvePersonal").ToString().ToEntero
|
||
Dim _CveSubProyecto As Integer = dRow("CveSubProyecto").ToString().ToEntero
|
||
Dim _CveTuero As Integer = DdlTurno.SelectedValue.ToEntero
|
||
Dim _Fechas As Date = dRow("Fecha").ToString().ToDate
|
||
Dim _CveAsistenciasInasistencias As Integer = dRow("CveAsistenciasInasistencias").ToString().ToEntero
|
||
Dim _PorcentajePago As Double = Double.Parse(dRow("PorcentajePago").ToString())
|
||
Dim _HorasDobles As Double = 0
|
||
Dim _HorasTriples As Double = 0
|
||
Dim _CveMotivoHoraExtra As Integer = -1
|
||
Dim _Observaciones As String = ""
|
||
Dim _SalarioDiario As Double = dRow("SalarioDiario").ToString().ToDouble
|
||
Dim _Semodifico As Integer = 0
|
||
|
||
If objRh.PreAsistenciaRegistrosAdd(_CvePersonal, _CveSubProyecto, _CveTuero, _Fechas, _CveAsistenciasInasistencias, _PorcentajePago, _HorasDobles, _HorasTriples, _CveMotivoHoraExtra,
|
||
_Observaciones, _SalarioDiario, _Semodifico, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||
ErrorProceso = False
|
||
Else
|
||
ErrorProceso = True
|
||
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
Catch ex As Exception
|
||
objRh.RollBack()
|
||
OnError("Se presento un error al procesar los registros de asistencia.", ex)
|
||
End Try
|
||
|
||
If ErrorProceso = True Then
|
||
objRh.RollBack()
|
||
Else
|
||
objRh.Commit()
|
||
BtnAgregar.Visible = False
|
||
UpAcciones.Update()
|
||
Alert("Proceso realizado correctamente.")
|
||
End If
|
||
objRh.Dispose()
|
||
|
||
|
||
End Sub
|
||
|
||
|
||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
||
If DdlAsistenciaInacistencia.SelectedValue.ToEntero > 0 Then
|
||
Dim ObjPersonal As New ClsRH
|
||
|
||
'If ObjPersonal.AddAsistencia(CvePersonalSeleccionado, -1, DdlSubProyecto.SelectedValue.ToEntero, FechaSeleccionada, DdlAsistenciaInacistencia.SelectedValue.ToEntero, 100, 0, 0, -1, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "C") Then
|
||
|
||
Dim CveMotivoHoraExtra As Integer = If(TxtHorasDobles.Text.ToDecimal = 0 And TxtHorasTriplesModal.Text.ToDecimal = 0, -1, DdlMotivoHoraExtraModal.SelectedValue.ToEntero)
|
||
|
||
If ObjPersonal.AddPreAsistencia(CvePersonalSeleccionado, FechaSeleccionada, DdlAsistenciaInacistencia.SelectedValue.ToEntero, TxtPorcentajePago.Text.ToDouble, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
||
TxtHorasDoblesModal.Text.ToDecimal, TxtHorasTriplesModal.Text.ToDecimal, CveMotivoHoraExtra, TxtObsModal.Text.Trim) Then
|
||
Alert("Registro Actualizado Correctamente.")
|
||
RegistraScript("$('#divDetallesDia').modal('hide');")
|
||
CargaDatos()
|
||
|
||
|
||
End If
|
||
|
||
ObjPersonal.Dispose()
|
||
End If
|
||
End Sub
|
||
|
||
Protected Sub LnkEnviarAsistencia_Click(sender As Object, e As EventArgs)
|
||
EnviarPreAsistencia()
|
||
'ValidaEnvioAsistencia
|
||
'EnviarAsistencia
|
||
|
||
End Sub
|
||
|
||
|
||
Private Sub ValidaEnvioAsistencia()
|
||
|
||
'Dim DTChecadorRegistros As New DataTable
|
||
|
||
Dim ObjPersonal As New ClsRH
|
||
|
||
'If ObjPersonal.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||
' DTChecadorRegistros = ObjPersonal.DtResultados
|
||
'End If
|
||
|
||
ObjPersonal.IniciaTransacSQL()
|
||
Dim TieneError As Boolean = False
|
||
|
||
Dim separador() As Char = {"|"c}
|
||
|
||
Try
|
||
For Each GvRow As GridViewRow In GVRegDatos.Rows
|
||
|
||
Dim CvePersonal As Integer = GvRow.DataKey("CvePersonal").ToEntero
|
||
Dim NombreCompleto As String = GvRow.DataKey("NombreCompleto")
|
||
|
||
Dim Fecha As Date = FechaInicioPeriodo
|
||
For x = 3 To GVRegDatos.Columns.Count - 1
|
||
|
||
If GVRegDatos.Columns(x).Visible Then
|
||
|
||
Dim lnkLinkSender As LinkButton = TryCast(GvRow.Cells(x).Controls(1), LinkButton)
|
||
|
||
If lnkLinkSender IsNot Nothing Then
|
||
Dim arrayComands As String() = lnkLinkSender.CommandArgument.Split(separador)
|
||
Dim TipoCorto = arrayComands(0)
|
||
Dim Filtro = arrayComands(1)
|
||
|
||
If TipoCorto.Contiene("_ND", "") Then
|
||
TieneError = True
|
||
Exit For
|
||
Else
|
||
'ok
|
||
End If
|
||
End If
|
||
End If
|
||
Fecha = Fecha.AddDays(1)
|
||
Next
|
||
If TieneError Then
|
||
Exit For
|
||
End If
|
||
Next
|
||
Catch ex As Exception
|
||
TieneError = True
|
||
End Try
|
||
|
||
|
||
If TieneError Then
|
||
ObjPersonal.RollBack()
|
||
Alert("Se presento un error al enviar asistencia.", TipoMensaje.MsgAdvertencia)
|
||
Else
|
||
ObjPersonal.Commit()
|
||
Alert("Asistencia enviada correctamente.")
|
||
End If
|
||
|
||
ObjPersonal.Dispose()
|
||
|
||
End Sub
|
||
Private Sub EnviarAsistencia()
|
||
|
||
'Dim ObjPersonal As New ClsRH
|
||
|
||
'ObjPersonal.IniciaTransacSQL()
|
||
'Dim TieneError As Boolean = False
|
||
|
||
'Dim separador() As Char = {"|"c}
|
||
|
||
'Try
|
||
' For Each GvRow As GridViewRow In GVRegDatos.Rows
|
||
|
||
' Dim CvePersonal As Integer = GvRow.DataKey("CvePersonal").ToEntero
|
||
' Dim NombreCompleto As String = GvRow.DataKey("NombreCompleto")
|
||
|
||
' Dim Fecha As Date = FechaInicioPeriodo
|
||
' For x = 3 To GVRegDatos.Columns.Count - 1
|
||
|
||
' If GVRegDatos.Columns(x).Visible Then
|
||
|
||
' Dim lnkLinkSender As LinkButton = TryCast(GvRow.Cells(x).Controls(1), LinkButton)
|
||
|
||
' If lnkLinkSender IsNot Nothing Then
|
||
' Dim arrayComands As String() = lnkLinkSender.CommandArgument.Split(separador)
|
||
' Dim TipoCorto = arrayComands(0)
|
||
' Dim Filtro = arrayComands(1)
|
||
|
||
' If TipoCorto.Contiene("_ND", "") Then
|
||
' TieneError = True
|
||
' Exit For
|
||
' Else
|
||
' Dim DTTipoAsistenciaInasistencia As DataTable = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltraParametros(" TipoCorto = '" & TipoCorto & "' ")
|
||
|
||
' Dim CveAsistenciasInasistencias As Integer = DTTipoAsistenciaInasistencia(0)("CveAsistenciasInasistencias").ToString.ToEntero
|
||
' Dim PorcentajePago As Integer = If(DTTipoAsistenciaInasistencia(0)("AplicaPago").ToString = "Aplica", 100, 0)
|
||
|
||
' If CveAsistenciasInasistencias > 0 Then
|
||
' If Not ObjPersonal.AddAsistencia(CvePersonal, -1, DdlSubProyecto.SelectedValue.ToEntero, Fecha, CveAsistenciasInasistencias, PorcentajePago, 0, 0, -1, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "C") Then
|
||
' TieneError = True
|
||
' Exit For
|
||
' End If
|
||
' Else
|
||
' TieneError = True
|
||
' Exit For
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' End If
|
||
' Fecha = Fecha.AddDays(1)
|
||
' Next
|
||
' If TieneError Then
|
||
' Exit For
|
||
' End If
|
||
' Next
|
||
'Catch ex As Exception
|
||
' TieneError = True
|
||
'End Try
|
||
|
||
|
||
'If TieneError Then
|
||
' ObjPersonal.RollBack()
|
||
' Alert("Se presento un error al enviar asistencia.", TipoMensaje.MsgAdvertencia)
|
||
'Else
|
||
' ObjPersonal.Commit()
|
||
' Alert("Asistencia enviada correctamente.")
|
||
'End If
|
||
|
||
'ObjPersonal.Dispose()
|
||
End Sub
|
||
|
||
Protected Sub LnkCargaMasiva_Click(sender As Object, e As EventArgs)
|
||
|
||
DVEnvioMasivo.Visible = False
|
||
Dim Enviado As Boolean = PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero)
|
||
|
||
If Enviado Then
|
||
Alert($"La información del periodo {DdlPeriodo.SelectedItem.Text} ya fue enviada a la pre nómina, esta información ya está bloqueda y si hay ajustes estos se deberán de hacer en pre nóminas")
|
||
Else
|
||
DVEnvioMasivo.Visible = True
|
||
End If
|
||
|
||
VerChkSeleccionPersonal = True
|
||
|
||
UpDatos.Update()
|
||
GvBind()
|
||
|
||
End Sub
|
||
|
||
Private Function PeriodoBloqueado(CvePeriodo As Integer) As Boolean
|
||
Dim respuesta As Boolean = True
|
||
If CvePeriodo > 0 Then
|
||
Using objPeriodos As New ClsNominas()
|
||
If objPeriodos.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) Then
|
||
|
||
If objPeriodos.DtResultados.Rows.Count > 0 Then
|
||
respuesta = Boolean.Parse(objPeriodos.DtResultados.Rows(0)("PreAsistenciaEnviada").ToString)
|
||
Else
|
||
respuesta = False
|
||
End If
|
||
|
||
End If
|
||
End Using
|
||
End If
|
||
|
||
Return respuesta
|
||
|
||
End Function
|
||
|
||
|
||
Protected Sub DdlPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||
|
||
Dim Enviado As Boolean = PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero)
|
||
|
||
If Enviado Then
|
||
LnkEnviarAsistencia.Visible = False
|
||
'LnkCargaMasiva.Visible = False
|
||
Else
|
||
LnkEnviarAsistencia.Visible = True
|
||
'LnkCargaMasiva.Visible = True
|
||
End If
|
||
|
||
UPFiltros.Update()
|
||
|
||
End Sub
|
||
|
||
Protected Sub LnklEnviarCargaMasiva_Click(sender As Object, e As EventArgs)
|
||
|
||
|
||
Dim Enviado As Boolean = PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero)
|
||
|
||
If Enviado Then
|
||
Alert($"La información del periodo {DdlPeriodo.SelectedItem.Text} ya fue enviada a la pre nómina, esta información ya está bloqueda y si hay ajustes estos se deberán de hacer en pre nóminas")
|
||
Exit Sub
|
||
End If
|
||
|
||
Dim FechaCarga As Date = TxtFechaCargaMasiva.Text.ToDate
|
||
Dim ProcesoOK As Boolean = True
|
||
|
||
If Not (FechaCarga >= FechaInicioPeriodo AndAlso FechaCarga <= FechaFinPeriodo) Then
|
||
Alert("La fecha de carga masiva debe de estar en el rango de fechas del período seleccionado.", TipoMensaje.MsgAdvertencia)
|
||
Exit Sub
|
||
End If
|
||
|
||
If DdlMotivoHoraExtra.SelectedValue.ToEntero > 0 And (TxtHorasDobles.Text.ToDecimal > 0 And TxtHorasTriples.Text.ToDecimal > 0) Then
|
||
Alert("Debe seleccionar un motivo de horas extra.", TipoMensaje.MsgAdvertencia)
|
||
Exit Sub
|
||
End If
|
||
|
||
Dim ObjRH As New ClsRH
|
||
ObjRH.IniciaTransacSQL()
|
||
|
||
|
||
For Each GvRow As GridViewRow In GVRegDatos.Rows
|
||
|
||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||
|
||
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
||
|
||
If Chk.Checked Then
|
||
Dim CvePersonal As Integer = GvRow.DataKey("CvePersonal").ToEntero
|
||
If Not ObjRH.AddPreAsistencia(CvePersonal, FechaCarga, DdlAsistenciaInacistenciaCarga.SelectedValue.ToEntero, TxtPorcentajePago.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
||
TxtHorasDobles.Text.ToDecimal, TxtHorasTriples.Text.ToDecimal, DdlMotivoHoraExtra.SelectedValue.ToEntero, TxtObs.Text) Then
|
||
ProcesoOK = False
|
||
Exit For
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
Next
|
||
|
||
If ProcesoOK Then
|
||
'ProcesoOK =
|
||
|
||
End If
|
||
|
||
If ProcesoOK Then
|
||
ObjRH.Commit()
|
||
Alert("Carga realizada correctamente.")
|
||
CargaDatos()
|
||
Else
|
||
ObjRH.RollBack()
|
||
End If
|
||
End Sub
|
||
|
||
|
||
Private Sub EnviarPreAsistencia()
|
||
|
||
If Not DdlPeriodo.SelectedValue.ToEntero > 0 Then
|
||
Exit Sub
|
||
End If
|
||
|
||
If PeriodoBloqueado(DdlPeriodo.SelectedValue.ToEntero) Then
|
||
Alert($"La información del periodo {DdlPeriodo.SelectedItem.Text} ya fue enviada a la pre nómina, esta información ya está bloqueda y si hay ajustes estos se deberán de hacer en pre nóminas")
|
||
Exit Sub
|
||
End If
|
||
|
||
|
||
|
||
Dim objRH As New ClsRH
|
||
Dim objGrales As New ClsGenerales
|
||
Dim DTDatos As New DataTable
|
||
Dim DtPersonal As New DataTable
|
||
Dim DTHorarioPersonal As DataTable
|
||
Dim DtVacaciones As New DataTable
|
||
|
||
Dim RetrasosMaximos As Integer = 3
|
||
Dim dt As New DataTable
|
||
|
||
Dim Retardos As Integer = 0
|
||
Dim DTPreAsistenciasInasistencias As New DataTable
|
||
Dim DTChecadorRegistros As New DataTable
|
||
Dim DTHorarios As New DataTable
|
||
Dim DTDiasInhabiles As New DataTable
|
||
Dim DTTipoPeriodo As New DataTable
|
||
Dim DTAsistenciasInasistenciasReg As New DataTable
|
||
|
||
Dim CveChecadorHorario As Integer = -1
|
||
Dim TolRetAcumulados As Integer = 0
|
||
Dim TolRetEntradaMin As Integer = 0
|
||
Dim TolFalEntradaMin As Integer = 0
|
||
Dim RetSalidaAntes As Boolean = True
|
||
Dim TolSalidaAntesMin As Integer = 0
|
||
|
||
Dim CveASistenciaInasistenciaAsistio As Integer = -1
|
||
Dim CveAsistenciaInasistenciaFalta As Integer = -1
|
||
Dim CveAsistenciaInasistenciaRetardo As Integer = -1
|
||
Dim CveAsistenciaInasistenciaDescanso As Integer = -1
|
||
|
||
Try
|
||
CveASistenciaInasistenciaAsistio = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'A'")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaFalta = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'F'")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaRetardo = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'R' ")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
CveAsistenciaInasistenciaDescanso = GlobalDTAsistenciasInasistencias(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" TipoCorto = 'D' ")(0)("CveAsistenciasInasistencias").ToString().ToEntero
|
||
|
||
Catch ex As Exception
|
||
Alert("Se presento un error al obtener las claves de asistencia.", TipoMensaje.MsgError)
|
||
Exit Sub
|
||
End Try
|
||
|
||
GeneraFechasInicioFinPerdiodo()
|
||
|
||
DiasPeriodo = (FechaFinPeriodo - FechaInicioPeriodo).TotalDays.ToEntero + 1
|
||
Dim objNom As New ClsNominas
|
||
|
||
If objNom.GetTiposPeriodos() Then
|
||
DdlTipoPeriodo.DataSource = objNom.DtResultados
|
||
DTTipoPeriodo = objNom.DtResultados
|
||
End If
|
||
|
||
objNom.Dispose()
|
||
|
||
If objGrales.DiasInhabiles_Get(-1, 1, UsuarioActual.CveEmpresa) Then
|
||
DTDiasInhabiles = objGrales.DtResultados
|
||
End If
|
||
|
||
objGrales.Dispose()
|
||
|
||
Dim Resultados As New DataTable
|
||
|
||
Resultados.Columns.Add("CvePersonal")
|
||
Resultados.Columns.Add("NombreCompleto")
|
||
Resultados.Columns.Add("Codigo")
|
||
Resultados.Columns.Add("CveSubProyecto")
|
||
Resultados.Columns.Add("SalarioDiario")
|
||
Resultados.Columns.Add("CveAsistenciasInasistencias")
|
||
Resultados.Columns.Add("PorcentajePago")
|
||
Resultados.Columns.Add("Fecha")
|
||
Resultados.Columns.Add("Asistio")
|
||
Resultados.Columns.Add("Retraso")
|
||
Resultados.Columns.Add("Inconsistencia")
|
||
Resultados.Columns.Add("Descanso")
|
||
Resultados.Columns.Add("Entrada")
|
||
Resultados.Columns.Add("Salida")
|
||
Resultados.Columns.Add("FaltaRetraso")
|
||
Resultados.Columns.Add("DiaInhabil")
|
||
Resultados.Columns.Add("FaltaPorRetrasos")
|
||
Resultados.Columns.Add("Mensaje")
|
||
Resultados.Columns.Add("FaltaRetardosAcumulados")
|
||
Resultados.Columns.Add("DiaInhabilStr")
|
||
Resultados.Columns.Add("DiaVacacion")
|
||
Resultados.Columns.Add("TipoCorto")
|
||
Resultados.Columns.Add("Sancion")
|
||
|
||
Resultados.Columns.Add("HorasDobles", GetType(Decimal))
|
||
Resultados.Columns.Add("HorasTriples", GetType(Decimal))
|
||
Resultados.Columns.Add("CveMotivoHoraExtra", GetType(Integer))
|
||
Resultados.Columns.Add("Observacion")
|
||
|
||
|
||
Dim DtTempPeriodo As DataTable = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue.ToEntero)
|
||
Dim FechaInicioPeriodoFiltro = DtTempPeriodo(0)("FechaInicio").ToString().ToDate
|
||
|
||
Dim FilCveDepartamento As Integer = DdlDepartamento.SelectedValue.ToEntero
|
||
|
||
Dim FilasFiltradas = From fila In GlobalDTRHPersonal(UsuarioActual.Empresa.CveEmpresa).AsEnumerable()
|
||
Let Inicio = fila.Field(Of Date)("FechaInicio")
|
||
Let FechaFinOriginal = fila.Field(Of Date?)("FechaFin")
|
||
Let FechaFin = If(FechaFinOriginal.HasValue, FechaFinOriginal.Value, Now)
|
||
Where Inicio <= FechaInicioPeriodoFiltro AndAlso FechaInicioPeriodoFiltro <= FechaFin
|
||
Select fila
|
||
|
||
DtPersonal = FilasFiltradas.CopyToDataTable()
|
||
|
||
|
||
|
||
If objRH.ChecadorHorariosGet(-1, 1, UsuarioActual.Empresa.CveEmpresa) Then
|
||
DTHorarios = objRH.DtResultados
|
||
|
||
If DdlTurno.SelectedIndex > 0 Then
|
||
Dim DTTemp As DataTable = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltraParametros("CveTurno = " & DdlTurno.SelectedValue)
|
||
Dim TMCveChecadorHorario As Integer = -1
|
||
|
||
If DTTemp.Rows.Count > 0 Then
|
||
TMCveChecadorHorario = DTTemp(0)("CveChecadorHorario").ToString().ToEntero
|
||
Dim DtHorarioTemp = DTHorarios.FiltraParametros("CveChecadorHorario = " & TMCveChecadorHorario)
|
||
|
||
If DtHorarioTemp.Rows.Count > 0 Then
|
||
TolRetAcumulados = DtHorarioTemp(0)("TolRetAcumulados").ToString().ToEntero
|
||
TolRetEntradaMin = DtHorarioTemp(0)("TolRetEntradaMin").ToString().ToEntero
|
||
TolFalEntradaMin = DtHorarioTemp(0)("TolFalEntradaMin").ToString().ToEntero
|
||
RetSalidaAntes = Boolean.Parse(DtHorarioTemp(0)("RetSalidaAntes").ToString())
|
||
TolSalidaAntesMin = DtHorarioTemp(0)("TolSalidaAntesMin").ToString().ToEntero
|
||
End If
|
||
End If
|
||
Else
|
||
If DTHorarios.Rows.Count > 0 Then
|
||
TolRetAcumulados = DTHorarios(0)("TolRetAcumulados").ToString().ToEntero
|
||
TolRetEntradaMin = DTHorarios(0)("TolRetEntradaMin").ToString().ToEntero
|
||
TolFalEntradaMin = DTHorarios(0)("TolFalEntradaMin").ToString().ToEntero
|
||
RetSalidaAntes = Boolean.Parse(DTHorarios(0)("RetSalidaAntes").ToString())
|
||
TolSalidaAntesMin = DTHorarios(0)("TolSalidaAntesMin").ToString().ToEntero
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
If objRH.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, False) Then
|
||
DTChecadorRegistros = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.VacacionesGet(-1, UsuarioActual.Empresa.CveEmpresa, FechaInicioPeriodo, FechaFinPeriodo) Then
|
||
DtVacaciones = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.GetPersonalPreAsistenciaRegistros(FechaInicioPeriodo, FechaFinPeriodo, UsuarioActual.CveEmpresa) Then
|
||
DTPreAsistenciasInasistencias = objRH.DtResultados
|
||
End If
|
||
|
||
If objRH.ChecadorPreAsistenciaRegistrosAsistenciasGet(CveTipoPeriodo, FechaInicioPeriodo, FechaFinPeriodo, UsuarioActual.Empresa.CveEmpresa) Then
|
||
DTAsistenciasInasistenciasReg = objRH.DtResultados
|
||
End If
|
||
|
||
objRH.Dispose()
|
||
|
||
|
||
For Each dRow As DataRow In DtPersonal.Rows
|
||
|
||
Dim Fecha As Date = FechaInicioPeriodo
|
||
Dim ContadorFaltas As Integer = 0
|
||
objRH = New ClsRH
|
||
If objRH.PreAsistenciaRegistrosGet(FechaInicioPeriodo, FechaFinPeriodo, DdlTurno.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, True) Then
|
||
DTChecadorRegistros = objRH.DtResultados
|
||
End If
|
||
objRH.Dispose()
|
||
|
||
Dim registrosPersonal As DataTable = DTChecadorRegistros.FiltraParametros(" CvePersonal = " & dRow(0).ToString())
|
||
|
||
Dim CveTurno As Integer = dRow("CveTurno").ToString.ToEntero
|
||
Dim DiaDescanso As Integer = GlobalDTTurno(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DiaDescanso", $" CveTurno = {CveTurno} ").ToEntero - 1 'El -1 es por que en .net el domingo empieza 0 y en la sql en 1
|
||
Dim Codigo As String = dRow("Codigo").ToString
|
||
|
||
If registrosPersonal.Rows.Count > 0 Then
|
||
DTHorarioPersonal = DTHorarios.FiltraParametros(" CveChecadorHorario = " & registrosPersonal(0)("CveHorario").ToString() & "")
|
||
Retardos = 0
|
||
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("PorcentajePago") = "0"
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("FaltaRetraso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
Dim diaSemana As Integer = Fecha.DayOfWeek
|
||
Dim Asistencia As Boolean = True
|
||
|
||
Dim Horario As DataTable = HorarioDiario(Fecha, DTHorarioPersonal, DiaDescanso)
|
||
Dim DiaLaboral As Boolean = Boolean.Parse(Horario(0)(0).ToString())
|
||
|
||
Dim HorarioEntrada As TimeSpan = TimeSpan.Parse(Horario(0)(1).ToString())
|
||
Dim HorarioSalidaComida As TimeSpan = TimeSpan.Parse(Horario(0)(2).ToString())
|
||
Dim HorarioEntradaComida As TimeSpan = TimeSpan.Parse(Horario(0)(3).ToString())
|
||
Dim HorarioSalida As TimeSpan = TimeSpan.Parse(Horario(0)(4).ToString())
|
||
|
||
Dim FechaHoraEntrada As DateTime
|
||
Dim FechahoraSalida As DateTime
|
||
Dim turnoNocturno As Boolean
|
||
|
||
Dim FechaHoraRegistroEntrada As DateTime
|
||
Dim FechaHoraRegistroSalida As DateTime
|
||
|
||
FechaHoraEntrada = Fecha + HorarioEntrada
|
||
If Not turnoNocturno Then
|
||
FechahoraSalida = Fecha + HorarioEntrada + (HorarioSalida - HorarioEntrada)
|
||
Else
|
||
FechahoraSalida = FechahoraSalida.AddDays(1) - HorarioEntrada + HorarioSalida
|
||
End If
|
||
|
||
Dim tempDatetime1 As DateTime = FechaHoraEntrada.AddHours(-2) 'la entrada se podra checar hasta dos horas antes de la hora de entrada
|
||
Dim tempDatetime2 As DateTime = FechahoraSalida.AddHours(4) 'Legalmente no se pueden hacer mas de 3 horas extras al día
|
||
|
||
Dim tabladelDia As DataTable = registrosPersonal.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND FechaRegistro >= '" & tempDatetime1.ToShortDateString & "' AND FechaRegistro <= '" & tempDatetime2.ToString() & "'")
|
||
|
||
|
||
If DTPreAsistenciasInasistencias.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND Fecha = '" & Fecha & "'").Rows.Count > 0 Then
|
||
|
||
Dim DTPreasistencia As DataTable = DTPreAsistenciasInasistencias.FiltraParametros(" CvePersonal = " & dRow(0).ToString() & " AND Fecha = '" & Fecha & "'")
|
||
|
||
If DTPreasistencia IsNot Nothing AndAlso DTPreasistencia.Rows.Count > 0 Then
|
||
ReRow("CveAsistenciasInasistencias") = DTPreasistencia.Rows(0)("CveAsistenciasInasistencias").ToString()
|
||
ReRow("HorasDobles") = DTPreasistencia.Rows(0)("HorasDobles").ToString.ToDecimal
|
||
ReRow("HorasTriples") = DTPreasistencia.Rows(0)("HorasTriples").ToString.ToDecimal
|
||
ReRow("CveMotivoHoraExtra") = DTPreasistencia.Rows(0)("CveMotivoHoraExtra").ToString.ToEntero
|
||
ReRow("Observacion") = DTPreasistencia.Rows(0)("Observacion").ToString
|
||
ReRow("PorcentajePago") = DTPreasistencia.Rows(0)("PorcentajePago").ToString.ToDecimal
|
||
|
||
End If
|
||
|
||
If ReRow("CveAsistenciasInasistencias").ToString.ToEntero > 0 Then
|
||
|
||
Dim drowAsistenciaInasistencia As DataRow = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltroPrimero($"CveAsistenciasInasistencias={ReRow("CveAsistenciasInasistencias").ToString.ToEntero}")
|
||
|
||
ReRow("Asistio") = drowAsistenciaInasistencia("AplicaAsistencia").ToString = "Aplica"
|
||
ReRow("PorcentajePago") = DTPreAsistenciasInasistencias(0)("PorcentajePago").ToString.ToDecimal
|
||
ReRow("Descanso") = drowAsistenciaInasistencia("AplicaVacacion").ToString = "Aplica"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaVacacion") = drowAsistenciaInasistencia("AplicaVacacion").ToString = "Aplica"
|
||
ReRow("FaltaRetardosAcumulados") = drowAsistenciaInasistencia("AplicaFalta").ToString = "Aplica"
|
||
ReRow("Retraso") = drowAsistenciaInasistencia("AplicaRetardo").ToString = "Aplica"
|
||
ReRow("FaltaRetraso") = False 'Not drowAsistenciaInasistencia("AplicaAsistencia").ToString = "Aplica"
|
||
ReRow("TipoCorto") = drowAsistenciaInasistencia("TipoCorto").ToString
|
||
|
||
End If
|
||
End If
|
||
|
||
If Not ReRow("CveAsistenciasInasistencias").ToString.ToEntero > 0 Then
|
||
|
||
'If tabladelDia.Rows.Count > 0 AndAlso tabladelDia.Rows.Count <> 4 And DiaLaboral = False Then
|
||
If tabladelDia.Rows.Count > 0 AndAlso tabladelDia.Rows.Count <> 4 Then
|
||
'Dim drowAsistenciaInasistencia As DataRow = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltroPrimero($"CveAsistenciasInasistencias={ReRow("CveAsistenciasInasistencias").ToString.ToEntero}")
|
||
|
||
ReRow("Asistio") = False
|
||
ReRow("PorcentajePago") = 0
|
||
ReRow("Descanso") = False
|
||
ReRow("DiaInhabil") = False
|
||
ReRow("DiaVacacion") = False
|
||
ReRow("FaltaRetardosAcumulados") = False
|
||
ReRow("Retraso") = False
|
||
ReRow("FaltaRetraso") = False
|
||
ReRow("TipoCorto") = "_ND"
|
||
|
||
Else
|
||
Dim CountRegistros As Integer = tabladelDia.Rows.Count
|
||
Dim Inconsistencia As Boolean = False
|
||
|
||
If Not DiaLaboral Then
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("Descanso") = "True"
|
||
End If
|
||
|
||
Dim TempDTValidaciones As DataTable = DTDiasInhabiles.FiltraParametros(" FechaInhabil = '" & Fecha.ToString() & "'")
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("DiaInhabil") = "True"
|
||
ReRow("DiaInhabilStr") = TempDTValidaciones(0)("DiaInhabil").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
End If
|
||
|
||
TempDTValidaciones = DtVacaciones.FiltraParametros(" Fecha = '" & Fecha.ToString() & "' AND CvePersonal = " & dRow(0).ToString())
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaVacacion") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
|
||
Else
|
||
ReRow("DiaVacacion") = "False"
|
||
End If
|
||
|
||
|
||
If Fecha >= NowADS() Then
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
|
||
If ReRow("DiaVacacion").ToString() <> "True" And ReRow("Descanso").ToString() <> "True" Then
|
||
|
||
If CountRegistros > 0 Then
|
||
|
||
FechaHoraRegistroEntrada = DateTime.Parse(tabladelDia(0)("FechaRegistro").ToString())
|
||
FechaHoraRegistroSalida = DateTime.Parse(tabladelDia(tabladelDia.Rows.Count - 1)("FechaRegistro").ToString())
|
||
|
||
If Not (FechaHoraRegistroEntrada - FechaHoraEntrada).TotalMinutes > TolFalEntradaMin Then
|
||
If (FechaHoraRegistroEntrada - FechaHoraEntrada).TotalMinutes > TolRetEntradaMin Then
|
||
|
||
Retardos = Retardos + 1
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Retardo"
|
||
|
||
If Retardos >= TolRetAcumulados Then
|
||
ReRow("Asistio") = "False"
|
||
ReRow("FaltaRetardosAcumulados") = "True"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & " Falta por " & TolRetAcumulados & " acumulados. "
|
||
Retardos = 0
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaRetardo
|
||
ReRow("PorcentajePago") = "100"
|
||
End If
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
End If
|
||
Else
|
||
Asistencia = False
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Falta por retardo."
|
||
ReRow("FaltaRetraso") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
If FechahoraSalida > FechaHoraRegistroSalida Then
|
||
|
||
Dim diferenciasalidaMinutos As Integer = (FechahoraSalida - FechaHoraRegistroSalida).TotalMinutes.ToString().ToEntero
|
||
|
||
If RetSalidaAntes Then
|
||
If diferenciasalidaMinutos > TolSalidaAntesMin Then
|
||
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "True"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Retraso por salida antes de tiempo (" & diferenciasalidaMinutos & " minutos)."
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaRetardo
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("Asistio") = "True"
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Mensaje") = ReRow("Mensaje").ToString() & vbLf & "Salida antes de tiempo (" & diferenciasalidaMinutos & " minutos)."
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
ReRow("PorcentajePago") = "100"
|
||
|
||
End If
|
||
End If
|
||
End If
|
||
|
||
Else
|
||
ReRow("Asistio") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
If ReRow("Asistio").ToString() = "True" Then ReRow("PorcentajePago") = "100" Else ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
|
||
End If
|
||
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next x
|
||
Else
|
||
|
||
For x As Integer = 1 To (DiasPeriodo)
|
||
|
||
Dim ReRow As DataRow = Resultados.NewRow
|
||
|
||
ReRow("CvePersonal") = dRow(0).ToString()
|
||
ReRow("NombreCompleto") = dRow("NombreCompleto").ToString()
|
||
ReRow("Codigo") = Codigo
|
||
ReRow("CveSubProyecto") = dRow("CveSubProyecto").ToString()
|
||
ReRow("SalarioDiario") = dRow("SalarioDiario").ToString()
|
||
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
ReRow("PorcentajePago") = "0"
|
||
|
||
ReRow("Fecha") = Fecha.ToString()
|
||
ReRow("Retraso") = "False"
|
||
ReRow("Inconsistencia") = "False"
|
||
ReRow("Descanso") = "False"
|
||
ReRow("FaltaPorRetrasos") = "False"
|
||
ReRow("Entrada") = "ND"
|
||
ReRow("Salida") = "ND"
|
||
ReRow("Mensaje") = ""
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("FaltaRetardosAcumulados") = "False"
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("DiaVacacion") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = "-1"
|
||
ReRow("TipoCorto") = ""
|
||
ReRow("Sancion") = "False"
|
||
|
||
ReRow("HorasDobles") = 0
|
||
ReRow("HorasTriples") = 0
|
||
ReRow("CveMotivoHoraExtra") = -1
|
||
ReRow("Observacion") = ""
|
||
|
||
If dRow("CveChecadorHorario").ToString().ToEntero > 0 Then
|
||
|
||
DTHorarioPersonal = DTHorarios.FiltraParametros(" CveChecadorHorario = " & dRow("CveChecadorHorario").ToString().ToEntero & "")
|
||
|
||
If Fecha >= NowADS() Then
|
||
ReRow("Asistio") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveASistenciaInasistenciaAsistio
|
||
Else
|
||
ReRow("Asistio") = "False"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaFalta
|
||
End If
|
||
|
||
Dim Horario As DataTable = HorarioDiario(Fecha, DTHorarioPersonal, DiaDescanso)
|
||
Dim DiaLaboral As Boolean = Boolean.Parse(Horario(0)(0).ToString())
|
||
|
||
If Not DiaLaboral Then
|
||
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
ReRow("Descanso") = "True"
|
||
Else
|
||
|
||
Dim TempDTValidaciones As DataTable = DTDiasInhabiles.FiltraParametros(" FechaInhabil = '" & Fecha.ToString() & "'")
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaInhabil") = "True"
|
||
ReRow("DiaInhabilStr") = TempDTValidaciones(0)("DiaInhabil").ToString()
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaInhabil") = "False"
|
||
ReRow("DiaInhabilStr") = ""
|
||
ReRow("PorcentajePago") = "0"
|
||
End If
|
||
|
||
TempDTValidaciones = DtVacaciones.FiltraParametros(" Fecha = '" & Fecha.ToString() & "' AND CvePersonal = " & dRow(0).ToString())
|
||
|
||
If TempDTValidaciones.Rows.Count > 0 Then
|
||
ReRow("DiaVacacion") = "True"
|
||
ReRow("CveAsistenciasInasistencias") = CveAsistenciaInasistenciaDescanso
|
||
ReRow("PorcentajePago") = "100"
|
||
Else
|
||
ReRow("DiaVacacion") = "False"
|
||
End If
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
Resultados.Rows.Add(ReRow)
|
||
Fecha = Fecha.AddDays(1)
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
|
||
|
||
'DtResultados = Resultados
|
||
|
||
dt.Columns.Add("CvePersonal")
|
||
dt.Columns.Add("Codigo")
|
||
dt.Columns.Add("NombreCompleto")
|
||
dt.Columns.Add("Fecha1")
|
||
dt.Columns.Add("Fecha2")
|
||
dt.Columns.Add("Fecha3")
|
||
dt.Columns.Add("Fecha4")
|
||
dt.Columns.Add("Fecha5")
|
||
dt.Columns.Add("Fecha6")
|
||
dt.Columns.Add("Fecha7")
|
||
dt.Columns.Add("Fecha8")
|
||
dt.Columns.Add("Fecha9")
|
||
dt.Columns.Add("Fecha10")
|
||
dt.Columns.Add("Fecha11")
|
||
dt.Columns.Add("Fecha12")
|
||
dt.Columns.Add("Fecha13")
|
||
dt.Columns.Add("Fecha14")
|
||
dt.Columns.Add("Fecha15")
|
||
dt.Columns.Add("Fecha16")
|
||
dt.Columns.Add("Fecha17")
|
||
dt.Columns.Add("Fecha18")
|
||
dt.Columns.Add("Fecha19")
|
||
dt.Columns.Add("Fecha20")
|
||
dt.Columns.Add("Fecha21")
|
||
dt.Columns.Add("Fecha22")
|
||
dt.Columns.Add("Fecha23")
|
||
dt.Columns.Add("Fecha24")
|
||
dt.Columns.Add("Fecha25")
|
||
dt.Columns.Add("Fecha26")
|
||
dt.Columns.Add("Fecha27")
|
||
dt.Columns.Add("Fecha28")
|
||
dt.Columns.Add("Fecha29")
|
||
dt.Columns.Add("Fecha30")
|
||
dt.Columns.Add("Fecha31")
|
||
|
||
|
||
Dim DTFechas As DataTable
|
||
Dim DTUPersonal As DataTable
|
||
|
||
Dim DTVFechas As New DataView(Resultados)
|
||
DTFechas = DTVFechas.ToTable(True, "Fecha")
|
||
DTUPersonal = DTVFechas.ToTable(True, {"CvePersonal", "NombreCompleto"})
|
||
|
||
Dim ColumN As Integer = (dt.Columns.Count) - 2
|
||
|
||
For x As Integer = 3 To dt.Columns.Count - 1
|
||
GVRegDatos.Columns(x).HeaderText = ""
|
||
GVRegDatos.Columns(x).Visible = False
|
||
Next
|
||
UpDatos.Update()
|
||
|
||
ColumN = 3
|
||
|
||
For Each drow As DataRow In DTFechas.Rows
|
||
GVRegDatos.Columns(ColumN).HeaderText = String.Format("<div class='Widthall' style='text-align:center;font-size:11px!important'>{1}</div><div class='Widthall' style='text-align:center'> {0} </div>", drow(0).ToString().ToDate.ToString("dd/MM/yyyy"), ObtenerDiaSemana(drow(0).ToString().ToDate))
|
||
GVRegDatos.Columns(ColumN).Visible = True
|
||
ColumN = ColumN + 1
|
||
Next
|
||
|
||
Dim medida As DateTime = NowADS()
|
||
|
||
Dim sbErrores As New StringBuilder
|
||
Dim TieneInconsistencias As Boolean = False
|
||
|
||
For Each pRow As DataRow In DtPersonal.Rows
|
||
|
||
Dim RRow As DataRow = dt.NewRow
|
||
RRow("CvePersonal") = pRow("CvePersonal")
|
||
RRow("NombreCompleto") = pRow("NombreCompleto")
|
||
RRow("Codigo") = pRow("Codigo")
|
||
|
||
ColumN = 3
|
||
|
||
Dim ResumenDia As New DataTable
|
||
Dim DTTempAsistencias As New DataTable
|
||
Dim filtro As String
|
||
Dim TipoCorto As String = ""
|
||
|
||
For Each drow As DataRow In DTFechas.Rows
|
||
|
||
filtro = " CvePersonal = " & pRow("CvePersonal").ToString() & " AND Fecha ='" & drow(0).ToString() & $"'"
|
||
ResumenDia = Resultados.FiltraParametros(filtro)
|
||
filtro = filtro & $"|{ResumenDia(0)("HorasDobles").ToString}|{ResumenDia(0)("HorasTriples").ToString}|{ResumenDia(0)("CveMotivoHoraExtra").ToString}|{ResumenDia(0)("Observacion").ToString}|{ResumenDia(0)("PorcentajePago").ToString}"
|
||
|
||
TipoCorto = ""
|
||
|
||
'If RdbChecador.Checked Then
|
||
|
||
RRow(ColumN) = "-"
|
||
|
||
If ResumenDia(0)("TipoCorto").ToString().Contiene("_ND") Then
|
||
sbErrores.Append($"{pRow("Codigo")} Fecha: {drow(0).ToString().ToDate.ToString("dd/MM/yyyy")} Incidencia no definida <br/>")
|
||
TieneInconsistencias = True
|
||
End If
|
||
|
||
If ResumenDia(0)("TipoCorto").ToString().Length > 0 Then
|
||
|
||
RRow(ColumN) = $"{ResumenDia(0)("TipoCorto").ToString()}|" & filtro
|
||
|
||
Else
|
||
|
||
|
||
If ResumenDia(0)("Asistio").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "A" Then
|
||
RRow(ColumN) = "A|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("DiaVacacion").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "V" Then
|
||
RRow(ColumN) = "V|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Asistio").ToString() = "False" Or ResumenDia(0)("TipoCorto").ToString() = "F" Then
|
||
RRow(ColumN) = "F|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Retraso").ToString() = "True" Or ResumenDia(0)("TipoCorto").ToString() = "R" Then
|
||
RRow(ColumN) = "R|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("FaltaRetraso").ToString() = "True" Or TipoCorto = "FR" Then
|
||
RRow(ColumN) = "FR|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Descanso").ToString() = "True" Or ResumenDia(0)("DiaInhabil").ToString() = "True" Then
|
||
RRow(ColumN) = "D|" & filtro
|
||
End If
|
||
|
||
If ResumenDia(0)("Inconsistencia").ToString() = "True" Then
|
||
RRow(ColumN) = "IN|" & filtro
|
||
If ResumenDia(0)("Descanso").ToString() = "True" Then
|
||
RRow(ColumN) = "IND|" & filtro
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
|
||
'Else
|
||
|
||
' DTTempAsistencias = DTAsistenciasInasistenciasReg.FiltraParametros(filtro)
|
||
' If DTTempAsistencias.Rows.Count > 0 Then
|
||
' TipoCorto = DTTempAsistencias(0)("TipoCorto").ToString()
|
||
' Else
|
||
' TipoCorto = "F"
|
||
' End If
|
||
|
||
' RRow(ColumN) = "" & TipoCorto & "|" & filtro
|
||
|
||
'End If
|
||
|
||
ColumN = ColumN + 1
|
||
|
||
Next
|
||
|
||
ResumenDia.Dispose()
|
||
DTTempAsistencias.Dispose()
|
||
|
||
dt.Rows.Add(RRow)
|
||
|
||
Next
|
||
|
||
|
||
Dim SalidaTiempo As Integer = (NowADS() - medida).TotalSeconds.ToString().ToEntero
|
||
SalidaTiempo = SalidaTiempo
|
||
|
||
|
||
|
||
'DtDatosTabla = dt
|
||
|
||
If TieneInconsistencias Then
|
||
Alert(sbErrores.ToString, TipoMensaje.MsgAdvertencia)
|
||
Exit Sub
|
||
Else
|
||
|
||
Dim ProcesoOK As Boolean = True
|
||
Dim separador() As Char = {"|"c}
|
||
|
||
Dim ObjPersonal As New ClsRH
|
||
ObjPersonal.IniciaTransacSQL()
|
||
|
||
For Each dRowPersonal As DataRow In dt.Rows
|
||
|
||
Dim CvePersonal As Integer = dRowPersonal(0).ToString.ToEntero
|
||
ColumN = 3
|
||
|
||
For Each drow As DataRow In DTFechas.Rows
|
||
Try
|
||
Dim Fecha As Date = drow(0).ToString.ToDate
|
||
Dim dato As String() = dRowPersonal(ColumN).ToString.Split(separador)
|
||
|
||
Dim DTTipoAsistenciaInasistencia As DataTable = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltraParametros(" TipoCorto = '" & dato(0) & "' ")
|
||
Dim CveAsistenciasInasistencias As Integer = DTTipoAsistenciaInasistencia(0)("CveAsistenciasInasistencias").ToString.ToEntero
|
||
|
||
Dim HorasDobles As Decimal = dato(2).ToDecimal
|
||
Dim HorasTriples As Decimal = dato(3).ToDecimal
|
||
Dim CveMotivoHoraExtra As Integer = dato(4).ToEntero
|
||
Dim Observaciones As String = dato(5)
|
||
Dim PorcentajePago As Decimal = dato(6).ToDecimal
|
||
|
||
If CveAsistenciasInasistencias > 0 Then
|
||
If Not ObjPersonal.AddAsistencia(CvePersonal, -1, -1, Fecha, CveAsistenciasInasistencias, PorcentajePago, HorasDobles, HorasTriples, CveMotivoHoraExtra, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "C") Then
|
||
ProcesoOK = False
|
||
Exit For
|
||
End If
|
||
Else
|
||
ProcesoOK = False
|
||
Exit For
|
||
End If
|
||
Catch ex As Exception
|
||
ProcesoOK = False
|
||
End Try
|
||
|
||
ColumN = ColumN + 1
|
||
Next
|
||
If Not ProcesoOK Then
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
|
||
If ProcesoOK Then
|
||
Dim ObjNomEnvio As New ClsNominas(ObjPersonal.IniciaTransacSQL)
|
||
If Not ObjNomEnvio.UpdatePeriodoEnvioPrenomina(DdlPeriodo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, True) Then
|
||
ProcesoOK = False
|
||
End If
|
||
|
||
End If
|
||
|
||
If ProcesoOK Then
|
||
ObjPersonal.Commit()
|
||
Alert("Asistencia enviada correctamente.")
|
||
Else
|
||
ObjPersonal.RollBack()
|
||
Alert("Se presento un error al enviar asistencia.", TipoMensaje.MsgAdvertencia)
|
||
End If
|
||
|
||
ObjPersonal.Dispose()
|
||
|
||
End If
|
||
|
||
|
||
End Sub
|
||
|
||
Protected Sub LnkDescargaExcel_Click(sender As Object, e As EventArgs)
|
||
|
||
Dim SubProyecto As String = ""
|
||
|
||
If DdlSubProyecto.SelectedValue.ToEntero > 0 Then
|
||
SubProyecto = DdlSubProyecto.SelectedItem.Text
|
||
End If
|
||
|
||
Dim SbFiltros As New StringBuilder()
|
||
SbFiltros.AppendFormat("Periodo: {0}, Sub Proyecto: {1}, Departamento: {2}", DdlPeriodo.SelectedItem.Text, SubProyecto, DdlDepartamento.SelectedItem.Text)
|
||
|
||
Dim Gv As New GridView
|
||
Gv = GVRegDatos
|
||
|
||
For Each gvRow As GridViewRow In Gv.Rows
|
||
|
||
Dim x As Integer = 3
|
||
For x = 3 To Gv.Columns.Count - 1
|
||
If Gv.Columns(x).Visible = True Then
|
||
|
||
Dim Lnk As LinkButton = gvRow.FCLinkButton($"LnkFecha{(x - 2)}")
|
||
Dim separador() As Char = {"|"c}
|
||
Dim dato As String() = Lnk.CommandArgument.Split(separador)
|
||
|
||
If dato(0) = "_ND" Then
|
||
gvRow.Cells(x).Text = "Inconsistencia"
|
||
Else
|
||
Dim DTTipoAsistenciaInasistencia As DataTable = GlobalDTAsistenciasInasistencias(UsuarioActual.CveEmpresa).FiltraParametros(" TipoCorto = '" & dato(0) & "' ")
|
||
|
||
If DTTipoAsistenciaInasistencia IsNot Nothing AndAlso DTTipoAsistenciaInasistencia.Rows.Count > 0 Then
|
||
Dim Tipo As String = DTTipoAsistenciaInasistencia(0)("Tipo").ToString
|
||
gvRow.Cells(x).Text = Tipo
|
||
End If
|
||
End If
|
||
|
||
|
||
|
||
|
||
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
|
||
Gv.ExportToExcelGembox("PreAsistencia", UsuarioActual, $"Pre Asistencia {DdlPeriodo.SelectedItem.Text}", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
|
||
|
||
|
||
End Sub
|
||
|
||
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
||
End Sub
|
||
|
||
|
||
End Class |