Primera versión
This commit is contained in:
@@ -0,0 +1,488 @@
|
||||
@* @page "/CDCIConf"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="factoCompleForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Nº Trabajadores:</label>
|
||||
<NumberInput TValue="int" @bind-Value="itemSeleccionado.numTrabajadores" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.numTrabajadores))" class="inputForm"></NumberInput>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.numTrabajadores))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Horas Prod. Anuales:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.HorasProduccionAnuales"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.HorasProduccionAnuales))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.HorasProduccionAnuales))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Horas Mínimo Anuales:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.CosteMinimoPersonal"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.CosteMinimoPersonal))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.CosteMinimoPersonal))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coste Máximo Personal:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.CosteMaxPersonal"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.CosteMaxPersonal))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.CosteMaxPersonal))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coste Directo Medio:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.HorasProduccionAnuales"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.HorasProduccionAnuales))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.HorasProduccionAnuales))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Costes Directos:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.CostesDirectos"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.CostesDirectos))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.CostesDirectos))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Costes Indirectos:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.CostesIndirectos"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.CostesIndirectos))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.CostesIndirectos))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Total Despacho Profesional:</label>
|
||||
<InputNumber TValue="double" @bind-Value="itemSeleccionado.TotalDespachoProfesional"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.TotalDespachoProfesional))"
|
||||
class="inputForm" Step="InputNumber" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.TotalDespachoProfesional))</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new costedespachoprofesional(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo CD+CI</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="costedespachoprofesional"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoCDCI"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
Height="100"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Nº Trabajadores">
|
||||
<span>@context.numTrabajadores</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Horas Prod. Anuales">
|
||||
<span>@context.HorasProduccionAnuales</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Coste Min. Personal">
|
||||
<span>@context.CosteMinimoPersonal</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Coste Max. Personal">
|
||||
<span>@context.CosteMaxPersonal</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Coste Directo Medio">
|
||||
<span>@context.CosteDirectoMedio</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Costes Directos">
|
||||
<span>@context.CostesDirectos</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Coste Indirectos">
|
||||
<span>@context.CostesIndirectos</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="costedespachoprofesional" HeaderText="Total Despacho Profesional">
|
||||
<span>@context.TotalDespachoProfesional</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="costedespachoprofesional" style="text-align: center !important;" HeaderText="">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" style="cursor: pointer;">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" style="cursor: pointer;">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<costedespachoprofesional> listadoCDCI { get; set; } = new List<costedespachoprofesional>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private costedespachoprofesional itemSeleccionado { get; set; } = new costedespachoprofesional();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string tipoFactorComplejidad = "FACCOMP.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoCDCI = bd.costedespachoprofesional.OrderBy(x => x.numTrabajadores).ToList();
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(costedespachoprofesional objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar CD+CI";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo CD+CI";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
|
||||
case nameof(itemSeleccionado.numTrabajadores):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.numTrabajadores = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSeleccionado.numTrabajadores = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case nameof(itemSeleccionado.HorasProduccionAnuales):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.HorasProduccionAnuales = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.HorasProduccionAnuales = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.CosteMinimoPersonal):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.CosteMinimoPersonal = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.CosteMinimoPersonal = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.CosteMaxPersonal):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.CosteMaxPersonal = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.CosteMaxPersonal = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.CosteDirectoMedio):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.CosteDirectoMedio = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.CosteDirectoMedio = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.CostesDirectos):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.CostesDirectos = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.CostesDirectos = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.CostesIndirectos):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.CostesIndirectos = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.CostesIndirectos = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.TotalDespachoProfesional):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.TotalDespachoProfesional = double.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSeleccionado.TotalDespachoProfesional = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.numTrabajadores }, nameof(itemSeleccionado.numTrabajadores));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.HorasProduccionAnuales }, nameof(itemSeleccionado.HorasProduccionAnuales));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.CosteMinimoPersonal }, nameof(itemSeleccionado.CosteMinimoPersonal));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.CosteMaxPersonal }, nameof(itemSeleccionado.CosteMaxPersonal));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.CosteDirectoMedio }, nameof(itemSeleccionado.CosteDirectoMedio));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.CostesIndirectos }, nameof(itemSeleccionado.CostesIndirectos));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.CostesDirectos }, nameof(itemSeleccionado.CostesDirectos));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.TotalDespachoProfesional }, nameof(itemSeleccionado.TotalDespachoProfesional));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var costeObtenido = bd.costedespachoprofesional.Where(x => x.idCosteDespachoProfesional == itemSeleccionado.idCosteDespachoProfesional).FirstOrDefault();
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarCosteDespachoProfesional(bd, costeObtenido, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearCosteDespachoProfesional(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarCosteDespachoProfesional(bd, costeObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoCDCI = bd.costedespachoprofesional.OrderBy(x => x.numTrabajadores).ToList();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(costedespachoprofesional objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] {
|
||||
nameof(itemSeleccionado.numTrabajadores),
|
||||
nameof(itemSeleccionado.HorasProduccionAnuales),
|
||||
nameof(itemSeleccionado.CosteMinimoPersonal),
|
||||
nameof(itemSeleccionado.CosteMaxPersonal),
|
||||
nameof(itemSeleccionado.CosteDirectoMedio),
|
||||
nameof(itemSeleccionado.CostesDirectos),
|
||||
nameof(itemSeleccionado.CostesIndirectos),
|
||||
nameof(itemSeleccionado.TotalDespachoProfesional)
|
||||
})
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(factorescorreccion).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
} *@
|
||||
@@ -0,0 +1,192 @@
|
||||
@page "/CalculoCDCI"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<div class="container-fluid">
|
||||
<span>Usa esta herramienta para ver como se calcula la tabla de CD+CI que se utiliza en los calculos</span>
|
||||
<br />
|
||||
<span>Seleccione una Provincia: </span>
|
||||
<InputSelect @bind-Value="@convenioSeleccionado" class="inputForm" @oninput="e => CalcularTabla(e.Value.ToString())">
|
||||
<option value="">Estatal</option>
|
||||
<option value="04">Almería</option>
|
||||
<option value="11">Cádiz</option>
|
||||
<option value="14">Córdoba</option>
|
||||
<option value="18">Granada</option>
|
||||
<option value="15">Huelva</option>
|
||||
<option value="29">Málaga</option>
|
||||
<option value="41">Sevilla</option>
|
||||
</InputSelect>
|
||||
<br>
|
||||
<b>Equipo de trabajo minimo:</b>
|
||||
<br />
|
||||
<div class="d-flex" style="">
|
||||
Titulado grado superior: <br />
|
||||
<InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda" Value="@minimoGradoSuperior" ValueExpression="() => minimoGradoSuperior" ValueChanged="(value) => MinimoSupCambiado(value)"></InputNumber>
|
||||
</div>
|
||||
<div class="d-flex" style="">
|
||||
Titulado grado medio: <br />
|
||||
<InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda" Value="@minimoGradoMedio" ValueExpression="() => minimoGradoMedio" ValueChanged="(value) => MinimoMedCambiado(value)"></InputNumber>
|
||||
</div>
|
||||
<table class="bb-table tablaCACOA table" style="width:275px">
|
||||
<tr>
|
||||
<td width="120">Téc. Superior</td>
|
||||
<td>@ValorTecSuperior</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Téc. Medio</td>
|
||||
<td>@ValorTecMedio</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Téc. Medio</td>
|
||||
<td>@ValorDelineante</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jornada Laboral Anual</td>
|
||||
<td>@jornadaLaboralAnual</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>%Horas Produccion media</td>
|
||||
<td>@horasProdMedia</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>%Costes Variables</td>
|
||||
<td>@porcentajeCostesVariables</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IPC COSTE INDIRECTO</td>
|
||||
<td>@ipcCosteDirecto</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<Grid TItem="CosteDirectoIndirecto"
|
||||
Class="tablaCACOA table"
|
||||
Data="listaCDCI"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
Height="100"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Nº Trabajadores">
|
||||
<span>@context.NumeroTrabajadores</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Horas Producción Anuales">
|
||||
<span>@context.HorasProduccionAnuales</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Coste Min Personal">
|
||||
<span>@context.CosteMinimoPersonal</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Coste Max Personal">
|
||||
<span>@context.CosteMaximoPersonal</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Coste Directo Medio">
|
||||
<span>@context.CosteMedioPersonal</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Costes Directos">
|
||||
<span>@context.CostesDirectos</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Costes Indirectos">
|
||||
<span>@context.CostesIndirectos</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Costes Variables">
|
||||
<span>@context.CostesVariables</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="CosteDirectoIndirecto" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Total Costes">
|
||||
<span>@context.TotalDespachoProfesional</span>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
public tsHerramientasCACOA bd;
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
string convenioSeleccionado = "";
|
||||
double ValorTecSuperior = 0;
|
||||
double ValorTecMedio = 0;
|
||||
double ValorDelineante = 0;
|
||||
int jornadaLaboralAnual = 0;
|
||||
double horasProdMedia = 0;
|
||||
double porcentajeCostesVariables = 0;
|
||||
double ipcCosteDirecto = 1;
|
||||
int minimoGradoSuperior = 1;
|
||||
int minimoGradoMedio = 0;
|
||||
|
||||
List<CosteDirectoIndirecto> listaCDCI { get; set; } = new List<CosteDirectoIndirecto>();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
CalcularTabla("");
|
||||
}
|
||||
private async Task MinimoSupCambiado(int valor)
|
||||
{
|
||||
if (valor < 1)
|
||||
{
|
||||
minimoGradoSuperior = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
minimoGradoSuperior = valor;
|
||||
}
|
||||
CalcularTabla(convenioSeleccionado);
|
||||
}
|
||||
private async Task MinimoMedCambiado(int valor)
|
||||
{
|
||||
|
||||
minimoGradoMedio = valor;
|
||||
CalcularTabla(convenioSeleccionado);
|
||||
}
|
||||
private async Task CalcularTabla(string idProvincia)
|
||||
{
|
||||
listaCDCI = new List<CosteDirectoIndirecto>();
|
||||
//Obtenemos variables a utilizar
|
||||
jornadaLaboralAnual =(int) bd.enumeraciones.First(x => x.Codigo == "VARCASA.JORLABANUAL").ValorNumerico1;
|
||||
horasProdMedia =(double) bd.enumeraciones.First(x => x.Codigo == "VARCASA.HORPRODMEDIA").ValorNumerico1;
|
||||
porcentajeCostesVariables = (double)bd.enumeraciones.First(x => x.Codigo == "VARCASA.COSTESVARIABLES").ValorNumerico1;
|
||||
ipcCosteDirecto = (double)bd.enumeraciones.First(x => x.Codigo == "VARCASA.IPCCD").ValorNumerico1;
|
||||
|
||||
var idGradSup = bd.enumeraciones.First(x => x.Codigo == "PUESTOTRABAJO.TECGRADSUP").idEnumeracion;
|
||||
var idGradMed = bd.enumeraciones.First(x => x.Codigo == "PUESTOTRABAJO.GESTPROY").idEnumeracion;
|
||||
var idDelin = bd.enumeraciones.First(x => x.Codigo == "PUESTOTRABAJO.DELINPROY").idEnumeracion;
|
||||
if(idProvincia== ""){ idProvincia = null; }
|
||||
|
||||
ValorTecSuperior = bd.conveniocolectivo.FirstOrDefault(x => x.idProvincia == idProvincia && x.idEnumeracion == idGradSup) != null ? bd.conveniocolectivo.First(x => x.idProvincia == idProvincia && x.idEnumeracion == idGradSup).CosteAnualTrabajador : 0;
|
||||
ValorTecMedio = bd.conveniocolectivo.FirstOrDefault(x => x.idProvincia == idProvincia && x.idEnumeracion == idGradMed) != null ? bd.conveniocolectivo.First(x => x.idProvincia == idProvincia && x.idEnumeracion == idGradMed).CosteAnualTrabajador : 0;
|
||||
ValorDelineante = bd.conveniocolectivo.FirstOrDefault(x => x.idProvincia == idProvincia && x.idEnumeracion == idDelin) != null ? bd.conveniocolectivo.First(x => x.idProvincia == idProvincia && x.idEnumeracion == idDelin).CosteAnualTrabajador : 0; ;
|
||||
|
||||
double masCaro = Math.Max(ValorTecSuperior, Math.Max(ValorTecMedio, ValorDelineante));
|
||||
double masBarato = Math.Min(ValorTecSuperior, Math.Min(ValorTecMedio, ValorDelineante));
|
||||
|
||||
int minimoTrabajadores = minimoGradoMedio + minimoGradoSuperior;
|
||||
//Se calcula
|
||||
//listaCDCI.Add(new CosteDirectoIndirecto(1, 1 * ValorTecSuperior, 1 * ValorTecSuperior, jornadaLaboralAnual, horasProdMedia, porcentajeCostesVariables));
|
||||
if (minimoTrabajadores == 1 && minimoGradoSuperior == 1)
|
||||
{//Se calcula como siempre, el calculo de licitaciones CASA
|
||||
for (int i = 2; i <= 20; i++)
|
||||
{
|
||||
double costeMinimo = ValorTecSuperior + (masBarato * (i - 1));
|
||||
double costeMaximo = ValorTecSuperior + (masCaro * (i - 1));
|
||||
listaCDCI.Add(new CosteDirectoIndirecto(i, costeMinimo, costeMaximo, jornadaLaboralAnual, horasProdMedia, porcentajeCostesVariables, ipcCosteDirecto));
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Se calcula con minimos, por si ponen minimos en licitaciones URBAN
|
||||
for (int i = minimoTrabajadores+1; i <= 20; i++)
|
||||
{
|
||||
var numresto = i - minimoTrabajadores;
|
||||
double costeMinimo = (ValorTecSuperior*minimoGradoSuperior)+(ValorTecMedio*minimoGradoMedio) + (masBarato * numresto);
|
||||
double costeMaximo = (ValorTecSuperior * minimoGradoSuperior) + (ValorTecMedio * minimoGradoMedio) + (masCaro * (numresto));
|
||||
listaCDCI.Add(new CosteDirectoIndirecto(i, costeMinimo, costeMaximo, jornadaLaboralAnual, horasProdMedia, porcentajeCostesVariables, ipcCosteDirecto));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
@page "/ConvenioColectivo"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="factoCompleForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Titulado Superior:</label>
|
||||
<NumberInput Min="0" TValue="double" @bind-Value="itemSeleccionado.valorGradoSup" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.valorGradoSup))" class="inputForm"></NumberInput>
|
||||
</div>
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Titulado Medio:</label>
|
||||
<NumberInput Min="0" TValue="double" @bind-Value="itemSeleccionado.valorGradoMed" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.valorGradoMed))" class="inputForm"></NumberInput>
|
||||
</div>
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Delineante / BIM:</label>
|
||||
<NumberInput Min="0" TValue="double" @bind-Value="itemSeleccionado.valorDelinPro" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idDelinPro))" class="inputForm"></NumberInput>
|
||||
</div>
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Administrativo:</label>
|
||||
<NumberInput Min="0" TValue="double" @bind-Value="itemSeleccionado.valorAdmin" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idAdmin))" class="inputForm"></NumberInput>
|
||||
</div>
|
||||
<!--<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.CosteAnualTrabajador))</div>-->
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div class="container-fluid mt-3">
|
||||
<div class="form-group mt-4">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<Grid TItem="ConvenioProvincia"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoConProv"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="800"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="ConvenioProvincia" HeaderTextAlignment="Alignment.Center" HeaderText="Convenio">
|
||||
<span>@context.NombreProvincia</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ConvenioProvincia" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Titulado Superior">
|
||||
<span>@context.valorGradoSup.MilesYDecimales() €</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="ConvenioProvincia" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Titulado Medio">
|
||||
<span>@context.valorGradoMed.MilesYDecimales() €</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ConvenioProvincia" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Delineante/BIM">
|
||||
<span>@context.valorDelinPro.MilesYDecimales() €</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="ConvenioProvincia" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Administrativo">
|
||||
<span>@context.valorAdmin.MilesYDecimales() €</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="ConvenioProvincia" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
@*
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" style="cursor: pointer;">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span> *@
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<ConvenioProvincia> listadoConProv = new List<ConvenioProvincia>();
|
||||
public List<ConvenioProvincia> listadoCCAux = new List<ConvenioProvincia>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private ConvenioProvincia itemSeleccionado { get; set; } = new ConvenioProvincia();
|
||||
|
||||
public string Filter { get; set; } = "";
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string tipoFactorComplejidad = "FACCOMP.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
obtenerListaConvenioProvincia();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var a = ex.Message;
|
||||
|
||||
}
|
||||
}
|
||||
private void obtenerListaConvenioProvincia()
|
||||
{
|
||||
var listadoCC = bd.conveniocolectivo.OrderBy(x => x.idProvincia).ToList();
|
||||
var listadoCP = listadoCC.GroupBy(x => x.idProvincia).ToList();
|
||||
for (int i = 0; i < listadoCP.Count; i++)
|
||||
{
|
||||
List<conveniocolectivo> cpg = listadoCP[i].ToList();
|
||||
|
||||
ConvenioProvincia cp = new ConvenioProvincia();
|
||||
cp.id = i;
|
||||
|
||||
cp.idProvincia = cpg.First().idProvincia;
|
||||
if (cp.idProvincia != null)
|
||||
{
|
||||
cp.NombreProvincia = cpg.First().idProvinciaNavigation.Nombre;
|
||||
}
|
||||
var gradoSup = cpg.First(x => x.idEnumeracionNavigation.Codigo == "PUESTOTRABAJO.TECGRADSUP");
|
||||
var gradoMed = cpg.First(x => x.idEnumeracionNavigation.Codigo == "PUESTOTRABAJO.GESTPROY");
|
||||
var delin = cpg.First(x => x.idEnumeracionNavigation.Codigo == "PUESTOTRABAJO.DELINPROY");
|
||||
var admin = cpg.First(x => x.idEnumeracionNavigation.Codigo == "PUESTOTRABAJO.ADMIN");
|
||||
cp.idGradoSup = gradoSup.idConvenioColectivo;
|
||||
cp.valorGradoSup = gradoSup.CosteAnualTrabajador;
|
||||
cp.idGradoMedio = gradoMed.idConvenioColectivo;
|
||||
cp.valorGradoMed = gradoMed.CosteAnualTrabajador;
|
||||
cp.idDelinPro = delin.idConvenioColectivo;
|
||||
cp.valorDelinPro = delin.CosteAnualTrabajador;
|
||||
cp.idAdmin = admin.idConvenioColectivo;
|
||||
cp.valorAdmin = admin.CosteAnualTrabajador;
|
||||
|
||||
listadoConProv.Add(cp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
listadoCCAux = listadoConProv;
|
||||
|
||||
}
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoConProv = new List<ConvenioProvincia>();
|
||||
foreach (ConvenioProvincia item in listadoCCAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoConProv.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(ConvenioProvincia listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.NombreProvincia != null && listado.NombreProvincia.Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task abrirPopupGestionDatos(ConvenioProvincia objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar CD+CI: " + itemSeleccionado.NombreProvincia;
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo CD+CI";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(itemSeleccionado.valorGradoSup):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.valorGradoSup = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSeleccionado.valorGradoSup = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.valorGradoMed):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.valorGradoMed = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSeleccionado.valorGradoMed = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.valorDelinPro):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.valorDelinPro = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSeleccionado.valorDelinPro = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(itemSeleccionado.valorAdmin):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
itemSeleccionado.valorAdmin = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSeleccionado.valorAdmin = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.valorGradoSup }, nameof(itemSeleccionado.valorGradoSup));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.valorGradoMed }, nameof(itemSeleccionado.valorGradoMed));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.valorDelinPro }, nameof(itemSeleccionado.valorDelinPro));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.valorAdmin }, nameof(itemSeleccionado.valorAdmin));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
//var convObtenido = bd.conveniocolectivo.Where(x => x.idConvenioColectivo == itemSeleccionado.idConvenioColectivo).FirstOrDefault();
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarConvenioColectivo(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
// case "create":
|
||||
// UtilidadesCASA.crearConvenioColectivo(bd, itemSeleccionado);
|
||||
|
||||
// await cerrarPopupGestionDatos();
|
||||
// mensajes.Add(new ToastMessage
|
||||
// {
|
||||
// Type = ToastType.Primary,
|
||||
// Message = $"Guardado correctamente.",
|
||||
// });
|
||||
// break;
|
||||
|
||||
// case "delete":
|
||||
// UtilidadesCASA.eliminarCosteDespachoProfesional(bd, costeObtenido);
|
||||
|
||||
// await cerrarPopupConfirmarBorrado();
|
||||
// mensajes.Add(new ToastMessage
|
||||
// {
|
||||
// Type = ToastType.Primary,
|
||||
// Message = $"Eliminado correctamente.",
|
||||
// });
|
||||
// break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
obtenerListaConvenioProvincia();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(ConvenioProvincia objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(itemSeleccionado.valorGradoSup), nameof(itemSeleccionado.valorGradoMed), nameof(itemSeleccionado.valorDelinPro), nameof(itemSeleccionado.valorAdmin) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(ConvenioProvincia).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
@page "/DocumentosUrban"
|
||||
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
|
||||
<div class="container-fluid pt-3">
|
||||
<Tabs>
|
||||
<Tab Title="Tipo Proyectos" Name="tabtipoPro" Active>
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.TipoProyectosUrban listadoTipoDocu="listadoTipoDocu"></HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.TipoProyectosUrban>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Documentación" Name="tabdocu">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.DocuUrban></HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.DocuUrban>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Tipo Documentación" Name="tabTipoDocu">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<CascadingValue Value="this">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.TipoDocuEnumUrban></HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.TipoDocuEnumUrban>
|
||||
</CascadingValue>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Proyecto & Documentación" Name="tabProyDocu">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.ProyectoDocumentacion></HerramientaCASA.Components.Pages.ConfiguracionPages.DocumentosUrbanTabs.ProyectoDocumentacion>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
public tsHerramientasCACOA bd;
|
||||
public List<enumeraciones> listadoTipoDocu { get; set; } = new List<enumeraciones>();
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
|
||||
listadoTipoDocu = bd.enumeraciones.Where(x => x.Codigo.Contains("TIPODOCU.")).ToList();
|
||||
}
|
||||
|
||||
|
||||
public void RefreshState()
|
||||
{
|
||||
listadoTipoDocu = bd.enumeraciones.Where(x => x.Codigo.Contains("TIPODOCU.")).ToList();
|
||||
this.StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="docuForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="200" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coeficiente:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="coeficienteItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(coeficienteItem))"
|
||||
class="inputForm" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Check:</label>
|
||||
<CheckboxInput Class="align-content-center" Value=@checkItem TValue="double" ValueExpression="() => checkItem" ValueChanged="(value) => opcionalCambiado(value)"></CheckboxInput>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new documentacion(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva documentación</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<Grid TItem="documentacion"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoDocumentancion"
|
||||
AllowFiltering="false"
|
||||
AllowPaging="true"
|
||||
PageSize="15"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
PaginationItemsTextFormat="{0} - {1} de {2} elementos"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="documentacion" HeaderTextAlignment="Alignment.Center" HeaderText="Descripcion">
|
||||
<span>@context.Descripcion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="documentacion" Class="columna30Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Coeficiente Horas">
|
||||
<span>@context.CoeficienteHoras.MilesYDecimales()</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="documentacion" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-center" HeaderText="Check">
|
||||
@if (context.Checkeable)
|
||||
{
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon Name="IconName.Check"></Icon>
|
||||
</span>
|
||||
}
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="documentacion" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<documentacion> listadoDocumentancion { get; set; } = new List<documentacion>();
|
||||
public List<documentacion> listadoDocumentancionAux { get; set; } = new List<documentacion>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private documentacion itemSeleccionado { get; set; } = new documentacion();
|
||||
|
||||
private string tituloPopup = "";
|
||||
public string Filter { get; set; } = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private double? coeficienteItem = 0;
|
||||
private bool checkItem = false;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private List<enumeraciones> listadoTipoDocu { get; set; } = new List<enumeraciones>();
|
||||
private string tipoProyectoEnum = "TIPODOCU.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoDocumentancion = bd.documentacion.ToList();
|
||||
listadoDocumentancionAux = listadoDocumentancion;
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoDocumentancion = new List<bdHerramientaCACOA.db.documentacion>();
|
||||
foreach (bdHerramientaCACOA.db.documentacion item in listadoDocumentancionAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoDocumentancion.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.documentacion listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.Descripcion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(documentacion objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
coeficienteItem = 0;
|
||||
checkItem = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.Descripcion;
|
||||
coeficienteItem = objeto.CoeficienteHoras;
|
||||
checkItem = objeto.Checkeable;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar documentanción";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Añadir documentanción";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var docuObtenida = bd.documentacion.Where(x => x.iddocumentacion== itemSeleccionado.iddocumentacion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.Descripcion = descripcionItem;
|
||||
itemSeleccionado.CoeficienteHoras = coeficienteItem;
|
||||
itemSeleccionado.Checkeable = checkItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarDocumentacion(bd, docuObtenida, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearDocumentacion(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarDocumentacion(bd, docuObtenida);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoDocumentancion = bd.documentacion.ToList();
|
||||
listadoDocumentancionAux = listadoDocumentancion;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void opcionalCambiado(bool e)
|
||||
{
|
||||
checkItem = e;
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(documentacion objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(documentacion).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" FormName="docuForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="false" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Proyecto:</label>
|
||||
<InputSelect @bind-Value="@idTipoProyecItem" class="inputForm">
|
||||
@foreach (var grupoProyecto in listProyectos)
|
||||
{
|
||||
<option value="@grupoProyecto.idtipoproyectos">@grupoProyecto.Descripcion</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Documentación:</label>
|
||||
<InputSelect @bind-Value="@idTipoDocItem" class="inputForm">
|
||||
@foreach (var grupoProyecto in listDocu)
|
||||
{
|
||||
<option value="@grupoProyecto.iddocumentacion">@grupoProyecto.Descripcion</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Tipo Documentación:</label>
|
||||
|
||||
<div class="form-check" style="gap:50px;">
|
||||
<div>
|
||||
<input checked="@docuMinimItem" name="instrumentos" type="radio" id="1" class="form-check-input" value="@docuMinimItem" @onchange="() => Seleccionar(1)">
|
||||
<label class="form-check-label" for="1">Mínima</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input checked="@docuOpcionalItem" name="instrumentos" type="radio" id="2" class="form-check-input" value="@docuOpcionalItem" @onchange="() => Seleccionar(2)">
|
||||
<label class="form-check-label" for="2">Opcional</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input checked="@docuNecesaItem" name="instrumentos" type="radio" id="3" class="form-check-input" value="@docuNecesaItem" @onchange="() => Seleccionar(3)">
|
||||
<label class="form-check-label" for="3">Necesaria</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm text-end" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new v_tipoproyecto_documentacion(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva documentación</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<Grid TItem="v_tipoproyecto_documentacion"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoTipos_Docu"
|
||||
AllowFiltering="false"
|
||||
AllowPaging="true"
|
||||
PageSize="15"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
PaginationItemsTextFormat="{0} - {1} de {2} elementos"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" HeaderTextAlignment="Alignment.Center" HeaderText="Tipo Proyecto">
|
||||
<span>@context.tipoproyecto</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" Class="columna30Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Documentación">
|
||||
<span>@context.documentacion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-center" HeaderText="Documentación mínima">
|
||||
@if (context.esMinima == true)
|
||||
{
|
||||
<span>
|
||||
<Icon Name="IconName.Check"></Icon>
|
||||
</span>
|
||||
}
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-center" HeaderText="Documentación opcional">
|
||||
@if (context.esOpcional == true)
|
||||
{
|
||||
<span>
|
||||
<Icon Name="IconName.Check"></Icon>
|
||||
</span>
|
||||
}
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-center" HeaderText="Documentación necesaria">
|
||||
@if (context.esNecesario == true)
|
||||
{
|
||||
<span>
|
||||
<Icon Name="IconName.Check"></Icon>
|
||||
</span>
|
||||
}
|
||||
</GridColumn>
|
||||
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
@context.orden
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="v_tipoproyecto_documentacion" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<v_tipoproyecto_documentacion> listadoTipos_Docu { get; set; } = new List<v_tipoproyecto_documentacion>();
|
||||
public List<v_tipoproyecto_documentacion> listadoTipos_DocuAux { get; set; } = new List<v_tipoproyecto_documentacion>();
|
||||
|
||||
public List<tipoproyectos> listProyectos { get; set; } = new List<tipoproyectos>();
|
||||
public List<documentacion> listDocu { get; set; } = new List<documentacion>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private v_tipoproyecto_documentacion itemSeleccionado { get; set; } = new v_tipoproyecto_documentacion();
|
||||
|
||||
private string tituloPopup = "";
|
||||
public string Filter { get; set; } = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private int? idTipoProyecItem = 0;
|
||||
private int? idTipoDocItem = 0;
|
||||
private int ordenItem= 0;
|
||||
private bool? docuOpcionalItem = false;
|
||||
private bool? docuMinimItem = false;
|
||||
private bool? docuNecesaItem = false;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoTipos_Docu = bd.v_tipoproyecto_documentacion.ToList();
|
||||
listadoTipos_DocuAux = listadoTipos_Docu;
|
||||
|
||||
listProyectos = bd.tipoproyectos.ToList();
|
||||
listDocu = bd.documentacion.ToList();
|
||||
}
|
||||
|
||||
private async void Seleccionar(int item)
|
||||
{
|
||||
switch(item){
|
||||
case 1:
|
||||
docuMinimItem = true;
|
||||
docuNecesaItem = false;
|
||||
docuOpcionalItem = false;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
docuMinimItem = false;
|
||||
docuNecesaItem = false;
|
||||
docuOpcionalItem = true;
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
docuMinimItem = false;
|
||||
docuNecesaItem = true;
|
||||
docuOpcionalItem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoTipos_Docu = new List<bdHerramientaCACOA.db.v_tipoproyecto_documentacion>();
|
||||
foreach (bdHerramientaCACOA.db.v_tipoproyecto_documentacion item in listadoTipos_DocuAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoTipos_Docu.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.v_tipoproyecto_documentacion listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.tipoproyecto.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.documentacion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(v_tipoproyecto_documentacion objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
idTipoProyecItem = 0;
|
||||
idTipoDocItem = 0;
|
||||
ordenItem = 0;
|
||||
docuOpcionalItem = false;
|
||||
docuMinimItem = false;
|
||||
docuNecesaItem = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
idTipoProyecItem = objeto.idtipoproyecto;
|
||||
idTipoDocItem = objeto.iddocumentacion;
|
||||
ordenItem = objeto.orden;
|
||||
docuOpcionalItem = objeto.esOpcional;
|
||||
docuMinimItem = objeto.esMinima;
|
||||
docuNecesaItem = objeto.esNecesario;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar documentanción";
|
||||
}
|
||||
else
|
||||
{
|
||||
idTipoProyecItem = listProyectos.First().idtipoproyectos;
|
||||
idTipoDocItem = listDocu.First().iddocumentacion;
|
||||
|
||||
docuMinimItem = true;
|
||||
|
||||
tituloPopup = "Añadir documentanción";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
var docuObtenida = bd.tipoproyecto_documentacion.Where(x => x.idtipoproyecto_documentacion == itemSeleccionado.idtipoproyecto_documentacion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.idtipoproyecto = idTipoProyecItem;
|
||||
itemSeleccionado.iddocumentacion = idTipoDocItem;
|
||||
itemSeleccionado.orden = ordenItem;
|
||||
itemSeleccionado.esOpcional = docuOpcionalItem;
|
||||
itemSeleccionado.esMinima = docuMinimItem;
|
||||
itemSeleccionado.esNecesario = docuNecesaItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarProyecto_Documentacion(bd, docuObtenida, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearProyecto_Documentacion(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarProyecto_Documentacion(bd, docuObtenida);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoTipos_Docu = bd.v_tipoproyecto_documentacion.ToList();
|
||||
listadoTipos_DocuAux = listadoTipos_Docu;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void opcionalCambiado(bool e)
|
||||
{
|
||||
docuMinimItem= e;
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(v_tipoproyecto_documentacion objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
string accion = nuevoElemento ? "create" : "update";
|
||||
await GestionarDatos(accion);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Danger,
|
||||
Message = $"Error al guardar.",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="costeIndiForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo tipo trabajo</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoTipoDocu"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoTipoDocu { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "TIPODOCU";
|
||||
|
||||
[CascadingParameter]
|
||||
public DocumentosUrban _Parent { get; set; }
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoTipoDocu = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar tipo trabajo";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Añadir tipo trabajo";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoTipoDocu = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
_Parent.RefreshState();
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
Nota: Si es el ùltimo tipo proyecto se borrara tambien su enumerado
|
||||
<br><br />
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="tipoProyeForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="200" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Tipo documento:</label>
|
||||
<InputSelect @bind-Value="@idTipoDocItem" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(idTipoDocItem))">
|
||||
@foreach (var grupoTipologia in listadoTipoDocu)
|
||||
{
|
||||
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||
}
|
||||
</InputSelect>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(idTipoDocItem))</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Abreviatura:</label>
|
||||
<InputText MaxLength="10" @bind-Value="abreviItem" @oninput="e => ValidarYActualizar(e, nameof(abreviItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(abreviItem))</div>
|
||||
</div>
|
||||
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new tipoproyectos(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo tipo proyecto</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<Grid TItem="tipoproyectos"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoTiposProyectos"
|
||||
AllowFiltering="false"
|
||||
AllowPaging="true"
|
||||
PageSize="15"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
PaginationItemsTextFormat="{0} - {1} de {2} elementos"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="tipoproyectos" HeaderTextAlignment="Alignment.Center" HeaderText="Descripcion">
|
||||
<span>@context.Descripcion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipoproyectos" Class="columna30Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Tipo documento">
|
||||
<span>@context.idTipoDocumentoNavigation.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipoproyectos" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho" HeaderText="Abreviatura">
|
||||
<span>@context.Abreviatura</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipoproyectos" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<tipoproyectos> listadoTiposProyectos { get; set; } = new List<tipoproyectos>();
|
||||
public List<tipoproyectos> listadoTiposProyectosAux { get; set; } = new List<tipoproyectos>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private tipoproyectos itemSeleccionado { get; set; } = new tipoproyectos();
|
||||
|
||||
[Parameter]
|
||||
public List<enumeraciones> listadoTipoDocu { get; set; } = new List<enumeraciones>();
|
||||
|
||||
private string tituloPopup = "";
|
||||
public string Filter { get; set; } = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int idTipoDocItem= 0;
|
||||
private string abreviItem = "";
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
|
||||
private string tipoProyectoEnum = "TIPODOCU.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoTiposProyectos = bd.tipoproyectos.Include(x => x.idTipoDocumentoNavigation).Where(x => x.idTipoDocumentoNavigation.Codigo.Contains(tipoProyectoEnum)).OrderBy(x => x.idTipoDocumentoNavigation.Orden).ToList();
|
||||
listadoTiposProyectosAux = listadoTiposProyectos;
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoTiposProyectos = new List<bdHerramientaCACOA.db.tipoproyectos>();
|
||||
foreach (bdHerramientaCACOA.db.tipoproyectos item in listadoTiposProyectosAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoTiposProyectos.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.tipoproyectos listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.idTipoDocumentoNavigation != null && listado.idTipoDocumentoNavigation.ValorAlfabetico1.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.Descripcion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (listado.Abreviatura.ToString().Contains(Filter, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(tipoproyectos objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
idTipoDocItem = 0;
|
||||
abreviItem = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.Descripcion;
|
||||
idTipoDocItem = objeto.idTipoDocumento;
|
||||
abreviItem = objeto.Abreviatura;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar tipo proyecto";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Añadir tipo proyecto";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(abreviItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
abreviItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
abreviItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(idTipoDocItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
idTipoDocItem = int.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
idTipoDocItem = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(abreviItem) && abreviItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La abreviatura no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(idTipoDocItem) && idTipoDocItem == 0)
|
||||
{
|
||||
messageStore?.Add(field, "Seleccione un tipo de documento.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = abreviItem }, nameof(abreviItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = idTipoDocItem }, nameof(idTipoDocItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var tipoProyectoObtenido = bd.tipoproyectos.Where(x => x.idtipoproyectos == itemSeleccionado.idtipoproyectos).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.Descripcion = descripcionItem;
|
||||
itemSeleccionado.Abreviatura = abreviItem;
|
||||
itemSeleccionado.idTipoDocumento = idTipoDocItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarTipoProyecto(bd, tipoProyectoObtenido, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearTipoProyecto(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarTipoProyecto(bd, tipoProyectoObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoTiposProyectos = bd.tipoproyectos.Include(x => x.idTipoDocumentoNavigation).Where(x => x.idTipoDocumentoNavigation.Codigo.Contains(tipoProyectoEnum)).OrderBy(x => x.idTipoDocumentoNavigation.Orden).ToList();
|
||||
listadoTiposProyectosAux = listadoTiposProyectos;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(tipoproyectos objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(abreviItem), nameof(idTipoDocItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(tipoproyectos).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
@page "/Enumeraciones"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
|
||||
|
||||
<div class="container-fluid pt-3">
|
||||
<Tabs>
|
||||
<Tab Title="Costes Indirectos" Name="tabCostesIndi" Active>
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.CostesIndirectosConf ></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.CostesIndirectosConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Periodos" Name="tabPeriodos">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.PeriodosConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.PeriodosConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Puestos Trabajos" Name="tabPuestosTrabajo">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.PuestosTrabajoConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.PuestosTrabajoConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Intervenciones" Name="tabIntervenciones">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.IntervencionesConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.IntervencionesConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Fases" Name="tabFases">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Costes Variables" Name="tabCosteVariable">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.CostesVariablesConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.CostesVariablesConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Otros Trabajos" Name="tabOtrosTrabajos">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.OtrosTrabajosConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.OtrosTrabajosConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Factores complejidad" Name="tabFactComple">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FactorCompleEnum></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FactorCompleEnum>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
<Tab Title="Factores rendimiento" Name="tabFactRend">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FactorRendiEnum></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FactorRendiEnum>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="costeIndiForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo coste indirecto</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoCostesIndirectos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoCostesIndirectos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "CI";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoCostesIndirectos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar coste indirecto";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo coste indirecto";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoCostesIndirectos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem)})
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="puestoTrabForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo coste variable</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoCostesVariables"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoCostesVariables { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "CV";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoCostesVariables = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar coste variable";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo coste variable";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoCostesVariables = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>Al crear un nuevo factor se añadirá automaticamente el "factor medio (0%) por seguridad"</p>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo factor complejidad</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoPeriodos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoPeriodos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "FACCOMP";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar factor complejidad";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo factor complejidad";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
try
|
||||
{
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
bd.SaveChanges();
|
||||
factorescorreccion fc = new factorescorreccion();
|
||||
fc.idEnumeracion = itemSeleccionado.idEnumeracion;
|
||||
fc.Descripcion = itemSeleccionado.ValorAlfabetico1 + "Medio (0%)";
|
||||
fc.Coeficiente = 0;
|
||||
UtilidadesCASA.crearFactorCorrecion(bd, fc);
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
string error = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem)})
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>Al crear un nuevo factor se añadirá automaticamente el "factor medio (0%) por seguridad"</p>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo factor rendimiento</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoPeriodos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoPeriodos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "FACREND";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar factor rendimiento";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo factor rendimiento";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
try
|
||||
{
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
bd.SaveChanges();
|
||||
factorescorreccion fc = new factorescorreccion();
|
||||
fc.idEnumeracion = itemSeleccionado.idEnumeracion;
|
||||
fc.Descripcion = itemSeleccionado.ValorAlfabetico1 + "Medio (0%)";
|
||||
fc.Coeficiente = 0;
|
||||
UtilidadesCASA.crearFactorCorrecion(bd, fc);
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem)})
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Valor numérico:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="valorNumericoItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(valorNumericoItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(valorNumericoItem))</div>
|
||||
|
||||
<div class="col-6 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Plazos:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="plazosItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(plazosItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(plazosItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva fase</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoFases"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Valor Numérico">
|
||||
<span>@context.ValorNumerico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Plazos">
|
||||
<span>@context.ValorNumerico2</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoFases { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private double? valorNumericoOriginal;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
private double? valorNumericoItem = 0;
|
||||
private double? plazosItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "FASES";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoFases = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
valorNumericoOriginal = objeto.ValorNumerico1;
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
valorNumericoItem = 0;
|
||||
plazosItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
valorNumericoItem = objeto.ValorNumerico1;
|
||||
plazosItem = objeto.ValorNumerico2;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar fase";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nueva fase";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(valorNumericoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
valorNumericoItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(plazosItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
plazosItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(valorNumericoItem) && valorNumericoItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El valor numérico no puede estar vacío.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = valorNumericoItem }, nameof(valorNumericoItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = plazosItem }, nameof(plazosItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoItem;
|
||||
itemSeleccionado.ValorNumerico2 = plazosItem;
|
||||
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoFases = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "create" : "update";
|
||||
bool porcentajeMenosCien = comprobarPorcentaje();
|
||||
|
||||
if (porcentajeMenosCien)
|
||||
{
|
||||
await GestionarDatos(accion);
|
||||
}
|
||||
else
|
||||
{
|
||||
await cerrarPopupGestionDatos();
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoOriginal;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Warning,
|
||||
Message = $"El porcentaje total no puede ser mayor de 100.",
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(valorNumericoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool comprobarPorcentaje()
|
||||
{
|
||||
bool menorCien = false;
|
||||
|
||||
var porcentajeTotal = listadoFases.Sum(x => x.ValorNumerico1);
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
if (porcentajeTotal <= 100)
|
||||
{
|
||||
menorCien = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (porcentajeTotal + valorNumericoItem <= 100)
|
||||
{
|
||||
menorCien = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return menorCien;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Valor numérico:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="valorNumericoItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(valorNumericoItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(valorNumericoItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva intervención</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoPeriodos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna20Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Valor Numérico">
|
||||
<span>@context.ValorNumerico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoPeriodos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
private double? valorNumericoItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "INTERVENCION";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
valorNumericoItem = 0;
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
valorNumericoItem = objeto.ValorNumerico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar intervención";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nueva intervención";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(valorNumericoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
valorNumericoItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(valorNumericoItem) && valorNumericoItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El valor numérico no puede estar vacío.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = valorNumericoItem }, nameof(valorNumericoItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(valorNumericoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="costeIndiForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo trabajo</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoOtrosTrabajos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoOtrosTrabajos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "OTROSTRAB";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoOtrosTrabajos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar trabajo";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo trabajo";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoOtrosTrabajos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem ) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Valor numérico:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="valorNumericoItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(valorNumericoItem))"
|
||||
class="inputForm"/>
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(valorNumericoItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo periodo</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoPeriodos"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna20Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Valor Numérico">
|
||||
<span>@context.ValorNumerico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoPeriodos { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
private double? valorNumericoItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "PERIODOS";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
valorNumericoItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
valorNumericoItem = objeto.ValorNumerico1;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar periodo";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo periodo";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(valorNumericoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
string parseado = value.Replace(",",".");
|
||||
valorNumericoItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(valorNumericoItem) && valorNumericoItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El valor numérico no puede estar vacío.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = valorNumericoItem }, nameof(valorNumericoItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoItem ;
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoPeriodos = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(valorNumericoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="puestoTrabForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo puesto trabajo</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoPuestosTrabajo"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoPuestosTrabajo { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "PUESTOTRABAJO";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoPuestosTrabajo = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar puesto trabajo";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo puesto trabajo";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoPuestosTrabajo = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
@page "/FactoresCorreccion"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
|
||||
<div class="container-fluid pt-3">
|
||||
<Tabs>
|
||||
<Tab Title="Factores Complejidad" Name="tabFactoComple" Active>
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.FactoresCorreccionTabs.FactoresCompleConf></HerramientaCASA.Components.Pages.ConfiguracionPages.FactoresCorreccionTabs.FactoresCompleConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Factores Rendimiento" Name="tabFactoRendi">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.FactoresCorreccionTabs.FactoresRendiConf></HerramientaCASA.Components.Pages.ConfiguracionPages.FactoresCorreccionTabs.FactoresRendiConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
Nota: Si es el ùltimo factor de complejidad se borrara tambien su enumerado
|
||||
<br><br />
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="factoCompleForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="45" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coeficiente:</label>
|
||||
<InputNumber TValue="double" @bind-Value="coeficienteItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(coeficienteItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(coeficienteItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Complejidad:</label>
|
||||
<InputSelect @bind-Value="@idCompleItem" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(idCompleItem))">
|
||||
@foreach (var grupoTipologia in listadoComplejidad)
|
||||
{
|
||||
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||
}
|
||||
</InputSelect>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(idCompleItem))</div>
|
||||
</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new factorescorreccion(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo factor complejidad</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<Grid TItem="factorescorreccion"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoFactoresComplejidad"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="factorescorreccion" HeaderTextAlignment="Alignment.Center" HeaderText="Tipo">
|
||||
<span>@context.idEnumeracionNavigation.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="factorescorreccion" Class="columna30Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.Descripcion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="factorescorreccion" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Coeficiente">
|
||||
<span>@context.Coeficiente</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="factorescorreccion" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<factorescorreccion> listadoFactoresComplejidad { get; set; } = new List<factorescorreccion>();
|
||||
public List<factorescorreccion> listadoFactoresComplejidadAux { get; set; } = new List<factorescorreccion>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private factorescorreccion itemSeleccionado { get; set; } = new factorescorreccion();
|
||||
|
||||
private string tituloPopup = "";
|
||||
public string Filter { get; set; } = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private double coeficienteItem = 0;
|
||||
private int idCompleItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private List<enumeraciones> listadoComplejidad { get; set; } = new List<enumeraciones>();
|
||||
private string tipoFactorComplejidad = "FACCOMP.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoComplejidad = bd.enumeraciones.Where(x => x.Codigo.Contains(tipoFactorComplejidad)).ToList();
|
||||
|
||||
listadoFactoresComplejidad = bd.factorescorreccion.Include(x => x.idEnumeracionNavigation).Where(x => x.idEnumeracionNavigation.Codigo.Contains(tipoFactorComplejidad)).OrderBy(x=> x.idEnumeracionNavigation.Orden).ToList();
|
||||
listadoFactoresComplejidadAux = listadoFactoresComplejidad;
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoFactoresComplejidad = new List<bdHerramientaCACOA.db.factorescorreccion>();
|
||||
foreach (bdHerramientaCACOA.db.factorescorreccion item in listadoFactoresComplejidadAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoFactoresComplejidad.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.factorescorreccion listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.idEnumeracionNavigation != null && listado.idEnumeracionNavigation.ValorAlfabetico1.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.Descripcion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (listado.Coeficiente.ToString().Contains(Filter, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(factorescorreccion objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
coeficienteItem = 0;
|
||||
idCompleItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.Descripcion;
|
||||
coeficienteItem = objeto.Coeficiente;
|
||||
idCompleItem = objeto.idEnumeracion;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar factor complejidad";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo factor complejidad";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(coeficienteItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
coeficienteItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case nameof(idCompleItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
idCompleItem = int.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
idCompleItem = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(coeficienteItem) && coeficienteItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El coeficiente no puede estar vacío.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(idCompleItem) && idCompleItem == 0)
|
||||
{
|
||||
messageStore?.Add(field, "Seleccione una complejidad.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = coeficienteItem }, nameof(coeficienteItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = idCompleItem }, nameof(idCompleItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var factorbtenido = bd.factorescorreccion.Where(x => x.idFactorCorreccion == itemSeleccionado.idFactorCorreccion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.Descripcion = descripcionItem;
|
||||
itemSeleccionado.Coeficiente = coeficienteItem;
|
||||
itemSeleccionado.idEnumeracion = idCompleItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarFactorCorrecion(bd, factorbtenido, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearFactorCorrecion(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarFactorCorrecion(bd, factorbtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoFactoresComplejidad = bd.factorescorreccion.Include(x => x.idEnumeracionNavigation).Where(x => x.idEnumeracionNavigation.Codigo.Contains(tipoFactorComplejidad)).OrderBy(x => x.idEnumeracionNavigation.Orden).ToList();
|
||||
listadoFactoresComplejidadAux = listadoFactoresComplejidad;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(factorescorreccion objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(coeficienteItem), nameof(idCompleItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(factorescorreccion).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@rendermode InteractiveServer
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="factoCompleForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="45" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coeficiente:</label>
|
||||
<InputNumber TValue="double" @bind-Value="coeficienteItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(coeficienteItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(coeficienteItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Rendimiento:</label>
|
||||
<InputSelect @bind-Value="@idRendiItem" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(idRendiItem))">
|
||||
@foreach (var grupoTipologia in listadoRendimiento)
|
||||
{
|
||||
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||
}
|
||||
</InputSelect>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(idRendiItem))</div>
|
||||
</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new factorescorreccion(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo factor rendimiento</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Grid TItem="factorescorreccion"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoFactoresRendimiento"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="factorescorreccion" HeaderTextAlignment="Alignment.Center" HeaderText="Tipo">
|
||||
<span>@context.idEnumeracionNavigation.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="factorescorreccion" Class="columna30Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.Descripcion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="factorescorreccion" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Coeficiente">
|
||||
<span>@context.Coeficiente</span>
|
||||
</GridColumn>
|
||||
|
||||
|
||||
<GridColumn TItem="factorescorreccion" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<factorescorreccion> listadoFactoresRendimiento { get; set; } = new List<factorescorreccion>();
|
||||
public List<factorescorreccion> listadoFactoresRendimientoAux { get; set; } = new List<factorescorreccion>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private factorescorreccion itemSeleccionado { get; set; } = new factorescorreccion();
|
||||
|
||||
private string tituloPopup = "";
|
||||
public string Filter { get; set; } = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private double coeficienteItem = 0;
|
||||
private int idRendiItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private List<enumeraciones> listadoRendimiento { get; set; } = new List<enumeraciones>();
|
||||
private string tipoFactorComplejidad = "FACREND.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoRendimiento = bd.enumeraciones.Where(x => x.Codigo.Contains(tipoFactorComplejidad)).OrderBy(x=>x.Orden).ToList();
|
||||
|
||||
listadoFactoresRendimiento = bd.factorescorreccion.Include(x => x.idEnumeracionNavigation).Where(x => x.idEnumeracionNavigation.Codigo.Contains(tipoFactorComplejidad)).OrderBy(x=> x.idEnumeracionNavigation.Orden).ToList();
|
||||
listadoFactoresRendimientoAux = listadoFactoresRendimiento;
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoFactoresRendimiento = new List<bdHerramientaCACOA.db.factorescorreccion>();
|
||||
foreach (bdHerramientaCACOA.db.factorescorreccion item in listadoFactoresRendimientoAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoFactoresRendimiento.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.factorescorreccion listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.idEnumeracionNavigation != null && listado.idEnumeracionNavigation.ValorAlfabetico1.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.Descripcion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (listado.Coeficiente.ToString().Contains(Filter, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task abrirPopupGestionDatos(factorescorreccion objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
coeficienteItem = 0;
|
||||
idRendiItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.Descripcion;
|
||||
coeficienteItem = objeto.Coeficiente;
|
||||
idRendiItem = objeto.idEnumeracion;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar factor rendimiento";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nuevo factor rendimiento";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(coeficienteItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
coeficienteItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case nameof(idRendiItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
idRendiItem = int.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
idRendiItem = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(coeficienteItem) && coeficienteItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El coeficiente no puede estar vacío.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(idRendiItem) && idRendiItem == 0)
|
||||
{
|
||||
messageStore?.Add(field, "Seleccione un rendimiento.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = coeficienteItem }, nameof(coeficienteItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = idRendiItem }, nameof(idRendiItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var factorbtenido = bd.factorescorreccion.Where(x => x.idFactorCorreccion == itemSeleccionado.idFactorCorreccion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.Descripcion = descripcionItem;
|
||||
itemSeleccionado.Coeficiente = coeficienteItem;
|
||||
itemSeleccionado.idEnumeracion = idRendiItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarFactorCorrecion(bd, factorbtenido, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearFactorCorrecion(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarFactorCorrecion(bd, factorbtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoFactoresRendimiento = bd.factorescorreccion.Include(x => x.idEnumeracionNavigation).Where(x => x.idEnumeracionNavigation.Codigo.Contains(tipoFactorComplejidad)).OrderBy(x => x.idEnumeracionNavigation.Orden).ToList();
|
||||
listadoFactoresRendimientoAux = listadoFactoresRendimiento;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(factorescorreccion objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(coeficienteItem), nameof(idRendiItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(factorescorreccion).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
@page "/PanelControlConf"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
|
||||
|
||||
<div class="row" style="height: calc(100vh - 54px);">
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorAMenu dive">
|
||||
<a href="Variables">
|
||||
<div>
|
||||
<h4 class="text-center">Variables</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorBMenu dive">
|
||||
<a href="Enumeraciones">
|
||||
<div>
|
||||
<h4 class="text-center">Enumerados</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorCMenu dive">
|
||||
<a href="FactoresCorreccion">
|
||||
<div>
|
||||
<h4 class="text-center">Factores Corrección</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorDMenu dive">
|
||||
<a href="TipologiasConf">
|
||||
<div>
|
||||
<h4 class="text-center">Tipologías</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorEMenu dive">
|
||||
<a href="DocumentosUrban">
|
||||
<div>
|
||||
<h4 class="text-center">Documentos URBAN</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 d-flex align-items-center justify-content-center colorAMenu dive">
|
||||
<a href="CalculoCDCI">
|
||||
<div>
|
||||
<h4 class="text-center">CD+CI</h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
@page "/TipologiasConf"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="factoCompleForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="100" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Coeficiente:</label>
|
||||
<InputNumber TValue="double" @bind-Value="coeficienteItem"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(coeficienteItem))"
|
||||
class="inputForm" Step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(coeficienteItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Grupo:</label>
|
||||
<InputSelect @bind-Value="@idGrupoItem" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(idGrupoItem))">
|
||||
@foreach (var grupoTipologia in listadoGrupos)
|
||||
{
|
||||
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||
}
|
||||
</InputSelect>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(idGrupoItem))</div>
|
||||
</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row" style="justify-content:space-between">
|
||||
<div class="form-group mt-4 col-6">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 col-2">
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new tipologias(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva tipología</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<Grid TItem="tipologias"
|
||||
Class="tablaCACOA table mt-2"
|
||||
Data="listadoTipologias"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="800"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="tipologias" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.Descripcion</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipologias" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Coeficiente">
|
||||
<span>@context.CoeficienteUso</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipologias" HeaderTextAlignment="Alignment.Center" Class="columna30Ancho" HeaderText="Coeficiente">
|
||||
<span>@context.idGrupoTipNavigation.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="tipologias" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<tipologias> listadoTipologias { get; set; } = new List<tipologias>();
|
||||
public List<tipologias> listadoTipologiasAux { get; set; } = new List<tipologias>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private tipologias itemSeleccionado { get; set; } = new tipologias();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
public string Filter { get; set; } = "";
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private double coeficienteItem = 0;
|
||||
private int idGrupoItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private List<enumeraciones> listadoGrupos { get; set; } = new List<enumeraciones>();
|
||||
private string tipoFactorComplejidad = "GRUPTIP.";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoGrupos = bd.enumeraciones.Where(x => x.Codigo.Contains(tipoFactorComplejidad)).ToList();
|
||||
|
||||
listadoTipologias = bd.tipologias.Include(x => x.idGrupoTipNavigation).Where(x => x.idGrupoTipNavigation.Codigo.Contains(tipoFactorComplejidad)).ToList();
|
||||
listadoTipologiasAux = listadoTipologias;
|
||||
}
|
||||
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoTipologias = new List<bdHerramientaCACOA.db.tipologias>();
|
||||
foreach (bdHerramientaCACOA.db.tipologias item in listadoTipologiasAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoTipologias.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.tipologias listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.CoeficienteUso.ToString().ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.Descripcion.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (listado.idGrupoTipNavigation.ValorAlfabetico1.ToString().ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task abrirPopupGestionDatos(tipologias objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
descripcionItem = "";
|
||||
coeficienteItem = 0;
|
||||
idGrupoItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.Descripcion;
|
||||
coeficienteItem = objeto.CoeficienteUso;
|
||||
idGrupoItem = objeto.idGrupoTip;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar tipología";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nueva tipología";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(coeficienteItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
coeficienteItem = double.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case nameof(idGrupoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
idGrupoItem = int.Parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
idGrupoItem = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(coeficienteItem) && coeficienteItem == 0)
|
||||
{
|
||||
messageStore?.Add(field, "El coeficiente no puede estar vacío.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(idGrupoItem) && idGrupoItem == 0)
|
||||
{
|
||||
messageStore?.Add(field, "Seleccione un grupo.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = coeficienteItem }, nameof(coeficienteItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = idGrupoItem }, nameof(idGrupoItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var tipologiaObtenida = bd.tipologias.Where(x => x.idtipologia == itemSeleccionado.idtipologia).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.Descripcion = descripcionItem;
|
||||
itemSeleccionado.CoeficienteUso = coeficienteItem;
|
||||
itemSeleccionado.idGrupoTip = idGrupoItem;
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.actualizarTipologias(bd, tipologiaObtenida, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.crearTipologia(bd, itemSeleccionado);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarTipologia(bd, tipologiaObtenida);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoTipologias = bd.tipologias.Include(x => x.idGrupoTipNavigation).Where(x => x.idGrupoTipNavigation.Codigo.Contains(tipoFactorComplejidad)).ToList();
|
||||
listadoTipologiasAux = listadoTipologias;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(tipologias objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(coeficienteItem), nameof(idGrupoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(tipologias).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
@page "/Variables"
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="variableForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Valor numérico:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="valorNumericoItem"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(valorNumericoItem))"
|
||||
class="inputForm" step="any" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(valorNumericoItem))</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">Modificar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
<div class="container-fluid mt-3">
|
||||
<p><b class="Fuente2">Variables</b> </p>
|
||||
|
||||
<div>
|
||||
<div class="form-group mt-4">
|
||||
<input class="form-control" type="text" style="width: 400px;" placeholder="Filtrar..."
|
||||
@bind-value="Filter" @bind-value:after="AplicarFiltros" />
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoVariables"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="800"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna20Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Valor Numérico">
|
||||
<span>@context.ValorNumerico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context,false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoVariables { get; set; } = new List<enumeraciones>();
|
||||
public List<enumeraciones> listadoVariablesAux { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
public string Filter { get; set; } = "";
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private double? valorNumericoItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoVariables = bd.enumeraciones.Where(x=>x.Codigo.Contains("VARCASA.") && !x.Codigo.Contains("CONCOL")).ToList();
|
||||
listadoVariablesAux = listadoVariables;
|
||||
}
|
||||
|
||||
private void AplicarFiltros()
|
||||
{
|
||||
// Filtra la lista en función de los criterios ingresados
|
||||
listadoVariables = new List<bdHerramientaCACOA.db.enumeraciones>();
|
||||
foreach (bdHerramientaCACOA.db.enumeraciones item in listadoVariablesAux)
|
||||
{
|
||||
if (IsVisible(item) == true)
|
||||
{
|
||||
listadoVariables.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(bdHerramientaCACOA.db.enumeraciones listado)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.ValorAlfabetico1.ToLower().Contains(Filter.ToLower(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listado.ValorNumerico1.ToString().Contains(Filter, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar variable";
|
||||
descripcionItem = objeto.Descripcion;
|
||||
valorNumericoItem = objeto.ValorNumerico1;
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(valorNumericoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
string parseado = value.Replace(",", ".");
|
||||
valorNumericoItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(valorNumericoItem) && valorNumericoItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El valor numérico no puede estar vacío.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = valorNumericoItem }, nameof(valorNumericoItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private void guardar()
|
||||
{
|
||||
var variableObtenida = bd.enumeraciones.Where(x=> x.idEnumeracion == itemSeleccionado.idEnumeracion).First();
|
||||
|
||||
variableObtenida.ValorAlfabetico1 = descripcionItem;
|
||||
variableObtenida.ValorNumerico1 = valorNumericoItem;
|
||||
variableObtenida.Descripcion = descripcionItem.ToUpper();
|
||||
bd.enumeraciones.Update(variableObtenida);
|
||||
|
||||
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||
cambiarFecha.Fecha1 = DateTime.Now;
|
||||
bd.enumeraciones.Update(cambiarFecha);
|
||||
|
||||
bd.SaveChanges();
|
||||
|
||||
cerrarPopupGestionDatos();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
guardar();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
}
|
||||
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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(valorNumericoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user