diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 4bbe11761..b72b6e8a7 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -2700,6 +2700,32 @@ Public Class ClsNominas End Try Return retorno End Function + + + Public Function ReporteVacaciones(CveProyecto As Integer, CveSubProyecto As Integer, cveEmpresa As Integer, fechaInicio As String, fechaFin As String) As Boolean + Dim retorno As Boolean = False + Try + DTSet = New DataSet() + DataAdapter("PA_Nom_ReporteVacaciones", CommandType.StoredProcedure) + SqlAdapter.SelectCommand.CommandTimeout = 2400 + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa + .Add("@FechaInicio", SqlDbType.Date).Value = fechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = fechaFin + End With + SqlAdapter.Fill(DTSet) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al realizar el reporte de vacaciones.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al realizar el reporte de vacaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function Public Function GetNominasSinTimbrar(CvePeriodo As Integer, CveEmpresa As Integer) As Boolean Dim retorno As Boolean = False Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index e0cf162da..75066cbde 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -8452,7 +8452,7 @@ Public Class ClsPaginas RptParametro.Add(New ReportParameter("Fecha", ObjNomina.Fecha.ToString)) RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) RptParametro.Add(New ReportParameter("DiasPagados", ObjNomina.DiasPagados.ToString)) - RptParametro.Add(New ReportParameter("MetodoPago", ObjNomina.MetodoPago)) '"""PUE"" (Pago en una sola exhibición)"- + RptParametro.Add(New ReportParameter("MetodoPago", """PUE"" (Pago en una sola exhibición)")) 'ObjNomina.MetodoPago RptParametro.Add(New ReportParameter("FormaPago", """99"" (Por definir)")) RptParametro.Add(New ReportParameter("Cantidad", "1")) RptParametro.Add(New ReportParameter("Unidad", "ACT")) @@ -9850,6 +9850,7 @@ Public Class ClsPaginas PaginaDict.Add("/Documentacion/TableroMaterialidadDetalle.aspx".ToUpper(), 965) PaginaDict.Add("/RH/DiasFestivos.aspx".ToUpper(), -1) PaginaDict.Add("/Nomina/FiniquitoB.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/ReporteVacaciones.aspx".ToUpper(), -1) '------------ Páginas agregadas recientemente (Implementación Metronic) ------------ PaginaDict.Add("/Default2.aspx".ToUpper(), -1) diff --git a/Nomina/ReporteVacaciones.aspx b/Nomina/ReporteVacaciones.aspx new file mode 100644 index 000000000..0e31011b4 --- /dev/null +++ b/Nomina/ReporteVacaciones.aspx @@ -0,0 +1,154 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ReporteVacaciones.aspx.cs" Inherits="Nomina_ReporteVacaciones" %> + + + + + + + + Reporte Vacaciones + + + + + + + + + + + +
+
+
+
+ + +
+ <%----%> + +
+ + + + + + + + +
+
+ +
+ <%----%> +
+ + + + + + + + +
+
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+
+
+
+ +
+
+ +
+ + +
+ + <%-- + --%> + + + + + + + <%-- Encabezados dinámicos para los ejercicios --%> + + + + + + + + + + + + + <%-- Encabezados dinámicos para los ejercicios --%> + + + + + + + + + + + + + + + <%----%> + + + + <%-- Subrepeater para los ejercicios --%> + + + + + + + + + + + + + +
<%# Eval("Ejercicio") %>
CódigoNombre CompletoFecha InicioAntigüedadDías VacacionesDías Pagados
<%# Eval("CvePersonal") %> + + <%# Eval("FechaInicio", "{0:yyyy-MM-dd}") %><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("Antiguedad") : "" %><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("DiasVacaciones") : "" %><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("DiasPagados") : "" %>
+
+
+
+
+ + + diff --git a/Nomina/ReporteVacaciones.aspx.cs b/Nomina/ReporteVacaciones.aspx.cs new file mode 100644 index 000000000..ec247c795 --- /dev/null +++ b/Nomina/ReporteVacaciones.aspx.cs @@ -0,0 +1,171 @@ +using ADSNetLibrary.Helpers; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Nomina_ReporteVacaciones : ClsPaginas +{ + #region "Propiedades" + protected int FiltCveProyecto + { + get + { + if (ViewState["FiltCveProyecto"] == null) { return -1; } + else { return ViewState["FiltCveProyecto"].ToString().ToEntero(); } + } + + set { ViewState["FiltCveProyecto"] = value; } + } + protected int FiltCveSubProyecto + { + get + { + if (ViewState["FiltCveSubProyecto"] == null) { return -1; } + else { return ViewState["FiltCveSubProyecto"].ToString().ToEntero(); } + } + + set { ViewState["FiltCveSubProyecto"] = value; } + } + protected string FiltFechaInicio + { + get + { + string fecha = $"{DateTime.Now.Year - 3}-01-01"; + if (ViewState["FiltFechaInicio"] == null) { return fecha ; } + else { return ViewState["FiltFechaInicio"].ToString(); } + } + + set { ViewState["FiltFechaInicio"] = value; } + } + protected string FiltFechaFin + { + get + { + string fecha = $"{DateTime.Now.Year}-12-31"; + if (ViewState["FiltFechaFin"] == null) { return fecha; } + else { return ViewState["FiltFechaFin"].ToString(); } + } + + set { ViewState["FiltFechaFin"] = value; } + } + #endregion + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + TxtRpdFechaInicio.Text = $"{FiltFechaInicio.ToDateTime():dd/MM/yyyy}"; + TxtRpdFechaFin.Text = $"{FiltFechaFin.ToDateTime():dd/MM/yyyy}"; + CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyeccto); + divddlproyeto.Visible = DdlProyecto.Visible; + getinfo(); + } + } + public void getinfo() + { + using (ClsNominas objnom = new ClsNominas()) + { + if (objnom.ReporteVacaciones(FiltCveProyecto, FiltCveSubProyecto, UsuarioActual.CveEmpresa, FiltFechaInicio, FiltFechaFin)) + { + DataTable tabla1 = objnom.DTSetResultados.Tables[0]; // Simula tu tabla 1 + DataTable tabla2 = objnom.DTSetResultados.Tables[1]; // Simula tu tabla 2 + DataTable tabla3 = objnom.DTSetResultados.Tables[2]; // Simula tu tabla 3 + RepeaterEjerciciosH1.DataSource= tabla3; + RepeaterEjerciciosH2.DataSource= tabla3; + RepeaterEjerciciosH1.DataBind(); + RepeaterEjerciciosH2.DataBind(); + // Convertir Tabla 1 a Enumerable con un campo extra + List resultado = tabla1.AsEnumerable().Select(row1 => new Registro() + { + CvePersonal = row1.Field("CvePersonal"), + Codigo = row1.Field("Codigo"), + NombreCompleto = row1.Field("NombreCompleto"), + //FechaFin = (row1("FechaFin")).ToString()., + FechaInicio = row1.Field("FechaInicio"), + FechaAntiguedad = row1.Field("FechaAntiguedad"), + Antiguedad = row1.Field("Antiguedad"), + + // Campo extra: Enumerable para cada Ejercicio de Tabla 3 + Ejercicios = tabla3.AsEnumerable().Select(row3 => + { + var ejercicio = row3.Field("Ejercicio"); + + // Buscar en Tabla 2 si existe el registro para CvePersonal y Ejercicio + var registro = tabla2.AsEnumerable().FirstOrDefault(row2 => + row2.Field("CvePersonal") == row1.Field("CvePersonal") && + row2.Field("EJercicio") == ejercicio); + + // Si no existe, crear un nuevo registro + if (registro == null) + { + return new EjercicioInfo() + { + Ejercicio = ejercicio, + FechaAntiguedad = row1.Field("FechaAntiguedad"), + Antiguedad = 0, + DiasVacaciones = 0, // Valor predeterminado + DiasPagados = 0, // Valor predeterminado + DiasDisfrutados = 0 // Valor predeterminado + }; + } + else + { + // Si existe, devolver los datos de la Tabla 2 + return new EjercicioInfo() + { + Ejercicio = registro.Field("EJercicio"), + FechaAntiguedad = registro.Field("FechaAntiguedad"), + Antiguedad = registro.Field("Antiguedad"), + DiasVacaciones = registro.Field("DiasVacaciones"), + DiasPagados = registro.Field("DiasPagados"), + DiasDisfrutados = registro.Field("DiasDisfrutados") + }; + } + }).ToList() + }).ToList(); + + + + RepeaterPrincipal.DataSource = resultado; + RepeaterPrincipal.DataBind(); + + } + + } + + } + + + + protected void LnkConsultar_Click(object sender, EventArgs e) + { + FiltFechaInicio = $"{TxtRpdFechaInicio.Text.ToDateTime():yyyy-MM-dd}"; + FiltFechaFin = $"{TxtRpdFechaFin.Text.ToDateTime():yyyy-MM-dd}"; + getinfo(); + } +} + +public class Registro +{ + public int CvePersonal { get; set; } + public string Codigo { get; set; } + public string NombreCompleto { get; set; } + public DateTime FechaInicio { get; set; } + public DateTime FechaFin { get; set; } + public DateTime FechaAntiguedad { get; set; } + public int Antiguedad { get; set; } + public List Ejercicios { get; set; } +} + +public class EjercicioInfo +{ + public int Ejercicio { get; set; } + public DateTime FechaAntiguedad { get; set; } + public int Antiguedad { get; set; } + public int DiasVacaciones { get; set; } + public int DiasPagados { get; set; } + public int DiasDisfrutados { get; set; } +} \ No newline at end of file