vacaciones

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2025-01-23 04:01:53 -07:00
parent ba67ae62e2
commit 4baf62291e
4 changed files with 353 additions and 1 deletions

View File

@@ -0,0 +1,154 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ReporteVacaciones.aspx.cs" Inherits="Nomina_ReporteVacaciones" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style>
/*.text-right {
text-align:right
}*/
td.borderleft,th.borderleft{
border-left:1px solid black !important;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
Reporte Vacaciones
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UpContenido" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter">
<div class="portlet-title portlet-filterT smalltitle">
<div class="titlefiltros caption">
<div class="row">
<label class="col-md-1 mediocol">Inicio:</label>
<div class="col-md-1">
<%--<asp:TextBox ID="TxtPeriodoInicio" Text="0" CssClass="form-control" runat="server"></asp:TextBox>--%>
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 138px !important; padding: 0px; margin-bottom: -10px;">
<asp:TextBox ID="TxtRpdFechaInicio" CssClass="form-control input-sm ADSMaskDate" Style="width: 80px" runat="server"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="LnkRpdFechaInicio" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MaskedEditExtender3" runat="server" TargetControlID="TxtRpdFechaInicio" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CalendarExtender3" TargetControlID="TxtRpdFechaInicio" PopupButtonID="LnkRpdFechaInicio" PopupPosition="BottomRight" Enabled="True" Format="dd/MM/yyyy"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvRpdFechaInicio" runat="server" ControlToValidate="TxtRpdFechaInicio" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha Inicio''</b> es necesario, por favor ingréselo." ValidationGroup="VGReporterepperde"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" HighlightCssClass="vco" TargetControlID="rfvRpdFechaInicio"></ajax:ValidatorCalloutExtender>
</div>
</div>
<label class="col-md-1 mediocol">Fin:</label>
<div class="col-md-1">
<%--<asp:TextBox ID="TxtPeriodoFin" Text="99" CssClass="form-control" runat="server"></asp:TextBox>--%>
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 138px !important; padding: 0px; margin-bottom: -10px;">
<asp:TextBox ID="TxtRpdFechaFin" CssClass="form-control input-sm ADSMaskDate" Style="width: 80px" runat="server"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="LnkFechaFin" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MaskedEditExtender5" runat="server" TargetControlID="TxtRpdFechaFin" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CalendarExtender4" TargetControlID="TxtRpdFechaFin" PopupButtonID="LnkFechaFin" PopupPosition="BottomRight" Enabled="True" Format="dd/MM/yyyy"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvRpdFechaFin" runat="server" ControlToValidate="TxtRpdFechaFin" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha Fin''</b> es necesario, por favor ingréselo." ValidationGroup="VGReporterepperde"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" HighlightCssClass="vco" TargetControlID="rfvRpdFechaFin"></ajax:ValidatorCalloutExtender>
</div>
</div>
<asp:Label ID="LblProyecto" CssClass="col-md-1 compoonenlabel" runat="server" Text="Proyecto:" Style="max-width: 100px;"></asp:Label>
<div runat="server" id="divddlproyeto" class="col-md-2">
<asp:DropDownList ID="DdlProyecto" runat="server" AppendDataBoundItems="true" CssClass="select2me" AutoPostBack="true" DataTextField="Proyecto" DataValueField="CveProyecto" Style="width: 100% !important;" ValidationGroup="GrpGuardar">
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:Label ID="LblSubProyeccto" CssClass="col-md-1 compoonenlabel" runat="server" Text="SubProyecto:" Style="max-width: 103px;"></asp:Label>
<div class="col-md-2">
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" CssClass="select2me" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Style="width: 100% !important;" ValidationGroup="GrpGuardar">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-md-1">
<asp:LinkButton ID="LnkConsultar" OnClick="LnkConsultar_Click" runat="server" Text="Consultar" class="btn btn-primary" />
</div>
</div>
</div>
<div class="tools">
<a href="javascript:;" class="expand" data-original-title="" title=""></a>
</div>
</div>
<div class="portlet-body" style="display: none">
</div>
</div>
<div>
<table id="gvReporteVacaciones" class="table table-striped table-advance table-hover ScrollAD Widthall gvReporteVacaciones" data-rows="2" data-heighterror="360">
<%-- <thead>
</thead>--%>
<tbody>
<tr>
<th></th>
<th></th>
<th></th>
<%-- Encabezados dinámicos para los ejercicios --%>
<asp:Repeater ID="RepeaterEjerciciosH1" runat="server">
<ItemTemplate>
<th class="borderleft" colspan="3"><%# Eval("Ejercicio") %></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<tr>
<th>Código</th>
<th>Nombre Completo</th>
<th>Fecha Inicio</th>
<%-- Encabezados dinámicos para los ejercicios --%>
<asp:Repeater ID="RepeaterEjerciciosH2" runat="server">
<ItemTemplate>
<th class="borderleft">Antigüedad</th>
<th>Días Vacaciones</th>
<th>Días Pagados</th>
</ItemTemplate>
</asp:Repeater>
</tr>
<asp:Repeater ID="RepeaterPrincipal" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr>
<%--<td><%# Eval("CvePersonal") %></td>--%>
<td>
<asp:HyperLink runat="server" Text='<%# Eval("Codigo") %>' NavigateUrl='<%# Eval("CvePersonal", "~/RH/Personal.aspx?CvePersonal={0}") %>'></asp:HyperLink></td>
<td>
<asp:HyperLink runat="server" Text='<%# Eval("NombreCompleto") %>' NavigateUrl='<%# Eval("CvePersonal", "~/RH/Personal.aspx?CvePersonal={0}") %>'></asp:HyperLink></td>
<td><%# Eval("FechaInicio", "{0:yyyy-MM-dd}") %></td>
<%-- Subrepeater para los ejercicios --%>
<asp:Repeater ID="RepeaterEjercicios" runat="server" DataSource='<%# Eval("Ejercicios") %>'>
<ItemTemplate>
<td class="text-right borderleft"><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("Antiguedad") : "" %></td>
<td class="text-right "><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("DiasVacaciones") : "" %></td>
<td class="text-right "><%# Convert.ToInt32(Eval("Antiguedad")) > 0 ? Eval("DiasPagados") : "" %></td>
</ItemTemplate>
</asp:Repeater>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
</asp:Content>

View File

@@ -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<Registro> resultado = tabla1.AsEnumerable().Select(row1 => new Registro()
{
CvePersonal = row1.Field<int>("CvePersonal"),
Codigo = row1.Field<string>("Codigo"),
NombreCompleto = row1.Field<string>("NombreCompleto"),
//FechaFin = (row1("FechaFin")).ToString().,
FechaInicio = row1.Field<DateTime>("FechaInicio"),
FechaAntiguedad = row1.Field<DateTime>("FechaAntiguedad"),
Antiguedad = row1.Field<int>("Antiguedad"),
// Campo extra: Enumerable para cada Ejercicio de Tabla 3
Ejercicios = tabla3.AsEnumerable().Select(row3 =>
{
var ejercicio = row3.Field<int>("Ejercicio");
// Buscar en Tabla 2 si existe el registro para CvePersonal y Ejercicio
var registro = tabla2.AsEnumerable().FirstOrDefault(row2 =>
row2.Field<int>("CvePersonal") == row1.Field<int>("CvePersonal") &&
row2.Field<int>("EJercicio") == ejercicio);
// Si no existe, crear un nuevo registro
if (registro == null)
{
return new EjercicioInfo()
{
Ejercicio = ejercicio,
FechaAntiguedad = row1.Field<DateTime>("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<int>("EJercicio"),
FechaAntiguedad = registro.Field<DateTime>("FechaAntiguedad"),
Antiguedad = registro.Field<int>("Antiguedad"),
DiasVacaciones = registro.Field<int>("DiasVacaciones"),
DiasPagados = registro.Field<int>("DiasPagados"),
DiasDisfrutados = registro.Field<int>("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<EjercicioInfo> 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; }
}