From 4dd0e3b7dab92abb67208f08bfdd6c35f6be9a76 Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 29 Apr 2026 12:31:38 +0200 Subject: [PATCH] Creados Ficheros maestros funcionando (pendientes de validaciones) --- .../Pages/FicherosMaestros/Bancos.razor | 253 +++++++--- .../FicherosMaestros/ConceptoGeneral.razor | 291 +++++++++++ .../FicherosMaestros/ConceptosGenerales.razor | 11 +- .../Pages/FicherosMaestros/Contrato.razor | 304 +++++++++++ .../Pages/FicherosMaestros/Contratos.razor | 230 ++++++++- .../FicherosMaestros/CuentaCotizacion.razor | 297 +++++++++++ .../FicherosMaestros/CuentasCotizacion.razor | 126 ++++- .../Pages/FicherosMaestros/Fiestas.razor | 167 ++++-- .../FicherosMaestros/TiposTramoSiltra.razor | 476 ++++++++++++++++++ .../Pages/FicherosMaestros/ValorNomina.razor | 363 +++++++++++++ .../FicherosMaestros/ValoresNomina.razor | 101 +++- .../Controllers/TIPOSTRAMOSController.cs | 28 ++ .../Controllers/VALORESNOMINAController.cs | 15 + 13 files changed, 2546 insertions(+), 116 deletions(-) create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptoGeneral.razor create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contrato.razor create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentaCotizacion.razor create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposTramoSiltra.razor create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValorNomina.razor create mode 100644 Antifraude.Net/SwaggerAntifraude/Controllers/VALORESNOMINAController.cs diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Bancos.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Bancos.razor index 8175e7b..284be94 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Bancos.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Bancos.razor @@ -8,26 +8,26 @@ @using BlazorBootstrap @using bdAntifraude.db @using Microsoft.AspNetCore.Components - @rendermode InteractiveServer @inject IJSRuntime JS @inject NavigationManager NavigationManager @inject IHttpClientFactory HttpClientFactory @inject IHttpContextAccessor HttpContextAccessor @inject UserState UserState - +
Bancos
+
- @if (lPuestos == null) + @if (lBancos == null) {
} - else if (!lPuestos.Any()) + else if (!lBancos.Any()) {

No se encontraron datos para mostrar.

} @@ -44,7 +44,7 @@
+ + + @context.CODIGO @context.NOMBRE - + @context.BIC @@ -69,24 +72,24 @@ } - + @* @context.IDTIPOPERSONANavigation.DESCRIPCION - - + + @if (context.FECHABAJA != null) { @context.FECHABAJA } - + *@
-
- @foreach (var itm in lPuestos) +
+ @foreach (var itm in lBancos) { var collapseId = $"collapse{itm.IDBANCO}";
@@ -104,11 +107,20 @@
@itm.BIC
Obsoleto
- @if(@itm.OBSOLETO) + @itm.OBSOLETO + +@* @if(itm.OBSOLETO) { } -
+ else + { + + } *@ + +
+ +
@@ -117,10 +129,48 @@
}
- + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + + +
+
@code { - private List lPuestos = new List(); - private List Puestos = new List(); + private List lBancos = new List(); + private List banco = new List(); + + private string tituloPopup = ""; + private Modal popupGestionDatos = default; + private bool EsItemNuevo = false; + private BANCOS ItemEnEdicion { get; set; } = new BANCOS(); + + List mensajes = new List(); + private EditContext? editContext; + + private string _filter = ""; public string Filter { @@ -136,7 +186,7 @@ } private void AplicarFiltros() { - lPuestos = Puestos.Where(per => + lBancos = banco.Where(per => string.IsNullOrEmpty(Filter) || Utilidades.RemoveDiacritics(per.CODIGO).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) || Utilidades.RemoveDiacritics(per.NOMBRE.ToString()).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) || @@ -144,57 +194,6 @@ ).ToList(); UserState.CurrentPage = 1; } - // Tamaño de página - // private int pageSize = 6; - - // Calcula el total de páginas basado en la lista filtrada - // private int TotalPaginas => (int)Math.Ceiling((double)lPuestos.Count / pageSize); - // Índice inicial y final de elementos para la página actual - // private int FromElement => lPuestos.Count == 0 ? 0 : (UserState.CurrentPage - 1) * pageSize + 1; - // private int ToElement - // { - // get - // { - // if (lPuestos.Count == 0) - // { - // return 0; - // } - // int last = FromElement + pageSize - 1; - // return last > lPuestos.Count ? lPuestos.Count : last; - // } - // } - // Sublista de datos para la página actual basada en la lista filtrada - // private List lPuestosPaginada => - // lPuestos.Skip((UserState.CurrentPage - 1) * pageSize).Take(pageSize).ToList(); - // private void PaginaAnterior() - // { - // if (UserState.CurrentPage > 1) - // { - // UserState.CurrentPage--; - // } - // } - // private void PaginaSiguiente() - // { - // if (UserState.CurrentPage < TotalPaginas) - // { - // UserState.CurrentPage++; - // } - // } - // private void PrimeraPagina() => UserState.CurrentPage = 1; - // private void UltimaPagina() => UserState.CurrentPage = TotalPaginas; - // private void NuevaPersona() - // { - // NavigationManager.NavigateTo("/InfoPersonas", forceLoad: true); - // } - private string HashRed(string id) - { - string link = "/infoPers?cl=" + tsUtilidades.crypt.FEncS( - id, - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", - 875421649); - return link; - } // Bandera que indica si se está en modo "Ver Todos" private bool verTodosActive = false; @@ -211,7 +210,7 @@ var resultPersonas = await client.GetAsync("/BANCOS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); - Puestos = JsonConvert.DeserializeObject>(resultContent) + banco = JsonConvert.DeserializeObject>(resultContent) ?? new List(); } else @@ -225,15 +224,15 @@ var resultPersonas = await client.GetAsync("/api/BANCOS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); - Puestos = JsonConvert.DeserializeObject>(resultContent) + banco = JsonConvert.DeserializeObject>(resultContent) ?? new List(); } - Puestos = Puestos + banco = banco .OrderBy(x => x.CODIGO) .ToList(); - lPuestos = Puestos; + lBancos = banco; UserState.CurrentPage = 1; Filter = ""; } @@ -242,21 +241,111 @@ { verTodosActive = false; var token = UserState.Token; - var client = HttpClientFactory.CreateClient(); - client.BaseAddress = new Uri(Utilidades.urlSwagger()); - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - - var resultPersonas = await client.GetAsync("/api/BANCOS"); + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + editContext = new EditContext(lBancos); + var resultPersonas = await cliente.GetAsync("/api/BANCOS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); - Puestos = JsonConvert.DeserializeObject>(resultContent) + banco = JsonConvert.DeserializeObject>(resultContent) ?? new List(); - Puestos = Puestos.OrderBy(x => x.CODIGO) + banco = banco.OrderBy(x => x.CODIGO) .ToList(); - lPuestos = Puestos; + lBancos = banco; + + + } + private async Task abrirPopupModificacion(BANCOS objeto, bool esNuevo) + { + ItemEnEdicion = Utilidades.ClonarObjeto(objeto); + EsItemNuevo = esNuevo; + if (!EsItemNuevo) + { + tituloPopup = "Modificando Banco"; + } + else + { + tituloPopup = "Nuevo Banco"; + } + + await popupGestionDatos.ShowAsync(); + } + private async Task cerrarPopupModificacion() + { + await popupGestionDatos.HideAsync(); } + // GUARDAR + private async Task GuardarCambiosPopup() + { + try + { + ValidarDatos(); + + if (!editContext!.GetValidationMessages().Any()) + { + string accion = EsItemNuevo ? "create" : "update"; + await GestionarDatos(accion); + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Warning, + Message = $"Debe rellenar los campos obligatorios.", + }); + } + + } + catch (Exception) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = $"Error al guardar.", + }); + } + + } + private async Task GestionarDatos(string accion) + { + var copia = new List(lBancos); + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + switch (accion) + { + case "update": + int indice = copia.FindIndex(x => x.IDBANCO == ItemEnEdicion.IDBANCO); + if (indice > -1) + { + copia[indice] = ItemEnEdicion; + } + var response = await Utilidades.ActualizarObjeto(cliente, "/api/BANCOS/" + ItemEnEdicion.IDBANCO, ItemEnEdicion, mensajes); + + break; + case "create": + copia.Add(ItemEnEdicion); + var responsec = await Utilidades.NuevoObjeto(cliente, "/api/BANCOS/", ItemEnEdicion, mensajes); + break; + case "delete": + + break; + } + cerrarPopupModificacion(); + lBancos = copia.OrderBy(x => x.CODIGO).ToList(); + await InvokeAsync(StateHasChanged); + } + private void ValidarDatos() + { + + } + private void MostrarErroresPopup() + { + // messageStore?.Clear(); + // foreach (var field in new[] { nameof(descripcionItem) }) + // { + // ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field); + // } + } } diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptoGeneral.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptoGeneral.razor new file mode 100644 index 0000000..fef3716 --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptoGeneral.razor @@ -0,0 +1,291 @@ +@page "/ConceptoGeneral" +@page "/ConceptoGeneral/{cl}" +@using BlazorBootstrap +@using GestionPersonalWeb.Components.Pages.FicherosMaestros.TipoPuestoTrabajoComponents +@using Newtonsoft.Json +@using GestionPersonalWeb.Components.Layout +@using Microsoft.AspNetCore.WebUtilities +@using GestionPersonalWeb.Components.Pages.InfoPersComponents +@using GestionPersonalWeb.Models +@using System.Linq.Expressions +@using Serialize.Linq.Serializers +@using System.Net.Http.Headers +@using bdAntifraude.clases +@using bdAntifraude.db +@using System.Reflection +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@inject IJSRuntime JSRuntime +@inject IJSRuntime JS +@rendermode InteractiveServer +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState +@inject ProtectedSessionStorage ProtectedSessionStore +@inject NavigationManager Navigation + + +@*
+
Tipo puesto de trabajo: @puestoTrabajo.DESCRIPCION
+
*@ + +
+
+
+
+
+
+
Concepto
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Aplicaciones Presupuestarias
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Funcionario
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Varios
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + + +@code { + [Parameter] + public string? cl { get; set; } = ""; + private static bdAntifraude.db.CONCEPTOSGENERALES Concepto = new CONCEPTOSGENERALES(); + private EditContext editContext = new EditContext(Concepto); + + private HttpClient cliente = new HttpClient(); + private ValidationMessageStore? messageStore; + private string errorMessage = ""; + List mensajes = new List(); + public bool mostrar { get; set; } = true; + public bool mostrarBtn { get; set; } = false; + + + + protected override async Task OnInitializedAsync() + { + try + { + var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) + { + cl = clValue; + } + + if (string.IsNullOrEmpty(cl)) + { + Concepto = new CONCEPTOSGENERALES(); + mostrarBtn = true; + } + else + { + // ListaSexos = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/SEXO"); + string idDesencriptado = Utilidades.Desencriptar(cl); + int id = int.Parse(idDesencriptado); + + var response = await cliente.GetAsync($"/api/CONCEPTOSGENERALES/{id}"); + if (!response.IsSuccessStatusCode) + { + throw new Exception($"Error al obtener los datos del Tipo de Trabajo. Código: {response.StatusCode}"); + } + var resultContent = await response.Content.ReadAsStringAsync(); + Concepto = JsonConvert.DeserializeObject(resultContent) ?? throw new Exception("Error al deserializar los datos de la persona."); + } + editContext = new EditContext(Concepto); + messageStore = new ValidationMessageStore(editContext); + + mostrar = false; + } + catch (Exception ex) + { + errorMessage = ex.Message; + Console.WriteLine($"Error durante la inicialización: {ex.Message}"); + mostrar = false; + } + finally + { + mostrar = false; + } + } + + private async Task GuardarPuestoTrabajo() + { + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + if (!editContext.GetValidationMessages().Any()) + { + if (Concepto.IDCONCEPTOSGENERALES == 0)//Nuevo + { + var response = await Utilidades.NuevoObjeto(cliente, "/api/CONCEPTOSGENERALES", Concepto, mensajes); + if (response != null) + { + Concepto = response; + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + await InvokeAsync(StateHasChanged); + } + else//Guardar + { + var response = await Utilidades.ActualizarObjeto(cliente, "/api/CONCEPTOSGENERALES/" + Concepto.IDCONCEPTOSGENERALES, Concepto, mensajes); + } + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = Utilidades.ListaErroresHtml(editContext.GetValidationMessages()), + }); + + } + } + +} diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptosGenerales.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptosGenerales.razor index 75f084e..91bd4f7 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptosGenerales.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ConceptosGenerales.razor @@ -17,8 +17,13 @@ @inject UserState UserState
-
-
Conceptos Generales
+
+
+
+ Conceptos Generales +
+
+ Nuevo
@if (lConceptos == null) @@ -113,7 +118,7 @@ private string HashRed(string id) { - string link = "/infoPers?cl=" + tsUtilidades.crypt.FEncS( + string link = "/ConceptoGeneral?cl=" + tsUtilidades.crypt.FEncS( id, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contrato.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contrato.razor new file mode 100644 index 0000000..e5001dc --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contrato.razor @@ -0,0 +1,304 @@ +@page "/Contrato" +@page "/Contrato/{cl}" +@using BlazorBootstrap +@using GestionPersonalWeb.Components.Pages.FicherosMaestros.TipoPuestoTrabajoComponents +@using Newtonsoft.Json +@using GestionPersonalWeb.Components.Layout +@using Microsoft.AspNetCore.WebUtilities +@using GestionPersonalWeb.Components.Pages.InfoPersComponents +@using GestionPersonalWeb.Models +@using System.Linq.Expressions +@using Serialize.Linq.Serializers +@using System.Net.Http.Headers +@using bdAntifraude.clases +@using bdAntifraude.db +@using System.Reflection +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@inject IJSRuntime JSRuntime +@inject IJSRuntime JS +@rendermode InteractiveServer +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState +@inject ProtectedSessionStorage ProtectedSessionStore +@inject NavigationManager Navigation + + +@*
+
Tipo puesto de trabajo: @puestoTrabajo.DESCRIPCION
+
*@ + +
+
+
+
+
+
+
Contrato
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Contigencias Comunes
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Formación Profesional
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Desempleo
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
FOGASA
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
MEI
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + + +@code { + [Parameter] + public string? cl { get; set; } = ""; + private static bdAntifraude.db.CONTRATOS iContrato = new CONTRATOS(); + private EditContext editContext = new EditContext(iContrato); + + private HttpClient cliente = new HttpClient(); + private ValidationMessageStore? messageStore; + private string errorMessage = ""; + List mensajes = new List(); + public bool mostrar { get; set; } = true; + public bool mostrarBtn { get; set; } = false; + + + + protected override async Task OnInitializedAsync() + { + try + { + var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) + { + cl = clValue; + } + + if (string.IsNullOrEmpty(cl)) + { + iContrato = new CONTRATOS(); + mostrarBtn = true; + } + else + { + string idDesencriptado = Utilidades.Desencriptar(cl); + int id = int.Parse(idDesencriptado); + + var response = await cliente.GetAsync($"/api/CONTRATOS/{id}"); + if (!response.IsSuccessStatusCode) + { + throw new Exception($"Error al obtener los datos del Contrato. Código: {response.StatusCode}"); + } + var resultContent = await response.Content.ReadAsStringAsync(); + iContrato = JsonConvert.DeserializeObject(resultContent) ?? throw new Exception("Error al deserializar los datos de la persona."); + } + editContext = new EditContext(iContrato); + messageStore = new ValidationMessageStore(editContext); + + mostrar = false; + } + catch (Exception ex) + { + errorMessage = ex.Message; + Console.WriteLine($"Error durante la inicialización: {ex.Message}"); + mostrar = false; + } + finally + { + mostrar = false; + } + } + + private async Task GuardarPuestoTrabajo() + { + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + if (!editContext.GetValidationMessages().Any()) + { + if (iContrato.IDCONTRATO == 0)//Nuevo + { + var response = await Utilidades.NuevoObjeto(cliente, "/api/CONTRATOS", iContrato, mensajes); + if (response != null) + { + iContrato = response; + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + await InvokeAsync(StateHasChanged); + } + else//Guardar + { + var response = await Utilidades.ActualizarObjeto(cliente, "/api/CONTRATOS/" + iContrato.IDCONTRATO, iContrato, mensajes); + } + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = Utilidades.ListaErroresHtml(editContext.GetValidationMessages()), + }); + + } + } + +} diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contratos.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contratos.razor index 04380e7..e03b733 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contratos.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Contratos.razor @@ -1,5 +1,233 @@ -

Contratos

+@page "/Contratos" +@using System.Net.Http.Headers +@using System.Linq.Expressions +@using Newtonsoft.Json +@using System.Text +@using Serialize.Linq.Serializers +@using GestionPersonalWeb.Models +@using BlazorBootstrap +@using bdAntifraude.db +@using Microsoft.AspNetCore.Components +@rendermode InteractiveServer +@inject IJSRuntime JS +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState + +
+
+
+
+ Contratos +
+
+ Nuevo +
+ + @if (lContratos == null) + { +
+
+
+ } + else if (!lContratos.Any()) + { +

No se encontraron datos para mostrar.

+ } + else + { +
+
+
+
+ +
+ +
+ + + + @context.CODIGO + + + @context.DESCRIPCION + + + @context.CONTCOMUNPORCENTEMPR + + + @context.CONTCOMUNPORCENTTRAB + + + @context.CONTCOMUNIMPORTEEMPR + + + @context.CONTCOMUNIMPORTETRAB + + + @context.FORMACIONPROFPORCENTEMPR + + + @context.FORMACIONPROFPORCENTTRAB + + + @context.FORMACIONPROFIMPORTEEMPR + + + @context.FORMACIONPROFIMPORTETRAB + + + @context.ACCITIMSCNAEPORCENTEMPR + + + @context.ACCITIMSCNAEPORCENTTRAB + + + @context.ACCITIMSCNAEIMPORTEEMPR + + + @context.ACCITIMSCNAEIMPORTEEMPR + + + @context.DESEMPLEOPORCENTAJEEMPRESA + + + @context.DESEMPLEOPORCENTAJETRABAJADOR + + + @context.DESEMPLEOIMPORTEEMPRESA + + + @context.DESEMPLEOIMPORTETRABAJADOR + + + @context.FOGASAPORCENTAJEEMPRESA + + + @context.FOGASAPORCENTAJETRABAJADOR + + + @context.FOGASAIMPORTEEMPRESA + + + @context.FOGASAIMPORTETRABAJADOR + + + @context.MEIPORCENTAJEEMPRESA + + + @context.MEIPORCENTAJETRABAJADOR + + + @context.MEIIMPORTEEMPRESA + + + @context.MEIIMPORTETRABAJADOR + + + +
+ + + } +
@code { + List lContratos = new List(); + private List contratos = new List(); + private string _filter = ""; + public string Filter + { + get => _filter; + set + { + if (_filter != value) + { + _filter = value; + AplicarFiltros(); + } + } + } + private void AplicarFiltros() + { + lContratos = contratos.Where(per => + string.IsNullOrEmpty(Filter) || + Utilidades.RemoveDiacritics(per.DESCRIPCION).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) + ).ToList(); + UserState.CurrentPage = 1; + } + // Bandera que indica si se está en modo "Ver Todos" + private bool verTodosActive = false; + List mensajes = new List(); + + private async Task ToggleVerTodos() + { + if (!verTodosActive) + { + verTodosActive = true; + var token = UserState.Token; + var client = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + var resultPersonas = await client.GetAsync("/CONTRATOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + contratos = JsonConvert.DeserializeObject>(resultContent) + ?? new List(); + } + else + { + verTodosActive = false; + var token = UserState.Token; + var client = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + var resultPersonas = await client.GetAsync("/api/CONTRATOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + contratos = JsonConvert.DeserializeObject>(resultContent) + ?? new List(); + } + + contratos = contratos.ToList(); + + lContratos = contratos; + UserState.CurrentPage = 1; + Filter = ""; + } + + protected override async Task OnInitializedAsync() + { + verTodosActive = false; + var token = UserState.Token; + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + var resultPersonas = await cliente.GetAsync("/api/CONTRATOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + contratos = JsonConvert.DeserializeObject>(resultContent) ?? new List(); + + contratos = contratos.ToList(); + + lContratos = contratos; + } + + private string HashRed(string id) + { + string link = "/Contrato?cl=" + tsUtilidades.crypt.FEncS( + id, + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + 875421649); + return link; + } } + diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentaCotizacion.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentaCotizacion.razor new file mode 100644 index 0000000..f505069 --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentaCotizacion.razor @@ -0,0 +1,297 @@ +@page "/CuentaCotizacion" +@page "/CuentaCotizacion/{cl}" +@using BlazorBootstrap +@using GestionPersonalWeb.Components.Pages.FicherosMaestros.TipoPuestoTrabajoComponents +@using Newtonsoft.Json +@using GestionPersonalWeb.Components.Layout +@using Microsoft.AspNetCore.WebUtilities +@using GestionPersonalWeb.Components.Pages.InfoPersComponents +@using GestionPersonalWeb.Models +@using System.Linq.Expressions +@using Serialize.Linq.Serializers +@using System.Net.Http.Headers +@using bdAntifraude.clases +@using bdAntifraude.db +@using System.Reflection +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@inject IJSRuntime JSRuntime +@inject IJSRuntime JS +@rendermode InteractiveServer +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState +@inject ProtectedSessionStorage ProtectedSessionStore +@inject NavigationManager Navigation + + +@*
+
Tipo puesto de trabajo: @puestoTrabajo.DESCRIPCION
+
*@ + +
+
+
+
+
+
+
Cuenta Cotizacion Patronal
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
Coeficientes Reductores, Contigencias Excluidas
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ +
+
+
Datos del titular
+
+
+
+
+ + + + @if (lTipoIPF != null) + { + @foreach (var enumera in lTipoIPF) + { + + } + } + +
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + + +@code { + [Parameter] + public string? cl { get; set; } = ""; + private static bdAntifraude.db.CUENTASCOTIZACIONPATRONAL iCuentaContizacion = new CUENTASCOTIZACIONPATRONAL(); + private EditContext editContext = new EditContext(iCuentaContizacion); + + private HttpClient cliente = new HttpClient(); + private ValidationMessageStore? messageStore; + private string errorMessage = ""; + List mensajes = new List(); + public bool mostrar { get; set; } = true; + public bool mostrarBtn { get; set; } = false; + + private List lTipoIPF = new List(); + + + + protected override async Task OnInitializedAsync() + { + try + { + var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) + { + cl = clValue; + } + + if (string.IsNullOrEmpty(cl)) + { + iCuentaContizacion = new CUENTASCOTIZACIONPATRONAL(); + mostrarBtn = true; + } + else + { + string idDesencriptado = Utilidades.Desencriptar(cl); + int id = int.Parse(idDesencriptado); + + var response = await cliente.GetAsync($"/api/CUENTASCOTIZACIONPATRONAL/{id}"); + if (!response.IsSuccessStatusCode) + { + throw new Exception($"Error al obtener los datos. Código: {response.StatusCode}"); + } + var resultContent = await response.Content.ReadAsStringAsync(); + iCuentaContizacion = JsonConvert.DeserializeObject(resultContent) ?? throw new Exception("Error al deserializar los datos de la persona."); + } + editContext = new EditContext(iCuentaContizacion); + messageStore = new ValidationMessageStore(editContext); + + mostrar = false; + + lTipoIPF = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/TIPIPF"); + } + catch (Exception ex) + { + errorMessage = ex.Message; + Console.WriteLine($"Error durante la inicialización: {ex.Message}"); + mostrar = false; + } + finally + { + mostrar = false; + } + } + + private async Task GuardarPuestoTrabajo() + { + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + if (!editContext.GetValidationMessages().Any()) + { + if (iCuentaContizacion.IDCUENTACOTIZACIONPATRONAL == 0)//Nuevo + { + var response = await Utilidades.NuevoObjeto(cliente, "/api/CUENTASCOTIZACIONPATRONAL", iCuentaContizacion, mensajes); + if (response != null) + { + iCuentaContizacion = response; + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + await InvokeAsync(StateHasChanged); + } + else//Guardar + { + var response = await Utilidades.ActualizarObjeto(cliente, "/api/CUENTASCOTIZACIONPATRONAL/" + iCuentaContizacion.IDCUENTACOTIZACIONPATRONAL, iCuentaContizacion, mensajes); + } + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = Utilidades.ListaErroresHtml(editContext.GetValidationMessages()), + }); + + } + } + +} diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentasCotizacion.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentasCotizacion.razor index fe7642a..331a0aa 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentasCotizacion.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/CuentasCotizacion.razor @@ -1,5 +1,129 @@ -

CuentasCotizacion

+@page "/CuentasCotizacion" +@using System.Net.Http.Headers +@using System.Linq.Expressions +@using Newtonsoft.Json +@using System.Text +@using Serialize.Linq.Serializers +@using GestionPersonalWeb.Models +@using BlazorBootstrap +@using bdAntifraude.db +@using Microsoft.AspNetCore.Components +@rendermode InteractiveServer +@inject IJSRuntime JS +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState + +
+
+
+
+ Cuentas Cotización +
+
+ Nuevo +
+ + @if (lCuentasCotizacion == null) + { +
+
+
+ } + else if (!lCuentasCotizacion.Any()) + { +

No se encontraron datos para mostrar.

+ } + else + { +
+
+
+
+ +
+ +
+ + + + @context.NOMBRE + + + @context.DESCRIPCION + + + +
+ + + } +
@code { + List lCuentasCotizacion = new List(); + private List cuentasCoti = new List(); + private string _filter = ""; + public string Filter + { + get => _filter; + set + { + if (_filter != value) + { + _filter = value; + AplicarFiltros(); + } + } + } + private void AplicarFiltros() + { + lCuentasCotizacion = cuentasCoti.Where(per => + string.IsNullOrEmpty(Filter) || + Utilidades.RemoveDiacritics(per.DESCRIPCION).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) + ).ToList(); + UserState.CurrentPage = 1; + } + // Bandera que indica si se está en modo "Ver Todos" + private bool verTodosActive = false; + List mensajes = new List(); + + protected override async Task OnInitializedAsync() + { + verTodosActive = false; + var token = UserState.Token; + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + var resultPersonas = await cliente.GetAsync("/api/CUENTASCOTIZACIONPATRONAL"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + cuentasCoti = JsonConvert.DeserializeObject>(resultContent) ?? new List(); + + cuentasCoti = cuentasCoti.ToList(); + + lCuentasCotizacion = cuentasCoti; + } + + private string HashRed(string id) + { + string link = "/CuentaCotizacion?cl=" + tsUtilidades.crypt.FEncS( + id, + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + 875421649); + return link; + } } + diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Fiestas.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Fiestas.razor index 7093a9e..e0feb69 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Fiestas.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/Fiestas.razor @@ -8,7 +8,6 @@ @using BlazorBootstrap @using bdAntifraude.db @using Microsoft.AspNetCore.Components - @rendermode InteractiveServer @inject IJSRuntime JS @inject NavigationManager NavigationManager @@ -16,9 +15,15 @@ @inject IHttpContextAccessor HttpContextAccessor @inject UserState UserState +
-
-
Fiestas
+
+
+
+ Fiestas +
+
+
@if (lFiestas == null) @@ -54,6 +59,9 @@ Responsive="true" PaginationItemsTextFormat="{0} - {1} de {2} elementos"> + + + @context.FECHA.Value.ToString().Substring(0,10) @@ -70,11 +78,40 @@ }
- + + + + + +
+
+ + +
+
+ + +
+
+
+ + + + +
+
@code { - private List lFiestas = new List(); + List lFiestas = new List(); private List fiestas = new List(); private string _filter = ""; + + private string tituloPopup = ""; + private Modal popupGestionDatos = default; + private bool EsItemNuevo = false; + private FIESTAS ItemEnEdicion { get; set; } = new FIESTAS(); + + private EditContext? editContext; + public string Filter { get => _filter; @@ -95,18 +132,9 @@ ).ToList(); UserState.CurrentPage = 1; } - - private string HashRed(string id) - { - string link = "/infoPers?cl=" + tsUtilidades.crypt.FEncS( - id, - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", - 875421649); - return link; - } // Bandera que indica si se está en modo "Ver Todos" private bool verTodosActive = false; + List mensajes = new List(); private async Task ToggleVerTodos() { @@ -114,10 +142,7 @@ { verTodosActive = true; var token = UserState.Token; - var client = HttpClientFactory.CreateClient(); - client.BaseAddress = new Uri(Utilidades.urlSwagger()); - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + var client = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); var resultPersonas = await client.GetAsync("/FIESTAS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); @@ -128,10 +153,7 @@ { verTodosActive = false; var token = UserState.Token; - var client = HttpClientFactory.CreateClient(); - client.BaseAddress = new Uri(Utilidades.urlSwagger()); - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + var client = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); var resultPersonas = await client.GetAsync("/api/FIESTAS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); @@ -152,12 +174,10 @@ { verTodosActive = false; var token = UserState.Token; - var client = HttpClientFactory.CreateClient(); - client.BaseAddress = new Uri(Utilidades.urlSwagger()); - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + editContext = new EditContext(lFiestas); - var resultPersonas = await client.GetAsync("/api/FIESTAS"); + var resultPersonas = await cliente.GetAsync("/api/FIESTAS"); var resultContent = await resultPersonas.Content.ReadAsStringAsync(); fiestas = JsonConvert.DeserializeObject>(resultContent) ?? new List(); @@ -169,5 +189,96 @@ lFiestas = fiestas; } + private async Task abrirPopupModificacion(FIESTAS objeto, bool esNuevo) + { + ItemEnEdicion = Utilidades.ClonarObjeto(objeto); + EsItemNuevo = esNuevo; + if (!EsItemNuevo) + { + tituloPopup = "Modificando Fiesta"; + } + else + { + tituloPopup = "Nueva Fiesta"; + } + + await popupGestionDatos.ShowAsync(); + } + private async Task cerrarPopupModificacion() + { + await popupGestionDatos.HideAsync(); + } + private async Task GuardarCambiosPopup() + { + try + { + ValidarDatos(); + + if (!editContext!.GetValidationMessages().Any()) + { + string accion = EsItemNuevo ? "create" : "update"; + await GestionarDatos(accion); + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Warning, + Message = $"Debe rellenar los campos obligatorios.", + }); + } + + } + catch (Exception) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = $"Error al guardar.", + }); + } + + } + private async Task GestionarDatos(string accion) + { + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + var copia = new List(lFiestas); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + switch (accion) + { + case "update": + int indice = copia.FindIndex(x => x.IDFIESTA == ItemEnEdicion.IDFIESTA); + if (indice > -1) + { + copia[indice] = ItemEnEdicion; + } + var response = await Utilidades.ActualizarObjeto(cliente, "/api/FIESTAS/" + ItemEnEdicion.IDFIESTA, ItemEnEdicion, mensajes); + + break; + case "create": + copia.Add(ItemEnEdicion); + var responsec = await Utilidades.NuevoObjeto(cliente, "/api/FIESTAS/", ItemEnEdicion, mensajes); + break; + case "delete": + + break; + } + cerrarPopupModificacion(); + lFiestas = copia.ToList(); + await InvokeAsync(StateHasChanged); + } + private void ValidarDatos() + { + + } + private void MostrarErroresPopup() + { + // messageStore?.Clear(); + // foreach (var field in new[] { nameof(descripcionItem) }) + // { + // ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field); + // } + } } diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposTramoSiltra.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposTramoSiltra.razor new file mode 100644 index 0000000..982d282 --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposTramoSiltra.razor @@ -0,0 +1,476 @@ +@page "/TiposTramosSiltra" +@using System.Net.Http.Headers +@using System.Linq.Expressions +@using Newtonsoft.Json +@using System.Text +@using Serialize.Linq.Serializers +@using GestionPersonalWeb.Models +@using BlazorBootstrap +@using bdAntifraude.db +@using Microsoft.AspNetCore.Components +@rendermode InteractiveServer +@inject IJSRuntime JS +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState + +
+
+
Tipos tramos SILTRA
+ +
+ + @if (lTiposTramoSiltra == null) + { +
+
+
+ } + else if (!lTiposTramoSiltra.Any()) + { +

No se encontraron datos para mostrar.

+ } + else + { +
+
+
+
+ +
+ +
+ + + + + + + @context.CODIGO + + + @context.DESCRIPCION + + + @if (@context.IDCODIGOTRAMOACUMULA != null) + { + lTiposTramoSiltra.First(x => x.IDCODIGOTRAMOACUMULA == @context.IDCODIGOTRAMOACUMULA); + } + + + @if (context.SOLICITADOALUSUARIO) + { + + } + + + @if (@context.IDREGIMENAPLICACION != null) + { + lRegimenAplicacion.First(x => x.IDENUMERACION == @context.IDREGIMENAPLICACION); + } + + + @if (@context.IDTIPOTRAMOFICHEROXML != null) + { + lTipoFicheroXml.First(x => x.IDENUMERACION == @context.IDTIPOTRAMOFICHEROXML); + } + + + @if (context.SEMANDAIMPORTEEMPRESA) + { + + } + + + @if (context.MODIFICABLE) + { + + } + + + @if (context.RESTAENACUMULADO) + { + + } + + + +
+ + +
+ @foreach (var itm in lTiposTramoSiltra) + { + var collapseId = $"collapse{itm.IDTIPOTRAMOS}"; +
+ +
+
+
+
Código
+
@itm.CODIGO
+
Descripcion
+
@itm.DESCRIPCION
+
Código Tramo Acumulado
+
+ @if (@itm.IDCODIGOTRAMOACUMULANavigation != null) + { + @itm.IDCODIGOTRAMOACUMULANavigation.CODIGO + } +
+
Solicitado al usuario
+
+ @itm.SOLICITADOALUSUARIO + +@* @if(itm.OBSOLETO) + { + + } + else + { + + } *@ +
+
Regimen Aplicación
+
@itm.IDREGIMENAPLICACIONNavigation
+
Tipo Fichero XML
+
+ @if (@itm.IDTIPOTRAMOFICHEROXMLNavigation != null) + { + @itm.IDTIPOTRAMOFICHEROXMLNavigation.DESCRIPCION + } +
+
Se Manda Importe a Empresa
+
+ @itm.SEMANDAIMPORTEEMPRESA + + @* @if(itm.OBSOLETO) + { + + } + else + { + + } *@ +
+
Modificable
+
+ @itm.MODIFICABLE + + @* @if(itm.OBSOLETO) + { + + } + else + { + + } *@ +
+
Resta en Acumulado
+
+ @itm.RESTAENACUMULADO + + @* @if(itm.OBSOLETO) + { + + } + else + { + + } *@ +
+
+ +
+
+
+
+
+ } +
+ } +
+ + + + +
+
+ + +
+
+ + +
+
+ + + + @if (lTiposTramoSiltra != null) + { + @foreach (var enumera in lTiposTramoSiltra) + { + + } + } + +
+
+ + + + @if (lRegimenAplicacion != null) + { + @foreach (var enumera in lRegimenAplicacion) + { + + } + } + +
+
+ + + + @if (lTipoFicheroXml != null) + { + @foreach (var enumera in lTipoFicheroXml) + { + + } + } + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + + +
+
+@code { + private List lTiposTramoSiltra = new List(); + private List banco = new List(); + + private string tituloPopup = ""; + private Modal popupGestionDatos = default; + private bool EsItemNuevo = false; + private TIPOSTRAMOS ItemEnEdicion { get; set; } = new TIPOSTRAMOS(); + + List mensajes = new List(); + private EditContext? editContext; + + private List lTipoFicheroXml = new List(); + private List lRegimenAplicacion = new List(); + + private string _filter = ""; + public string Filter + { + get => _filter; + set + { + if (_filter != value) + { + _filter = value; + AplicarFiltros(); + } + } + } + private void AplicarFiltros() + { + lTiposTramoSiltra = banco.Where(per => + string.IsNullOrEmpty(Filter) || + Utilidades.RemoveDiacritics(per.CODIGO).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) || + Utilidades.RemoveDiacritics(per.DESCRIPCION.ToString()).Contains(Utilidades.RemoveDiacritics(Filter), StringComparison.OrdinalIgnoreCase) + ).ToList(); + UserState.CurrentPage = 1; + } + // Bandera que indica si se está en modo "Ver Todos" + private bool verTodosActive = false; + + private async Task ToggleVerTodos() + { + if (!verTodosActive) + { + verTodosActive = true; + var token = UserState.Token; + var client = HttpClientFactory.CreateClient(); + client.BaseAddress = new Uri(Utilidades.urlSwagger()); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var resultPersonas = await client.GetAsync("/TIPOSTRAMOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + banco = JsonConvert.DeserializeObject>(resultContent) + ?? new List(); + } + else + { + verTodosActive = false; + var token = UserState.Token; + var client = HttpClientFactory.CreateClient(); + client.BaseAddress = new Uri(Utilidades.urlSwagger()); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var resultPersonas = await client.GetAsync("/api/TIPOSTRAMOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + banco = JsonConvert.DeserializeObject>(resultContent) + ?? new List(); + } + + banco = banco + .OrderBy(x => x.CODIGO) + .ToList(); + + lTiposTramoSiltra = banco; + UserState.CurrentPage = 1; + Filter = ""; + } + + protected override async Task OnInitializedAsync() + { + verTodosActive = false; + var token = UserState.Token; + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + editContext = new EditContext(lTiposTramoSiltra); + var resultPersonas = await cliente.GetAsync("/api/TIPOSTRAMOS"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + banco = JsonConvert.DeserializeObject>(resultContent) + ?? new List(); + + banco = banco.OrderBy(x => x.CODIGO) + .ToList(); + + lTiposTramoSiltra = banco; + + lTipoFicheroXml = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/TIPTRAXML"); + lRegimenAplicacion = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/REGAPL"); + + } + private async Task abrirPopupModificacion(TIPOSTRAMOS objeto, bool esNuevo) + { + ItemEnEdicion = Utilidades.ClonarObjeto(objeto); + EsItemNuevo = esNuevo; + if (!EsItemNuevo) + { + tituloPopup = "Modificando Tipo Tramo Siltra"; + } + else + { + tituloPopup = "Nuevo Tipo Tramo Siltra"; + } + + await popupGestionDatos.ShowAsync(); + } + private async Task cerrarPopupModificacion() + { + await popupGestionDatos.HideAsync(); + } + + // GUARDAR + private async Task GuardarCambiosPopup() + { + try + { + ValidarDatos(); + + if (!editContext!.GetValidationMessages().Any()) + { + string accion = EsItemNuevo ? "create" : "update"; + await GestionarDatos(accion); + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Warning, + Message = $"Debe rellenar los campos obligatorios.", + }); + } + + } + catch (Exception) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = $"Error al guardar.", + }); + } + + } + private async Task GestionarDatos(string accion) + { + var copia = new List(lTiposTramoSiltra); + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + switch (accion) + { + case "update": + int indice = copia.FindIndex(x => x.IDTIPOTRAMOS == ItemEnEdicion.IDTIPOTRAMOS); + if (indice > -1) + { + copia[indice] = ItemEnEdicion; + } + var response = await Utilidades.ActualizarObjeto(cliente, "/api/TIPOSTRAMOS/" + ItemEnEdicion.IDTIPOTRAMOS, ItemEnEdicion, mensajes); + + break; + case "create": + copia.Add(ItemEnEdicion); + var responsec = await Utilidades.NuevoObjeto(cliente, "/api/TIPOSTRAMOS/", ItemEnEdicion, mensajes); + break; + case "delete": + + break; + } + cerrarPopupModificacion(); + lTiposTramoSiltra = copia.OrderBy(x => x.CODIGO).ToList(); + await InvokeAsync(StateHasChanged); + } + private void ValidarDatos() + { + + } + private void MostrarErroresPopup() + { + // messageStore?.Clear(); + // foreach (var field in new[] { nameof(descripcionItem) }) + // { + // ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field); + // } + } +} + diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValorNomina.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValorNomina.razor new file mode 100644 index 0000000..ba47984 --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValorNomina.razor @@ -0,0 +1,363 @@ +@page "/ValorNomina" +@page "/ValorNomina/{cl}" +@using BlazorBootstrap +@using GestionPersonalWeb.Components.Pages.FicherosMaestros.TipoPuestoTrabajoComponents +@using Newtonsoft.Json +@using GestionPersonalWeb.Components.Layout +@using Microsoft.AspNetCore.WebUtilities +@using GestionPersonalWeb.Components.Pages.InfoPersComponents +@using GestionPersonalWeb.Models +@using System.Linq.Expressions +@using Serialize.Linq.Serializers +@using System.Net.Http.Headers +@using bdAntifraude.clases +@using bdAntifraude.db +@using System.Reflection +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@inject IJSRuntime JSRuntime +@inject IJSRuntime JS +@rendermode InteractiveServer +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState +@inject ProtectedSessionStorage ProtectedSessionStore +@inject NavigationManager Navigation + + +@*
+
Tipo puesto de trabajo: @puestoTrabajo.DESCRIPCION
+
*@ + + +
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
Valor Nomina
+
+
+
+
+
Sueldos
+ + + + + + + + + + + + +
+
+
+
+
Sueldos Extra
+ + + + + + + + + + + + +
+ +
+
+
+
Trienio Administración
+ + + + + + + + + + + + +
+
+
+
+
Trienio Administración Extra
+ + + + + + + + + + + + +
+
+
+
+
Trienio Oficina Antifraude
+ + + + + + + + + + + + +
+
+
+
+
Trienio Oficina Antifraude Extra
+ + + + + + + + + + + + +
+
+
+
+
Complemento Carrera Tramo I
+ + + + + + + + + + + + +
+
+
+
+
Complemento Carrera Tramo II
+ + + + + + + + + + + + +
+
+
+
+
Complemento Carrera Tramo III
+ + + + + + + + + + + + +
+
+
+
+
Complemento Carrera Tramo IV
+ + + + + + + + + + + + +
+
+
+
+
Complemento Carrera Tramo V
+ + + + + + + + + + + + +
+
+
+
+
+
+
+ + + +@code { + [Parameter] + public string? cl { get; set; } = ""; + private static bdAntifraude.db.VALORESNOMINA oValorNomina = new VALORESNOMINA(); + private EditContext editContext = new EditContext(oValorNomina); + + private HttpClient cliente = new HttpClient(); + private ValidationMessageStore? messageStore; + private string errorMessage = ""; + List mensajes = new List(); + public bool mostrar { get; set; } = true; + public bool mostrarBtn { get; set; } = false; + + + + protected override async Task OnInitializedAsync() + { + try + { + var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) + { + cl = clValue; + } + + if (string.IsNullOrEmpty(cl)) + { + oValorNomina = new VALORESNOMINA(); + mostrarBtn = true; + } + else + { + // ListaSexos = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/SEXO"); + string idDesencriptado = Utilidades.Desencriptar(cl); + int id = int.Parse(idDesencriptado); + + var response = await cliente.GetAsync($"/api/VALORESNOMINA/{id}"); + if (!response.IsSuccessStatusCode) + { + throw new Exception($"Error al obtener los datos del Tipo de Trabajo. Código: {response.StatusCode}"); + } + var resultContent = await response.Content.ReadAsStringAsync(); + oValorNomina = JsonConvert.DeserializeObject(resultContent) ?? throw new Exception("Error al deserializar los datos."); + } + editContext = new EditContext(oValorNomina); + messageStore = new ValidationMessageStore(editContext); + + mostrar = false; + } + catch (Exception ex) + { + errorMessage = ex.Message; + Console.WriteLine($"Error durante la inicialización: {ex.Message}"); + mostrar = false; + } + finally + { + mostrar = false; + } + } + + private async Task GuardarPuestoTrabajo() + { + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + if (!editContext.GetValidationMessages().Any()) + { + if (oValorNomina.IDVALNOMINA == 0)//Nuevo + { + var response = await Utilidades.NuevoObjeto(cliente, "/api/VALORESNOMINA", oValorNomina, mensajes); + if (response != null) + { + oValorNomina = response; + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + await InvokeAsync(StateHasChanged); + } + else//Guardar + { + var response = await Utilidades.ActualizarObjeto(cliente, "/api/VALORESNOMINA/" + oValorNomina.IDVALNOMINA, oValorNomina, mensajes); + } + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = Utilidades.ListaErroresHtml(editContext.GetValidationMessages()), + }); + + } + } + +} diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValoresNomina.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValoresNomina.razor index e7bc882..1eff7b8 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValoresNomina.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/ValoresNomina.razor @@ -1,5 +1,104 @@ -

ValoresNomina

+@page "/ValoresNomina" +@using System.Net.Http.Headers +@using System.Linq.Expressions +@using Newtonsoft.Json +@using System.Text +@using Serialize.Linq.Serializers +@using GestionPersonalWeb.Models +@using BlazorBootstrap +@using bdAntifraude.db +@using Microsoft.AspNetCore.Components +@rendermode InteractiveServer +@inject IJSRuntime JS +@inject NavigationManager NavigationManager +@inject IHttpClientFactory HttpClientFactory +@inject IHttpContextAccessor HttpContextAccessor +@inject UserState UserState + +
+
+
+
+ Valores Nomina +
+
+ Nuevo +
+ + @if (lValoresNomina == null) + { +
+
+
+ } + else if (!lValoresNomina.Any()) + { +

No se encontraron datos para mostrar.

+ } + else + { +
+
+
+ +
+ + + + @context.FECHAINCIO + + + @context.FECHAFIN + + + +
+ + + } +
@code { + List lValoresNomina = new List(); + private List cuentasCoti = new List(); + + // Bandera que indica si se está en modo "Ver Todos" + private bool verTodosActive = false; + List mensajes = new List(); + protected override async Task OnInitializedAsync() + { + verTodosActive = false; + var token = UserState.Token; + var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + var resultPersonas = await cliente.GetAsync("/api/VALORESNOMINA"); + var resultContent = await resultPersonas.Content.ReadAsStringAsync(); + cuentasCoti = JsonConvert.DeserializeObject>(resultContent) ?? new List(); + + cuentasCoti = cuentasCoti.ToList(); + + lValoresNomina = cuentasCoti; + } + + private string HashRed(string id) + { + string link = "/ValorNomina?cl=" + tsUtilidades.crypt.FEncS( + id, + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + 875421649); + return link; + } } + diff --git a/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSTRAMOSController.cs b/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSTRAMOSController.cs index 99899c3..80c0e44 100644 --- a/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSTRAMOSController.cs +++ b/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSTRAMOSController.cs @@ -1,5 +1,8 @@ using bdAntifraude.db; +using bdAntifraude.dbcontext; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; namespace SwaggerAntifraude.Controllers { @@ -11,5 +14,30 @@ namespace SwaggerAntifraude.Controllers : base() { } + + [HttpGet] + public override async Task GetAll() + { + try + { + using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false)) + { + var entities = await context.TIPOSTRAMOS + .Include(x => x.IDTIPOTRAMOFICHEROXMLNavigation) + .Include(x => x.IDCODIGOTRAMOACUMULANavigation) + .Include(x => x.IDREGIMENAPLICACIONNavigation) + .AsNoTracking() + .ToListAsync(); + //.Include(v => v.IDSERVICIOADSCRITONavigation) + //.Include(v => v.IDUNIDADADMINISTRATIVANavigation) + return Ok(entities); + } + } + catch (Exception ex) + { + return StatusCode(500, $"Error interno del servidor: {ex.Message}"); + } + } + } } diff --git a/Antifraude.Net/SwaggerAntifraude/Controllers/VALORESNOMINAController.cs b/Antifraude.Net/SwaggerAntifraude/Controllers/VALORESNOMINAController.cs new file mode 100644 index 0000000..607e03c --- /dev/null +++ b/Antifraude.Net/SwaggerAntifraude/Controllers/VALORESNOMINAController.cs @@ -0,0 +1,15 @@ +using bdAntifraude.db; +using Microsoft.AspNetCore.Mvc; + +namespace SwaggerAntifraude.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class VALORESNOMINAController : GenericoController + { + public VALORESNOMINAController() + : base() + { + } + } +}