From a3d9768a4d8ee62d46d76c7185063ab3a26b5520 Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Apr 2026 14:22:49 +0200 Subject: [PATCH 1/5] Creacion del Fichero Maestro "Tipos puestos trabajo" y sus ventanas --- .../FicherosMaestros/TipoPuestoTrabajo.razor | 234 ++++++++++++++ .../ConceptosTipoTrabajoGrid.razor | 297 ++++++++++++++++++ .../FicherosMaestros/TiposPuestoTrabajo.razor | 14 +- .../Components/Pages/InfoPers.razor | 2 +- .../GestionPersonalWeb/Models/Utilidades.cs | 138 +++++++- .../CONCEPTOSTIPOSPUESTOSTRABAJOController.cs | 70 +++++ .../TIPOSPUESTOSTRABAJOController.cs | 10 +- 7 files changed, 741 insertions(+), 24 deletions(-) create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajo.razor create mode 100644 Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor create mode 100644 Antifraude.Net/SwaggerAntifraude/Controllers/CONCEPTOSTIPOSPUESTOSTRABAJOController.cs diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajo.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajo.razor new file mode 100644 index 0000000..aedabfe --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajo.razor @@ -0,0 +1,234 @@ +@page "/TipoPuestoTrabajo" +@page "/TipoPuestoTrabajo/{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
+
*@ + +
+
+
+
+
+
+
+
+ + +
+
+ + + + @if (lGrupos != null) + { + @foreach (var enumera in lGrupos) + { + + } + } + + +
+
+ + +
+
+
+
+
+
+ + + + @if (lTipoPersonal != null) + { + @foreach (var enumera in lTipoPersonal) + { + + } + } + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ @if (puestoTrabajo.IDTIPOPUESTO != 0) + { + + } +
+
+
+ + + +@code { + [Parameter] + public string? cl { get; set; } = ""; + private static bdAntifraude.db.TIPOSPUESTOSTRABAJO puestoTrabajo = new TIPOSPUESTOSTRABAJO(); + private List lGrupos = new List(); + private List lTipoPersonal = new List(); + private EditContext editContext = new EditContext(puestoTrabajo); + private Tabs tabsPuesTrab { get; set; } = new Tabs(); + + 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)) + { + puestoTrabajo = new TIPOSPUESTOSTRABAJO(); + 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/TIPOSPUESTOSTRABAJO/{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(); + puestoTrabajo = JsonConvert.DeserializeObject(resultContent) ?? throw new Exception("Error al deserializar los datos de la persona."); + } + editContext = new EditContext(puestoTrabajo); + messageStore = new ValidationMessageStore(editContext); + + mostrar = false; + await CargarSelects(); + } + 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 (puestoTrabajo.IDTIPOPUESTO == 0)//Nuevo + { + var response = await Utilidades.NuevoObjeto(cliente, "/api/TIPOSPUESTOSTRABAJO", puestoTrabajo,mensajes); + if (response != null) + { + puestoTrabajo = response; + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + await InvokeAsync(StateHasChanged); + } + else//Guardar + { + var response = await Utilidades.ActualizarObjeto(cliente, "/api/TIPOSPUESTOSTRABAJO/" + puestoTrabajo.IDTIPOPUESTO, puestoTrabajo,mensajes); + } + } + else + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = Utilidades.ListaErroresHtml(editContext.GetValidationMessages()), + }); + + } + } + + private async Task CargarSelects() + { + try + { + + lTipoPersonal = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/TIPPER"); + lGrupos = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/GRUPOFUNCIONARIO"); + StateHasChanged(); + } + catch (Exception ex) + { + errorMessage = ex.Message; + Console.WriteLine($"Error durante la inicialización: {ex.Message}"); + mostrar = false; + } + + } +} diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor new file mode 100644 index 0000000..ba88d03 --- /dev/null +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor @@ -0,0 +1,297 @@ +@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 + + + +
+
+ +
+
+ Conceptos Tipos Puestos de Trabajo +
+
+
+
+ + + + + + + + @lConceptosGenerales.First(x => x.IDCONCEPTOSGENERALES == context.IDCONCEPTOGENERAL).DESCRIPCION + + + @context.DESCRIPCION + + + @context.IMPORTE + + + @context.CONCEPTOAPLPRES + + + @context.APLICACIONPRESUPUESTARIA + + + @if (context.COTIZASEGURIDADSOCIAL) + { + + } + + + @if (context.COTIZAIRPF) + { + + } + + + @if (context.RETRIBUCIONES) + { + + } + + + @if (context.DEDUCCIONES) + { + + } + + + @if (context.EXTRA) + { + + } + + + + +
+
+ + + + + +
+
+ + + + @if (lConceptosGenerales != null) + { + @foreach (var concepto in lConceptosGenerales) + { + + } + } + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ + + + +
+
+@code { + [Parameter] + public TIPOSPUESTOSTRABAJO PuestoTrabajo { get; set; } = new TIPOSPUESTOSTRABAJO(); + private HttpClient cliente = new HttpClient(); + private List itmList = new List(); + private List lConceptosGenerales = new List(); + + private string tituloPopup = ""; + private Modal popupGestionDatos = default; + private bool EsItemNuevo = false; + private CONCEPTOSTIPOSPUESTOSTRABAJO ItemEnEdicion { get; set; } = new CONCEPTOSTIPOSPUESTOSTRABAJO(); + + private EditContext? editContext; + List listnom = new List(); + + List mensajes = new List(); + + protected override async Task OnInitializedAsync() + { + try + { + listnom= PuestoTrabajo.CONCEPTOSTIPOSPUESTOSTRABAJO.ToList(); + foreach (CONCEPTOSTIPOSPUESTOSTRABAJO i in listnom) { itmList.Add(i); } + editContext=new EditContext(listnom); + + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + lConceptosGenerales = await Utilidades.ObtenerObjeto>(cliente, "/api/CONCEPTOSGENERALES/"); + } + catch (Exception e) + { + Console.WriteLine($"Error al obtener los datos: {e.Message}"); + } + } + + private async Task abrirPopupModificacion( CONCEPTOSTIPOSPUESTOSTRABAJO objeto, bool esNuevo) + { + ItemEnEdicion = Utilidades.ClonarObjeto(objeto); + EsItemNuevo = esNuevo; + if (!EsItemNuevo) + { + tituloPopup = "Modificando Concepto Tipo Trabajo"; + } + else + { + tituloPopup = "Nuevo Concepto Tipo Trabajo"; + } + + 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(itmList); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + + switch (accion) + { + case "update": + int indice = copia.FindIndex(x => x.IDCONCEPTOSTIPOSPUESTOTRABAJO == ItemEnEdicion.IDCONCEPTOSTIPOSPUESTOTRABAJO); + if (indice > -1) + { + copia[indice] = ItemEnEdicion; + } + var response = await Utilidades.ActualizarObjeto(cliente, "/api/CONCEPTOSTIPOSPUESTOSTRABAJO/" + ItemEnEdicion.IDCONCEPTOSTIPOSPUESTOTRABAJO, ItemEnEdicion, mensajes); + + break; + case "create": + ItemEnEdicion.IDTIPOPUESTOSTRABAJO = PuestoTrabajo.IDTIPOPUESTO; + copia.Add(ItemEnEdicion); + var responsec = await Utilidades.NuevoObjeto(cliente, "/api/CONCEPTOSTIPOSPUESTOSTRABAJO/", ItemEnEdicion,mensajes); + break; + case "delete": + + break; + } + cerrarPopupModificacion(); + itmList = 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/TiposPuestoTrabajo.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor index 5c8e896..f24f357 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor @@ -17,8 +17,13 @@ @inject UserState UserState
-
-
Tipos puesto de trabajo
+
+ Nuevo +
+
+ Conceptos Tipos Puestos de Trabajo +
+
@if (lPuestos == null) @@ -54,6 +59,9 @@ Responsive="true" PaginationItemsTextFormat="{0} - {1} de {2} elementos"> +@* + @context.IDTIPOPUESTO + *@ @context.DESCRIPCION @@ -186,7 +194,7 @@ // } private string HashRed(string id) { - string link = "/infoPers?cl=" + tsUtilidades.crypt.FEncS( + string link = "/TipoPuestoTrabajo?cl=" + tsUtilidades.crypt.FEncS( id, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor index 3e893ca..4ec0d80 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor @@ -383,7 +383,7 @@ if (persona.IDFICHEROFOTO != null) { var responsef = await Utilidades.ActualizarObjeto(cliente, "/api/FICHEROS/" + fi.IDFICHERO, fi); - persona.IDFICHEROFOTO = responsef.IDFICHERO; + //persona.IDFICHEROFOTO = responsef.IDFICHERO; } else diff --git a/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs b/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs index 459cfa9..575086b 100644 --- a/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs +++ b/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs @@ -1,15 +1,18 @@ -using System.Net.Http.Headers; -using Newtonsoft.Json; -using System.Linq.Expressions; -using Serialize.Linq.Serializers; -using System.Text; -using System.Globalization; -using tsDocumentos; -using Microsoft.JSInterop; +using BlazorBootstrap; using ClosedXML.Excel; //using System.Drawing; using ClosedXML.Excel; +using DevExpress.DataAccess.Native.Web; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.JSInterop; using MigraDocCore.DocumentObjectModel; +using Newtonsoft.Json; +using Serialize.Linq.Serializers; +using System.Globalization; +using System.Linq.Expressions; +using System.Net.Http.Headers; +using System.Text; +using tsDocumentos; namespace GestionPersonalWeb.Models @@ -111,7 +114,7 @@ namespace GestionPersonalWeb.Models return default(T); } } - public static async Task NuevoObjeto(HttpClient cliente, String uri, T objeto) + public static async Task NuevoObjeto(HttpClient cliente, String uri, T objeto, List mensajes = null) { try { @@ -122,22 +125,77 @@ namespace GestionPersonalWeb.Models if (response.IsSuccessStatusCode) { + if (mensajes != null) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } var resultContent = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(resultContent); } else { + if (mensajes != null) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = $"{response}", + AutoHide = false + }); + } return default(T); } + } catch (Exception ex) { var mess = ex.ToString(); + if (mensajes != null) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"{mess}", + AutoHide = false + }); + } + return default(T); } } - public static async Task ActualizarObjeto(HttpClient cliente, String uri, T objeto) + //public static async Task ActualizarObjeto(HttpClient cliente, String uri, T objeto) + //{ + // try + // { + // // Limpiar propiedades de navegación + // VaciarPropiedadesDeNavegacion(objeto); + + // // Realizar la solicitud PUT + // var response = await cliente.PutAsJsonAsync(uri, objeto); + + // if (response.IsSuccessStatusCode) + // { + // var resultContent = await response.Content.ReadAsStringAsync(); + // return JsonConvert.DeserializeObject(resultContent); + // } + // else + // { + // Console.WriteLine($"Error al actualizar: {response.StatusCode}, {await response.Content.ReadAsStringAsync()}"); + // return default(T); + // } + // } + // catch (Exception ex) + // { + // var mess = ex.ToString(); + // return default(T); + // } + //} + public static async Task ActualizarObjeto(HttpClient cliente, String uri, T objeto, List mensajes = null) { try { @@ -149,19 +207,40 @@ namespace GestionPersonalWeb.Models if (response.IsSuccessStatusCode) { - var resultContent = await response.Content.ReadAsStringAsync(); - return JsonConvert.DeserializeObject(resultContent); + //var resultContent = await response.Content.ReadAsStringAsync(); + //return JsonConvert.DeserializeObject(resultContent); + + if (mensajes != null) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Success, + Message = $"Guardado Correctamente.", + }); + } + return "Ok"; } else { - Console.WriteLine($"Error al actualizar: {response.StatusCode}, {await response.Content.ReadAsStringAsync()}"); - return default(T); + //Console.WriteLine($"Error al actualizar: {response.StatusCode}, {await response.Content.ReadAsStringAsync()}"); + //return default(T); + + if (mensajes != null) + { + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + Message = $"{response}", + AutoHide = false + }); + } + return $"Error al actualizar: {response.StatusCode}, {await response.Content.ReadAsStringAsync()}"; } } catch (Exception ex) { var mess = ex.ToString(); - return default(T); + return mess; } } public static async Task ExportarExcelEnBrowser(IJSRuntime js, IEnumerable datos, byte[] logoBytes, XLColor headerColor, string nombreFichero) @@ -201,6 +280,35 @@ namespace GestionPersonalWeb.Models } } + public static string Encriptar(object valor) { + return tsUtilidades.crypt.FEncS(valor.ToString(), + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + 875421649); + } + public static string Desencriptar(object valor) { + return tsUtilidades.crypt.FEncS(valor.ToString(), + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", + -875421649); + } + + public static string ListaErroresHtml(IEnumerable lista) { + var html = ""; + html += "Revise los errores antes de guardar:"; + foreach (string m in lista) + { + html += "\n" + m + ". "; + } + return html; + } + + public static T ClonarObjeto(T objeto) + { + var json = System.Text.Json.JsonSerializer.Serialize(objeto); + return System.Text.Json.JsonSerializer.Deserialize(json); + } + } } diff --git a/Antifraude.Net/SwaggerAntifraude/Controllers/CONCEPTOSTIPOSPUESTOSTRABAJOController.cs b/Antifraude.Net/SwaggerAntifraude/Controllers/CONCEPTOSTIPOSPUESTOSTRABAJOController.cs new file mode 100644 index 0000000..f054ec2 --- /dev/null +++ b/Antifraude.Net/SwaggerAntifraude/Controllers/CONCEPTOSTIPOSPUESTOSTRABAJOController.cs @@ -0,0 +1,70 @@ +using bdAntifraude.db; +using bdAntifraude.dbcontext; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using Serialize.Linq.Serializers; +using System.Linq.Expressions; +using SwaggerAntifraude.Controllers; + +namespace SwaggerAntifraude.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class CONCEPTOSTIPOSPUESTOSTRABAJOController : GenericoController + { + public CONCEPTOSTIPOSPUESTOSTRABAJOController() + : base() + { + } + + [HttpGet] + public override async Task GetAll() + { + try + { + using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false)) + { + var entities = await context.CONCEPTOSTIPOSPUESTOSTRABAJO + //.Include(x => x.IDTIPOPERSONANavigation) + .AsNoTracking() + .ToListAsync(); + return Ok(entities); + } + } + catch (Exception ex) + { + return StatusCode(500, $"Error interno del servidor: {ex.Message}"); + } + } + + [Authorize(Policy = "LecturaPolicy")] + [HttpGet("{id}")] + public override IActionResult GetById(int id) + { + try + { + using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false)) + { + //var dbSet = context.Set(); + var entities = context.CONCEPTOSTIPOSPUESTOSTRABAJO + .AsNoTracking() + .FirstOrDefault(v => v.IDCONCEPTOSTIPOSPUESTOTRABAJO == id); + + + + if (entities == null) + return NotFound(); + + return Ok(entities); + } + } + catch (Exception ex) + { + return StatusCode(500, $"Error interno del servidor: {ex.Message}"); + } + } + + + } +} diff --git a/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSPUESTOSTRABAJOController.cs b/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSPUESTOSTRABAJOController.cs index 4b64d16..a7ffa41 100644 --- a/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSPUESTOSTRABAJOController.cs +++ b/Antifraude.Net/SwaggerAntifraude/Controllers/TIPOSPUESTOSTRABAJOController.cs @@ -27,6 +27,7 @@ namespace SwaggerAntifraude.Controllers { var entities = await context.TIPOSPUESTOSTRABAJO .Include(x => x.IDTIPOPERSONANavigation) + .Include(x=> x.CONCEPTOSTIPOSPUESTOSTRABAJO).ThenInclude(x=> x.IDCONCEPTOGENERALNavigation) .AsNoTracking() .ToListAsync(); return Ok(entities); @@ -47,13 +48,12 @@ namespace SwaggerAntifraude.Controllers using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false)) { //var dbSet = context.Set(); - var entities = context.NOMINAS - .Include(x => x.IDTIPONavigation) - .Include(x => x.IDSITUACIONNOMINANavigation) - //.Include(x => x.NOMINATRABAJADORCABECERA) + var entities = context.TIPOSPUESTOSTRABAJO + .Include(x => x.IDTIPOPERSONANavigation) + .Include(x => x.CONCEPTOSTIPOSPUESTOSTRABAJO).ThenInclude(x => x.IDCONCEPTOGENERALNavigation) //.ThenInclude(pr => pr.IDPERSONANavigation) .AsNoTracking() - .FirstOrDefault(v => v.IDNOMINAS == id); + .FirstOrDefault(v => v.IDTIPOPUESTO == id); From 9b4e8071ac633e103620333c3e8cf24aa7b01fdc Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Apr 2026 14:52:12 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Ajustes=20dise=C3=B1o=20Puesto=20de=20traba?= =?UTF-8?q?jo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConceptosTipoTrabajoGrid.razor | 38 +++++++++---------- .../FicherosMaestros/TiposPuestoTrabajo.razor | 4 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor index ba88d03..cbdb8f2 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TipoPuestoTrabajoComponents/ConceptosTipoTrabajoGrid.razor @@ -18,12 +18,12 @@
-
-
+
Conceptos Tipos Puestos de Trabajo
+
- +
-
-
- +
+
+
- +
- +
-
-
+
+
-
+
+
+ + +
-
+
-
+
-
-
- - -
-
diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor index f24f357..2fd6864 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/FicherosMaestros/TiposPuestoTrabajo.razor @@ -18,12 +18,12 @@
- Nuevo
-
+
Conceptos Tipos Puestos de Trabajo
+ Nuevo
@if (lPuestos == null) From d066628241c2e52a1705ed650ccc548f542d875e Mon Sep 17 00:00:00 2001 From: Alejandro Date: Thu, 23 Apr 2026 14:23:37 +0200 Subject: [PATCH 3/5] actualizacion gestionWeb --- .../Components/Pages/InfoPers.razor | 4 +- .../Components/Pages/NominaPersona.razor | 122 ++++++++++++++---- .../GestionPersonalWeb/Models/Utilidades.cs | 4 +- .../Components/Pages/ListadoPersonas.razor | 2 +- .../NOMINATRABAJADORCABECERAController.cs | 6 +- .../extensiones/NOMINATRABAJADORCABECERA.cs | 12 +- 6 files changed, 119 insertions(+), 31 deletions(-) diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor index 4ec0d80..42fee09 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/InfoPers.razor @@ -404,7 +404,9 @@ } else//Actualizar { - var responsea = await Utilidades.ActualizarObjeto(cliente, "/api/PERSONAS/" + persona.IDPERSONA, persona); + var personaGuardar = persona; + personaGuardar.NOMINATRABAJADORCABECERA = null; + var responsea = await Utilidades.ActualizarObjeto(cliente, "/api/PERSONAS/" + personaGuardar.IDPERSONA, personaGuardar); var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) { cl = clValue; } cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Pages/NominaPersona.razor b/Antifraude.Net/GestionPersonalWeb/Components/Pages/NominaPersona.razor index 8f6b1db..88dc566 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Pages/NominaPersona.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Pages/NominaPersona.razor @@ -22,19 +22,19 @@
- +
- +
- +
- + @if (lSexo != null) { @@ -47,7 +47,7 @@
- + @if (lTipoContra != null) { @@ -60,6 +60,20 @@ @* *@
+ + + + +

Se van a dar de alta o modificar datos de la persona seleccionada ¿desea continuar?

+
+ + + + + + +
+
@@ -125,11 +139,11 @@ @if (Nomina.IDSINDICATO1Navigation != null) { - + } else { - + }
@@ -149,7 +163,7 @@ @if (Nomina.IDSINDICATO2Navigation != null) { - + } else { @@ -591,7 +605,7 @@ @code { [Parameter] public PERSONAS Persona { get; set; } = new PERSONAS(); - public NOMINATRABAJADORCABECERA Nomina { get; set; } = new NOMINATRABAJADORCABECERA(); + public static NOMINATRABAJADORCABECERA Nomina { get; set; } = new NOMINATRABAJADORCABECERA(); private HttpClient cliente = new HttpClient(); [Parameter] public EventCallback OnPersonaActualizada { get; set; } @@ -605,10 +619,23 @@ private List lSiltra= new List(); private ValidationMessageStore? messageStore; private string errorMessage = ""; + public string nifDesencriptado { get; set; } + public int NominaDesencriptada { get; set; } public string? cl { get; set; } = ""; public string? cn { get; set; } = ""; private Tabs tabsDtsPer { get; set; } = new Tabs(); private Tabs tabsDtsNom { get; set; } = new Tabs(); + private Modal popupConfirmacion = default!; + List mensajes = new List(); + private EditContext editContext = new EditContext(Nomina); + private async Task abrirGuardar() + { + await popupConfirmacion.ShowAsync(); + } + private async Task CerrarConfirmacion() + { + await popupConfirmacion.HideAsync(); + } private async Task OnTabShownAsync(TabsEventArgs args) { var panelActivo = args.ActiveTabName; @@ -625,22 +652,17 @@ if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) { cl = clValue; - } - // if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cn", out var cnValue)) - // { - // cn = cnValue; - // } - + } cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); - // ListaSexos = await Utilidades.ObtenerObjeto>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/SEXO"); + string clDesencriptado = tsUtilidades.crypt.FEncS(cl, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", -875421649); var clCn = clDesencriptado.Split("-"); - var nifDesencriptado = clCn[0]; - var NominaDesencriptada = Int32.Parse(clCn[1]); + nifDesencriptado = clCn[0]; + NominaDesencriptada = Int32.Parse(clCn[1]); // int NominaDesencriptada = Int32.Parse(tsUtilidades.crypt.FEncS(cn, // "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", // "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", @@ -678,8 +700,6 @@ Console.WriteLine($"Error durante la inicialización: {ex.Message}"); } } - - private string HashRed(string id) { string link = "/PeriodoSiltra?cl=" + tsUtilidades.crypt.FEncS( @@ -689,8 +709,6 @@ 875421649); return link; } - - private async Task CargarSelects() { try @@ -712,6 +730,66 @@ } } + private async Task GuardarNomina() + { + CerrarConfirmacion(); + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + // ValidarTodos(); + if (!editContext.GetValidationMessages().Any()) + + { + if (Nomina.IDNOMINATRABAJADOR== 0)//Nuevo + { + + var response = await Utilidades.NuevoObjeto(cliente, "/api/NOMINATRABAJADORCABECERA", Nomina); + string link = "/NomPers?cl=" + tsUtilidades.crypt.FEncS(response.IDNOMINATRABAJADOR.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649); + NavigationManager.NavigateTo(link, forceLoad: true); + + } + else//Actualizar + { + // Nomina.IMPORTESEGURO = null; + var responsea = await Utilidades.ActualizarObjeto(cliente, "/api/NOMINATRABAJADORCABECERA/" + Nomina.IDNOMINATRABAJADOR, Nomina); + var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue)) { cl = clValue; } + cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory); + var responsePers = await cliente.GetAsync($"/api/PERSONAS/PersonaNominaNif/{nifDesencriptado}"); + if (!responsePers.IsSuccessStatusCode) + { + throw new Exception($"Error al obtener los datos de la persona. Código: {responsePers.StatusCode}"); + } + + var resultContentPers = await responsePers.Content.ReadAsStringAsync(); + Persona = JsonConvert.DeserializeObject(resultContentPers) ?? throw new Exception("Error al deserializar los datos de la persona."); + Nomina = Persona.NOMINATRABAJADORCABECERA?.FirstOrDefault(x => x.IDNOMINA == NominaDesencriptada); + + mensajes.Add(new ToastMessage + { + Type = ToastType.Primary, + Message = $"Guardado correctamente.", + }); + } + } + else + { + var html = ""; + html += "Revise los errores antes de guardar:"; + foreach (string m in editContext.GetValidationMessages()) + { + html += "\n" + m + ". "; + } + + mensajes.Add(new ToastMessage + { + Type = ToastType.Danger, + + Message = html, + + }); + + } + + } } diff --git a/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs b/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs index 575086b..78cc176 100644 --- a/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs +++ b/Antifraude.Net/GestionPersonalWeb/Models/Utilidades.cs @@ -198,13 +198,13 @@ namespace GestionPersonalWeb.Models public static async Task ActualizarObjeto(HttpClient cliente, String uri, T objeto, List mensajes = null) { try - { + { // Limpiar propiedades de navegación VaciarPropiedadesDeNavegacion(objeto); // Realizar la solicitud PUT var response = await cliente.PutAsJsonAsync(uri, objeto); - + if (response.IsSuccessStatusCode) { //var resultContent = await response.Content.ReadAsStringAsync(); diff --git a/Antifraude.Net/RegistroPersonalAN/Components/Pages/ListadoPersonas.razor b/Antifraude.Net/RegistroPersonalAN/Components/Pages/ListadoPersonas.razor index 3f8a0bf..2c0ff0a 100644 --- a/Antifraude.Net/RegistroPersonalAN/Components/Pages/ListadoPersonas.razor +++ b/Antifraude.Net/RegistroPersonalAN/Components/Pages/ListadoPersonas.razor @@ -1,4 +1,4 @@ -@page "/ListadoPersonas" + @page "/ListadoPersonas" @using System.Net.Http.Headers @using System.Linq.Expressions @using Newtonsoft.Json diff --git a/Antifraude.Net/SwaggerAntifraude/Controllers/NOMINATRABAJADORCABECERAController.cs b/Antifraude.Net/SwaggerAntifraude/Controllers/NOMINATRABAJADORCABECERAController.cs index 39eddae..1524e7e 100644 --- a/Antifraude.Net/SwaggerAntifraude/Controllers/NOMINATRABAJADORCABECERAController.cs +++ b/Antifraude.Net/SwaggerAntifraude/Controllers/NOMINATRABAJADORCABECERAController.cs @@ -26,10 +26,10 @@ namespace SwaggerAntifraude.Controllers using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false)) { //var dbSet = context.Set(); - var entities = context.PERIODOSSILTRA - .Include(x => x.TRAMOSSILTRA) + var entities = context.NOMINATRABAJADORCABECERA + .Include(x => x.IDPERSONANavigation) .AsNoTracking() - .FirstOrDefault(v => v.IDPERIODOSILTRA == id); + .FirstOrDefault(v => v.IDNOMINATRABAJADOR == id); diff --git a/Antifraude.Net/bdAntifraude/extensiones/NOMINATRABAJADORCABECERA.cs b/Antifraude.Net/bdAntifraude/extensiones/NOMINATRABAJADORCABECERA.cs index d44579d..dd9991d 100644 --- a/Antifraude.Net/bdAntifraude/extensiones/NOMINATRABAJADORCABECERA.cs +++ b/Antifraude.Net/bdAntifraude/extensiones/NOMINATRABAJADORCABECERA.cs @@ -1631,11 +1631,19 @@ namespace bdAntifraude.db } } [NotMapped] - public double IMPORTESEGURO + public double? IMPORTESEGURO { get { - return (double)(this.IDPERSONANavigation.SEGUROACCIDENTE); + if (this.IDPERSONANavigation != null) + { +return (double)(this.IDPERSONANavigation.SEGUROACCIDENTE); + } + else + { + return 0; + } + } } From 3d6288ca34ada5f902e92bec65f5e8698b1e1bd9 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Thu, 23 Apr 2026 14:52:51 +0200 Subject: [PATCH 4/5] cambios gestionWeb --- .../GestionPersonalWeb/Components/Layout/MainLayout.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Antifraude.Net/GestionPersonalWeb/Components/Layout/MainLayout.razor b/Antifraude.Net/GestionPersonalWeb/Components/Layout/MainLayout.razor index 9bffa19..6db8bba 100644 --- a/Antifraude.Net/GestionPersonalWeb/Components/Layout/MainLayout.razor +++ b/Antifraude.Net/GestionPersonalWeb/Components/Layout/MainLayout.razor @@ -92,7 +92,7 @@