vacaciones
This commit is contained in:
171
Nomina/ReporteVacaciones.aspx.cs
Normal file
171
Nomina/ReporteVacaciones.aspx.cs
Normal 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; }
|
||||
}
|
||||
Reference in New Issue
Block a user