Primera versión
This commit is contained in:
31
HerramientaCASA.sln
Normal file
31
HerramientaCASA.sln
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35312.102
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HerramientaCASA", "HerramientaCASA\HerramientaCASA.csproj", "{60B569DA-FC18-45B9-8ACC-8E29D8C2EA2C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "bdHerramientaCACOA", "bdHerramientaCACOA\bdHerramientaCACOA.csproj", "{5A4F92A5-CFD3-46F7-968C-7657BA57459D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{60B569DA-FC18-45B9-8ACC-8E29D8C2EA2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{60B569DA-FC18-45B9-8ACC-8E29D8C2EA2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{60B569DA-FC18-45B9-8ACC-8E29D8C2EA2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{60B569DA-FC18-45B9-8ACC-8E29D8C2EA2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5A4F92A5-CFD3-46F7-968C-7657BA57459D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5A4F92A5-CFD3-46F7-968C-7657BA57459D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5A4F92A5-CFD3-46F7-968C-7657BA57459D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5A4F92A5-CFD3-46F7-968C-7657BA57459D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {7361A131-4003-4809-BF4C-8CFA8A879159}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
24
HerramientaCASA/Components/App.razor
Normal file
24
HerramientaCASA/Components/App.razor
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<base href="/" />
|
||||||
|
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="app.css" />
|
||||||
|
<link rel="stylesheet" href="HerramientaCASA.styles.css" />
|
||||||
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
<HeadOutlet />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<Routes @rendermode="new InteractiveServerRenderMode(prerender:false)" />
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||||
|
<script src="_framework/blazor.web.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
108
HerramientaCASA/Components/Layout/ConfiguracionLayout.razor
Normal file
108
HerramientaCASA/Components/Layout/ConfiguracionLayout.razor
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
@inherits LayoutComponentBase
|
||||||
|
@using BlazorBootstrap;
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
|
||||||
|
<link href="Content/Site.css?v=0.15" rel="stylesheet" />
|
||||||
|
<link href="Content/all.min.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<script src="Scripts/jquery.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
<!-- Add chart.js reference if chart components are used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add sortable.js reference if SortableList component is used in your application. -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
|
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||||
|
<script src="Scripts/popper.min.js"></script>
|
||||||
|
<script src="Scripts/all.min.js"></script>
|
||||||
|
<script src="Scripts/Util.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<main style="height: 100%;">
|
||||||
|
<header class="d-none d-md-block">
|
||||||
|
<div class="pa-header-t1">
|
||||||
|
<div class="pa-header-row1">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top bg-light" style="background-color:white !important">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#topMenu" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="https://www.cacoa.es/">
|
||||||
|
<img src="Content/Imagenes/logo_CACOA_alta.jpg" style="height: 40px" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse" id="topMenu">
|
||||||
|
<ul class="navbar-nav mr-auto ulMenu">
|
||||||
|
<li id="liPC" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="PanelControlConf">Menú</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCC" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="Variables">Variables</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCS" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="Enumeraciones">Enumeraciones</NavLink>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li id="liCB" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="FactoresCorreccion">Factores Corrección</NavLink>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li id="liMS" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="TipologiasConf">Tipologías</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liMS" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="ConvenioColectivo">Convenio Colectivo</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liMS" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="DocumentosUrban">Documentos URBAN</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liMS" class="nav-item">
|
||||||
|
<NavLink class="nav-link" href="CalculoCDCI">Calculo CD+CI</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="ml-auto">
|
||||||
|
<ul class="navbar-nav mr-auto ulMenu">
|
||||||
|
<li class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="/"> <i class="fas fa-user-slash"></i>Cerrar Sesión</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="pagina">
|
||||||
|
@Body
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync<bool>("EsAdmin");
|
||||||
|
var obtenerDatoId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
// Redirigir al home si no hay token y la ruta no es pública
|
||||||
|
if (obtenerDatoId.Value == 0 || !obtenerDatoAdmin.Value)
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
HerramientaCASA/Components/Layout/LoginLayout.razor
Normal file
40
HerramientaCASA/Components/Layout/LoginLayout.razor
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
@inherits LayoutComponentBase
|
||||||
|
@using BlazorBootstrap;
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
|
||||||
|
<link href="Content/Site.css?v=0.4" rel="stylesheet" />
|
||||||
|
<link href="Content/all.min.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<script src="Scripts/jquery.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
<!-- Add chart.js reference if chart components are used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add sortable.js reference if SortableList component is used in your application. -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
|
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||||
|
<script src="Scripts/popper.min.js"></script>
|
||||||
|
<script src="Scripts/all.min.js"></script>
|
||||||
|
<script src="Scripts/Util.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="main">
|
||||||
|
<div class="">
|
||||||
|
@Body
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code{
|
||||||
|
|
||||||
|
}
|
||||||
113
HerramientaCASA/Components/Layout/MainLayout.razor
Normal file
113
HerramientaCASA/Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
@using BlazorBootstrap;
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@inherits LayoutComponentBase
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
|
||||||
|
<link href="Content/Site.css?v=0.43" rel="stylesheet" />
|
||||||
|
<link href="Content/all.min.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<script src="Scripts/jquery.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
<!-- Add chart.js reference if chart components are used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<!-- Add sortable.js reference if SortableList component is used in your application. -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
|
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||||
|
<script src="Scripts/popper.min.js"></script>
|
||||||
|
<script src="Scripts/all.min.js"></script>
|
||||||
|
<script src="Scripts/Util.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<main style="height: 100%;">
|
||||||
|
<header class="d-none d-md-block">
|
||||||
|
<div class="pa-header-t1">
|
||||||
|
<div class="pa-header-row1">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top bg-light navCACOA">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#topMenu" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="https://www.cacoa.es/">
|
||||||
|
<img src="Content/Imagenes/logo_CACOA_alta.jpg" style="height: 40px" class="logoCacoa" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse" id="topMenu">
|
||||||
|
@if (!MostrarExtra)
|
||||||
|
{
|
||||||
|
<ul class="navbar-nav mr-auto ulMenu">
|
||||||
|
<li id="liPC" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="PanelControl"><i class="fa-solid fa-house"></i> Menú</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCC" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="HerramientaCASASimulaciones">CASA – Edificación</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCS" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="LicitacionCASASimulaciones">Licitaciones Edificación</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCS" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="HerramientaURBANSimulaciones">CASA – Urbanismo</NavLink>
|
||||||
|
</li>
|
||||||
|
<li id="liCS" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="LicitacionUrbanSimulaciones">Licitaciones Urbanismo</NavLink>
|
||||||
|
</li>
|
||||||
|
@* <li id="liCB" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="BajasSimulaciones">Licitaciones Bajas</NavLink>
|
||||||
|
</li> *@
|
||||||
|
<li id="liMS" class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="MisSimulaciones">Mis Simulaciones</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div style="width:100%" class="d-flex justify-content-center">
|
||||||
|
<label class="headNav" style="color: #078b98 !important; font-size: large; font-weight: bold;">Costes Asociados a los Servicios de Arquitectura - CASA</label>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="ml-auto">
|
||||||
|
<ul class="navbar-nav mr-auto ulMenu">
|
||||||
|
<li class="nav-item">
|
||||||
|
<NavLink class="nav-link headNav" href="/"> <i class="fas fa-user-slash"></i>Cerrar Sesión</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="pagina">
|
||||||
|
@Body
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private bool MostrarExtra => Navigation.Uri.Contains("PanelControl", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync<bool>("EsAdmin");
|
||||||
|
var obtenerDatoId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
// Redirigir al home si no hay token y la ruta no es pública
|
||||||
|
if (obtenerDatoId.Value == 0 || obtenerDatoAdmin.Value)
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
HerramientaCASA/Components/Layout/MainLayout.razor.css
Normal file
96
HerramientaCASA/Components/Layout/MainLayout.razor.css
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
.page {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row {
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
border-bottom: 1px solid #d6d5d5;
|
||||||
|
justify-content: flex-end;
|
||||||
|
height: 3.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-left: 1.5rem;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row ::deep a:first-child {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640.98px) {
|
||||||
|
.top-row {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 641px) {
|
||||||
|
.page {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 250px;
|
||||||
|
height: 100vh;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row.auth ::deep a:first-child {
|
||||||
|
flex: 1;
|
||||||
|
text-align: right;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row, article {
|
||||||
|
padding-left: 2rem !important;
|
||||||
|
padding-right: 1.5rem !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#blazor-error-ui {
|
||||||
|
background: lightyellow;
|
||||||
|
bottom: 0;
|
||||||
|
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||||
|
display: none;
|
||||||
|
left: 0;
|
||||||
|
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blazor-error-ui .dismiss {
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
right: 0.75rem;
|
||||||
|
top: 0.5rem;
|
||||||
|
}
|
||||||
30
HerramientaCASA/Components/Layout/NavMenu.razor
Normal file
30
HerramientaCASA/Components/Layout/NavMenu.razor
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div class="top-row ps-3 navbar navbar-dark">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="">HerramientaCASA</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
|
||||||
|
|
||||||
|
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
||||||
|
<nav class="flex-column">
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||||
|
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="counter">
|
||||||
|
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="weather">
|
||||||
|
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
105
HerramientaCASA/Components/Layout/NavMenu.razor.css
Normal file
105
HerramientaCASA/Components/Layout/NavMenu.razor.css
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
.navbar-toggler {
|
||||||
|
appearance: none;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 3.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
color: white;
|
||||||
|
position: absolute;
|
||||||
|
top: 0.5rem;
|
||||||
|
right: 1rem;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-toggler:checked {
|
||||||
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-row {
|
||||||
|
height: 3.5rem;
|
||||||
|
background-color: rgba(0,0,0,0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
width: 1.25rem;
|
||||||
|
height: 1.25rem;
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
top: -1px;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi-house-door-fill-nav-menu {
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi-plus-square-fill-nav-menu {
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi-list-nested-nav-menu {
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item:first-of-type {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item:last-of-type {
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item ::deep .nav-link {
|
||||||
|
color: #d7d7d7;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
height: 3rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
line-height: 3rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item ::deep a.active {
|
||||||
|
background-color: rgba(255,255,255,0.37);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item ::deep .nav-link:hover {
|
||||||
|
background-color: rgba(255,255,255,0.1);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-scrollable {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-toggler:checked ~ .nav-scrollable {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 641px) {
|
||||||
|
.navbar-toggler {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-scrollable {
|
||||||
|
/* Never collapse the sidebar for wide screens */
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
/* Allow sidebar to scroll for tall menus */
|
||||||
|
height: calc(100vh - 3.5rem);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
513
HerramientaCASA/Components/Pages/Bajas.razor
Normal file
513
HerramientaCASA/Components/Pages/Bajas.razor
Normal file
@@ -0,0 +1,513 @@
|
|||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
@page "/Bajas"
|
||||||
|
@page "/Bajas/{idSimulador}"
|
||||||
|
|
||||||
|
@inject UserState userState
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
<p class="TituloVentana">
|
||||||
|
@TextoSuperior
|
||||||
|
</p>
|
||||||
|
@if (!actualizado)
|
||||||
|
{
|
||||||
|
<div class="UpdateCacoa d-flex">
|
||||||
|
<span>Esta simulación utiliza valores desactualizados. ¿Quiere Realizar una copia actualizada?</span>
|
||||||
|
<button @onclick="@(() => clonarBaja())" class="btnBlue ms-auto">Actualizar</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Modal @ref="popupGuardar" title="@TituloBoton" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
|
||||||
|
@if (TituloBoton == "Guardar")
|
||||||
|
{
|
||||||
|
<p>Se va a <b>guardar</b> esta <b>nueva simulación</b> podrá acceder a ella para consultarla y editarla desde el apartado <b>Mis Simulaciones</b> </p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Se van a <b>sobrescribir</b> los datos de la <b>simulación actual</b> con los cambios realizados, <b>esta opción no puede deshacerse.</b><br /><br /> ¿Desea continuar? </p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGuardar">Cerrar</Button>
|
||||||
|
<Button @onclick="@(() => guardarBaja())" Color="ButtonColor.Primary">@TituloBoton</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
<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>
|
||||||
|
<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="itemSeleccionado.Descripcion" class="inputForm"></InputText>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Nº trabajadores:</label>
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionado.NumTrabajadores" class="inputForm"></NumberInput>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Horas semanales:</label>
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionado.HorasSemanales" class="inputForm"></NumberInput>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||||
|
@if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("update"))" Color="ButtonColor.Primary">Modificar</Button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("create"))" Color="ButtonColor.Primary">Añadir</Button>
|
||||||
|
}
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="d-flex mb-2 mt-2" style="width:100%">
|
||||||
|
<button @onclick="@(() => abrirPopupGuardar())" class="btnBlue d-flex align-items-center"> <i class="fas fa-save pe-1"></i>@TituloBoton</button>
|
||||||
|
<b class="Fuente2 ps-2 pe-2 nomSim">Nombre de la simulación: </b>
|
||||||
|
<InputText @bind-Value="objetoBaja.Descripcion" class="form-control inputForm formatoMoneda inputTabla " style="text-align:left;font-weight:bold;"></InputText>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mt-3 mb-2">
|
||||||
|
<div><b>Convenio Colectivo:</b></div>
|
||||||
|
<InputSelect @bind-Value="@objetoBaja.idProvincia" 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>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Datos del Despacho Profesional</b></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Año oferta:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<NumberInput @bind-Value="objetoBaja.AnyoOferta" class="inputForm derecha inputTabla"></NumberInput>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Oferta económica:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<CurrencyInput HideCurrencySymbol="true" TValue="double" Locale="es-ES" Min="0" @bind-Value="objetoBaja.OfertaEconomica" class="inputForm derecha inputTabla formatoMoneda"></CurrencyInput> €
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Tasa producción:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="objetoBaja.TasaProduccion" class="inputForm derecha inputTabla"></NumberInput> %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6"></div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<Grid TItem="DatosGrupoTrabajo"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoGrupos"
|
||||||
|
AllowFiltering="false"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
Height="100"
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="DatosGrupoTrabajo" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" Class="colorFilasIntro w4">
|
||||||
|
<span>@context.Descripcion</span>
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="DatosGrupoTrabajo" HeaderTextAlignment="Alignment.Center" HeaderText="Nº Trabajadores">
|
||||||
|
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda derecha inputTabla" Value="@context.NumTrabajadores" ValueExpression="() => context.NumTrabajadores" ValueChanged="(value) => NumTrabCambiado(value,context)"></InputNumber>
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="DatosGrupoTrabajo" HeaderTextAlignment="Alignment.Center" HeaderText="Horas Semanales">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm derecha inputTabla" Value="@context.HorasSemanales" ValueExpression="() => context.HorasSemanales" ValueChanged="(value) => HorasSemanalesCambiado(value,context)"></InputNumber> h
|
||||||
|
</div>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Total Costes Personal (€)</td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.TotalCostesPersonales €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas Despacho</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<span>
|
||||||
|
@objetoBaja.HorasDespacho h
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Tasa de Producción</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<span>@objetoBaja.TasaProduccion %</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold"> Coste Directo Hora Producción</td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.CosteDirectoHP €</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold"> Costes Indirectos</td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.CosteIndirecto €</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold"> Costes Variables</td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.CosteVariable €</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold"> Total Coste Hora Producción</td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.TotalCosteHP €</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold"> Tiempo ejecución Trab. Prof. </td>
|
||||||
|
<td class="text-end">
|
||||||
|
<span> @objetoBaja.TiempoEjecucionTrabProf h</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter fw-bold"> Semanas Producción </td>
|
||||||
|
<td class="text-end"><span>@objetoBaja.SemanasProduccion</span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
public bool actualizado = true;
|
||||||
|
|
||||||
|
public string TextoSuperior = "Nueva Simulación de Baja";
|
||||||
|
public string TituloBoton = "Guardar";
|
||||||
|
private Modal popupGuardar = default!;
|
||||||
|
|
||||||
|
public BAJA objetoBaja { get; set; }
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
List<DatosGrupoTrabajo> listadoGrupos = new List<DatosGrupoTrabajo>();
|
||||||
|
|
||||||
|
private DatosGrupoTrabajo itemSeleccionado { get; set; } = new DatosGrupoTrabajo();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
private string nombreOriginal = "";
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objetoBaja = new BAJA();
|
||||||
|
objetoBaja.Inicializar(bd);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var a = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
simulaciones simu = bd.simulaciones.Where(x => x.idSimulacion == int.Parse(idDesencriptado)).First();
|
||||||
|
int idFicheroJSON = simu.idFicheroJSON;
|
||||||
|
idSimulador = idDesencriptado;
|
||||||
|
var byteFichero = bd.ficheros.Where(x => x.idFichero == idFicheroJSON).First().Fichero;
|
||||||
|
|
||||||
|
string BajaJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
objetoBaja = System.Text.Json.JsonSerializer.Deserialize<BAJA>(BajaJson);
|
||||||
|
|
||||||
|
var fechaActVar = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD").Fecha1;
|
||||||
|
if ((simu.FechaModificacion != null && simu.FechaModificacion < fechaActVar) || (simu.FechaModificacion == null && simu.FechaCreacion < fechaActVar))
|
||||||
|
{
|
||||||
|
actualizado = false;
|
||||||
|
}
|
||||||
|
TextoSuperior = "Modificando simulación \"" + simu.Descripcion + "\"";
|
||||||
|
TituloBoton = "Modificar";
|
||||||
|
|
||||||
|
nombreOriginal = objetoBaja.Descripcion;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
listadoGrupos = objetoBaja.ListaDespachoProfesional.ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error durante la inicialización: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(DatosGrupoTrabajo objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar uso";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Nuevo uso";
|
||||||
|
}
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoBaja.ActualizarDatosGrupoTrabajo(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoBaja.ListaDespachoProfesional.Add(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoBaja.ListaDespachoProfesional.Remove(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listadoGrupos = objetoBaja.ListaDespachoProfesional.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(DatosGrupoTrabajo objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void NumTrabCambiado(double e, DatosGrupoTrabajo objeto)
|
||||||
|
{
|
||||||
|
objeto.NumTrabajadores = (double)e;
|
||||||
|
objetoBaja.ActualizarDatosGrupoTrabajo(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
private async void HorasSemanalesCambiado(double e, DatosGrupoTrabajo objeto)
|
||||||
|
{
|
||||||
|
objeto.HorasSemanales = (double)e;
|
||||||
|
objetoBaja.ActualizarDatosGrupoTrabajo(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void guardarBaja()
|
||||||
|
{
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoBaja);
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == HerramientaCASA.UtilidadesCASA.obtenerTipoSimulacion(HerramientaCASA.UtilidadesCASA.TiposSimulaciones.BAJA)).idEnumeracion;
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
if (bd.simulaciones.Any(x => x.Descripcion ==objetoBaja.Descripcion&& x.idTipoSimulacion == idtipoSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crearBaja(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var listadoSimulacionesExistentes = bd.simulaciones.Where(x => x.Descripcion != nombreOriginal && x.idTipoSimulacion == idtipoSimulacion).ToList();
|
||||||
|
|
||||||
|
if (listadoSimulacionesExistentes.Any(x => x.Descripcion == objetoBaja.Descripcion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actualizarBaja(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void crearBaja(string jsonObjeto)
|
||||||
|
{
|
||||||
|
int idBajaCreada= UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.BAJA, jsonObjeto, objetoBaja.Descripcion, "baja.json", userState.idUser);
|
||||||
|
string link = "/Bajas?idSimulador=" + tsUtilidades.crypt.FEncS(idBajaCreada.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Baja creada correctamente.",
|
||||||
|
});
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
private void actualizarBaja(string jsonObjeto)
|
||||||
|
{
|
||||||
|
UtilidadesCASA.actualziarObjeto(bd, jsonObjeto, objetoBaja.Descripcion, idSimulador);
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Baja actualizada correctamente.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarBaja()
|
||||||
|
{
|
||||||
|
objetoBaja.Inicializar(bd);
|
||||||
|
objetoBaja.CalcularBaja();
|
||||||
|
objetoBaja.Descripcion = objetoBaja.Descripcion + " (Act:" + DateTime.Now + ")";
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoBaja);
|
||||||
|
var id = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.CASA, jsonObjeto, objetoBaja.Descripcion, "baja.json", userState.idUser);
|
||||||
|
|
||||||
|
var link = "/Bajas?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
private async Task CalcularTabla(string idProvincia)
|
||||||
|
{
|
||||||
|
|
||||||
|
objetoBaja.idProvincia = idProvincia;
|
||||||
|
objetoBaja.ListaCDCI = objetoBaja.CalcularTabla(idProvincia);
|
||||||
|
objetoBaja.CalcularBaja();
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
private async Task abrirPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
157
HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor
Normal file
157
HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
@using HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesionalComponents
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
|
||||||
|
@if (listadoSimulaciones.Count > 0)
|
||||||
|
{
|
||||||
|
<Modal @ref="popupGestionDatos" title="Copiar Despacho de otra Simulación" IsVerticallyCentered="false" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="row">
|
||||||
|
<p>
|
||||||
|
Esta opción le permite copiar <b>sólo los datos de la pestaña despacho profesional</b> de una simulacion existente.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Se reemplazarán los datos</b> del despacho profesional <b>de la simulación actual</b>.<br />Los cambios no se almacenarán hasta que pulse en el botón Guardar/Modificar.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-2 mb-3">
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
<label class="tituloLbl mb-2">¿De que simulación desea obtener los datos?</label>
|
||||||
|
<InputSelect @bind-Value="@idFicheroObtenido" class="inputForm selectTabla">
|
||||||
|
@foreach (var simulacion in listadoSimulaciones)
|
||||||
|
{
|
||||||
|
<option value="@simulacion.idFicheroJSON">@simulacion.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||||
|
<Button @onclick="clonarDespacho" Color="ButtonColor.Primary">Copiar Despacho</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos())" class="btnBlue ms-auto" style="background-color: #65b7c3 !important;"><i class="fas fa-file-import me-2"></i> Copiar despacho de otra simulación</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public ClonarDespachoVM datosDespachoClonado { get; set; } = new ClonarDespachoVM();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesional _Parent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// CAMBIAR POR LA OTRA PAGINA QUE LLAMA A CLONAR DESPACHO Y CAMBIAR ABAJO EN LA FUNCION
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfesionalURBAN _OtroParent { get; set; }
|
||||||
|
|
||||||
|
private List<simulaciones> listadoSimulaciones = new List<simulaciones>();
|
||||||
|
private int idFicheroObtenido;
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
cargarListaSimulaciones();
|
||||||
|
|
||||||
|
idFicheroObtenido = listadoSimulaciones.Count > 0 ? listadoSimulaciones.First().idFicheroJSON : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void cargarListaSimulaciones()
|
||||||
|
{
|
||||||
|
|
||||||
|
var idUser = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
|
||||||
|
listadoSimulaciones = bd.simulaciones.Include(x => x.idTipoSimulacionNavigation).Where(x => x.idCodigo == idUser.Value && (x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA.CASA" || x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA.URBAND") && x.idSimulacion != datosDespachoClonado.idSimulacion).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
private async Task abrirPopupGestionDatos()
|
||||||
|
{
|
||||||
|
StateHasChanged();
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarDespacho()
|
||||||
|
{
|
||||||
|
if (_Parent != null)
|
||||||
|
{
|
||||||
|
var byteFichero = bd.ficheros.First(x => x.idFichero == idFicheroObtenido).Fichero;
|
||||||
|
|
||||||
|
string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
var casaCopiada = System.Text.Json.JsonSerializer.Deserialize<CASA>(CASAJson);
|
||||||
|
|
||||||
|
datosDespachoClonado.despachoProf.Trabajadores = casaCopiada.DespachoProfesional.Trabajadores;
|
||||||
|
datosDespachoClonado.despachoProf.CostesIndirectos = casaCopiada.DespachoProfesional.CostesIndirectos;
|
||||||
|
datosDespachoClonado.despachoProf.CostesPersonal = casaCopiada.DespachoProfesional.CostesPersonal;
|
||||||
|
|
||||||
|
refrescarPadre();
|
||||||
|
StateHasChanged();
|
||||||
|
cerrarPopupGestionDatos();
|
||||||
|
// Navigation.NavigateTo("/HerramientaCASAS?idClonado=" + tsUtilidades.crypt.FEncS(idFicheroObtenido.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649), true);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (_OtroParent != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
var byteFichero = bd.ficheros.First(x => x.idFichero == idFicheroObtenido).Fichero;
|
||||||
|
|
||||||
|
string CASAURBANJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
var casaCopiada = System.Text.Json.JsonSerializer.Deserialize<URBAN>(CASAURBANJson);
|
||||||
|
|
||||||
|
datosDespachoClonado.despachoProf.Trabajadores = casaCopiada.DespachoProfesional.Trabajadores;
|
||||||
|
datosDespachoClonado.despachoProf.CostesIndirectos = casaCopiada.DespachoProfesional.CostesIndirectos;
|
||||||
|
datosDespachoClonado.despachoProf.CostesPersonal = casaCopiada.DespachoProfesional.CostesPersonal;
|
||||||
|
|
||||||
|
|
||||||
|
refrescarPadre();
|
||||||
|
StateHasChanged();
|
||||||
|
cerrarPopupGestionDatos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refrescarPadre()
|
||||||
|
{
|
||||||
|
if (_Parent != null)
|
||||||
|
{
|
||||||
|
_Parent.hacerCalculos();
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else if (_OtroParent != null)
|
||||||
|
{
|
||||||
|
_OtroParent.hacerCalculos();
|
||||||
|
_OtroParent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
505
HerramientaCASA/Components/Pages/Comun/OtrosTrabajos.razor
Normal file
505
HerramientaCASA/Components/Pages/Comun/OtrosTrabajos.razor
Normal file
@@ -0,0 +1,505 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@using HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.CASA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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="tiposForm">
|
||||||
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Trabajo:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idTrabajo" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idTrabajo))">
|
||||||
|
@foreach (var grupoTipologia in enumeracionOtrosTrabajos)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idTrabajo))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Coste:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" @bind-Value="itemSeleccionadoTemporal.Coste"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.Coste))"
|
||||||
|
class="inputForm text-end" /> €
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.Coste))</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="mt-3">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Otros trabajos incluidos en el Encargo</b>
|
||||||
|
</div>
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
<Grid TItem="CASA.OtrosTrabajos"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listOtrosTrabajos"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.OtrosTrabajos" HeaderTextAlignment="Alignment.Center" HeaderText="Encargo" Class="colorA">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.OtrosTrabajos" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Precio">
|
||||||
|
@context.Coste.MilesYDecimales() €
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.OtrosTrabajos" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.OtrosTrabajos(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir Trabajo</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total Otros trabajos:
|
||||||
|
|
||||||
|
@if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
<span> @objetoLicitaciones.TotalOtrosTrabajos.MilesYDecimales() €</span>
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
<span> @objetoCASA.CostesProduccion.TotalOtrosTrabajos.MilesYDecimales() €</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
List<CASA.OtrosTrabajos> listOtrosTrabajos = new List<CASA.OtrosTrabajos>();
|
||||||
|
|
||||||
|
List<enumeracionesCASA> enumeracionOtrosTrabajos = new List<enumeracionesCASA>();
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.OtrosTrabajos itemSeleccionado { get; set; } = new CASA.OtrosTrabajos();
|
||||||
|
|
||||||
|
private CASA.OtrosTrabajos itemSeleccionadoTemporal { get; set; } = new CASA.OtrosTrabajos();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
// PADRE LICITACIONES
|
||||||
|
[CascadingParameter]
|
||||||
|
public Licitaciones _LicitacionPadre { get; set; }
|
||||||
|
|
||||||
|
// PADRE LICITACIONES
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesTrabajo _HerramientaCASAPadre { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
|
||||||
|
@if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
enumeracionOtrosTrabajos = objetoLicitaciones.Enumerados.ListaOtrosTrabajos;
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
enumeracionOtrosTrabajos = objetoCASA.Enumerados.ListaOtrosTrabajos;
|
||||||
|
}
|
||||||
|
|
||||||
|
cargarListado();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cargarListado()
|
||||||
|
{
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
listOtrosTrabajos = objetoLicitaciones.OtrosTrabajos.ToList();
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
listOtrosTrabajos = objetoCASA.CostesProduccion.OtrosTrabajos.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CALCULOS PARA LICITACIONES
|
||||||
|
private async void OtroTrabajoCambiadoLicitaciones(double e, CASA.OtrosTrabajos objeto)
|
||||||
|
{
|
||||||
|
objeto.Coste = (double)e;
|
||||||
|
objetoLicitaciones.ActualizarOtrosTrabajos(objeto);
|
||||||
|
objetoLicitaciones.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_LicitacionPadre.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALCULOS PARA CASA
|
||||||
|
private async void OtroTrabajoCambiadoCASA(double e, CASA.OtrosTrabajos objeto)
|
||||||
|
{
|
||||||
|
objeto.Coste = (double)e;
|
||||||
|
objetoCASA.ActualizarOtrosTrabajos(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_HerramientaCASAPadre.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refrescarPadre()
|
||||||
|
{
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
_LicitacionPadre.RefreshState();
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
_HerramientaCASAPadre.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comprobarPadre(string accion)
|
||||||
|
{
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
|
||||||
|
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.ActualizarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
objetoCASA.ActualizarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
|
||||||
|
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.InsertarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
objetoCASA.InsertarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
|
||||||
|
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.EliminarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
objetoCASA.EliminarOtrosTrabajos(itemSeleccionado);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////// PARTE DE GESTIONAR DATOS POPUP ///////////
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
itemSeleccionado.Denominacion = objetoLicitaciones.Enumerados.ListaOtrosTrabajos.First(x => x.idEnumeracion == itemSeleccionado.idTrabajo).ValorAlfabetico1;
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
itemSeleccionado.Denominacion = objetoCASA.Enumerados.ListaOtrosTrabajos.First(x => x.idEnumeracion == itemSeleccionado.idTrabajo).ValorAlfabetico1;
|
||||||
|
}
|
||||||
|
|
||||||
|
comprobarPadre(accion);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
if (_LicitacionPadre != null)
|
||||||
|
{
|
||||||
|
itemSeleccionado.Denominacion = objetoLicitaciones.Enumerados.ListaOtrosTrabajos.First(x => x.idEnumeracion == itemSeleccionado.idTrabajo).ValorAlfabetico1;
|
||||||
|
}
|
||||||
|
else if (_HerramientaCASAPadre != null)
|
||||||
|
{
|
||||||
|
itemSeleccionado.Denominacion = objetoCASA.Enumerados.ListaOtrosTrabajos.First(x => x.idEnumeracion == itemSeleccionado.idTrabajo).ValorAlfabetico1;
|
||||||
|
}
|
||||||
|
|
||||||
|
comprobarPadre(accion);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
comprobarPadre(accion);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cargarListado();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.OtrosTrabajos objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
itemSeleccionadoTemporal = new CASA.OtrosTrabajos();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new CASA.OtrosTrabajos()
|
||||||
|
{
|
||||||
|
idTrabajo = objeto.idTrabajo,
|
||||||
|
Coste = objeto.Coste,
|
||||||
|
Denominacion = objeto.Denominacion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar Trabajo";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Añadir 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(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionadoTemporal.Coste):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
string parseado = value.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.Coste = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.idTrabajo):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idTrabajo = int.Parse(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTrabajo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.Coste) && itemSeleccionadoTemporal.Coste <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "El coste debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idTrabajo) && itemSeleccionadoTemporal.idTrabajo == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione un trabajo.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.Coste }, nameof(itemSeleccionadoTemporal.Coste));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idTrabajo }, nameof(itemSeleccionadoTemporal.idTrabajo));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
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(itemSeleccionadoTemporal.Coste), nameof(itemSeleccionadoTemporal.idTrabajo) })
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.OtrosTrabajos).GetProperty(field)?.GetValue(itemSeleccionadoTemporal) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.OtrosTrabajos objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.OtrosTrabajos> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTrabajo = itemSeleccionadoTemporal.idTrabajo;
|
||||||
|
itemSeleccionado.Coste = itemSeleccionadoTemporal.Coste;
|
||||||
|
itemSeleccionado.Denominacion = itemSeleccionadoTemporal.Denominacion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
HerramientaCASA/Components/Pages/Error.razor
Normal file
36
HerramientaCASA/Components/Pages/Error.razor
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
@page "/Error"
|
||||||
|
@using System.Diagnostics
|
||||||
|
|
||||||
|
<PageTitle>Error</PageTitle>
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@code{
|
||||||
|
[CascadingParameter]
|
||||||
|
private HttpContext? HttpContext { get; set; }
|
||||||
|
|
||||||
|
private string? RequestId { get; set; }
|
||||||
|
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
|
||||||
|
protected override void OnInitialized() =>
|
||||||
|
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
|
||||||
|
}
|
||||||
269
HerramientaCASA/Components/Pages/HerramientaCASAS.razor
Normal file
269
HerramientaCASA/Components/Pages/HerramientaCASAS.razor
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
@page "/HerramientaCASAS"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
<p class="TituloVentana">
|
||||||
|
@TextoSuperior
|
||||||
|
</p>
|
||||||
|
@if (!actualizado)
|
||||||
|
{
|
||||||
|
<div class="UpdateCacoa d-flex">
|
||||||
|
<span>Esta simulación utiliza valores desactualizados. ¿Quiere Realizar una copia actualizada?</span>
|
||||||
|
<button @onclick="@(() => clonarCASA())" class="btnBlue ms-auto">Actualizar</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Modal @ref="popupGuardar" title="@TituloBoton" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
|
||||||
|
@if (TituloBoton == "Guardar")
|
||||||
|
{
|
||||||
|
<p>Se va a <b>guardar</b> esta <b>nueva simulación</b> podrá acceder a ella para consultarla y editarla desde el apartado <b>Mis Simulaciones</b> </p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Se van a <b>sobrescribir</b> los datos de la <b>simulación actual</b> con los cambios realizados, <b>esta opción no puede deshacerse.</b><br /><br /> ¿Desea continuar? </p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGuardar">Cerrar</Button>
|
||||||
|
<Button @onclick="@(() => guardarCasa())" Color="ButtonColor.Primary">@TituloBoton</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="d-flex mb-2 mt-2" style="width:100%">
|
||||||
|
<button @onclick="@(() => abrirPopupGuardar())" class="btnBlue d-flex align-items-center"> <i class="fas fa-save pe-2"></i>@TituloBoton</button>
|
||||||
|
<b class="Fuente2 ps-2 pe-2 nomSim">Nombre de la simulación: </b>
|
||||||
|
<InputText @bind-Value="casa.NombreSimulacion" class="form-control inputForm formatoMoneda inputTabla " style="text-align:left;font-weight:bold;"></InputText>
|
||||||
|
</div>
|
||||||
|
<Tabs>
|
||||||
|
<Tab Title="Despacho Profesional" Name="tabDespachoProf" Active>
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesional objetoCASA="casa"></HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesional>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Trabajo Profesional" Name="tabTrabajoProf">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.TrabajoProfesional objetoCASA="casa"></HerramientaCASA.Components.Pages.HerramientaCASATabs.TrabajoProfesional>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Costes de producción" Name="tabCosteProd">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccion objetoCASA="casa"></HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccion>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
public string TextoSuperior = "Nueva simulación CASA de Edificación";
|
||||||
|
public string TituloBoton = "Guardar";
|
||||||
|
private Modal popupGuardar = default!;
|
||||||
|
|
||||||
|
public bool actualizado = true;
|
||||||
|
string nombreOriginal = "";
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
public bdHerramientaCACOA.CASA casa = new CASA();
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
private int idUser = 0;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// if (!string.IsNullOrEmpty(idClonado))
|
||||||
|
// {
|
||||||
|
// string idDesencriptado = tsUtilidades.crypt.FEncS(idClonado,
|
||||||
|
// "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
// "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
// -875421649);
|
||||||
|
|
||||||
|
// var byteFichero = bd.ficheros.Where(x => x.idFichero == int.Parse(idDesencriptado)).First().Fichero;
|
||||||
|
|
||||||
|
// string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
// var casaCopiada = System.Text.Json.JsonSerializer.Deserialize<CASA>(CASAJson);
|
||||||
|
|
||||||
|
// casa = new bdHerramientaCACOA.CASA();
|
||||||
|
// casa.RellenarCamposExtra(bd);
|
||||||
|
// casa.DespachoProfesional = casaCopiada.DespachoProfesional;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
casa = new bdHerramientaCACOA.CASA();
|
||||||
|
casa.RellenarCamposExtra(bd);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
var a = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var fechaActVar = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD").Fecha1;
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
simulaciones simu = bd.simulaciones.Where(x => x.idSimulacion == int.Parse(idDesencriptado)).First();
|
||||||
|
int idFicheroJSON = simu.idFicheroJSON;
|
||||||
|
idSimulador = idDesencriptado;
|
||||||
|
var byteFichero = bd.ficheros.Where(x => x.idFichero == idFicheroJSON).First().Fichero;
|
||||||
|
|
||||||
|
string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
casa = System.Text.Json.JsonSerializer.Deserialize<CASA>(CASAJson);
|
||||||
|
|
||||||
|
if ((simu.FechaModificacion != null && simu.FechaModificacion < fechaActVar) || (simu.FechaModificacion==null && simu.FechaCreacion<fechaActVar))
|
||||||
|
{
|
||||||
|
actualizado = false;
|
||||||
|
}
|
||||||
|
TextoSuperior = "Modificando simulación \"" + casa.NombreSimulacion + "\"";
|
||||||
|
TituloBoton = "Modificar";
|
||||||
|
|
||||||
|
nombreOriginal = casa.NombreSimulacion;
|
||||||
|
}
|
||||||
|
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
idUser = obtenerID.Value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error durante la inicialización: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void guardarCasa()
|
||||||
|
{
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == HerramientaCASA.UtilidadesCASA.obtenerTipoSimulacion(HerramientaCASA.UtilidadesCASA.TiposSimulaciones.CASA)).idEnumeracion;
|
||||||
|
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(casa);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty( idSimulador))
|
||||||
|
{
|
||||||
|
if (bd.simulaciones.Any(x => x.Descripcion == casa.NombreSimulacion && x.idTipoSimulacion == idtipoSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crearSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var listadoSimulacionesExistentes = bd.simulaciones.Where(x => x.Descripcion != nombreOriginal && x.idTipoSimulacion == idtipoSimulacion).ToList();
|
||||||
|
|
||||||
|
if (listadoSimulacionesExistentes.Any(x => x.Descripcion == casa.NombreSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actualizarSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void crearSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
int idSimulacionCreada = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.CASA, jsonObjeto, casa.NombreSimulacion, "casa.json", idUser);
|
||||||
|
string link = "/HerramientaCASAS?idSimulador=" + tsUtilidades.crypt.FEncS(idSimulacionCreada.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Simulación creada correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
private void actualizarSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
UtilidadesCASA.actualziarObjeto(bd, jsonObjeto, casa.NombreSimulacion, idSimulador);
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Simulación actualizada correctamente.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarCASA()
|
||||||
|
{
|
||||||
|
casa.RellenarCamposExtra(bd);
|
||||||
|
casa.CalcularFinales();
|
||||||
|
casa.CalcularHorasTPE();
|
||||||
|
casa.NombreSimulacion = casa.NombreSimulacion + " (Act:" + DateTime.Now + ")";
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(casa);
|
||||||
|
var id = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.CASA, jsonObjeto, casa.NombreSimulacion, "casa.json", idUser);
|
||||||
|
|
||||||
|
var link = "/HerramientaCASAS?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task abrirPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
@page "/CostesProduccion"
|
||||||
|
<div class="p-2">
|
||||||
|
<h5>Euros/Hora</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.CostesVariables objetoCASA="objetoCASA"></HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.CostesVariables>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<hr class="hrCasa" />
|
||||||
|
<h5>Horas</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.HorasCostes objetoCASA="objetoCASA"></HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.HorasCostes>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<hr class="hrCasa" />
|
||||||
|
<h5>Euros</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.CostesTrabajo objetoCASA="objetoCASA"></HerramientaCASA.Components.Pages.HerramientaCASATabs.CostesProduccionComponents.CostesTrabajo>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.CASA objetoCASA { get; set; } = new bdHerramientaCACOA.CASA();
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@using HerramientaCASA.Components.Pages.Comun
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mt-3">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Costes Asociados a los Servicios de Arquitectura</b>
|
||||||
|
</div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Concepto</th>
|
||||||
|
<th class="colorB fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB w4"><p><b>COSTES DE PRODUCCIÓN DEL TRABAJO PROFESIONAL</b></p> </td>
|
||||||
|
<td class="text-end align-content-center"><span> @objetoCASA.CostesProduccion.CostesProduccionTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro w4"><p> <b>Beneficio</b> (antes de impuestos)</p></td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoCASA.CostesProduccion.Beneficio" ValueExpression="() => objetoCASA.CostesProduccion.Beneficio" ValueChanged="(value) => BeneficioCambiado(value)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
PRECIO DEL TRABAJO PROFESIONAL: <span>@objetoCASA.CostesProduccion.PrecioTrabProf.MilesYDecimales() € </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<OtrosTrabajos objetoCASA="objetoCASA"></OtrosTrabajos>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-top:32px">
|
||||||
|
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0" style="width: 100%;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
PRECIO DEL ENCARGO: <span>@objetoCASA.CostesProduccion.PrecioDelEncargo.MilesYDecimales() € </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
List<CASA.OtrosTrabajos> listOtrosTrabajos = new List<CASA.OtrosTrabajos>();
|
||||||
|
private bool esCalcular = true;
|
||||||
|
private bool esPorcentajeCostes = false;
|
||||||
|
|
||||||
|
private double porcentajeCostes;
|
||||||
|
private double sumaTotal;
|
||||||
|
private bool editarElemento;
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.OtrosTrabajos itemSeleccionado { get; set; } = new CASA.OtrosTrabajos();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccion _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
|
||||||
|
listOtrosTrabajos = objetoCASA.CostesProduccion.OtrosTrabajos.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void BeneficioCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoCASA.CostesProduccion.Beneficio = e;
|
||||||
|
objetoCASA.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,530 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
|
||||||
|
<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="tiposForm">
|
||||||
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Coste Variable:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idCoste" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idCoste))">
|
||||||
|
@foreach (var grupoTipologia in objetoCASA.Enumerados.ListaCostesVariables)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idCoste))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Coste:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" @bind-Value="itemSeleccionadoTemporal.Coste"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.Coste))"
|
||||||
|
class="inputForm text-end" /> €
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.Coste))</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="row">
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<b>Costes variables</b>
|
||||||
|
<div class="pt-1 col-md-12 d-flex" style="gap: 40px; height:25px;">
|
||||||
|
<div class="d-flex">
|
||||||
|
|
||||||
|
<RadioInput style="margin-right: 10px;" Label="Calcular" Value="esCalcular" ValueExpression="() => esCalcular" ValueChanged="(value) => esCalcularChanged(value)" />
|
||||||
|
<RadioInput style="margin-right: 10px; margin-left:10px;" Label="% sobre los costes de producción" Value="esPorcentajeCostes" ValueExpression="() => esPorcentajeCostes" ValueChanged="(value) => esPorcentajeCostesChanged(value)" />
|
||||||
|
|
||||||
|
@if (esPorcentajeCostes)
|
||||||
|
{
|
||||||
|
<p class="ms-3">
|
||||||
|
<InputNumber TValue="double" Value="@porcentajeCostes" ValueExpression="() => porcentajeCostes"
|
||||||
|
step="any"
|
||||||
|
style="width:60px;"
|
||||||
|
ValueChanged="(value) => porcentajeCambiado(value)"
|
||||||
|
class="inputForm text-end" /> %
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (esCalcular)
|
||||||
|
{
|
||||||
|
<div style="position:relative;margin-bottom: 19px;">
|
||||||
|
<Grid TItem="CASA.CosteVariable"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listCostesVariables"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" HeaderTextAlignment="Alignment.Center" HeaderText="Conceptos" Class="colorB columna50Ancho">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda columna40Ancho text-end" HeaderText="Coste">
|
||||||
|
@context.Coste.MilesYDecimales() €
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1" style="height:28px">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.CosteVariable(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir coste variable</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total costes variables: <span> @objetoCASA.CostesProduccion.TotalCostesVariables.MilesYDecimales() €</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="align-items: flex-end;">
|
||||||
|
<div style="height: 49px;">
|
||||||
|
<b>Coste hora Despacho Profesional</b>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Tipo de costes</th>
|
||||||
|
<th class="colorB fw-bold">Coste/hora</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB w4">Costes directos</td>
|
||||||
|
<td class="text-end">@objetoCASA.DespachoProfesional.CostesDirectos.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB ">Costes indirectos</td>
|
||||||
|
<td class="text-end">@objetoCASA.DespachoProfesional.TasaCostesIndirectos.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB ">Costes variables</td>
|
||||||
|
<td class="text-end">@objetoCASA.CostesProduccion.CostesVariables.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
<div style="height:28px; align-content:center;">
|
||||||
|
Total Coste hora Despacho Profesional: <span> @objetoCASA.CostesProduccion.TotalCostes.MilesYDecimales() €/hora</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
|
||||||
|
<div style="height: 49px;">
|
||||||
|
<b>Coste hora Externalización</b>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Externalización</th>
|
||||||
|
<th class="colorB fw-bold">Porcentaje</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro w4">Incremento por externalización</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px">
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoCASA.CostesProduccion.CoeficienteCostesExternalizacion" ValueExpression="() => objetoCASA.CostesProduccion.CoeficienteCostesExternalizacion" ValueChanged="(value) => CosteExtCambiado(value)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
Coste hora Externalización: <span> @objetoCASA.CostesProduccion.CosteHoraExternalizacion.MilesYDecimales() €/hora</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
List<CASA.CosteVariable> listCostesVariables = new List<CASA.CosteVariable>();
|
||||||
|
|
||||||
|
private bool esCalcular = true;
|
||||||
|
private bool esPorcentajeCostes = false;
|
||||||
|
|
||||||
|
private double porcentajeCostes;
|
||||||
|
private bool editarElemento;
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.CosteVariable itemSeleccionado { get; set; } = new CASA.CosteVariable();
|
||||||
|
|
||||||
|
private CASA.CosteVariable itemSeleccionadoTemporal { get; set; } = new CASA.CosteVariable();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccion _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
listCostesVariables = objetoCASA.CostesProduccion.ListaCostesVariables.ToList();
|
||||||
|
|
||||||
|
porcentajeCostes = objetoCASA.CostesProduccion.porcentaje;
|
||||||
|
esCalcular = objetoCASA.CostesProduccion.EsCalculado;
|
||||||
|
|
||||||
|
if (!esCalcular)
|
||||||
|
{
|
||||||
|
esPorcentajeCostes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void porcentajeCambiado(double porcentajeCostesCambiado)
|
||||||
|
{
|
||||||
|
porcentajeCostes = porcentajeCostesCambiado;
|
||||||
|
objetoCASA.CostesProduccion.porcentaje = porcentajeCostes;
|
||||||
|
esPorcentajeCostesChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CosteExtCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoCASA.CostesProduccion.CoeficienteCostesExternalizacion = e;
|
||||||
|
objetoCASA.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void esCalcularChanged(bool res)
|
||||||
|
{
|
||||||
|
esCalcular = res;
|
||||||
|
esPorcentajeCostes = !res;
|
||||||
|
objetoCASA.CostesProduccion.EsCalculado = res;
|
||||||
|
|
||||||
|
objetoCASA.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void esPorcentajeCostesChanged(bool res)
|
||||||
|
{
|
||||||
|
esPorcentajeCostes = res;
|
||||||
|
esCalcular = !res;
|
||||||
|
objetoCASA.CostesProduccion.EsCalculado = !res;
|
||||||
|
|
||||||
|
objetoCASA.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CosteVariableCambiado(double e, CASA.CosteVariable objeto)
|
||||||
|
{
|
||||||
|
objeto.Coste = (int)e;
|
||||||
|
objetoCASA.ActualizarCostesVariables(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
itemSeleccionado.Denominacion = objetoCASA.Enumerados.ListaCostesVariables.First(x => x.idEnumeracion == itemSeleccionado.idCoste).ValorAlfabetico1;
|
||||||
|
objetoCASA.ActualizarCostesVariables(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
itemSeleccionado.Denominacion = objetoCASA.Enumerados.ListaCostesVariables.First(x => x.idEnumeracion == itemSeleccionado.idCoste).ValorAlfabetico1;
|
||||||
|
objetoCASA.InsertarCostesVariables(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoCASA.EliminarCostesVariables(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listCostesVariables = objetoCASA.CostesProduccion.ListaCostesVariables.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.CosteVariable objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
itemSeleccionadoTemporal = new CASA.CosteVariable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new CASA.CosteVariable()
|
||||||
|
{
|
||||||
|
Coste = objeto.Coste,
|
||||||
|
Denominacion = objeto.Denominacion,
|
||||||
|
idCoste = objeto.idCoste
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionadoTemporal.Coste):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
string parseado = value.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.Coste = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.idCoste):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idCoste = int.Parse(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idCoste = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.Coste) && itemSeleccionadoTemporal.Coste <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "El coste debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idCoste) && itemSeleccionadoTemporal.idCoste == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione un coste.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.Coste }, nameof(itemSeleccionadoTemporal.Coste));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idCoste }, nameof(itemSeleccionadoTemporal.idCoste));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
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(itemSeleccionadoTemporal.Coste), nameof(itemSeleccionadoTemporal.idCoste) })
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.CosteVariable).GetProperty(field)?.GetValue(itemSeleccionadoTemporal) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.CosteVariable objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.CosteVariable> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.idCoste = itemSeleccionadoTemporal.idCoste;
|
||||||
|
itemSeleccionado.Coste = itemSeleccionadoTemporal.Coste;
|
||||||
|
itemSeleccionado.Denominacion = itemSeleccionadoTemporal.Denominacion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
<div class="d-flex flex-column">
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
|
||||||
|
<div class="col-md-6 row">
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Plazo de presentación de la documentación:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double"
|
||||||
|
@bind-Value="objetoCASA.CostesProduccion.PlazoPresentacionDocumentos"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => controlarMeses(e.Value?.ToString())"
|
||||||
|
class="inputForm formatoMoneda inputTabla text-end" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@* @if (objetoCASA.CostesProduccion.IncrementoUrgencia > 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="color:red">
|
||||||
|
Incremento por urgencia del @objetoCASA.CostesProduccion.IncrementoUrgencia% en el coste de producción de la documentación
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
} *@
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<div class="mb-3" style="height:20px;">
|
||||||
|
@if (objetoCASA.CostesProduccion.IncrementoUrgencia > 0)
|
||||||
|
{
|
||||||
|
<label style="font-size:10px;">Incremento del @objetoCASA.CostesProduccion.IncrementoUrgencia% en los costes de producción de la documentación por plazo de presentación reducido</label>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex mt-3 justify-content-center">
|
||||||
|
<div class="col-md-6 row">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Trabajo profesional</b>
|
||||||
|
</div>
|
||||||
|
@* <table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Trabajos</th>
|
||||||
|
<th class="colorB fw-bold">Horas</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas elaboración documentación</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPEDocumentacion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">HORAS ANUALES DE PRODUCCIÓN</td>
|
||||||
|
<td class="text-end">@objetoCASA.DespachoProfesional.HorasTotalesProduccion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Nº Horas a completar mediante externalización</td>
|
||||||
|
<td class="text-end">@objetoCASA.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas de dirección de obra</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPEDireccion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas de producción en este plazo</td>
|
||||||
|
<td class="text-end">@objetoCASA.CostesProduccion.HorasProduccionDespachoElabDocumentacion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorC fw-bold w4">HORAS TRABAJO PROFESIONAL (fases encargadas)</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPE.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table> *@
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Trabajos</th>
|
||||||
|
<th class="colorB fw-bold">Horas</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas elaboración documentación</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPEDocumentacion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB text-end">Horas de documentación en Despacho Profesional</td>
|
||||||
|
<td class="text-start">@objetoCASA.CostesProduccion.HorasProduccionDespachoElabDocumentacion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB text-end">Horas de documentación mediante externalización</td>
|
||||||
|
<td class="text-start">@objetoCASA.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas de dirección de obra</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPEDireccion.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorC fw-bold w4">HORAS TRABAJO PROFESIONAL</td>
|
||||||
|
<td class="text-end">@objetoCASA.TrabajoProfesional.HorasTPE.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccion _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void PlazoPresentacionDocumentosCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoCASA.CostesProduccion.PlazoPresentacionDocumentos = e;
|
||||||
|
|
||||||
|
objetoCASA.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlarMeses(string meses)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (double.TryParse(meses, out var valor))
|
||||||
|
{
|
||||||
|
string parseado = meses.ToString().Replace(",", ".");
|
||||||
|
objetoCASA.CostesProduccion.PlazoPresentacionDocumentos = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlazoPresentacionDocumentosCambiado(objetoCASA.CostesProduccion.PlazoPresentacionDocumentos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
@page "/DespachoProfesional"
|
||||||
|
@using HerramientaCASA.Components.Pages.Comun
|
||||||
|
@using HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesionalComponents
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<ClonarDespacho datosDespachoClonado="datosClonar"></ClonarDespacho>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container-fluid m-0 p-0">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 d-flex flex-column">
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<TrabajadorGrid objetoCASA="objetoCASA"></TrabajadorGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-auto">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<table class="tablaAlter">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter">Coste/Hora Despacho profesional: </td>
|
||||||
|
<td class="tdAlineadoDerecha" style="font-weight:bold;">
|
||||||
|
@objetoCASA.DespachoProfesional.CosteHoraDespachoProfesional.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Costes directos </td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
@objetoCASA.DespachoProfesional.CostesDirectos.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Costes indirectos</td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
@objetoCASA.DespachoProfesional.TasaCostesIndirectos.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<CosteIndirectoGrid objetoCASA="objetoCASA"></CosteIndirectoGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.CASA objetoCASA { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
private int idFicheroObtenido = 0;
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
public ClonarDespachoVM datosClonar = new ClonarDespachoVM();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
datosClonar.despachoProf = objetoCASA.DespachoProfesional;
|
||||||
|
datosClonar.idSimulacion = !string.IsNullOrEmpty(idDesencriptado) ? int.Parse(idDesencriptado) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hacerCalculos()
|
||||||
|
{
|
||||||
|
objetoCASA.CalcularFinales();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void clonarDespacho()
|
||||||
|
// {
|
||||||
|
// var byteFichero = bd.ficheros.First(x=> x.idFichero == idFicheroObtenido).Fichero;
|
||||||
|
|
||||||
|
// string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
// var casaCopiada = System.Text.Json.JsonSerializer.Deserialize<CASA>(CASAJson);
|
||||||
|
|
||||||
|
|
||||||
|
// objetoCASA.DespachoProfesional = casaCopiada.DespachoProfesional;
|
||||||
|
// objetoCASA.CalcularFinales();
|
||||||
|
|
||||||
|
// StateHasChanged();
|
||||||
|
// // Navigation.NavigateTo("/HerramientaCASAS?idClonado=" + tsUtilidades.crypt.FEncS(idFicheroObtenido.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649), true);
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3 alturaTitulosTabla">
|
||||||
|
<div><b>Costes Indirectos Anuales</b></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="position:relative;margin-bottom: 20px;">
|
||||||
|
<Grid
|
||||||
|
@ref="grid"
|
||||||
|
TItem="CASA.CosteIndirecto"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="costesIndirectos"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CosteIndirecto" HeaderText="Concepto" HeaderTextAlignment="Alignment.Center" PropertyName="Concepto" Class="colorFilasIntro">
|
||||||
|
@context.Concepto
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteIndirecto" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda columna30Ancho" HeaderText="Importe" PropertyName="importe">
|
||||||
|
<div class="d-flex separadorMoneda">
|
||||||
|
<CurrencyInput HideCurrencySymbol="true" TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@context.importe" ValueExpression="() => context.importe" ValueChanged="(value) => valorCambiado(value,context)"></CurrencyInput> €
|
||||||
|
</div>
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end columna20Ancho" TItem="CASA.CosteIndirecto" HeaderText="Periocidad">
|
||||||
|
@* @if (context != itemSeleccionado)
|
||||||
|
{
|
||||||
|
<span>@listadoPeriodos.FirstOrDefault(p => p.idEnumeracion == context.idPeriodicidad)?.ValorAlfabetico1</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ *@
|
||||||
|
<InputSelect Value="@context.idPeriodicidad" class="inputForm selectTabla" ValueExpression="() => context.idPeriodicidad" TValue="int" ValueChanged="(value) => valorCICambiado(value,context)">
|
||||||
|
@foreach (var periodo in listadoPeriodos)
|
||||||
|
{
|
||||||
|
<option value="@periodo.idEnumeracion">@periodo.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
@* } *@
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end columna30Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.CosteIndirecto" HeaderText="Coste" PropertyName="coste">
|
||||||
|
<span >@context.coste.ToString("C", new System.Globalization.CultureInfo("es-ES"))</span>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-19px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
Total Costes Indirectos: <span>
|
||||||
|
@objetoCASA.DespachoProfesional.TotalCostesIndirectos.MilesYDecimales() €
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; }
|
||||||
|
|
||||||
|
public List<CASA.CosteIndirecto> costesIndirectos { get; set; } = new List<CASA.CosteIndirecto>();
|
||||||
|
private CASA.CosteIndirecto itemSeleccionado = new CASA.CosteIndirecto();
|
||||||
|
|
||||||
|
Grid<CASA.CosteIndirecto> grid = default!;
|
||||||
|
|
||||||
|
private List<CASA.enumeracionesCASA> listadoPeriodos = new List<CASA.enumeracionesCASA>();
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
|
||||||
|
private bool editarElemento;
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public DespachoProfesional _Parent { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfesionalURBAN _OtroParent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
listadoPeriodos = objetoCASA.Enumerados.Periodos.ToList();
|
||||||
|
//costesIndirectos = objetoCASA.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
costesIndirectos = objetoCASA.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.CosteIndirecto> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
private async void valorCambiado(double e,CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (objeto.idPeriodicidad != 0)
|
||||||
|
{
|
||||||
|
objeto.importe = (double)e;
|
||||||
|
objetoCASA.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async void valorCICambiado(int e, CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objeto.idPeriodicidad = (int)e;
|
||||||
|
objetoCASA.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void guardar(CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objetoCASA.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
// mensajes.Add(new ToastMessage
|
||||||
|
// {
|
||||||
|
// Type = ToastType.Primary,
|
||||||
|
// Message = $"Guardado correctamente.",
|
||||||
|
// });
|
||||||
|
|
||||||
|
costesIndirectos = objetoCASA.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void limpiarDatos(CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objetoCASA.LimpiarCosteIndirecto(objeto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refrescarPadre()
|
||||||
|
{
|
||||||
|
if (_Parent != null)
|
||||||
|
{
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else if (_OtroParent != null)
|
||||||
|
{
|
||||||
|
_OtroParent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,318 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
|
||||||
|
<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="costesPersonalForm">
|
||||||
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
<label class="tituloLbl">Denominación grupo:</label>
|
||||||
|
<InputText @bind-Value="itemSeleccionado.DenominacionGrupo" class="inputForm"></InputText>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
<label class="tituloLbl">Categoría Profesional:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionado.idCategoriaProfesional" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idCategoriaProfesional))" class="inputForm">
|
||||||
|
@foreach (var puesTrab in objetoCASA.Enumerados.ListaPuestosTrabajo)
|
||||||
|
{
|
||||||
|
<option value="@puesTrab.idEnumeracion">@puesTrab.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.idCategoriaProfesional))</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Complementos:</label>
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionado.Complementos" class="inputForm"></NumberInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Nº Pagas Año:</label>
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionado.numPagasAnuales" class="inputForm"></NumberInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Jornada Laboral (Hor/Sem):</label>
|
||||||
|
<NumberInput TValue="int" Min="0" @bind-Value="itemSeleccionado.HorasJornadaLaboral" class="inputForm"></NumberInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">% Producción (Costes Directos):</label>
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionado.PorcentajeProduccion" class="inputForm"></NumberInput>
|
||||||
|
</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="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Calcular Costes de Personal del Despacho Profesional</b></div>
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.GrupoTrabajador(), true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i>Nuevo Grupo de Trabajador</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Grid TItem="CASA.GrupoTrabajador"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="GrupoTrab"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Denominación del grupo" PropertyName="DenominacionGrupo" Class="colorA">
|
||||||
|
@context.DenominacionGrupo
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Categoria Profesional" PropertyName="idCategoriaProfesional">
|
||||||
|
@objetoCASA.Enumerados.ListaPuestosTrabajo?.FirstOrDefault(x => x.idEnumeracion == context.idCategoriaProfesional)?.ValorAlfabetico1
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Total devengado" PropertyName="TotalDevengado">
|
||||||
|
@context.TotalDevengado
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Nº de trabajadores" PropertyName="Complementos">
|
||||||
|
@context.Complementos
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Seg. Social" PropertyName="segSocialEmpresa">
|
||||||
|
@context.segSocialEmpresa
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Nº Pagas Año" PropertyName="numPagasAnuales">
|
||||||
|
@context.numPagasAnuales
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Jornada Laboral (Hor/Sem)" PropertyName="HorasJornadaLaboral">
|
||||||
|
@context.HorasJornadaLaboral
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Coste Anual Individual (Incl. Seg Social)" PropertyName="CosteAnualIndividual">
|
||||||
|
@context.CosteAnualIndividual
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Horas/Año" PropertyName="HorasAnuales">
|
||||||
|
@context.HorasAnuales
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="% Producción" PropertyName="PorcentajeProduccion">
|
||||||
|
@context.PorcentajeProduccion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="% Administración" PropertyName="PorcentajeAdministración">
|
||||||
|
@context.PorcentajeAdministración
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" HeaderText="Horas Producción" PropertyName="HorasProduccion">
|
||||||
|
@context.HorasProduccion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.GrupoTrabajador" 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>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
public List<CASA.GrupoTrabajador> GrupoTrab { get; set; } = new List<CASA.GrupoTrabajador>();
|
||||||
|
private CASA.GrupoTrabajador itemSeleccionado = new CASA.GrupoTrabajador();
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
private EditContext? editContext;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
GrupoTrab = objetoCASA.DespachoProfesional.CostesPersonal.GrupoTrabajadores;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoCASA.ActualizarGrupoTrabajador(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoCASA.InsertarGrupoTrabajador(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoCASA.EliminarGrupoTrabajo(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GrupoTrab = objetoCASA.DespachoProfesional.CostesPersonal.GrupoTrabajadores.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.GrupoTrabajador objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar Grupo";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Nuevo Grupo";
|
||||||
|
objeto.DenominacionGrupo = "Arquitecto";
|
||||||
|
objeto.numPagasAnuales = 14;
|
||||||
|
objeto.HorasJornadaLaboral = 40;
|
||||||
|
objeto.PorcentajeProduccion = 80;
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.GrupoTrabajador objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionado.idCategoriaProfesional):
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionado.idCategoriaProfesional = int.Parse(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionado.idCategoriaProfesional = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionado.idCategoriaProfesional) && itemSeleccionado.idCategoriaProfesional == null || itemSeleccionado.idCategoriaProfesional == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione una categoría.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionado.idCategoriaProfesional }, nameof(itemSeleccionado.idCategoriaProfesional));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
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.idCategoriaProfesional)})
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.UsosTipologia).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.RegularExpressions
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
<label class="tituloLbl">Denominación grupo:</label>
|
||||||
|
<InputText @bind-Value="itemSeleccionadoTemporal.Nombre" class="inputForm" list="sugerenciasGrupo"></InputText>
|
||||||
|
|
||||||
|
<datalist id="sugerenciasGrupo">
|
||||||
|
@foreach (var grupo in grupos)
|
||||||
|
{
|
||||||
|
<option value="@grupo" />
|
||||||
|
}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Coste anual:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionadoTemporal.CosteAnual" class="inputForm derecha formatoMoneda"></NumberInput> €
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Jornada laboral:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionadoTemporal.JornadaLaboral" class="inputForm derecha"></NumberInput> h/sem
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">
|
||||||
|
<Tooltip Title=@tituloInfo class="custom-tooltip" role="button">
|
||||||
|
<Icon Name="IconName.InfoCircleFill" Class="text-primary"></Icon>
|
||||||
|
</Tooltip>
|
||||||
|
Porcentaje producción:
|
||||||
|
</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
|
||||||
|
<NumberInput TValue="double" Step="1" Min="0" @oninput="EvitarDecimalesPorcentaje" @bind-Value:format="F0" @bind-Value="itemSeleccionadoTemporal.PorcentajeProduccion" class="inputForm derecha"></NumberInput> %
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Nº de trabajadores:</label>
|
||||||
|
<NumberInput TValue="double" Step="1" @oninput="EvitarDecimalesTrabajores" Min="0" @bind-Value="itemSeleccionadoTemporal.NumTrabajadores" class="inputForm derecha"></NumberInput>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||||
|
@if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("update"))" Color="ButtonColor.Primary">Modificar</Button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("create"))" Color="ButtonColor.Primary">Añadir</Button>
|
||||||
|
}
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3 alturaTitulosTabla">
|
||||||
|
<div><b>Costes Directos Anuales del Personal</b></div>
|
||||||
|
</div>
|
||||||
|
<div style="position:relative;margin-bottom: 45px;">
|
||||||
|
<Grid TItem="CASA.Trabajador"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="Trabajadores"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Denominación del grupo" PropertyName="Nombre" Class="colorA">
|
||||||
|
@context.Nombre
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda text-end" HeaderText="Coste anual" PropertyName="CosteAnual">
|
||||||
|
<span>@context.CosteAnual.MilesYDecimales() €</span>
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Jornada laboral" PropertyName="JornadaLaboral">
|
||||||
|
@context.JornadaLaboral.MilesYDecimales() h
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Porcentaje producción" PropertyName="PorcentajeProduccion">
|
||||||
|
@context.PorcentajeProduccion %
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" TItem="CASA.Trabajador"HeaderTextAlignment="Alignment.Center" HeaderText="Nº de trabajadores" PropertyName="NumTrabajadores">
|
||||||
|
@context.NumTrabajadores
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Coste Anual" PropertyName="CosteAnualTotal">
|
||||||
|
@context.CosteAnualTotal.MilesYDecimales() €
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Horas Producción" PropertyName="HorasProduccion">
|
||||||
|
@context.HorasProduccion.MilesYDecimales() h
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-36px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC" >
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.Trabajador(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i>Nuevo Grupo de Trabajador</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>Total Coste Anual: @objetoCASA.DespachoProfesional.CostesDirectosAnuales.MilesYDecimales() €</span><br />
|
||||||
|
<span>Total Horas Producción: @objetoCASA.DespachoProfesional.HorasTotalesProduccion.MilesYDecimales() h</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
public List<CASA.Trabajador> Trabajadores { get; set; } = new List<CASA.Trabajador>();
|
||||||
|
|
||||||
|
private CASA.Trabajador itemSeleccionado = new CASA.Trabajador();
|
||||||
|
private CASA.Trabajador itemSeleccionadoTemporal = new CASA.Trabajador();
|
||||||
|
|
||||||
|
private List<string> grupos = new()
|
||||||
|
{
|
||||||
|
"Arquitecto/a",
|
||||||
|
"Arquitecto/a técnico/a",
|
||||||
|
"Delineante",
|
||||||
|
"Administrativo/a"
|
||||||
|
};
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private string tituloInfo = "";
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public DespachoProfesional _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
tituloInfo = "Es el porcentaje de tiempo que el empleado destina a la producción del trabajo profesional concreto, dedicando el resto del tiempo a otras tareas del despacho.";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
|
||||||
|
Trabajadores = objetoCASA.DespachoProfesional.Trabajadores;
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EvitarDecimalesPorcentaje(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
var input = e?.Value?.ToString();
|
||||||
|
|
||||||
|
if (double.TryParse(input, out var valor))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.PorcentajeProduccion = Math.Round(valor, 0, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EvitarDecimalesTrabajores(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
var input = e?.Value?.ToString();
|
||||||
|
|
||||||
|
if (double.TryParse(input, out var valor))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.NumTrabajadores = Math.Round(valor, 0, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoCASA.ActualizarTrabajador(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoCASA.InsertarTrabajador(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoCASA.EliminarTrabajador(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Trabajadores = objetoCASA.DespachoProfesional.Trabajadores.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.Trabajador objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new CASA.Trabajador()
|
||||||
|
|
||||||
|
{
|
||||||
|
CosteAnual = objeto.CosteAnual,
|
||||||
|
CosteAnualTotal = objeto.CosteAnualTotal,
|
||||||
|
HorasProduccion = objeto.HorasProduccion,
|
||||||
|
IdTrabajador = objeto.IdTrabajador,
|
||||||
|
JornadaLaboral = objeto.JornadaLaboral,
|
||||||
|
Nombre = objeto.Nombre,
|
||||||
|
NumTrabajadores = objeto.NumTrabajadores,
|
||||||
|
PorcentajeProduccion = objeto.PorcentajeProduccion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar grupo de trabajadores";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = new CASA.Trabajador();
|
||||||
|
tituloPopup = "Nuevo grupo de trabajadores";
|
||||||
|
itemSeleccionadoTemporal.Nombre = "Arquitecto";
|
||||||
|
itemSeleccionadoTemporal.JornadaLaboral = 40;
|
||||||
|
itemSeleccionadoTemporal.PorcentajeProduccion = 80;
|
||||||
|
itemSeleccionadoTemporal.NumTrabajadores = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.Trabajador objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.CosteAnual = itemSeleccionadoTemporal.CosteAnual;
|
||||||
|
itemSeleccionado.CosteAnualTotal = itemSeleccionadoTemporal.CosteAnualTotal;
|
||||||
|
itemSeleccionado.HorasProduccion = itemSeleccionadoTemporal.HorasProduccion;
|
||||||
|
itemSeleccionado.IdTrabajador = itemSeleccionadoTemporal.IdTrabajador;
|
||||||
|
itemSeleccionado.JornadaLaboral = itemSeleccionadoTemporal.JornadaLaboral;
|
||||||
|
itemSeleccionado.Nombre = itemSeleccionadoTemporal.Nombre;
|
||||||
|
itemSeleccionado.NumTrabajadores = itemSeleccionadoTemporal.NumTrabajadores;
|
||||||
|
itemSeleccionado.PorcentajeProduccion = itemSeleccionadoTemporal.PorcentajeProduccion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
@page "/TrabajoProfesional"
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@using HerramientaCASA.Components.Pages.HerramientaCASATabs.TrabajoProfesionalComponents
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
|
||||||
|
<div class="row p-0 m-0">
|
||||||
|
<div class="col-md-12 d-flex" style="gap: 40px;">
|
||||||
|
<RadioInput style="margin-right: 10px;" Label="Cálculo por superficie y uso" Value="modificarTabla" ValueExpression="() => modificarTabla" ValueChanged="(value) => modificarTablaChanged(value)" />
|
||||||
|
<RadioInput style="margin-right: 10px;" Label="Cálculo por tiempo" Value="modificarHoras" ValueExpression="() => modificarHoras" ValueChanged="(value) => modificarHorasChanged(value)" />
|
||||||
|
</div>
|
||||||
|
@if (modificarTabla)
|
||||||
|
{
|
||||||
|
<div class="col-md-12 mt-3 mb-5">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<UsosTipologiaGrid objetoCASA="objetoCASA"></UsosTipologiaGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<FasesTrabajoProfesionalGrid objetoCASA="objetoCASA"></FasesTrabajoProfesionalGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<TablaHorasGrid objetoCASA="objetoCASA"></TablaHorasGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<CoeficientesCorrectoresGrid objetoCASA="objetoCASA"></CoeficientesCorrectoresGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
@* <CascadingValue Value="this">
|
||||||
|
<TablaHorasGrid objetoCASA="objetoCASA"></TablaHorasGrid>
|
||||||
|
</CascadingValue> *@
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (modificarHoras)
|
||||||
|
{
|
||||||
|
<div class="col-md-3">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<FasesTrabajoProfesionalGrid objetoCASA="objetoCASA"></FasesTrabajoProfesionalGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<TablaHorasGrid objetoCASA="objetoCASA"></TablaHorasGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
public bool modificarTabla = true;
|
||||||
|
public bool modificarHoras = false;
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
public double horasTPEOriginal = 0;
|
||||||
|
|
||||||
|
public double ultimaHoraDocumentacion = 0;
|
||||||
|
public double ultimaHoraObra = 0;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
modificarTabla = objetoCASA.TrabajoProfesional.EsPorUsos;
|
||||||
|
|
||||||
|
if (!modificarTabla)
|
||||||
|
{
|
||||||
|
modificarHorasChanged(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void calcularModificarHora()
|
||||||
|
{
|
||||||
|
ultimaHoraDocumentacion = objetoCASA.TrabajoProfesional.HorasTPEDocumentacion;
|
||||||
|
ultimaHoraObra = objetoCASA.TrabajoProfesional.HorasTPEDireccion;
|
||||||
|
|
||||||
|
objetoCASA.CalcularHorasTPEManual(objetoCASA.TrabajoProfesional.HorasTPEDocumentacion, objetoCASA.TrabajoProfesional.HorasTPEDireccion);
|
||||||
|
horasTPEOriginal = objetoCASA.TrabajoProfesional.HorasTPE;
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void restablecerHoras()
|
||||||
|
{
|
||||||
|
objetoCASA.TrabajoProfesional.HorasTPEDocumentacion= ultimaHoraDocumentacion;
|
||||||
|
objetoCASA.TrabajoProfesional.HorasTPEDireccion = ultimaHoraObra;
|
||||||
|
|
||||||
|
objetoCASA.CalcularHorasTPEManual(objetoCASA.TrabajoProfesional.HorasTPEDocumentacion, objetoCASA.TrabajoProfesional.HorasTPEDireccion);
|
||||||
|
horasTPEOriginal = objetoCASA.TrabajoProfesional.HorasTPE;
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void modificarTablaChanged(bool res)
|
||||||
|
{
|
||||||
|
objetoCASA.TrabajoProfesional.HorasTPE = 0;
|
||||||
|
objetoCASA.TrabajoProfesional.HorasTPEDocumentacion = 0;
|
||||||
|
objetoCASA.TrabajoProfesional.HorasTPEDireccion = 0;
|
||||||
|
|
||||||
|
if (objetoCASA.TrabajoProfesional.Usos.ToList().Count() != 0)
|
||||||
|
{
|
||||||
|
objetoCASA.CalcularHorasTPE();
|
||||||
|
}
|
||||||
|
|
||||||
|
modificarTabla = res;
|
||||||
|
modificarHoras = !res;
|
||||||
|
objetoCASA.TrabajoProfesional.EsPorUsos = true;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
private async void modificarHorasChanged(bool res)
|
||||||
|
{
|
||||||
|
horasTPEOriginal = objetoCASA.TrabajoProfesional.HorasTPE;
|
||||||
|
ultimaHoraDocumentacion = objetoCASA.TrabajoProfesional.HorasTPEDocumentacion;
|
||||||
|
ultimaHoraObra = objetoCASA.TrabajoProfesional.HorasTPEDireccion;
|
||||||
|
|
||||||
|
|
||||||
|
modificarHoras = res;
|
||||||
|
modificarTabla = !res;
|
||||||
|
objetoCASA.TrabajoProfesional.EsPorUsos = false;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Coeficientes correctores por Complejidad</b></div>
|
||||||
|
</div>
|
||||||
|
<Grid TItem="CASA.CoeficientesCorrectores"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFactoresComplejidad"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
Height="100"
|
||||||
|
Responsive="true"
|
||||||
|
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CoeficientesCorrectores" HeaderTextAlignment="Alignment.Center" HeaderText="Factores de Complejidad" PropertyName="Factores" Class="colorFilasIntro">
|
||||||
|
@context.Nombre
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CoeficientesCorrectores" HeaderText="">
|
||||||
|
<InputSelect Value="@context.idCorrecion" class="inputForm selectTabla" ValueExpression="() => context.idCorrecion" TValue="int" ValueChanged="(value) => valorFCCambiado(value,context)">
|
||||||
|
@foreach (var factor in objetoCASA.Enumerados.FactoresCorreccionPorGrupo(@context.idTipoFactor))
|
||||||
|
{
|
||||||
|
<option value="@factor.idFactorCorreccion">@factor.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Coeficientes correctores por Rendimiento</b></div>
|
||||||
|
</div>
|
||||||
|
<Grid TItem="CASA.CoeficientesCorrectores"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFactoresRendimiento"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
PageSizeSelectorItems="@(new int[] { 5, 10, 20, 50 })"
|
||||||
|
Responsive="true"
|
||||||
|
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CoeficientesCorrectores" HeaderTextAlignment="Alignment.Center" HeaderText="Factores de Rendimiento" PropertyName="Factores" Class="colorFilasIntro">
|
||||||
|
@context.Nombre
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CoeficientesCorrectores" HeaderText="" >
|
||||||
|
<InputSelect Value="@context.idCorrecion" class="inputForm selectTabla" ValueExpression="() => context.idCorrecion" TValue="int" ValueChanged="(value) => valorFRCambiado(value,context)">
|
||||||
|
@foreach (var factor in objetoCASA.Enumerados.FactoresCorreccionPorGrupo(@context.idTipoFactor))
|
||||||
|
{
|
||||||
|
<option value="@factor.idFactorCorreccion">@factor.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabajoProfesional _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
private bool desactivarSelects;
|
||||||
|
|
||||||
|
public List<CASA.CoeficientesCorrectores> listadoFactoresComplejidad { get; set; } = new List<CASA.CoeficientesCorrectores>();
|
||||||
|
public List<CASA.CoeficientesCorrectores> listadoFactoresRendimiento { get; set; } = new List<CASA.CoeficientesCorrectores>();
|
||||||
|
|
||||||
|
private List<factorescorreccion> listFactoresComplejidad = new List<factorescorreccion>();
|
||||||
|
private List<conveniocolectivo> listFactoresRendimiento = new List<conveniocolectivo>();
|
||||||
|
|
||||||
|
private CASA.CoeficientesCorrectores itemSeleccionado = new CASA.CoeficientesCorrectores();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
listadoFactoresComplejidad = objetoCASA.TrabajoProfesional.FactoresComplejidad;
|
||||||
|
listadoFactoresRendimiento = objetoCASA.TrabajoProfesional.FactoresRendimiento;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void valorFCCambiado(int e, CASA.CoeficientesCorrectores objeto)
|
||||||
|
{
|
||||||
|
objeto.idCorrecion = (int)e;
|
||||||
|
objetoCASA.ActualizarFactorComplejidad(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void valorFRCambiado(int e, CASA.CoeficientesCorrectores objeto)
|
||||||
|
{
|
||||||
|
objeto.idCorrecion = (int)e;
|
||||||
|
objetoCASA.ActualizarFactorRendimiento(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Fases</b></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
<div style="justify-content: end; display: flex;">
|
||||||
|
</div>
|
||||||
|
<Grid TItem="CASA.FasesTrabajo"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFases"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.FasesTrabajo" HeaderTextAlignment="Alignment.Center" HeaderText="Fases" PropertyName="Denominacion" Class="colorFilasIntro">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.FasesTrabajo" HeaderText="">
|
||||||
|
<div class="d-flex">
|
||||||
|
<InputNumber Min="0" class="inputForm inputTabla tdAlineadoDerecha pe-0 me-1" Value=@context.Porcentaje TValue="double" ValueExpression="() => context.Porcentaje" ValueChanged="(value) => porcentajeCambiado(value,context)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => restablecerValores())" class="btnBlue d-flex align-items-center"> <i class="fas fa-undo pe-1"></i> Restablecer </button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
@if (totalPorcentaje != 100)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Trabajo en misión parcial: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Total: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabajoProfesional _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
private double totalPorcentaje = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public List<CASA.FasesTrabajo> listadoFases { get; set; } = new List<CASA.FasesTrabajo>();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
listadoFases = objetoCASA.TrabajoProfesional.FasesTrabajo.ToList();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoCASA.TrabajoProfesional.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.FasesTrabajo> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void porcentajeCambiado(double e, CASA.FasesTrabajo objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
double porcentajeTotal = calcularPorcentaje(e, objeto);
|
||||||
|
|
||||||
|
if (porcentajeTotal <= 100)
|
||||||
|
{
|
||||||
|
objeto.Porcentaje = (double)e;
|
||||||
|
|
||||||
|
if (objetoCASA.TrabajoProfesional.EsPorUsos)
|
||||||
|
{
|
||||||
|
objetoCASA.ActualizarFase(objeto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objetoCASA.ActualizarFaseCalculo(_Parent.horasTPEOriginal);
|
||||||
|
}
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
objeto.Porcentaje = 0;
|
||||||
|
objetoCASA.ActualizarFase(objeto);
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"La suma de los porcentajes no puede ser mayor de 100.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
totalPorcentaje = objetoCASA.TrabajoProfesional.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calcularPorcentaje(double e, CASA.FasesTrabajo objeto)
|
||||||
|
{
|
||||||
|
double porcentajeTotal = 0;
|
||||||
|
objeto.Porcentaje = e;
|
||||||
|
|
||||||
|
int indice = objetoCASA.TrabajoProfesional.FasesTrabajo
|
||||||
|
.FindIndex(x => x.idFase == objeto.idFase);
|
||||||
|
|
||||||
|
if (indice >= 0)
|
||||||
|
{
|
||||||
|
objetoCASA.TrabajoProfesional.FasesTrabajo[indice] = objeto;
|
||||||
|
}
|
||||||
|
|
||||||
|
porcentajeTotal = objetoCASA.TrabajoProfesional.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
return porcentajeTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void restablecerValores()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < objetoCASA.Enumerados.FasesTrabajoOriginal.ToList().Count; i++)
|
||||||
|
{
|
||||||
|
objetoCASA.TrabajoProfesional.FasesTrabajo[i].Porcentaje = objetoCASA.Enumerados.FasesTrabajoOriginal.ToList()[i].Porcentaje;
|
||||||
|
}
|
||||||
|
if(objetoCASA.TrabajoProfesional.EsPorUsos){
|
||||||
|
// if (objetoCASA.TrabajoProfesional.HorasTPE != 0 && objetoCASA.TrabajoProfesional.HorasTPEDocumentacion != 0 && objetoCASA.TrabajoProfesional.HorasTPEDireccion != 0)
|
||||||
|
// {
|
||||||
|
// objetoCASA.CalcularHorasTPE();
|
||||||
|
// }
|
||||||
|
objetoCASA.CalcularHorasTPE();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if (objetoCASA.TrabajoProfesional.HorasTPE != 0 && objetoCASA.TrabajoProfesional.HorasTPEDocumentacion != 0 && objetoCASA.TrabajoProfesional.HorasTPEDireccion != 0)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
_Parent.restablecerHoras();
|
||||||
|
}
|
||||||
|
|
||||||
|
totalPorcentaje = objetoCASA.CalcularTotalFases();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6" style="margin-top:50px; width: 100%; display: flex;">
|
||||||
|
<table class="tablaAlter">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter">Horas Trabajo Profesional Edificación: </td>
|
||||||
|
|
||||||
|
<td class="tdAlineadoDerecha" style="width: 30%; font-weight:bold;">
|
||||||
|
@if (!_Parent.modificarHoras)
|
||||||
|
{
|
||||||
|
<span>
|
||||||
|
@objetoCASA.TrabajoProfesional.TotalHorasTPE.MilesYDecimales() h
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span>
|
||||||
|
@objetoCASA.TrabajoProfesional.HorasTPE.MilesYDecimales() h
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Horas TPE Documentacion </td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
|
||||||
|
@if (!_Parent.modificarHoras)
|
||||||
|
{
|
||||||
|
<span>
|
||||||
|
@objetoCASA.TrabajoProfesional.HorasTPEDocumentacion.MilesYDecimales() h
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex" style="gap: 3px;">
|
||||||
|
<InputNumber TValue="double" @onblur="_Parent.calcularModificarHora" @bind-Value="@objetoCASA.TrabajoProfesional.HorasTPEDocumentacion" Min="0" class="inputForm inputTabla tdAlineadoDerecha" />h
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Horas TPE Dirección de obra </td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
|
||||||
|
@if (!_Parent.modificarHoras)
|
||||||
|
{
|
||||||
|
<span>
|
||||||
|
@objetoCASA.TrabajoProfesional.HorasTPEDireccion.MilesYDecimales() h
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex" style="gap: 3px;">
|
||||||
|
<InputNumber TValue="double" @onblur="_Parent.calcularModificarHora" @bind-Value="@objetoCASA.TrabajoProfesional.HorasTPEDireccion" Min="0" class="inputForm inputTabla tdAlineadoDerecha" />h
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabajoProfesional _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
// private string estiloTabla => _Parent.modificarHoras == true ? "" : "";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,443 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
<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="tiposForm">
|
||||||
|
<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">Superficie:</label>
|
||||||
|
<InputNumber TValue="double" @bind-Value="itemSeleccionadoTemporal.superficie"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.superficie))"
|
||||||
|
class="inputForm" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.superficie))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Uso:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idGrupoTipologia" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idGrupoTipologia))">
|
||||||
|
@foreach (var grupoTipologia in objetoCASA.Enumerados.GruposTipologias)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idGrupoTipologia))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Tipología:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idTipologia" class="inputForm">
|
||||||
|
@foreach (var tipologia in tipologiasAux)
|
||||||
|
{
|
||||||
|
<option value="@tipologia.idTipologia">@tipologia.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt2">
|
||||||
|
<label class="tituloLbl">Intervención:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idTipoIntervencion" class="inputForm">
|
||||||
|
@foreach (var intervencion in intervencionesAux)
|
||||||
|
{
|
||||||
|
<option value="@intervencion.idEnumeracion">@intervencion.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</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="d-flex justify-content-between">
|
||||||
|
<div><b>Usos/Tipología</b></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
|
||||||
|
<Grid TItem="CASA.UsosTipologia"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="UsosTipologias"
|
||||||
|
AllowFiltering="false"
|
||||||
|
AllowRowClick="true"
|
||||||
|
OnRowClick="OnRowClick"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
Height="100"
|
||||||
|
Style="table-layout:fixed !important"
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Class="columna20Ancho text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Superficie">
|
||||||
|
<span>
|
||||||
|
@context.superficie.MilesYDecimales()
|
||||||
|
</span>
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn Class="columna20Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Uso">
|
||||||
|
@objetoCASA.Enumerados.GruposTipologias?.FirstOrDefault(x => x.idEnumeracion == context.idGrupoTipologia)?.ValorAlfabetico1
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="CASA.UsosTipologia" HeaderTextAlignment="Alignment.Center" HeaderText="Tipología">
|
||||||
|
@objetoCASA.Enumerados.Tipologias?.FirstOrDefault(x => x.idTipologia == context.idTipologia)?.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn Class="columna20Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Intervención">
|
||||||
|
@objetoCASA.Enumerados.Intervenciones?.FirstOrDefault(x => x.idEnumeracion == context.idTipoIntervencion)?.ValorAlfabetico1
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="CASA.UsosTipologia" 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>
|
||||||
|
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.UsosTipologia(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir nuevo Uso</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total superficie: <span>
|
||||||
|
@UsosTipologias.Sum(x => x.superficie).MilesYDecimales()
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabajoProfesional _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public CASA objetoCASA { get; set; } = new CASA();
|
||||||
|
|
||||||
|
public List<CASA.UsosTipologia> UsosTipologias { get; set; } = new List<CASA.UsosTipologia>();
|
||||||
|
private List<CASA.tipologiasCASA> tipologiasAux = new List<CASA.tipologiasCASA>();
|
||||||
|
private List<CASA.enumeracionesCASA> intervencionesAux = new List<CASA.enumeracionesCASA>();
|
||||||
|
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.UsosTipologia itemSeleccionado { get; set; } = new CASA.UsosTipologia();
|
||||||
|
|
||||||
|
private CASA.UsosTipologia itemSeleccionadoTemporal { get; set; } = new CASA.UsosTipologia();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
|
||||||
|
UsosTipologias = objetoCASA.TrabajoProfesional.Usos.ToList();
|
||||||
|
//tipologiasAux = objetoCASA.Enumerados.Tipologias.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
rellenarItem();
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoCASA.ActualizarUso(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoCASA.InsertarUso(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoCASA.EliminarUso(itemSeleccionado);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UsosTipologias = objetoCASA.TrabajoProfesional.Usos.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var a = ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.UsosTipologia objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = new CASA.UsosTipologia();
|
||||||
|
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal = new CASA.UsosTipologia()
|
||||||
|
{
|
||||||
|
CoefIntervencion = objeto.CoefIntervencion,
|
||||||
|
CoefTipologia = objeto.CoefTipologia,
|
||||||
|
idGrupoTipologia = objeto.idGrupoTipologia,
|
||||||
|
idTipoIntervencion = objeto.idTipoIntervencion,
|
||||||
|
idTipologia = objeto.idTipologia,
|
||||||
|
superficie = objeto.superficie,
|
||||||
|
SuperficieCoefIntervencion = objeto.SuperficieCoefIntervencion,
|
||||||
|
SuperficieCoefTipologia = objeto.SuperficieCoefTipologia
|
||||||
|
};
|
||||||
|
|
||||||
|
await cambiarTipologia();
|
||||||
|
nuevoElemento = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar uso";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Nuevo uso";
|
||||||
|
}
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cambiarTipologia()
|
||||||
|
{
|
||||||
|
tipologiasAux = objetoCASA.Enumerados.TipologiasPorGrupo(itemSeleccionadoTemporal.idGrupoTipologia).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
if (itemSeleccionadoTemporal.idTipologia == 0)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = tipologiasAux.First().idTipologia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tipologiasAux.Any(x => x.idTipologia == itemSeleccionadoTemporal.idTipologia))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = itemSeleccionadoTemporal.idTipologia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = tipologiasAux.First().idTipologia;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
intervencionesAux = objetoCASA.Enumerados.Intervenciones.ToList();
|
||||||
|
itemSeleccionadoTemporal.idTipoIntervencion = itemSeleccionadoTemporal.idTipoIntervencion == 0 ? intervencionesAux.First().idEnumeracion : itemSeleccionadoTemporal.idTipoIntervencion;
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.UsosTipologia objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.UsosTipologia> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionadoTemporal.superficie):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
string parseado = value.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.superficie = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.idGrupoTipologia):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idGrupoTipologia = int.Parse(value);
|
||||||
|
cambiarTipologia();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idGrupoTipologia = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.superficie) && itemSeleccionadoTemporal.superficie <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "La superficie debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idGrupoTipologia) && itemSeleccionadoTemporal.idGrupoTipologia == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione un tipo de uso.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.superficie }, nameof(itemSeleccionadoTemporal.superficie));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idGrupoTipologia }, nameof(itemSeleccionadoTemporal.idGrupoTipologia));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
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.superficie), nameof(itemSeleccionado.idGrupoTipologia) })
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.UsosTipologia).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.CoefIntervencion = itemSeleccionadoTemporal.CoefIntervencion;
|
||||||
|
itemSeleccionado.CoefTipologia = itemSeleccionadoTemporal.CoefTipologia;
|
||||||
|
itemSeleccionado.idGrupoTipologia = itemSeleccionadoTemporal.idGrupoTipologia;
|
||||||
|
itemSeleccionado.idTipoIntervencion = itemSeleccionadoTemporal.idTipoIntervencion;
|
||||||
|
itemSeleccionado.idTipologia = itemSeleccionadoTemporal.idTipologia;
|
||||||
|
itemSeleccionado.superficie = itemSeleccionadoTemporal.superficie;
|
||||||
|
itemSeleccionado.SuperficieCoefIntervencion = itemSeleccionadoTemporal.SuperficieCoefIntervencion;
|
||||||
|
itemSeleccionado.SuperficieCoefTipologia = itemSeleccionadoTemporal.SuperficieCoefTipologia;
|
||||||
|
}
|
||||||
|
}
|
||||||
250
HerramientaCASA/Components/Pages/HerramientaURBAN.razor
Normal file
250
HerramientaCASA/Components/Pages/HerramientaURBAN.razor
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
@page "/HerramientaURBAN"
|
||||||
|
@using System.Text
|
||||||
|
@using System.Text.Json
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
<p class="TituloVentana">
|
||||||
|
@TextoSuperior
|
||||||
|
</p>
|
||||||
|
@if (!actualizado)
|
||||||
|
{
|
||||||
|
<div class="UpdateCacoa d-flex">
|
||||||
|
<span>Esta simulación utiliza valores desactualizados. ¿Quiere Realizar una copia actualizada?</span>
|
||||||
|
<button @onclick="@(() => clonarUrban())" class="btnBlue ms-auto">Actualizar</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Modal @ref="popupGuardar" title="@TituloBoton" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
|
||||||
|
@if (TituloBoton == "Guardar")
|
||||||
|
{
|
||||||
|
<p>Se va a <b>guardar</b> esta <b>nueva simulación</b> podrá acceder a ella para consultarla y editarla desde el apartado <b>Mis Simulaciones</b> </p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Se van a <b>sobrescribir</b> los datos de la <b>simulación actual</b> con los cambios realizados, <b>esta opción no puede deshacerse.</b><br /><br /> ¿Desea continuar? </p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGuardar">Cerrar</Button>
|
||||||
|
<Button @onclick="@(() => guardarUrban())" Color="ButtonColor.Primary">@TituloBoton</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="d-flex mb-2 mt-2" style="width:100%">
|
||||||
|
<button @onclick="@(() => abrirPopupGuardar())" class="btnBlue d-flex align-items-center"> <i class="fas fa-save pe-1"></i>@TituloBoton</button>
|
||||||
|
<b class="Fuente2 ps-2 pe-2 nomSim">Nombre de la simulación: </b>
|
||||||
|
<InputText @bind-Value="urban.NombreSimulacion" class="form-control inputForm formatoMoneda inputTabla " style="text-align:left;font-weight:bold;"></InputText>
|
||||||
|
</div>
|
||||||
|
<Tabs>
|
||||||
|
<Tab Title="Despacho Profesional" Name="tabDespachoProf" Active>
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfesionalURBAN objetoURBAN="urban"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfesionalURBAN>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Trabajo Profesional" Name="tabTrabajoProf">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.TrabProfUrban objetoURBAN="urban"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.TrabProfUrban>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Costes de producción" Name="tabCosteProd">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProduccionURBAN objetoURBAN="urban"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProduccionURBAN>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
public string TextoSuperior = "Nueva simulación CASA de Urbanismo";
|
||||||
|
public string TituloBoton = "Guardar";
|
||||||
|
private Modal popupGuardar = default!;
|
||||||
|
|
||||||
|
public bool actualizado = true;
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
private static URBAN urban;
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
string nombreOriginal = "";
|
||||||
|
|
||||||
|
private int idUser = 0;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
urban = new URBAN();
|
||||||
|
urban.RellenarCamposExtra(bd, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var a = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var fechaActVar = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD").Fecha1;
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
simulaciones simu = bd.simulaciones.Where(x => x.idSimulacion == int.Parse(idDesencriptado)).First();
|
||||||
|
int idFicheroJSON = simu.idFicheroJSON;
|
||||||
|
idSimulador = idDesencriptado;
|
||||||
|
var byteFichero = bd.ficheros.Where(x => x.idFichero == idFicheroJSON).First().Fichero;
|
||||||
|
|
||||||
|
string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
urban = System.Text.Json.JsonSerializer.Deserialize<URBAN>(CASAJson);
|
||||||
|
|
||||||
|
if ((simu.FechaModificacion != null && simu.FechaModificacion < fechaActVar) || (simu.FechaModificacion == null && simu.FechaCreacion < fechaActVar))
|
||||||
|
{
|
||||||
|
actualizado = false;
|
||||||
|
}
|
||||||
|
TextoSuperior = "Modificando simulación \"" + simu.Descripcion + "\"";
|
||||||
|
TituloBoton = "Modificar";
|
||||||
|
|
||||||
|
nombreOriginal = urban.NombreSimulacion;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
idUser = obtenerID.Value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error durante la inicialización: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void guardarUrban()
|
||||||
|
{
|
||||||
|
//HACER
|
||||||
|
// para evitar loops
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == HerramientaCASA.UtilidadesCASA.obtenerTipoSimulacion(HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBAN)).idEnumeracion;
|
||||||
|
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(urban);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
if (bd.simulaciones.Any(x => x.Descripcion == urban.NombreSimulacion && x.idTipoSimulacion == idtipoSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crearSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var listadoSimulacionesExistentes = bd.simulaciones.Where(x => x.Descripcion != nombreOriginal && x.idTipoSimulacion == idtipoSimulacion).ToList();
|
||||||
|
|
||||||
|
if (listadoSimulacionesExistentes.Any(x => x.Descripcion == urban.NombreSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actualizarSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void crearSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
int idSimulacionCreada = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBAN, jsonObjeto, urban.NombreSimulacion, "urban.json", idUser);
|
||||||
|
string link = "/HerramientaURBAN?idSimulador=" + tsUtilidades.crypt.FEncS(idSimulacionCreada.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Simulación creada correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
private void actualizarSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
UtilidadesCASA.actualziarObjeto(bd, jsonObjeto, urban.NombreSimulacion, idSimulador);
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Simulación actualizada correctamente.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarUrban()
|
||||||
|
{
|
||||||
|
urban.RellenarCamposExtra(bd, true);
|
||||||
|
urban.CalcularFinales();
|
||||||
|
urban.NombreSimulacion = urban.NombreSimulacion + " (Act:" + DateTime.Now + ")";
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(urban);
|
||||||
|
var id = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBAN, jsonObjeto, urban.NombreSimulacion, "urban.json", idUser);
|
||||||
|
|
||||||
|
var link = "/HerramientaURBAN?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task abrirPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,528 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
|
||||||
|
<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="tiposForm">
|
||||||
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Coste Variable:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idCoste" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idCoste))">
|
||||||
|
@foreach (var grupoTipologia in objetoURBAN.Enumerados.ListaCostesVariables)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idCoste))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Coste:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" @bind-Value="itemSeleccionadoTemporal.Coste"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.Coste))"
|
||||||
|
class="inputForm text-end" /> €
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.Coste))</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="row">
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<b>Costes variables</b>
|
||||||
|
<div class="pt-1 col-md-12 d-flex" style="gap: 40px; height:25px;">
|
||||||
|
<div class="d-flex">
|
||||||
|
|
||||||
|
|
||||||
|
<RadioInput style="margin-right: 10px;" Label="Calcular" Value="esCalcular" ValueExpression="() => esCalcular" ValueChanged="(value) => esCalcularChanged(value)" />
|
||||||
|
|
||||||
|
<RadioInput style="margin-right: 10px; margin-left:15px;" Label="% sobre los costes de producción" Value="esPorcentajeCostes" ValueExpression="() => esPorcentajeCostes" ValueChanged="(value) => esPorcentajeCostesChanged(value)" />
|
||||||
|
|
||||||
|
@if (esPorcentajeCostes)
|
||||||
|
{
|
||||||
|
<p class="ms-3">
|
||||||
|
<InputNumber TValue="double" Value="@porcentajeCostes" ValueExpression="() => porcentajeCostes"
|
||||||
|
step="any"
|
||||||
|
style="width:100px;"
|
||||||
|
ValueChanged="(value) => porcentajeCambiado(value)"
|
||||||
|
class="inputForm text-end" /> %
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (esCalcular)
|
||||||
|
{
|
||||||
|
<div style="position:relative;margin-bottom: 19px;">
|
||||||
|
<Grid TItem="CASA.CosteVariable"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listCostesVariables"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" HeaderTextAlignment="Alignment.Center" HeaderText="Conceptos" Class="colorB">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda text-end" HeaderText="Coste">
|
||||||
|
@context.Coste.MilesYDecimales() €
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteVariable" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.CosteVariable(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir coste variable</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total costes variables: <span> @objetoURBAN.CostesProduccion.TotalCostesVariables.MilesYDecimales() €</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="align-items: flex-end;">
|
||||||
|
<div style="height: 49px;">
|
||||||
|
<b>Coste hora Despacho Profesional</b>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Tipo de costes</th>
|
||||||
|
<th class="colorB fw-bold">Coste/hora</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Costes directos</td>
|
||||||
|
<td class="text-end">@objetoURBAN.DespachoProfesional.CostesDirectos.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Costes indirectos</td>
|
||||||
|
<td class="text-end">@objetoURBAN.DespachoProfesional.TasaCostesIndirectos.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Costes variables</td>
|
||||||
|
<td class="text-end">@objetoURBAN.CostesProduccion.CostesVariables.MilesYDecimales() €/hora</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
Total Coste hora Despacho Profesional: <span> @objetoURBAN.CostesProduccion.TotalCostes.MilesYDecimales() €/hora</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
|
||||||
|
<div style="height: 49px;">
|
||||||
|
<b>Coste hora Externalización</b>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Externalización</th>
|
||||||
|
<th class="colorB fw-bold">Porcentaje</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Incremento por externalización</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px">
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoURBAN.CostesProduccion.CoeficienteCostesExternalizacion" ValueExpression="() => objetoURBAN.CostesProduccion.CoeficienteCostesExternalizacion" ValueChanged="(value) => CosteExtCambiado(value)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
Coste hora Externalización: <span> @objetoURBAN.CostesProduccion.CosteHoraExternalizacion.MilesYDecimales() €/hora</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
List<CASA.CosteVariable> listCostesVariables = new List<CASA.CosteVariable>();
|
||||||
|
|
||||||
|
private bool esCalcular = true;
|
||||||
|
private bool esPorcentajeCostes = false;
|
||||||
|
|
||||||
|
private double porcentajeCostes;
|
||||||
|
private bool editarElemento;
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.CosteVariable itemSeleccionado { get; set; } = new CASA.CosteVariable();
|
||||||
|
|
||||||
|
private CASA.CosteVariable itemSeleccionadoTemporal { get; set; } = new CASA.CosteVariable();
|
||||||
|
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccionURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
listCostesVariables = objetoURBAN.CostesProduccion.ListaCostesVariables.ToList();
|
||||||
|
|
||||||
|
porcentajeCostes = objetoURBAN.CostesProduccion.porcentaje;
|
||||||
|
esCalcular = objetoURBAN.CostesProduccion.EsCalculado;
|
||||||
|
|
||||||
|
if (!esCalcular)
|
||||||
|
{
|
||||||
|
esPorcentajeCostes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void porcentajeCambiado(double porcentajeCostesCambiado)
|
||||||
|
{
|
||||||
|
porcentajeCostes = porcentajeCostesCambiado;
|
||||||
|
objetoURBAN.CostesProduccion.porcentaje = porcentajeCostes;
|
||||||
|
esPorcentajeCostesChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CosteExtCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoURBAN.CostesProduccion.CoeficienteCostesExternalizacion = e;
|
||||||
|
objetoURBAN.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void esCalcularChanged(bool res)
|
||||||
|
{
|
||||||
|
esCalcular = res;
|
||||||
|
esPorcentajeCostes = !res;
|
||||||
|
objetoURBAN.CostesProduccion.EsCalculado = res;
|
||||||
|
|
||||||
|
objetoURBAN.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void esPorcentajeCostesChanged(bool res)
|
||||||
|
{
|
||||||
|
esPorcentajeCostes = res;
|
||||||
|
esCalcular = !res;
|
||||||
|
objetoURBAN.CostesProduccion.EsCalculado = !res;
|
||||||
|
|
||||||
|
objetoURBAN.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CosteVariableCambiado(double e, CASA.CosteVariable objeto)
|
||||||
|
{
|
||||||
|
objeto.Coste = (int)e;
|
||||||
|
objetoURBAN.ActualizarCostesVariables(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
itemSeleccionado.Denominacion = objetoURBAN.Enumerados.ListaCostesVariables.First(x => x.idEnumeracion == itemSeleccionado.idCoste).ValorAlfabetico1;
|
||||||
|
objetoURBAN.ActualizarCostesVariables(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
itemSeleccionado.Denominacion = objetoURBAN.Enumerados.ListaCostesVariables.First(x => x.idEnumeracion == itemSeleccionado.idCoste).ValorAlfabetico1;
|
||||||
|
objetoURBAN.InsertarCostesVariables(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoURBAN.EliminarCostesVariables(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listCostesVariables = objetoURBAN.CostesProduccion.ListaCostesVariables.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.CosteVariable objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
itemSeleccionadoTemporal = new CASA.CosteVariable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new CASA.CosteVariable()
|
||||||
|
{
|
||||||
|
Coste = objeto.Coste,
|
||||||
|
Denominacion = objeto.Denominacion,
|
||||||
|
idCoste = objeto.idCoste
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionadoTemporal.Coste):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
string parseado = value.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.Coste = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.idCoste):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idCoste = int.Parse(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idCoste = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.Coste) && itemSeleccionadoTemporal.Coste <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "El coste debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idCoste) && itemSeleccionadoTemporal.idCoste == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione un coste.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.Coste }, nameof(itemSeleccionadoTemporal.Coste));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idCoste }, nameof(itemSeleccionadoTemporal.idCoste));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
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(itemSeleccionadoTemporal.Coste), nameof(itemSeleccionadoTemporal.idCoste) })
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.CosteVariable).GetProperty(field)?.GetValue(itemSeleccionadoTemporal) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.CosteVariable objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.CosteVariable> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.idCoste = itemSeleccionadoTemporal.idCoste;
|
||||||
|
itemSeleccionado.Coste = itemSeleccionadoTemporal.Coste;
|
||||||
|
itemSeleccionado.Denominacion = itemSeleccionadoTemporal.Denominacion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@using HerramientaCASA.Components.Pages.Comun
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6 mt-3">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
@* <b>Costes Asociados a los Servicios de Arquitectura</b> *@
|
||||||
|
</div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Concepto</th>
|
||||||
|
<th class="colorB fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">COSTES DE PRODUCCIÓN DEL TRABAJO PROFESIONAL</td>
|
||||||
|
<td class="text-end"><span> @objetoURBAN.CostesProduccion.CostesProduccionTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro w4"><p> <b>Beneficio</b> (antes de impuestos)</p></td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoURBAN.CostesProduccion.Beneficio" ValueExpression="() => objetoURBAN.CostesProduccion.Beneficio" ValueChanged="(value) => BeneficioCambiado(value)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
PRECIO DEL TRABAJO PROFESIONAL: <span>@objetoURBAN.CostesProduccion.PrecioTrabajoProfesional.MilesYDecimales() € </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
private double porcentajeCostes;
|
||||||
|
private double sumaTotal;
|
||||||
|
private bool editarElemento;
|
||||||
|
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccionURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void BeneficioCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoURBAN.CostesProduccion.Beneficio = e;
|
||||||
|
objetoURBAN.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
<div class="d-flex flex-column">
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
|
||||||
|
<div class="col-md-6 row">
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Plazo de presentación de la documentación:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
@* <InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos" ValueExpression="() => objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos" ValueChanged="(value) => PlazoPresentacionDocumentosCambiado(value)"></InputNumber> meses *@
|
||||||
|
<InputNumber TValue="double" @bind-Value="objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => controlarMeses(e.Value?.ToString())"
|
||||||
|
class="inputForm formatoMoneda inputTabla text-end" /> meses
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex mt-3 justify-content-center">
|
||||||
|
<div class="col-md-6 row">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Trabajo profesional</b>
|
||||||
|
</div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Trabajos</th>
|
||||||
|
<th class="colorB fw-bold">Horas</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas en despacho profesional</td>
|
||||||
|
<td class="text-end">@objetoURBAN.CostesProduccion.HorasEnPlazo.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold">Horas mediante externalización</td>
|
||||||
|
<td class="text-end">@objetoURBAN.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@* <tr>
|
||||||
|
<td class="colorB fw-bold">Horas de producción en este plazo</td>
|
||||||
|
<td class="text-end">@objetoURBAN.CostesProduccion.HorasEnPlazo.MilesYDecimales() h</td>
|
||||||
|
</tr> *@
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end colorC fw-bold w4">
|
||||||
|
Total horas del trabajo profesional: <span>@objetoURBAN.CostesProduccion.HorasTrabajoProfesional.MilesYDecimales() h </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@* <div class="col-md-6">
|
||||||
|
<p>Horas Trabajo profesional: @objetoURBAN.CostesProduccion.HorasTrabajoProfesional </p>
|
||||||
|
<p>Horas Anuales de produccion del desapacho profesional: @objetoURBAN.DespachoProfesional.HorasTotalesProduccion</p>
|
||||||
|
<p>Horas de produccion del despacho en ese plazo: @objetoURBAN.CostesProduccion.HorasEnPlazo</p>
|
||||||
|
<p>nº horas mínimo de externalizacion: @objetoURBAN.CostesProduccion.NumHorasMinimoExt</p>
|
||||||
|
</div> *@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public CostesProduccionURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void PlazoPresentacionDocumentosCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos = e;
|
||||||
|
|
||||||
|
objetoURBAN.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlarMeses(string meses)
|
||||||
|
{
|
||||||
|
if (double.TryParse(meses, out var valor))
|
||||||
|
{
|
||||||
|
string parseado = meses.ToString().Replace(",", ".");
|
||||||
|
objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlazoPresentacionDocumentosCambiado(objetoURBAN.CostesProduccion.PlazoPresentacionDocumentos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
@page "/CostesProduccionUrban"
|
||||||
|
<div class="p-2">
|
||||||
|
<h5>Euros/Hora</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.CosteVariableUrban objetoURBAN="objetoURBAN"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.CosteVariableUrban>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<hr class="hrCasa" />
|
||||||
|
<h5>Horas</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.HorasCostesURBAN objetoURBAN="objetoURBAN"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.HorasCostesURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<hr class="hrCasa" />
|
||||||
|
<h5>Euros</h5>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.EurosUrban objetoURBAN="objetoURBAN"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.CostesProducURBAN.EurosUrban>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.HerramientaURBAN.URBAN objetoURBAN { get; set; } = new bdHerramientaCACOA.HerramientaURBAN.URBAN();
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3 alturaTitulosTabla">
|
||||||
|
<div><b>Costes Indirectos Anuales</b></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="position:relative;margin-bottom: 20px;">
|
||||||
|
<Grid @ref="grid"
|
||||||
|
TItem="CASA.CosteIndirecto"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="costesIndirectos"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.CosteIndirecto" HeaderTextAlignment="Alignment.Center" HeaderText="Concepto" PropertyName="Concepto" Class="colorFilasIntro">
|
||||||
|
@context.Concepto
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.CosteIndirecto" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda columna30Ancho" HeaderText="Importe" PropertyName="importe">
|
||||||
|
<div class="d-flex separadorMoneda">
|
||||||
|
<CurrencyInput HideCurrencySymbol="true" TValue="double" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@context.importe" ValueExpression="() => context.importe" ValueChanged="(value) => valorCambiado(value,context)"></CurrencyInput> €
|
||||||
|
</div>
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end columna20Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.CosteIndirecto" HeaderText="Periocidad">
|
||||||
|
@* @if (context != itemSeleccionado)
|
||||||
|
{
|
||||||
|
<span>@listadoPeriodos.FirstOrDefault(p => p.idEnumeracion == context.idPeriodicidad)?.ValorAlfabetico1</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ *@
|
||||||
|
<InputSelect Value="@context.idPeriodicidad" class="inputForm selectTabla" ValueExpression="() => context.idPeriodicidad" TValue="int" ValueChanged="(value) => valorCICambiado(value,context)">
|
||||||
|
@foreach (var periodo in listadoPeriodos)
|
||||||
|
{
|
||||||
|
<option value="@periodo.idEnumeracion">@periodo.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
@* } *@
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end columna30Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.CosteIndirecto" HeaderText="Coste" PropertyName="coste">
|
||||||
|
<span>@context.coste.ToString("C", new System.Globalization.CultureInfo("es-ES"))</span>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-19px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
Total Costes Indirectos: <span>
|
||||||
|
@objetoURBAN.DespachoProfesional.TotalCostesIndirectos.MilesYDecimales() €
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
public List<CASA.CosteIndirecto> costesIndirectos { get; set; } = new List<CASA.CosteIndirecto>();
|
||||||
|
private CASA.CosteIndirecto itemSeleccionado = new CASA.CosteIndirecto();
|
||||||
|
|
||||||
|
Grid<CASA.CosteIndirecto> grid = default!;
|
||||||
|
|
||||||
|
private List<CASA.enumeracionesCASA> listadoPeriodos = new List<CASA.enumeracionesCASA>();
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
|
||||||
|
private bool editarElemento;
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public DespachoProfesionalURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
// CAMBIAR POR LA OTRA PAGINA QUE LLAMA A CLONAR DESPACHO Y CAMBIAR ABAJO EN LA FUNCION
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfesionalURBAN _OtroParent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
listadoPeriodos = objetoURBAN.Enumerados.Periodos.ToList();
|
||||||
|
//costesIndirectos = objetoCASA.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
costesIndirectos = objetoURBAN.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.CosteIndirecto> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
private async void valorCambiado(double e, CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (objeto.idPeriodicidad != 0)
|
||||||
|
{
|
||||||
|
objeto.importe = (double)e;
|
||||||
|
objetoURBAN.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async void valorCICambiado(int e, CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objeto.idPeriodicidad = (int)e;
|
||||||
|
objetoURBAN.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void guardar(CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objetoURBAN.ActualizarCosteIndirecto(objeto);
|
||||||
|
|
||||||
|
// mensajes.Add(new ToastMessage
|
||||||
|
// {
|
||||||
|
// Type = ToastType.Primary,
|
||||||
|
// Message = $"Guardado correctamente.",
|
||||||
|
// });
|
||||||
|
|
||||||
|
costesIndirectos = objetoURBAN.DespachoProfesional.CostesIndirectos.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
refrescarPadre();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void limpiarDatos(CASA.CosteIndirecto objeto)
|
||||||
|
{
|
||||||
|
objetoURBAN.LimpiarCosteIndirecto(objeto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refrescarPadre()
|
||||||
|
{
|
||||||
|
if (_Parent != null)
|
||||||
|
{
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else if (_OtroParent != null)
|
||||||
|
{
|
||||||
|
_OtroParent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,336 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.RegularExpressions
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
<label class="tituloLbl">Denominación grupo:</label>
|
||||||
|
<InputText @bind-Value="itemSeleccionadoTemporal.Nombre" class="inputForm" list="sugerenciasGrupo"></InputText>
|
||||||
|
|
||||||
|
<datalist id="sugerenciasGrupo">
|
||||||
|
@foreach (var grupo in grupos)
|
||||||
|
{
|
||||||
|
<option value="@grupo" />
|
||||||
|
}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Coste anual:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionadoTemporal.CosteAnual" class="inputForm derecha formatoMoneda"></NumberInput> €
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Jornada laboral:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<NumberInput TValue="double" Min="0" @bind-Value="itemSeleccionadoTemporal.JornadaLaboral" class="inputForm derecha"></NumberInput> h/sem
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">
|
||||||
|
<Tooltip Title=@tituloInfo class="custom-tooltip" role="button">
|
||||||
|
<Icon Name="IconName.InfoCircleFill" Class="text-primary"></Icon>
|
||||||
|
</Tooltip>
|
||||||
|
Porcentaje producción:
|
||||||
|
</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
|
||||||
|
<NumberInput TValue="double" Step="1" Min="0" @oninput="EvitarDecimalesPorcentaje" @bind-Value:format="F0" @bind-Value="itemSeleccionadoTemporal.PorcentajeProduccion" class="inputForm derecha"></NumberInput> %
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6 formatoCampos">
|
||||||
|
<label class="tituloLbl">Nº de trabajadores:</label>
|
||||||
|
<NumberInput TValue="double" Step="1" @oninput="EvitarDecimalesTrabajores" Min="0" @bind-Value="itemSeleccionadoTemporal.NumTrabajadores" class="inputForm derecha"></NumberInput>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||||
|
@if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("update"))" Color="ButtonColor.Primary">Modificar</Button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<Button @onclick="@(() => GestionarDatos("create"))" Color="ButtonColor.Primary">Añadir</Button>
|
||||||
|
}
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3 alturaTitulosTabla">
|
||||||
|
<div><b>Costes Directos Anuales del Personal</b></div>
|
||||||
|
</div>
|
||||||
|
<div style="position:relative;margin-bottom: 45px;">
|
||||||
|
<Grid TItem="CASA.Trabajador"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="Trabajadores"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" HeaderText="Denominación del grupo" PropertyName="Nombre" Class="colorA">
|
||||||
|
@context.Nombre
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" HeaderTextAlignment="Alignment.Center" Class="formatoMoneda text-end" HeaderText="Coste anual" PropertyName="CosteAnual">
|
||||||
|
<span>@context.CosteAnual.MilesYDecimales() €</span>
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.Trabajador" HeaderText="Jornada laboral" PropertyName="JornadaLaboral">
|
||||||
|
@context.JornadaLaboral.MilesYDecimales() h
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.Trabajador" HeaderText="Porcentaje producción" PropertyName="PorcentajeProduccion">
|
||||||
|
@context.PorcentajeProduccion %
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.Trabajador" HeaderText="Nº de trabajadores" PropertyName="NumTrabajadores">
|
||||||
|
@context.NumTrabajadores
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.Trabajador" HeaderText="Coste Anual" PropertyName="CosteAnualTotal">
|
||||||
|
@context.CosteAnualTotal.MilesYDecimales() €
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Class="text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.Trabajador" HeaderText="Horas Producción" PropertyName="HorasProduccion">
|
||||||
|
@context.HorasProduccion.MilesYDecimales() h
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.Trabajador" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-36px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.Trabajador(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i>Nuevo Grupo de Trabajador</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>Total Coste Anual: @objetoURBAN.DespachoProfesional.CostesDirectosAnuales.MilesYDecimales() €</span><br />
|
||||||
|
<span>Total Horas Producción: @objetoURBAN.DespachoProfesional.HorasTotalesProduccion.MilesYDecimales() h</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
public List<CASA.Trabajador> Trabajadores { get; set; } = new List<CASA.Trabajador>();
|
||||||
|
|
||||||
|
private CASA.Trabajador itemSeleccionado = new CASA.Trabajador();
|
||||||
|
private CASA.Trabajador itemSeleccionadoTemporal = new CASA.Trabajador();
|
||||||
|
|
||||||
|
|
||||||
|
private List<string> grupos = new()
|
||||||
|
{
|
||||||
|
"Arquitecto/a",
|
||||||
|
"Arquitecto/a técnico/a",
|
||||||
|
"Delineante",
|
||||||
|
"Administrativo/a"
|
||||||
|
};
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private string tituloInfo = "";
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public DespachoProfesionalURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
tituloInfo = "Es el porcentaje de tiempo que el empleado destina a la producción del trabajo profesional concreto, dedicando el resto del tiempo a otras tareas del despacho.";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
|
||||||
|
Trabajadores = objetoURBAN.DespachoProfesional.Trabajadores;
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EvitarDecimalesPorcentaje(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
var input = e?.Value?.ToString();
|
||||||
|
|
||||||
|
if (double.TryParse(input, out var valor))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.PorcentajeProduccion = Math.Round(valor, 0, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EvitarDecimalesTrabajores(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
var input = e?.Value?.ToString();
|
||||||
|
|
||||||
|
if (double.TryParse(input, out var valor))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.NumTrabajadores = Math.Round(valor, 0, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoURBAN.ActualizarTrabajador(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoURBAN.InsertarTrabajador(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoURBAN.EliminarTrabajador(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Trabajadores = objetoURBAN.DespachoProfesional.Trabajadores.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.Trabajador objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new CASA.Trabajador()
|
||||||
|
|
||||||
|
{
|
||||||
|
CosteAnual = objeto.CosteAnual,
|
||||||
|
CosteAnualTotal = objeto.CosteAnualTotal,
|
||||||
|
HorasProduccion = objeto.HorasProduccion,
|
||||||
|
IdTrabajador = objeto.IdTrabajador,
|
||||||
|
JornadaLaboral = objeto.JornadaLaboral,
|
||||||
|
Nombre = objeto.Nombre,
|
||||||
|
NumTrabajadores = objeto.NumTrabajadores,
|
||||||
|
PorcentajeProduccion = objeto.PorcentajeProduccion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar grupo de trabajadores";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = new CASA.Trabajador();
|
||||||
|
tituloPopup = "Nuevo grupo de trabajadores";
|
||||||
|
itemSeleccionadoTemporal.Nombre = "Arquitecto";
|
||||||
|
itemSeleccionadoTemporal.JornadaLaboral = 40;
|
||||||
|
itemSeleccionadoTemporal.PorcentajeProduccion = 80;
|
||||||
|
itemSeleccionadoTemporal.NumTrabajadores = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.Trabajador objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.CosteAnual = itemSeleccionadoTemporal.CosteAnual;
|
||||||
|
itemSeleccionado.CosteAnualTotal = itemSeleccionadoTemporal.CosteAnualTotal;
|
||||||
|
itemSeleccionado.HorasProduccion = itemSeleccionadoTemporal.HorasProduccion;
|
||||||
|
itemSeleccionado.IdTrabajador = itemSeleccionadoTemporal.IdTrabajador;
|
||||||
|
itemSeleccionado.JornadaLaboral = itemSeleccionadoTemporal.JornadaLaboral;
|
||||||
|
itemSeleccionado.Nombre = itemSeleccionadoTemporal.Nombre;
|
||||||
|
itemSeleccionado.NumTrabajadores = itemSeleccionadoTemporal.NumTrabajadores;
|
||||||
|
itemSeleccionado.PorcentajeProduccion = itemSeleccionadoTemporal.PorcentajeProduccion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
@page "/DespachoProfesionalUrban"
|
||||||
|
@using HerramientaCASA.Components.Pages.Comun
|
||||||
|
@using HerramientaCASA.Components.Pages.HerramientaCASATabs.DespachoProfesionalComponents
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<ClonarDespacho datosDespachoClonado="datosClonar"></ClonarDespacho>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container-fluid m-0 p-0">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 d-flex flex-column">
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfURBAN.TrabajadorGridURBAN objetoURBAN="objetoURBAN"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfURBAN.TrabajadorGridURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-auto">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<table class="tablaAlter">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter">Coste/Hora Despacho profesional: </td>
|
||||||
|
<td class="tdAlineadoDerecha" style="font-weight:bold;">
|
||||||
|
@objetoURBAN.DespachoProfesional.CosteHoraDespachoProfesional.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Costes directos </td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
@objetoURBAN.DespachoProfesional.CostesDirectos.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlterSub">Costes indirectos</td>
|
||||||
|
<td class="tdAlineadoDerecha">
|
||||||
|
@objetoURBAN.DespachoProfesional.TasaCostesIndirectos.MilesYDecimales() €/h
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfURBAN.CosteIndirectoGridURBAN objetoURBAN="objetoURBAN"></HerramientaCASA.Components.Pages.HerramientaURBANTabs.DespachoProfURBAN.CosteIndirectoGridURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
private int idFicheroObtenido = 0;
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
public ClonarDespachoVM datosClonar = new ClonarDespachoVM();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
datosClonar.despachoProf = objetoURBAN.DespachoProfesional;
|
||||||
|
datosClonar.idSimulacion = !string.IsNullOrEmpty(idDesencriptado) ? int.Parse(idDesencriptado) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hacerCalculos()
|
||||||
|
{
|
||||||
|
objetoURBAN.CalcularFinales();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
@page "/TrabProfUrban"
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@using HerramientaCASA.Components.Pages.HerramientaURBANTabs.TrabajoProfURBAN
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
|
||||||
|
<div class="row p-0 m-0">
|
||||||
|
<div class="col-md-12 mt-3 mb-3">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<DocumentosURBAN objetoURBAN="objetoURBAN"></DocumentosURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row p-0 m-0">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<FasesURBAN objetoURBAN="objetoURBAN"></FasesURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<InstrumentosURBAN objetoURBAN="objetoURBAN"></InstrumentosURBAN>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
}
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.HerramientaUrban
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.HerramientaURBAN.URBAN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Tipo de Documento:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionado.idTipoDocumentacion" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idTipoDocumentacion))">
|
||||||
|
@foreach (var grupoTipologia in objetoURBAN.Enumerados.TiposDeDocumentos)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Documento:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionado.idTipoProyecto" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idTipoProyecto))">
|
||||||
|
@foreach (var tipoProy in tipoProyectoAux)
|
||||||
|
{
|
||||||
|
<option value="@tipoProy.idtipoproyectos">@tipoProy.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Documentación Mínima:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoURBAN.TrabajoProfesional.DocumentacionMinima"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documentacion">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Documentación Opcional:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoURBAN.TrabajoProfesional.DocumentacionOpcional"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documencación" Class="colorA">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Añadida">
|
||||||
|
<div class="d-flex justify-content-center checkTabla">
|
||||||
|
<CheckboxInput Class="align-content-center checkGordo" Value=@context.Checkeada TValue="double" ValueExpression="() => context.Checkeada" ValueChanged="(value) => opcionalCambiado(value,context)"></CheckboxInput>
|
||||||
|
</div>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Datos Necesarios:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoURBAN.TrabajoProfesional.DatosNecesarios"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documencación" Class="colorA">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Valor">
|
||||||
|
@if (context.esCheckbox)
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-center checkTabla">
|
||||||
|
<CheckboxInput Class="align-content-center checkGordo" Value=@context.Checkeada TValue="double" ValueExpression="() => context.Checkeada" ValueChanged="(value) => DatoNecesarioCheckeado(value,context)"></CheckboxInput>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex">
|
||||||
|
<InputNumber Min="0" class="inputForm inputTabla tdAlineadoDerecha pe-0 me-1" Value=@context.ValorNecesario TValue="double" ValueExpression="() => context.ValorNecesario" ValueChanged="(value) => DatoNecesarioCambiado(value,context)"></InputNumber>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
private List<tipoproyectosURBAN> tipoProyectoAux = new List<tipoproyectosURBAN>();
|
||||||
|
|
||||||
|
|
||||||
|
private URBANTrabajoProfesional itemSeleccionado = new URBANTrabajoProfesional();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private string tituloInfo = "";
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabProfUrban _Parent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (objetoURBAN.TrabajoProfesional.idTipoDocumentacion != 0)
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoProyecto = objetoURBAN.TrabajoProfesional.idTipoProyecto;
|
||||||
|
itemSeleccionado.idTipoDocumentacion = objetoURBAN.TrabajoProfesional.idTipoDocumentacion;
|
||||||
|
cambiarSelectDocumentos();
|
||||||
|
|
||||||
|
// cambiarListasDocumentacion();
|
||||||
|
objetoURBAN.ObtenerHoraTipoDocumento();
|
||||||
|
itemSeleccionado.idInstrumento = objetoURBAN.TrabajoProfesional.idInstrumento;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionado.idTipoDocumentacion):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionado.idTipoDocumentacion = int.Parse(value);
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoDocumentacion = itemSeleccionado.idTipoDocumentacion;
|
||||||
|
cambiarSelectDocumentos();
|
||||||
|
cambiarListasDocumentacion();
|
||||||
|
|
||||||
|
calcularHoraTrabajo();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoDocumentacion = 0;
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoDocumentacion = itemSeleccionado.idTipoDocumentacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionado.idTipoProyecto):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionado.idTipoProyecto = int.Parse(value);
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
cambiarListasDocumentacion();
|
||||||
|
calcularHoraTrabajo();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoProyecto = 0;
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void calcularHoraTrabajo()
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var datos in objetoURBAN.TrabajoProfesional.DatosNecesarios.ToList())
|
||||||
|
{
|
||||||
|
objetoURBAN.ActualizarDatoNecesario(datos);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cambiarSelectDocumentos()
|
||||||
|
{
|
||||||
|
tipoProyectoAux = objetoURBAN.Enumerados.ProyectosPorTipo(itemSeleccionado.idTipoDocumentacion);
|
||||||
|
|
||||||
|
if (itemSeleccionado.idTipoProyecto == 0)
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoProyecto = tipoProyectoAux.First().idtipoproyectos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tipoProyectoAux.Any(x => x.idtipoproyectos == itemSeleccionado.idTipoProyecto))
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.idTipoProyecto = tipoProyectoAux.First().idtipoproyectos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task cambiarListasDocumentacion()
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.DocumentacionMinima = objetoURBAN.DocumentacionMinima(objetoURBAN.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoURBAN.TrabajoProfesional.DocumentacionOpcional = objetoURBAN.DocumentacionOpcional(objetoURBAN.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoURBAN.TrabajoProfesional.DatosNecesarios = objetoURBAN.DatosNecesarios(objetoURBAN.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoURBAN.ObtenerHoraTipoDocumento();
|
||||||
|
//await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void opcionalCambiado(bool e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
objeto.Checkeada = e;
|
||||||
|
objetoURBAN.ActualizarDocumentacionOpcional(objeto);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async void DatoNecesarioCheckeado(bool e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
objeto.Checkeada = e;
|
||||||
|
objetoURBAN.ActualizarDatoNecesario(objeto);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async void DatoNecesarioCambiado(double e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
objeto.ValorNecesario = (double)e;
|
||||||
|
objetoURBAN.ActualizarDatoNecesario(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.Json
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Fases</b></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 35px;">
|
||||||
|
<Grid TItem="URBAN.FasesURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFases"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.FasesURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Fases" PropertyName="Denominacion" Class="colorA">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.FasesURBAN" HeaderText="">
|
||||||
|
<div class="d-flex">
|
||||||
|
<InputNumber Min="0" class="inputForm inputTabla tdAlineadoDerecha pe-0 me-1" Value=@context.Porcentaje TValue="double" ValueExpression="() => context.Porcentaje" ValueChanged="(value) => porcentajeCambiado(value,context)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => restablecerValores())" class="btnBlue d-flex align-items-center"> <i class="fas fa-undo pe-1"></i> Restablecer </button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
@if (totalPorcentaje != 100)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Trabajo en misión parcial: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Total: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabProfUrban _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
private double totalPorcentaje = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public List<URBAN.FasesURBAN> listadoFases { get; set; } = new List<URBAN.FasesURBAN>();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
listadoFases = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.ToList();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.FasesTrabajo> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void porcentajeCambiado(double e, URBAN.FasesURBAN objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
double porcentajeTotal = calcularPorcentaje(e, objeto);
|
||||||
|
|
||||||
|
if (porcentajeTotal <= 100)
|
||||||
|
{
|
||||||
|
objeto.Porcentaje = (double)e;
|
||||||
|
objetoURBAN.ActualizarFase(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
objeto.Porcentaje = 0;
|
||||||
|
objetoURBAN.ActualizarFase(objeto);
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"La suma de los porcentajes no puede ser mayor de 100.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
totalPorcentaje = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calcularPorcentaje(double e, URBAN.FasesURBAN objeto)
|
||||||
|
{
|
||||||
|
double porcentajeTotal = 0;
|
||||||
|
objeto.Porcentaje = e;
|
||||||
|
|
||||||
|
int indice = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional
|
||||||
|
.FindIndex(x => x.idFase == objeto.idFase);
|
||||||
|
|
||||||
|
if (indice >= 0)
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional[indice] = objeto;
|
||||||
|
}
|
||||||
|
|
||||||
|
porcentajeTotal = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
return porcentajeTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void restablecerValores()
|
||||||
|
{
|
||||||
|
var lista = JsonSerializer.Deserialize<List<URBAN.FasesURBAN>>(JsonSerializer.Serialize(objetoURBAN.Enumerados.FasesTrabajo));
|
||||||
|
objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional = lista;
|
||||||
|
|
||||||
|
listadoFases = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.ToList();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoURBAN.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
objetoURBAN.CalcularHorasTrabajoProfesional();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.Json
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.CASA
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="mt-3 mb-3"><b>Innovacion de los instrumentos</b></div>
|
||||||
|
<p class="col-6">
|
||||||
|
@* @if (!nuevaRedaccion)
|
||||||
|
{ *@
|
||||||
|
<InputNumber TValue="double" Value="@objetoURBAN.TrabajoProfesional.valorInstrumentos"
|
||||||
|
ValueExpression="() => objetoURBAN.TrabajoProfesional.valorInstrumentos"
|
||||||
|
ValueChanged="(value) => ValorModificado(value)"
|
||||||
|
step="any"
|
||||||
|
class="inputForm text-end" /> <span>%</span>
|
||||||
|
@* }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<label>100 %</label>
|
||||||
|
} *@
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@foreach (var enu in listadoInstrumentos)
|
||||||
|
{
|
||||||
|
<div class="form-check" style="gap:10px;">
|
||||||
|
<input name="instrumentos" checked="@enu.Seleccionado" type="radio" id="@enu.idEnumeracion" class="form-check-input" value="@enu.ValorNumerico1" @onchange="() => Seleccionar(enu)">
|
||||||
|
|
||||||
|
<label class="form-check-label" for="@enu.idEnumeracion">@enu.Descripcion</label>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<table class="tablaAlter mt-4" style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter" style="width:50%;">Horas Trabajo Profesional </td>
|
||||||
|
<td class="tdAlineadoDerecha">@objetoURBAN.TrabajoProfesional.horasTrabProfesional.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
<div style="justify-content: end; display: flex;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public TrabProfUrban _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public URBAN objetoURBAN { get; set; } = new URBAN();
|
||||||
|
|
||||||
|
private bool nuevaRedaccion = false;
|
||||||
|
private enumeracionesCASA itemSeleccinado;
|
||||||
|
|
||||||
|
public List<CASA.enumeracionesCASA> listadoInstrumentos { get; set; } = new List<CASA.enumeracionesCASA>();
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
listadoInstrumentos = objetoURBAN.Enumerados.ListaInstrumentos.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
Seleccionar(listadoInstrumentos.First());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Seleccionar(listadoInstrumentos.FirstOrDefault(x => x.Seleccionado == true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ValorModificado(double valor)
|
||||||
|
{
|
||||||
|
objetoURBAN.TrabajoProfesional.valorInstrumentos = Convert.ToDouble(valor);
|
||||||
|
objetoURBAN.TrabajoProfesional.idInstrumento = itemSeleccinado.idEnumeracion;
|
||||||
|
itemSeleccinado.ValorNumerico1 = Convert.ToDouble(valor);
|
||||||
|
|
||||||
|
objetoURBAN.CalcularHorasTrabajoProfesional();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Seleccionar(enumeracionesCASA item)
|
||||||
|
{
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
if (item.Codigo.Contains("NUEVARED"))
|
||||||
|
{
|
||||||
|
nuevaRedaccion = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevaRedaccion = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemSeleccinado = item;
|
||||||
|
itemSeleccinado.Seleccionado = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var intru in listadoInstrumentos.Where(x => x.idEnumeracion != item.idEnumeracion))
|
||||||
|
{
|
||||||
|
intru.Seleccionado = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
objetoURBAN.TrabajoProfesional.valorInstrumentos = Convert.ToDouble(item.ValorNumerico1);
|
||||||
|
objetoURBAN.TrabajoProfesional.idInstrumento = item.idEnumeracion;
|
||||||
|
objetoURBAN.CalcularHorasTrabajoProfesional();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
HerramientaCASA/Components/Pages/Home.razor
Normal file
5
HerramientaCASA/Components/Pages/Home.razor
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
@page "/a"
|
||||||
|
|
||||||
|
<PageTitle>Home</PageTitle>
|
||||||
|
|
||||||
|
<h1>En desarrollo</h1>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="mt-3">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Costes Asociados Urban</b>
|
||||||
|
</div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Concepto</th>
|
||||||
|
<th class="colorB fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Plazo de presentación de la documentación:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
@* <InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoLicitaciones.PlazoPresentacionDocumentos" ValueExpression="() => objetoLicitaciones.PlazoPresentacionDocumentos" ValueChanged="(value) => PlazoPresentacionDocumentosCambiado(value)"></InputNumber> meses *@
|
||||||
|
<InputNumber TValue="double" @bind-Value="objetoLicitaciones.PlazoPresentacionDocumentos"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => controlarMeses(e.Value?.ToString())"
|
||||||
|
class="inputForm formatoMoneda inputTabla text-end" /> meses
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Coste de producción del Trabajo Profesional</td>
|
||||||
|
<td class="text-end"><span> @objetoLicitaciones.CostesProduccionTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">
|
||||||
|
G.G. + B.I. <br />
|
||||||
|
<span class="fw-normal" style="font-size:10px;">(40/19 Junta Consultiva de Contratación Pública del Estado)</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end" style="align-content:center;">
|
||||||
|
<div class="d-flex" style="justify-content: end; gap:3px;">
|
||||||
|
@objetoLicitaciones.Beneficio %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
Precio del Trabajo objeto de la Licitación: <span>@objetoLicitaciones.PrecioTrabProf.MilesYDecimales() €</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.LicitacionesURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void PlazoPresentacionDocumentosCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.PlazoPresentacionDocumentos = e;
|
||||||
|
objetoLicitaciones.CalcularHorasSuperficie();
|
||||||
|
objetoLicitaciones.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlarMeses(string meses)
|
||||||
|
{
|
||||||
|
if (double.TryParse(meses, out var valor))
|
||||||
|
{
|
||||||
|
string parseado = meses.ToString().Replace(",", ".");
|
||||||
|
objetoLicitaciones.PlazoPresentacionDocumentos = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlazoPresentacionDocumentosCambiado(objetoLicitaciones.PlazoPresentacionDocumentos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.HerramientaUrban
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.HerramientaURBAN.URBAN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Tipo de Documento:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionado.idTipoDocumentacion" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idTipoDocumentacion))">
|
||||||
|
@foreach (var grupoTipologia in objetoLicitacionUrban.Enumerados.TiposDeDocumentos)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Documento:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionado.idTipoProyecto" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.idTipoProyecto))">
|
||||||
|
@foreach (var tipoProy in tipoProyectoAux)
|
||||||
|
{
|
||||||
|
<option value="@tipoProy.idtipoproyectos">@tipoProy.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Documentación Mínima:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoLicitacionUrban.TrabajoProfesional.DocumentacionMinima"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documentacion">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Documentación Opcional:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoLicitacionUrban.TrabajoProfesional.DocumentacionOpcional"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documencación" Class="colorA">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Añadida">
|
||||||
|
<div class="d-flex justify-content-center checkTabla">
|
||||||
|
<CheckboxInput Class="align-content-center checkGordo" Value=@context.Checkeada TValue="double" ValueExpression="() => context.Checkeada" ValueChanged="(value) => opcionalCambiado(value,context)"></CheckboxInput>
|
||||||
|
</div>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<label class="tituloLbl">Datos Necesarios:</label>
|
||||||
|
<Grid TItem="URBAN.DocumentacionURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoLicitacionUrban.TrabajoProfesional.DatosNecesarios"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción" PropertyName="Documencación" Class="colorA">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.DocumentacionURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Valor">
|
||||||
|
@if (context.esCheckbox)
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-center checkTabla">
|
||||||
|
<CheckboxInput Class="align-content-center checkGordo" Value=@context.Checkeada TValue="double" ValueExpression="() => context.Checkeada" ValueChanged="(value) => DatoNecesarioCheckeado(value,context)"></CheckboxInput>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex">
|
||||||
|
<InputNumber Min="0" class="inputForm inputTabla tdAlineadoDerecha pe-0 me-1" Value=@context.ValorNecesario TValue="double" ValueExpression="() => context.ValorNecesario" ValueChanged="(value) => DatoNecesarioCambiado(value,context)"></InputNumber>
|
||||||
|
@* <NumberInput TValue="double" Min="0" @onchange="cambiarNumero" @bind-Value="context.ValorNecesario" class="inputForm"></NumberInput> *@
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<CascadingValue Value="this" IsFixed="false">
|
||||||
|
@* <InstrumentosLicitacionesUrban objetoLicitacionUrban="objetoLicitacionUrban"></InstrumentosLicitacionesUrban> *@
|
||||||
|
<InstrumentosLicitacionesUrban @ref="componenteInstrumentos" objetoLicitacionUrban="objetoLicitacionUrban" />
|
||||||
|
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.LicitacionesURBAN objetoLicitacionUrban { get; set; } = new LicitacionesURBAN();
|
||||||
|
private List<tipoproyectosURBAN> tipoProyectoAux = new List<tipoproyectosURBAN>();
|
||||||
|
|
||||||
|
private InstrumentosLicitacionesUrban componenteInstrumentos;
|
||||||
|
|
||||||
|
private URBANTrabajoProfesional itemSeleccionado = new URBANTrabajoProfesional();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private string tituloInfo = "";
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.LicitacionesURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (objetoLicitacionUrban.TrabajoProfesional.idTipoDocumentacion != 0)
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoProyecto = objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto;
|
||||||
|
itemSeleccionado.idTipoDocumentacion = objetoLicitacionUrban.TrabajoProfesional.idTipoDocumentacion;
|
||||||
|
cambiarSelectDocumentos();
|
||||||
|
|
||||||
|
cambiarListasDocumentacion();
|
||||||
|
itemSeleccionado.idInstrumento = objetoLicitacionUrban.TrabajoProfesional.idInstrumento;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void cambiarNumero()
|
||||||
|
{
|
||||||
|
componenteInstrumentos?.Recargar();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
private async void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionado.idTipoDocumentacion):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionado.idTipoDocumentacion = int.Parse(value);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoDocumentacion = itemSeleccionado.idTipoDocumentacion;
|
||||||
|
cambiarSelectDocumentos();
|
||||||
|
calcularHoraTrabajo();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoDocumentacion = 0;
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoDocumentacion = itemSeleccionado.idTipoDocumentacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionado.idTipoProyecto):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionado.idTipoProyecto = int.Parse(value);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
cambiarListasDocumentacion();
|
||||||
|
calcularHoraTrabajo();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionado.idTipoProyecto = 0;
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void calcularHoraTrabajo()
|
||||||
|
{
|
||||||
|
foreach (var datos in objetoLicitacionUrban.TrabajoProfesional.DatosNecesarios.ToList())
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.ActualizarDatoNecesario(datos);
|
||||||
|
}
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cambiarSelectDocumentos()
|
||||||
|
{
|
||||||
|
tipoProyectoAux = objetoLicitacionUrban.Enumerados.ProyectosPorTipo(itemSeleccionado.idTipoDocumentacion);
|
||||||
|
|
||||||
|
if (itemSeleccionado.idTipoProyecto == 0)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto = tipoProyectoAux.First().idtipoproyectos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tipoProyectoAux.Any(x => x.idtipoproyectos == itemSeleccionado.idTipoProyecto))
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto = itemSeleccionado.idTipoProyecto;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto = tipoProyectoAux.First().idtipoproyectos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cambiarListasDocumentacion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task cambiarListasDocumentacion()
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.DocumentacionMinima = objetoLicitacionUrban.DocumentacionMinima(objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.DocumentacionOpcional = objetoLicitacionUrban.DocumentacionOpcional(objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.DatosNecesarios = objetoLicitacionUrban.DatosNecesarios(objetoLicitacionUrban.TrabajoProfesional.idTipoProyecto);
|
||||||
|
objetoLicitacionUrban.ObtenerHoraTipoDocumento();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void opcionalCambiado(bool e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
objeto.Checkeada = e;
|
||||||
|
objetoLicitacionUrban.ActualizarDocumentacionOpcional(objeto);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void DatoNecesarioCheckeado(bool e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
objeto.Checkeada = e;
|
||||||
|
objetoLicitacionUrban.ActualizarDatoNecesario(objeto);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
private async void DatoNecesarioCambiado(double e, URBAN.DocumentacionURBAN objeto)
|
||||||
|
{
|
||||||
|
objeto.ValorNecesario = (double)e;
|
||||||
|
objetoLicitacionUrban.ActualizarDatoNecesario(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
_Parent.RefreshState();
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.Json
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3" style="padding-bottom:6px;">
|
||||||
|
<div><b>Fases</b></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 35px;">
|
||||||
|
<Grid TItem="URBAN.FasesURBAN"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFases"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="URBAN.FasesURBAN" HeaderTextAlignment="Alignment.Center" HeaderText="Fases" PropertyName="Denominacion" Class="colorA">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="URBAN.FasesURBAN" HeaderText="">
|
||||||
|
<div class="d-flex">
|
||||||
|
<InputNumber Min="0" class="inputForm inputTabla tdAlineadoDerecha pe-0 me-1" Value=@context.Porcentaje TValue="double" ValueExpression="() => context.Porcentaje" ValueChanged="(value) => porcentajeCambiado(value,context)"></InputNumber> %
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => restablecerValores())" class="btnBlue d-flex align-items-center"> <i class="fas fa-undo pe-1"></i> Restablecer </button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
@if (totalPorcentaje != 100)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Trabajo en misión parcial: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Total: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.LicitacionesURBAN _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.LicitacionesURBAN objetoLicitacionUrban { get; set; } = new bdHerramientaCACOA.LicitacionesURBAN();
|
||||||
|
|
||||||
|
private double totalPorcentaje = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public List<URBAN.FasesURBAN> listadoFases { get; set; } = new List<URBAN.FasesURBAN>();
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
listadoFases = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.ToList();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.FasesTrabajo> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void porcentajeCambiado(double e, URBAN.FasesURBAN objeto)
|
||||||
|
{
|
||||||
|
|
||||||
|
double porcentajeTotal = calcularPorcentaje(e, objeto);
|
||||||
|
|
||||||
|
if (porcentajeTotal <= 100)
|
||||||
|
{
|
||||||
|
objeto.Porcentaje = (double)e;
|
||||||
|
objetoLicitacionUrban.ActualizarFase(objeto);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
objeto.Porcentaje = 0;
|
||||||
|
objetoLicitacionUrban.ActualizarFase(objeto);
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"La suma de los porcentajes no puede ser mayor de 100.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
totalPorcentaje = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calcularPorcentaje(double e, URBAN.FasesURBAN objeto)
|
||||||
|
{
|
||||||
|
double porcentajeTotal = 0;
|
||||||
|
objeto.Porcentaje = e;
|
||||||
|
|
||||||
|
int indice = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional
|
||||||
|
.FindIndex(x => x.idFase == objeto.idFase);
|
||||||
|
|
||||||
|
if (indice >= 0)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional[indice] = objeto;
|
||||||
|
}
|
||||||
|
|
||||||
|
porcentajeTotal = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
return porcentajeTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void restablecerValores()
|
||||||
|
{
|
||||||
|
var lista = JsonSerializer.Deserialize<List<URBAN.FasesURBAN>>(JsonSerializer.Serialize(objetoLicitacionUrban.Enumerados.FasesTrabajo));
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional = lista;
|
||||||
|
|
||||||
|
listadoFases = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.ToList();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoLicitacionUrban.TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
|
||||||
|
objetoLicitacionUrban.CalcularHorasTrabajoProfesional();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.Json
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.CASA
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<div style="height:100%">
|
||||||
|
<div>
|
||||||
|
<div class="mt-3 mb-3"><b>Innovacion de los instrumentos</b></div>
|
||||||
|
<p class="col-6">
|
||||||
|
@* @if (!nuevaRedaccion)
|
||||||
|
{ *@
|
||||||
|
<InputNumber TValue="double" Value="@objetoLicitacionUrban.TrabajoProfesional.valorInstrumentos"
|
||||||
|
ValueExpression="() => objetoLicitacionUrban.TrabajoProfesional.valorInstrumentos"
|
||||||
|
ValueChanged="(value) => ValorModificado(value)"
|
||||||
|
step="any"
|
||||||
|
class="inputForm text-end" /> <span>%</span>
|
||||||
|
@* }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<label>100 %</label>
|
||||||
|
} *@
|
||||||
|
|
||||||
|
</p>
|
||||||
|
@foreach (var enu in listadoInstrumentos)
|
||||||
|
{
|
||||||
|
<div class="form-check" style="gap:10px;">
|
||||||
|
<input name="instrumentos" checked="@enu.Seleccionado" type="radio" id="@enu.idEnumeracion" class="form-check-input" value="@enu.ValorNumerico1" @onchange="() => Seleccionar(enu)">
|
||||||
|
|
||||||
|
<label class="form-check-label" for="@enu.idEnumeracion">@enu.Descripcion</label>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table class="tablaAlter mt-4" style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter" style="width:50%;">Horas Trabajo Profesional </td>
|
||||||
|
<td class="tdAlineadoDerecha">@objetoLicitacionUrban.TrabajoProfesional.horasTrabProfesional.MilesYDecimales() h</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.LicitacionUrban.DocumentosLicitacion _Parent { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.LicitacionesURBAN objetoLicitacionUrban { get; set; } = new bdHerramientaCACOA.LicitacionesURBAN();
|
||||||
|
|
||||||
|
private bool nuevaRedaccion = false;
|
||||||
|
private enumeracionesCASA itemSeleccinado;
|
||||||
|
|
||||||
|
public List<CASA.enumeracionesCASA> listadoInstrumentos { get; set; } = new List<CASA.enumeracionesCASA>();
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
|
||||||
|
public void Recargar()
|
||||||
|
{
|
||||||
|
// Vuelve a cargar los instrumentos y selecciona el actual
|
||||||
|
listadoInstrumentos = objetoLicitacionUrban.Enumerados.ListaInstrumentos.ToList();
|
||||||
|
var seleccionado = listadoInstrumentos.FirstOrDefault(x => x.idEnumeracion == objetoLicitacionUrban.TrabajoProfesional.idInstrumento);
|
||||||
|
Seleccionar(seleccionado ?? listadoInstrumentos.First());
|
||||||
|
objetoLicitacionUrban.CalcularHorasTrabajoProfesional();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
listadoInstrumentos = objetoLicitacionUrban.Enumerados.ListaInstrumentos.ToList();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
Seleccionar(listadoInstrumentos.First());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Seleccionar(listadoInstrumentos.First(x => x.Seleccionado == true));
|
||||||
|
}
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ValorModificado(double valor)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.valorInstrumentos = Convert.ToDouble(valor);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idInstrumento = itemSeleccinado.idEnumeracion;
|
||||||
|
itemSeleccinado.ValorNumerico1 = Convert.ToDouble(valor);
|
||||||
|
|
||||||
|
objetoLicitacionUrban.CalcularHorasTrabajoProfesional();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Seleccionar(enumeracionesCASA item)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (item.Codigo.Contains("NUEVARED"))
|
||||||
|
{
|
||||||
|
nuevaRedaccion = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevaRedaccion = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemSeleccinado = item;
|
||||||
|
itemSeleccinado.Seleccionado = true;
|
||||||
|
|
||||||
|
foreach (var intru in listadoInstrumentos.Where(x=>x.idEnumeracion != item.idEnumeracion))
|
||||||
|
{
|
||||||
|
intru.Seleccionado = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.valorInstrumentos = Convert.ToDouble(item.ValorNumerico1);
|
||||||
|
objetoLicitacionUrban.TrabajoProfesional.idInstrumento = item.idEnumeracion;
|
||||||
|
objetoLicitacionUrban.CalcularHorasTrabajoProfesional();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,410 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using System.Text.Json
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Globalization
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using static bdHerramientaCACOA.CASA
|
||||||
|
|
||||||
|
<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="tiposForm">
|
||||||
|
<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="50" @bind-Value="itemSeleccionado.Descripcion" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionado.Descripcion))" class="inputForm"></InputText>
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionado.Descripcion))</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Nº Trabajadores:</label>
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
<InputNumber TValue="int" @bind-Value="itemSeleccionadoTemporal.Cantidad"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.Cantidad))"
|
||||||
|
class="inputForm text-end" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.Cantidad))</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Grupo Trabajador:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idConvenioColectivo" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idConvenioColectivo))">
|
||||||
|
@foreach (var grupoTipologia in objetoLicitacionUrban.Enumerados.ListaGrupoTrabajadores)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idConvenioColectivo))</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 style="position:relative;margin-bottom: 45px;">
|
||||||
|
<div class="d-flex justify-content-between mt-3" style="padding-bottom:6px;">
|
||||||
|
<div><b>Solvencia técnica</b></div>
|
||||||
|
</div>
|
||||||
|
<Grid TItem="LicitacionesURBAN.SolvenciaTecnica"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listaSolvenciaTecnica"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="LicitacionesURBAN.SolvenciaTecnica" Class="columna40Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Trabajadores" PropertyName="Documentacion">
|
||||||
|
@context.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="LicitacionesURBAN.SolvenciaTecnica" Class="text-end columna10Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Nº Trabajadores" PropertyName="Documentacion">
|
||||||
|
@context.Cantidad
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="LicitacionesURBAN.SolvenciaTecnica" Class="columna40Ancho" HeaderTextAlignment="Alignment.Center" HeaderText="Categoría Profesional" PropertyName="Documentacion">
|
||||||
|
@context.TipoConvenio
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="LicitacionesURBAN.SolvenciaTecnica" Class="botonesTabla columna10Ancho" 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>
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new LicitacionesURBAN.SolvenciaTecnica(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir Trabajadores</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total trabajadores:
|
||||||
|
<span> @objetoLicitacionUrban.ListaSolvenciaTecnica.Sum(x => x.Cantidad)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
@* <table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorA fw-bold">Equipo de trabajo mínimo</th>
|
||||||
|
<th class="colorA fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro w4"><p>Titulado grado superior</p> </td>
|
||||||
|
<td class="text-end align-content-center">
|
||||||
|
<div>
|
||||||
|
<InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda" Value="@objetoLicitacionUrban.minimoGradoSuperior" ValueExpression="() => objetoLicitacionUrban.minimoGradoSuperior" ValueChanged="(value) => MinimoSupCambiado(value)"></InputNumber>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro w4"><p>Titulado grado medio</p> </td>
|
||||||
|
<td class="text-end align-content-center">
|
||||||
|
<div>
|
||||||
|
<InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda" Value="@objetoLicitacionUrban.minimoGradoMedio" ValueExpression="() => objetoLicitacionUrban.minimoGradoMedio" ValueChanged="(value) => MinimoMedCambiado(value)"></InputNumber>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table> *@
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public HerramientaCASA.Components.Pages.LicitacionesURBAN _Parent { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bdHerramientaCACOA.LicitacionesURBAN objetoLicitacionUrban { get; set; } = new bdHerramientaCACOA.LicitacionesURBAN();
|
||||||
|
|
||||||
|
private bool nuevaRedaccion = false;
|
||||||
|
|
||||||
|
public List<CASA.enumeracionesCASA> listadoInstrumentos { get; set; } = new List<CASA.enumeracionesCASA>();
|
||||||
|
|
||||||
|
private LicitacionesURBAN.SolvenciaTecnica itemSeleccionado = new LicitacionesURBAN.SolvenciaTecnica();
|
||||||
|
private LicitacionesURBAN.SolvenciaTecnica itemSeleccionadoTemporal { get; set; } = new LicitacionesURBAN.SolvenciaTecnica();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private EditContext editContext;
|
||||||
|
|
||||||
|
private bool nuevoElemento;
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
List<LicitacionesURBAN.SolvenciaTecnica> listaSolvenciaTecnica;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
|
||||||
|
listaSolvenciaTecnica = objetoLicitacionUrban.ListaSolvenciaTecnica.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(LicitacionesURBAN.SolvenciaTecnica objeto, bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
nuevoElemento = true;
|
||||||
|
itemSeleccionadoTemporal = new LicitacionesURBAN.SolvenciaTecnica();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nuevoElemento = false;
|
||||||
|
itemSeleccionadoTemporal = new LicitacionesURBAN.SolvenciaTecnica()
|
||||||
|
{
|
||||||
|
idConvenioColectivo = objeto.idConvenioColectivo,
|
||||||
|
Cantidad = objeto.Cantidad,
|
||||||
|
Descripcion = objeto.Descripcion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar Trabajo";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Añadir Trabajo";
|
||||||
|
}
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.Descripcion }, nameof(itemSeleccionadoTemporal.Descripcion));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.Cantidad }, nameof(itemSeleccionadoTemporal.Cantidad));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idConvenioColectivo }, nameof(itemSeleccionadoTemporal.idConvenioColectivo));
|
||||||
|
}
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
GestionarDatos(accion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Warning,
|
||||||
|
Message = $"Debe rellenar los campos obligatorios.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Error al guardar.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
rellenarItem();
|
||||||
|
objetoLicitacionUrban.ActualizarSolvenciaTecnica(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
rellenarItem();
|
||||||
|
objetoLicitacionUrban.InsertarSolvenciaTecnica(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoLicitacionUrban.EliminarSolvenciaTecnica(itemSeleccionado);
|
||||||
|
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listaSolvenciaTecnica = objetoLicitacionUrban.ListaSolvenciaTecnica.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
private void MostrarErrores()
|
||||||
|
{
|
||||||
|
// messageStore?.Clear();
|
||||||
|
// foreach (var field in new[] { nameof(itemSeleccionadoTemporal.Coste), nameof(itemSeleccionadoTemporal.idTrabajo) })
|
||||||
|
// {
|
||||||
|
// ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.OtrosTrabajos).GetProperty(field)?.GetValue(itemSeleccionadoTemporal) }, field);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionadoTemporal.Descripcion):
|
||||||
|
itemSeleccionadoTemporal.Descripcion = value;
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.Cantidad):
|
||||||
|
if (value == "")
|
||||||
|
{
|
||||||
|
value = "0";
|
||||||
|
}
|
||||||
|
string parseado = value;//.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.Cantidad = int.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
break;
|
||||||
|
case nameof(itemSeleccionadoTemporal.idConvenioColectivo):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idConvenioColectivo = int.Parse(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idConvenioColectivo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.Descripcion) && itemSeleccionadoTemporal.Descripcion == "")
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Rellene este campo");
|
||||||
|
}
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.Cantidad) && itemSeleccionadoTemporal.Cantidad <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "El Nº Trabajadores debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idConvenioColectivo) && itemSeleccionadoTemporal.idConvenioColectivo == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione uno.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(LicitacionesURBAN.SolvenciaTecnica objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.idConvenioColectivo = itemSeleccionadoTemporal.idConvenioColectivo;
|
||||||
|
itemSeleccionado.Cantidad = itemSeleccionadoTemporal.Cantidad;
|
||||||
|
itemSeleccionado.Descripcion = itemSeleccionadoTemporal.Descripcion;
|
||||||
|
itemSeleccionado.TipoConvenio = objetoLicitacionUrban.Enumerados.ListaGrupoTrabajadores.First(x => x.idEnumeracion == itemSeleccionado.idConvenioColectivo).ValorAlfabetico1;
|
||||||
|
|
||||||
|
}
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
private async Task MinimoSupCambiado(int valor)
|
||||||
|
{
|
||||||
|
if (valor < 1)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.minimoGradoSuperior = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.minimoGradoSuperior = valor;
|
||||||
|
}
|
||||||
|
await _Parent.CalcularTabla(objetoLicitacionUrban.idProvincia);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task MinimoMedCambiado(int valor)
|
||||||
|
{
|
||||||
|
|
||||||
|
objetoLicitacionUrban.minimoGradoMedio = valor;
|
||||||
|
await _Parent.CalcularTabla(objetoLicitacionUrban.idProvincia);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
377
HerramientaCASA/Components/Pages/Licitaciones.razor
Normal file
377
HerramientaCASA/Components/Pages/Licitaciones.razor
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
@using HerramientaCASA.Components.Pages.Comun
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using HerramientaCASA.Components.Pages.LicitacionesGrids
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@page "/LicitacionCASA"
|
||||||
|
@page "/LicitacionCASA/{idSimulador}"
|
||||||
|
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<p class="TituloVentana">
|
||||||
|
@TextoSuperior
|
||||||
|
</p>
|
||||||
|
@if (!actualizado)
|
||||||
|
{
|
||||||
|
<div class="UpdateCacoa d-flex">
|
||||||
|
<span>Esta simulación utiliza valores desactualizados. ¿Quiere Realizar una copia actualizada?</span>
|
||||||
|
<button @onclick="@(() => clonarLicitacion())" class="btnBlue ms-auto">Actualizar</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Modal @ref="popupGuardar" title="@TituloBoton" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
|
||||||
|
@if (TituloBoton == "Guardar")
|
||||||
|
{
|
||||||
|
<p>Se va a <b>guardar</b> esta <b>nueva simulación</b> podrá acceder a ella para consultarla y editarla desde el apartado <b>Mis Simulaciones</b> </p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Se van a <b>sobrescribir</b> los datos de la <b>simulación actual</b> con los cambios realizados, <b>esta opción no puede deshacerse.</b><br /><br /> ¿Desea continuar? </p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGuardar">Cerrar</Button>
|
||||||
|
<Button @onclick="@(() => guardarLicitacion())" Color="ButtonColor.Primary">@TituloBoton</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
<div class="container-fluid pt-3">
|
||||||
|
|
||||||
|
<div class="d-flex" style="width:100%">
|
||||||
|
<button @onclick="@(() => abrirPopupGuardar())" class="btnBlue d-flex align-items-center"> <i class="fas fa-save pe-1"></i>@TituloBoton</button>
|
||||||
|
<b class="Fuente2 ps-2 pe-2 nomSim">Nombre de la simulación: </b>
|
||||||
|
<InputText @bind-Value="objetoLicitaciones.Descripcion" class="form-control inputForm formatoMoneda inputTabla " style="text-align:left;font-weight:bold;"></InputText>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mt-3 mb-2">
|
||||||
|
<div><b>Convenio Colectivo:</b></div>
|
||||||
|
<InputSelect @bind-Value="@objetoLicitaciones.idProvincia" 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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mt-3 mb-5">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<TrabajoProfLicitacionesGrid objetoLicitaciones="objetoLicitaciones"></TrabajoProfLicitacionesGrid>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-3" >
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<FasesTrabajoLicitaciones objetoLicitaciones="objetoLicitaciones"></FasesTrabajoLicitaciones>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-5">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<CostesProLicitaciones objetoLicitaciones="objetoLicitaciones"></CostesProLicitaciones>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<OtrosTrabajos objetoLicitaciones="objetoLicitaciones"></OtrosTrabajos>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
<div style="margin-top:32px">
|
||||||
|
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0" style="width: 100%;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
PRECIO LICITACIÓN / CONCURSO: <span>@objetoLicitaciones.PrecioDelEncargo.MilesYDecimales() € </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@* <div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<table class="tablaAlter mt-3 mb-3">
|
||||||
|
<tr>
|
||||||
|
<td class="tdAlter">PRECIO LICITACIÓN / CONCURSO: </td>
|
||||||
|
<td class="tdAlineadoDerecha"> @objetoLicitaciones.PrecioDelEncargo.MilesYDecimales() €</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div> *@
|
||||||
|
<div class="pt-5" style="margin-top:2000px;">
|
||||||
|
<p><b>Datos configuración para revisión de datos</b></p>
|
||||||
|
<b>superficie</b> @objetoLicitaciones.superficie;<br />
|
||||||
|
<b>Coef sup total</b> @objetoLicitaciones.coefSupTotal; (sin redondeo:@objetoLicitaciones.coefsinredondeo)<br />
|
||||||
|
<b>coef tip </b> @objetoLicitaciones.coefTipoTotal;<br />
|
||||||
|
@* <b>coef tip total</b> @objetoLicitaciones.totalCoefiTipologia;<br /> *@
|
||||||
|
@* <b>int total</b> @objetoLicitaciones.totalCoefIntervencion;<br /> *@
|
||||||
|
<b>coef int total</b> @objetoLicitaciones.coefIntervencionTotal;<br />
|
||||||
|
<b>fases encargadas</b> @objetoLicitaciones.fasesEncargadas;<br />
|
||||||
|
<b style="color:orange">horas prod</b> @objetoLicitaciones.horasProduccion;<br />
|
||||||
|
@* <b>horas porcentaje</b> @objetoLicitaciones.horasPorcentaje;<br /> *@
|
||||||
|
<b>horas docu</b> @objetoLicitaciones.horasDocumentacion;<br />
|
||||||
|
<b>plazo medio</b> @objetoLicitaciones.plazoMedio;<br />
|
||||||
|
<b>coef plazos</b> @objetoLicitaciones.coefPlazos;<br />
|
||||||
|
<b style="color:darkred" >horas anuales minimas</b> @objetoLicitaciones.horasAnualesMinimas;<br />
|
||||||
|
<b>CD</b> @objetoLicitaciones.CD;<br />
|
||||||
|
<b>CI</b> @objetoLicitaciones.CI;<br />
|
||||||
|
<b>CosteCDCI</b> @objetoLicitaciones.CosteCDCI;<br />
|
||||||
|
<b>tasa costes var</b> @objetoLicitaciones.tasaCostesVariables;<br />
|
||||||
|
<b>coste hora prod</b> @objetoLicitaciones.costeHoraProduccion;
|
||||||
|
</div>
|
||||||
|
<div class="pt-5">
|
||||||
|
<b>Tabla CD+CI para visualizacion de datos, se quitara cuando se vea que los calculos son correctos</b><br />
|
||||||
|
<b>IPC Coste Indirecto:</b>@objetoLicitaciones.Variables.IPCCosteIndirecto;<br />
|
||||||
|
<Grid TItem="CosteDirectoIndirecto"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoLicitaciones.Enumerados.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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
public bool actualizado = true;
|
||||||
|
|
||||||
|
public string TextoSuperior = "Nueva Licitación de Edificación";
|
||||||
|
public string TituloBoton = "Guardar";
|
||||||
|
private Modal popupGuardar = default!;
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
private string nombreOriginal = "";
|
||||||
|
|
||||||
|
private bdHerramientaCACOA.LICITACIONES objetoLicitaciones;
|
||||||
|
|
||||||
|
private int idUser = 0;
|
||||||
|
|
||||||
|
public Licitaciones()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objetoLicitaciones = new bdHerramientaCACOA.LICITACIONES();
|
||||||
|
objetoLicitaciones.Inicializar(bd);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
var a = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var fechaActVar = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD").Fecha1;
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
simulaciones simu = bd.simulaciones.Where(x => x.idSimulacion == int.Parse(idDesencriptado)).First();
|
||||||
|
int idFicheroJSON = simu.idFicheroJSON;
|
||||||
|
idSimulador = idDesencriptado;
|
||||||
|
var byteFichero = bd.ficheros.Where(x => x.idFichero == idFicheroJSON).First().Fichero;
|
||||||
|
|
||||||
|
string LicitacionesJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
objetoLicitaciones = System.Text.Json.JsonSerializer.Deserialize<LICITACIONES>(LicitacionesJson);
|
||||||
|
|
||||||
|
if ((simu.FechaModificacion != null && simu.FechaModificacion < fechaActVar) || (simu.FechaModificacion == null && simu.FechaCreacion < fechaActVar))
|
||||||
|
{
|
||||||
|
actualizado = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextoSuperior = "Modificando Licitación \"" + simu.Descripcion + "\"";
|
||||||
|
TituloBoton = "Modificar";
|
||||||
|
|
||||||
|
nombreOriginal = objetoLicitaciones.Descripcion;
|
||||||
|
|
||||||
|
}
|
||||||
|
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
idUser = obtenerID.Value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error durante la inicialización: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void guardarLicitacion()
|
||||||
|
{
|
||||||
|
|
||||||
|
// para evitar loops
|
||||||
|
var settings = new Newtonsoft.Json.JsonSerializerSettings
|
||||||
|
{
|
||||||
|
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoLicitaciones, settings);
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == HerramientaCASA.UtilidadesCASA.obtenerTipoSimulacion(HerramientaCASA.UtilidadesCASA.TiposSimulaciones.LICITACIONCASA)).idEnumeracion;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (bd.simulaciones.Any(x => x.Descripcion == objetoLicitaciones.Descripcion && x.idTipoSimulacion == idtipoSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crearLicitacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var listadoSimulacionesExistentes = bd.simulaciones.Where(x => x.Descripcion != nombreOriginal && x.idTipoSimulacion == idtipoSimulacion).ToList();
|
||||||
|
|
||||||
|
if (listadoSimulacionesExistentes.Any(x => x.Descripcion == objetoLicitaciones.Descripcion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actualizarLicitacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void crearLicitacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
int idLicitacionCreada = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.LICITACIONCASA, jsonObjeto, objetoLicitaciones.Descripcion, "licitaciones.json", idUser);
|
||||||
|
|
||||||
|
string link = "/LicitacionCASA?idSimulador=" + tsUtilidades.crypt.FEncS(idLicitacionCreada.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Licitación creada correctamente.",
|
||||||
|
});
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
private void actualizarLicitacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
UtilidadesCASA.actualziarObjeto(bd, jsonObjeto, objetoLicitaciones.Descripcion, idSimulador);
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Licitación actualizada correctamente.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarLicitacion()
|
||||||
|
{
|
||||||
|
objetoLicitaciones.Inicializar(bd);
|
||||||
|
objetoLicitaciones.CalcularHorasSuperficie();
|
||||||
|
objetoLicitaciones.CalcularCostesProduccion();
|
||||||
|
objetoLicitaciones.Descripcion = objetoLicitaciones.Descripcion + " (Act:" + DateTime.Now + ")";
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoLicitaciones);
|
||||||
|
var id = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.LICITACIONCASA, jsonObjeto, objetoLicitaciones.Descripcion, "licitaciones.json", idUser);
|
||||||
|
|
||||||
|
var link = "/LicitacionCASA?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CalcularTabla(string idProvincia)
|
||||||
|
{
|
||||||
|
|
||||||
|
objetoLicitaciones.idProvincia = idProvincia;
|
||||||
|
objetoLicitaciones.Enumerados.ListaCDCI= objetoLicitaciones.CalcularTabla(idProvincia);
|
||||||
|
objetoLicitaciones.CalcularHorasSuperficie();
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
private async Task abrirPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="mt-3">
|
||||||
|
<div style="height: 24px;">
|
||||||
|
<b>Costes Asociados a los Servicios de Arquitectura</b>
|
||||||
|
</div>
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Concepto</th>
|
||||||
|
<th class="colorB fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Plazo de presentación de la documentación:</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
@* <InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoLicitaciones.PlazoPresentacionDocumentos" ValueExpression="() => objetoLicitaciones.PlazoPresentacionDocumentos" ValueChanged="(value) => PlazoPresentacionDocumentosCambiado(value)"></InputNumber> meses *@
|
||||||
|
<InputNumber TValue="double" @bind-Value="objetoLicitaciones.PlazoPresentacionDocumentos"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => controlarMeses(e.Value?.ToString())"
|
||||||
|
class="inputForm formatoMoneda inputTabla text-end" /> meses
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Coste hora de producción</td>
|
||||||
|
<td class="text-end"><span> @objetoLicitaciones.costeHoraProduccion.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Horas Trabajo profesional</td>
|
||||||
|
<td class="text-end"><span> @objetoLicitaciones.horasProduccion.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Coste de producción del Trabajo Profesional</td>
|
||||||
|
<td class="text-end"><span> @objetoLicitaciones.CostesProduccionTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">
|
||||||
|
G.G. + B.I. <br />
|
||||||
|
<span class="fw-normal" style="font-size:10px;">(40/19 Junta Consultiva de Contratación Pública del Estado)</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end" style="align-content:center;">
|
||||||
|
<div class="d-flex" style="justify-content: end; gap:3px;">
|
||||||
|
@objetoLicitaciones.Beneficio %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">COSTE DEL TRABAJO PROFESIONAL</td>
|
||||||
|
<td class="text-end"><span> @objetoLicitaciones.PrecioTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
COSTES DE PRODUCCIÓN DEL TRABAJO PROFESIONAL: <span>@objetoLicitaciones.PrecioTrabProf.MilesYDecimales() €</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES();
|
||||||
|
|
||||||
|
List<CASA.OtrosTrabajos> listOtrosTrabajos = new List<CASA.OtrosTrabajos>();
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public Licitaciones _Parent { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
listOtrosTrabajos = objetoLicitaciones.OtrosTrabajos.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void PlazoPresentacionDocumentosCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.PlazoPresentacionDocumentos = e;
|
||||||
|
objetoLicitaciones.CalcularHorasSuperficie();
|
||||||
|
objetoLicitaciones.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlarMeses(string meses)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (double.TryParse(meses, out var valor))
|
||||||
|
{
|
||||||
|
string parseado = meses.ToString().Replace(",", ".");
|
||||||
|
objetoLicitaciones.PlazoPresentacionDocumentos = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlazoPresentacionDocumentosCambiado(objetoLicitaciones.PlazoPresentacionDocumentos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
@using BlazorBootstrap
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Fases</b></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div style="position:relative;margin-bottom: 19px;">
|
||||||
|
<Grid TItem="CASA.FasesTrabajo"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoFases"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="CASA.FasesTrabajo" HeaderTextAlignment="Alignment.Center" HeaderText="Fases" PropertyName="Denominacion" Class="colorFilasIntro">
|
||||||
|
@context.Denominacion
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CASA.FasesTrabajo" Class="justify-content-end" HeaderText="">
|
||||||
|
<div class="d-flex align-items-center justify-content-end gap-2">
|
||||||
|
<span class="align-middle">@context.Porcentaje.ToString() %</span>
|
||||||
|
<input type="checkbox"
|
||||||
|
class="form-check-input"
|
||||||
|
checked="@context.Seleccionado"
|
||||||
|
@onchange="(e) => PorcentajeCambiado(((ChangeEventArgs)e).Value is bool b && b, context)" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
@* <p><b class="Fuente2">TOTAL:</b> @totalPorcentaje %</p> *@
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-18px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
@* <div class="mt-1">
|
||||||
|
<button @onclick="@(() => restablecerValores())" class="btnBlue d-flex align-items-center"> <i class="fas fa-undo pe-1"></i> Restablecer valores</button>
|
||||||
|
</div> *@
|
||||||
|
<div style="align-self: center;">
|
||||||
|
@if (totalPorcentaje != 100)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Trabajo en misión parcial: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
Total: <span> @totalPorcentaje %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public Licitaciones _Parent { get; set; }
|
||||||
|
|
||||||
|
private double totalPorcentaje = 0;
|
||||||
|
private bool isChecked;
|
||||||
|
[Parameter]
|
||||||
|
public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES();
|
||||||
|
|
||||||
|
public List<CASA.FasesTrabajo> listadoFases { get; set; } = new List<CASA.FasesTrabajo>();
|
||||||
|
public List<CASA.FasesTrabajo> listadoFasesAux { get; set; } = new List<CASA.FasesTrabajo>();
|
||||||
|
|
||||||
|
|
||||||
|
private string tituloPopup = "";
|
||||||
|
private Modal popupGestionDatos = default!;
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
|
||||||
|
private CASA.FasesTrabajo itemSeleccionado = new CASA.FasesTrabajo();
|
||||||
|
|
||||||
|
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
listadoFases = objetoLicitaciones.FasesTrabajo.ToList();
|
||||||
|
|
||||||
|
foreach (var fase in listadoFases)
|
||||||
|
{
|
||||||
|
listadoFasesAux.Add(new CASA.FasesTrabajo
|
||||||
|
{
|
||||||
|
Codigo = fase.Codigo,
|
||||||
|
Denominacion = fase.Denominacion,
|
||||||
|
idFase = fase.idFase,
|
||||||
|
Porcentaje = fase.Porcentaje
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
totalPorcentaje = listadoFases
|
||||||
|
.Where(f => f.Seleccionado)
|
||||||
|
.Sum(f => f.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.FasesTrabajo> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PorcentajeCambiado(bool value, CASA.FasesTrabajo item)
|
||||||
|
{
|
||||||
|
item.Seleccionado = value;
|
||||||
|
RecalcularTotal(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
private async void RecalcularTotal(CASA.FasesTrabajo item)
|
||||||
|
{
|
||||||
|
totalPorcentaje = listadoFases
|
||||||
|
.Where(f => f.Seleccionado)
|
||||||
|
.Sum(f => f.Porcentaje);
|
||||||
|
|
||||||
|
if (totalPorcentaje <= 100)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.ActualizarFase(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Porcentaje = 0;
|
||||||
|
objetoLicitaciones.ActualizarFase(item);
|
||||||
|
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"La suma de los porcentajes no puede ser mayor de 100.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
|
||||||
|
totalPorcentaje = listadoFases
|
||||||
|
.Where(f => f.Seleccionado)
|
||||||
|
.Sum(f => f.Porcentaje);
|
||||||
|
}
|
||||||
|
|
||||||
|
// private async void porcentajeCambiado(double e, CASA.FasesTrabajo objeto)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// double porcentajeTotal = calcularPorcentaje(e, objeto);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// totalPorcentaje = objetoLicitaciones.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private double calcularPorcentaje(double e, CASA.FasesTrabajo objeto)
|
||||||
|
// {
|
||||||
|
// double porcentajeTotal = 0;
|
||||||
|
// objeto.Porcentaje = e;
|
||||||
|
|
||||||
|
// int indice = objetoLicitaciones.FasesTrabajo.ToList().IndexOf(objeto);
|
||||||
|
// objetoLicitaciones.FasesTrabajo[indice] = objeto;
|
||||||
|
|
||||||
|
// porcentajeTotal = objetoLicitaciones.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
// return porcentajeTotal;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
private async void restablecerValores()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < listadoFasesAux.Count; i++)
|
||||||
|
{
|
||||||
|
objetoLicitaciones.FasesTrabajo[i].Porcentaje = listadoFasesAux[i].Porcentaje;
|
||||||
|
}
|
||||||
|
|
||||||
|
objetoLicitaciones.CalcularHorasSuperficie();
|
||||||
|
|
||||||
|
//Comprobar si esta va aqui, porque sino no modifca el precio licitación/concurso
|
||||||
|
objetoLicitaciones.CalcularCostesProduccion();
|
||||||
|
|
||||||
|
totalPorcentaje = objetoLicitaciones.FasesTrabajo.Sum(x => x.Porcentaje);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using System.Globalization
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
|
||||||
|
<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="tiposForm">
|
||||||
|
<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">Superficie:</label>
|
||||||
|
<InputNumber TValue="double" @bind-Value="itemSeleccionadoTemporal.superficie"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.superficie))"
|
||||||
|
class="inputForm" />
|
||||||
|
</div>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.superficie))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Uso:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idGrupoTipologia" class="inputForm" @oninput="e => ValidarYActualizar(e, nameof(itemSeleccionadoTemporal.idGrupoTipologia))">
|
||||||
|
@foreach (var grupoTipologia in objetoLicitaciones.Enumerados.GruposTipologias)
|
||||||
|
{
|
||||||
|
<option value="@grupoTipologia.idEnumeracion">@grupoTipologia.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
<div class="validation-message">@GetExternalValidationMessage(nameof(itemSeleccionadoTemporal.idGrupoTipologia))</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt-2">
|
||||||
|
<label class="tituloLbl">Tipología:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idTipologia" class="inputForm">
|
||||||
|
@foreach (var tipologia in tipologiasAux)
|
||||||
|
{
|
||||||
|
<option value="@tipologia.idTipologia">@tipologia.Descripcion</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 formatoCampos pt2">
|
||||||
|
<label class="tituloLbl">Intervención:</label>
|
||||||
|
<InputSelect @bind-Value="@itemSeleccionadoTemporal.idTipoIntervencion" class="inputForm">
|
||||||
|
@foreach (var intervencion in intervencionesAux)
|
||||||
|
{
|
||||||
|
<option value="@intervencion.idEnumeracion">@intervencion.ValorAlfabetico1</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</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="d-flex justify-content-between mt-3">
|
||||||
|
<div><b>Usos/Tipología</b></div>
|
||||||
|
@* <button @onclick="@(() => abrirPopupGestionDatos(new CASA.UsosTipologia(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nuevo Uso</button> *@
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="position:relative;margin-bottom: 15px;">
|
||||||
|
|
||||||
|
<Grid TItem="CASA.UsosTipologia"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="UsosTipologias"
|
||||||
|
AllowFiltering="false"
|
||||||
|
AllowRowClick="true"
|
||||||
|
OnRowClick="OnRowClick"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
Height="100"
|
||||||
|
Style="table-layout:fixed !important"
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Class="columna20Ancho text-end" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Superficie">
|
||||||
|
<span>
|
||||||
|
@context.superficie.MilesYDecimales()
|
||||||
|
</span>
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn Class="columna20Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Uso">
|
||||||
|
@objetoLicitaciones.Enumerados.GruposTipologias?.FirstOrDefault(x => x.idEnumeracion == context.idGrupoTipologia)?.ValorAlfabetico1
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="CASA.UsosTipologia" HeaderTextAlignment="Alignment.Center" HeaderText="Tipología">
|
||||||
|
@objetoLicitaciones.Enumerados.Tipologias?.FirstOrDefault(x => x.idTipologia == context.idTipologia)?.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn Class="columna20Ancho" HeaderTextAlignment="Alignment.Center" TItem="CASA.UsosTipologia" HeaderText="Intervención">
|
||||||
|
@objetoLicitaciones.Enumerados.Intervenciones?.FirstOrDefault(x => x.idEnumeracion == context.idTipoIntervencion)?.ValorAlfabetico1
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="CASA.UsosTipologia" 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>
|
||||||
|
|
||||||
|
<table class="table tablaCACOA mb-0" style="position:absolute;bottom:-33px;">
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold colorC">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div class="mt-1">
|
||||||
|
<button @onclick="@(() => abrirPopupGestionDatos(new CASA.UsosTipologia(),true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Añadir nuevo Uso</button>
|
||||||
|
</div>
|
||||||
|
<div style="align-self: center;">
|
||||||
|
Total superficie: <span>
|
||||||
|
@UsosTipologias.Sum(x => x.superficie).MilesYDecimales()
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public Licitaciones _Parent { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES();
|
||||||
|
|
||||||
|
public List<CASA.UsosTipologia> UsosTipologias { get; set; } = new List<CASA.UsosTipologia>();
|
||||||
|
private List<CASA.tipologiasCASA> tipologiasAux = new List<CASA.tipologiasCASA>();
|
||||||
|
private List<CASA.enumeracionesCASA> intervencionesAux = new List<CASA.enumeracionesCASA>();
|
||||||
|
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CASA.UsosTipologia itemSeleccionado { get; set; } = new CASA.UsosTipologia();
|
||||||
|
|
||||||
|
private CASA.UsosTipologia itemSeleccionadoTemporal { get; set; } = new CASA.UsosTipologia();
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
editContext = new EditContext(itemSeleccionado);
|
||||||
|
messageStore = new ValidationMessageStore(editContext);
|
||||||
|
UsosTipologias = objetoLicitaciones.Usos.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GestionarDatos(string accion)
|
||||||
|
{
|
||||||
|
rellenarItem();
|
||||||
|
|
||||||
|
switch (accion)
|
||||||
|
{
|
||||||
|
case "update":
|
||||||
|
objetoLicitaciones.ActualizarUso(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Actualizado correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "create":
|
||||||
|
objetoLicitaciones.InsertarUso(itemSeleccionado);
|
||||||
|
await cerrarPopupGestionDatos();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Guardado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
objetoLicitaciones.EliminarUso(itemSeleccionado);
|
||||||
|
await cerrarPopupConfirmarBorrado();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Eliminado correctamente.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UsosTipologias = objetoLicitaciones.Usos.ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
_Parent.RefreshState();
|
||||||
|
}
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
await GestionarDatos("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task abrirPopupGestionDatos(CASA.UsosTipologia objeto,bool esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
|
||||||
|
if (esNuevo)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = new CASA.UsosTipologia();
|
||||||
|
nuevoElemento = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = new CASA.UsosTipologia()
|
||||||
|
{
|
||||||
|
CoefIntervencion = objeto.CoefIntervencion,
|
||||||
|
CoefTipologia = objeto.CoefTipologia,
|
||||||
|
idGrupoTipologia = objeto.idGrupoTipologia,
|
||||||
|
idTipoIntervencion = objeto.idTipoIntervencion,
|
||||||
|
idTipologia = objeto.idTipologia,
|
||||||
|
superficie = objeto.superficie,
|
||||||
|
SuperficieCoefIntervencion = objeto.SuperficieCoefIntervencion,
|
||||||
|
SuperficieCoefTipologia = objeto.SuperficieCoefTipologia
|
||||||
|
};
|
||||||
|
|
||||||
|
await cambiarTipologia();
|
||||||
|
nuevoElemento = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nuevoElemento)
|
||||||
|
{
|
||||||
|
tituloPopup = "Modificar uso";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tituloPopup = "Nuevo uso";
|
||||||
|
}
|
||||||
|
await popupGestionDatos.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGestionDatos()
|
||||||
|
{
|
||||||
|
await popupGestionDatos.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task cambiarTipologia()
|
||||||
|
{
|
||||||
|
tipologiasAux = objetoLicitaciones.Enumerados.TipologiasPorGrupo(itemSeleccionadoTemporal.idGrupoTipologia).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (itemSeleccionadoTemporal.idTipologia == 0)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = tipologiasAux.First().idTipologia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tipologiasAux.Any(x => x.idTipologia == itemSeleccionadoTemporal.idTipologia))
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = itemSeleccionadoTemporal.idTipologia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idTipologia = tipologiasAux.First().idTipologia;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
intervencionesAux = objetoLicitaciones.Enumerados.Intervenciones.ToList();
|
||||||
|
itemSeleccionadoTemporal.idTipoIntervencion = itemSeleccionadoTemporal.idTipoIntervencion == 0 ? intervencionesAux.First().idEnumeracion : itemSeleccionadoTemporal.idTipoIntervencion;
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado(CASA.UsosTipologia objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnRowClick(GridRowEventArgs<CASA.UsosTipologia> objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto.Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||||
|
{
|
||||||
|
var value = e.Value?.ToString();
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
|
||||||
|
switch (fieldName)
|
||||||
|
{
|
||||||
|
case nameof(itemSeleccionado.superficie):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
string parseado = value.Replace(",", ".");
|
||||||
|
itemSeleccionadoTemporal.superficie = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(itemSeleccionadoTemporal.idGrupoTipologia):
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
|
||||||
|
itemSeleccionadoTemporal.idGrupoTipologia = int.Parse(value);
|
||||||
|
cambiarTipologia();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemSeleccionadoTemporal.idGrupoTipologia = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageStore?.Clear(field);
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.superficie) && itemSeleccionadoTemporal.superficie <= 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "La superficie debe ser mayor que 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fieldName == nameof(itemSeleccionadoTemporal.idGrupoTipologia) && itemSeleccionadoTemporal.idGrupoTipologia == 0)
|
||||||
|
{
|
||||||
|
messageStore?.Add(field, "Seleccione un tipo de uso.");
|
||||||
|
}
|
||||||
|
|
||||||
|
editContext?.NotifyValidationStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidarTodo()
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.superficie }, nameof(itemSeleccionadoTemporal.superficie));
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = itemSeleccionadoTemporal.idGrupoTipologia }, nameof(itemSeleccionadoTemporal.idGrupoTipologia));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetExternalValidationMessage(string fieldName)
|
||||||
|
{
|
||||||
|
var field = new FieldIdentifier(itemSeleccionadoTemporal, fieldName);
|
||||||
|
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GUARDAR
|
||||||
|
private async Task guardarFormulario()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValidarTodo();
|
||||||
|
|
||||||
|
if (!editContext!.GetValidationMessages().Any())
|
||||||
|
{
|
||||||
|
string accion = nuevoElemento ? "create" : "update";
|
||||||
|
GestionarDatos(accion);
|
||||||
|
|
||||||
|
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(itemSeleccionado.superficie), nameof(itemSeleccionado.idGrupoTipologia) })
|
||||||
|
{
|
||||||
|
ValidarYActualizar(new ChangeEventArgs { Value = typeof(CASA.UsosTipologia).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void rellenarItem()
|
||||||
|
{
|
||||||
|
itemSeleccionado.CoefIntervencion = itemSeleccionadoTemporal.CoefIntervencion;
|
||||||
|
itemSeleccionado.CoefTipologia = itemSeleccionadoTemporal.CoefTipologia;
|
||||||
|
itemSeleccionado.idGrupoTipologia = itemSeleccionadoTemporal.idGrupoTipologia;
|
||||||
|
itemSeleccionado.idTipoIntervencion = itemSeleccionadoTemporal.idTipoIntervencion;
|
||||||
|
itemSeleccionado.idTipologia = itemSeleccionadoTemporal.idTipologia;
|
||||||
|
itemSeleccionado.superficie = itemSeleccionadoTemporal.superficie;
|
||||||
|
itemSeleccionado.SuperficieCoefIntervencion = itemSeleccionadoTemporal.SuperficieCoefIntervencion;
|
||||||
|
itemSeleccionado.SuperficieCoefTipologia = itemSeleccionadoTemporal.SuperficieCoefTipologia;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
404
HerramientaCASA/Components/Pages/LicitacionesURBAN.razor
Normal file
404
HerramientaCASA/Components/Pages/LicitacionesURBAN.razor
Normal file
@@ -0,0 +1,404 @@
|
|||||||
|
|
||||||
|
@page "/LicitacionesUrban"
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@using HerramientaCASA.Components.Pages.LicitacionUrban
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Globalization
|
||||||
|
@using bdHerramientaCACOA.HerramientaURBAN
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||||
|
|
||||||
|
<p class="TituloVentana">
|
||||||
|
@TextoSuperior
|
||||||
|
</p>
|
||||||
|
@if (!actualizado)
|
||||||
|
{
|
||||||
|
<div class="UpdateCacoa d-flex">
|
||||||
|
<span>Esta simulación utiliza valores desactualizados. ¿Quiere Realizar una copia actualizada?</span>
|
||||||
|
<button @onclick="@(() => clonarUrban())" class="btnBlue ms-auto">Actualizar</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Modal @ref="popupGuardar" title="@TituloBoton" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||||
|
<BodyTemplate>
|
||||||
|
<div class="col-12 formatoCampos">
|
||||||
|
|
||||||
|
@if (TituloBoton == "Guardar")
|
||||||
|
{
|
||||||
|
<p>Se va a <b>guardar</b> esta <b>nueva simulación</b> podrá acceder a ella para consultarla y editarla desde el apartado <b>Mis Simulaciones</b> </p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Se van a <b>sobrescribir</b> los datos de la <b>simulación actual</b> con los cambios realizados, <b>esta opción no puede deshacerse.</b><br /><br /> ¿Desea continuar? </p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGuardar">Cerrar</Button>
|
||||||
|
<Button @onclick="@(() => guardarUrban())" Color="ButtonColor.Primary">@TituloBoton</Button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</Modal>
|
||||||
|
<div class="container-fluid pt-3">
|
||||||
|
<div class="d-flex" style="width:100%">
|
||||||
|
<button @onclick="@(() => abrirPopupGuardar())" class="btnBlue d-flex align-items-center"> <i class="fas fa-save pe-2"></i>@TituloBoton</button>
|
||||||
|
<b class="Fuente2 ps-2 pe-2 nomSim">Nombre de la licitación: </b>
|
||||||
|
<InputText @bind-Value="objetoLicitacionUrban.NombreSimulacion" class="form-control inputForm formatoMoneda inputTabla " style="text-align:left;font-weight:bold;"></InputText>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mt-3 mb-2">
|
||||||
|
<div><b>Convenio Colectivo:</b></div>
|
||||||
|
<InputSelect @bind-Value="@objetoLicitacionUrban.idProvincia" 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row p-0 m-0">
|
||||||
|
<div class="col-md-12 mt-3 mb-3">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<DocumentosLicitacion objetoLicitacionUrban="objetoLicitacionUrban"></DocumentosLicitacion>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row p-0 m-0">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<FasesLicitacionesUrban objetoLicitacionUrban="objetoLicitacionUrban"></FasesLicitacionesUrban>
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-5">
|
||||||
|
|
||||||
|
<CascadingValue Value="this">
|
||||||
|
<TablaTrabajadoresUrban objetoLicitacionUrban="objetoLicitacionUrban"></TablaTrabajadoresUrban>
|
||||||
|
</CascadingValue>
|
||||||
|
|
||||||
|
@* <CascadingValue Value="this">
|
||||||
|
<InstrumentosLicitacionesUrban objetoLicitacionUrban="objetoLicitacionUrban"></InstrumentosLicitacionesUrban>
|
||||||
|
</CascadingValue> *@
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="mt-3 mb-3"><b>Costes Asociados a los Servicios de Arquitectura</b></div>
|
||||||
|
|
||||||
|
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="colorB fw-bold">Concepto</th>
|
||||||
|
<th class="colorB fw-bold text-end"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="colorFilasIntro fw-bold w4">Plazo de presentación de la documentación:</td>
|
||||||
|
<td class="text-end columna40Ancho">
|
||||||
|
<div class="d-flex" style="gap:3px;">
|
||||||
|
@* <InputNumber TValue="int" Locale="es-ES" Min="0" class="inputForm formatoMoneda inputTabla" Value="@objetoLicitacionUrban.PlazoPresentacionDocumentos" ValueExpression="() => objetoLicitacionUrban.PlazoPresentacionDocumentos" ValueChanged="(value) => PlazoPresentacionDocumentosCambiado(value)"></InputNumber> meses *@
|
||||||
|
<InputNumber TValue="double" @bind-Value="objetoLicitacionUrban.PlazoPresentacionDocumentos"
|
||||||
|
step="any"
|
||||||
|
@oninput="e => controlarMeses(e.Value?.ToString())"
|
||||||
|
class="inputForm formatoMoneda inputTabla text-end" /> meses
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Coste hora de producción</td>
|
||||||
|
<td class="text-end columna40Ancho"><span> @objetoLicitacionUrban.CosteHP.MilesYDecimales() €/hora</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">Coste de producción del Trabajo Profesional</td>
|
||||||
|
<td class="text-end columna40Ancho"><span> @objetoLicitacionUrban.CostesProduccionTrabProf.MilesYDecimales() €</span></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="colorB fw-bold w4">
|
||||||
|
G.G. + B.I. <br />
|
||||||
|
<span class="fw-normal" style="font-size:10px;">(40/19 Junta Consultiva de Contratación Pública del Estado)</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end columna40Ancho" style="align-content:center;">
|
||||||
|
<div class="d-flex" style="justify-content: end; gap:3px;">
|
||||||
|
@objetoLicitacionUrban.Beneficio %
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-end fw-bold" style="background: #ffc107;">
|
||||||
|
COSTES DE PRODUCCIÓN DEL TRABAJO PROFESIONAL: <span>@objetoLicitacionUrban.PrecioDelTrabajo.MilesYDecimales() €</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-5" style="margin-top:2000px;">
|
||||||
|
<b>Tabla CD+CI para visualizacion de datos, se quitara cuando se vea que los calculos son correctos</b><br />
|
||||||
|
<b>IPC Coste Indirecto:</b>@objetoLicitacionUrban.Variables.IPCCosteIndirecto;<br />
|
||||||
|
<Grid TItem="CosteDirectoIndirecto"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="objetoLicitacionUrban.Enumerados.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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? idSimulador { get; set; } = "";
|
||||||
|
public string TextoSuperior = "Nueva licitación de Urbanismo";
|
||||||
|
public string TituloBoton = "Guardar";
|
||||||
|
private Modal popupGuardar = default!;
|
||||||
|
public bool actualizado = true;
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
private bdHerramientaCACOA.LicitacionesURBAN objetoLicitacionUrban;
|
||||||
|
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||||
|
|
||||||
|
private string nombreOriginal = "";
|
||||||
|
|
||||||
|
private int idUser = 0;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("idSimulador", out var clValue))
|
||||||
|
{
|
||||||
|
idSimulador = clValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
objetoLicitacionUrban = new bdHerramientaCACOA.LicitacionesURBAN();
|
||||||
|
objetoLicitacionUrban.RellenarCamposExtra(bd);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
var a = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var fechaActVar = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD").Fecha1;
|
||||||
|
string idDesencriptado = tsUtilidades.crypt.FEncS(idSimulador,
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||||
|
-875421649);
|
||||||
|
|
||||||
|
simulaciones simu = bd.simulaciones.Where(x => x.idSimulacion == int.Parse(idDesencriptado)).First();
|
||||||
|
int idFicheroJSON = simu.idFicheroJSON;
|
||||||
|
idSimulador = idDesencriptado;
|
||||||
|
var byteFichero = bd.ficheros.Where(x => x.idFichero == idFicheroJSON).First().Fichero;
|
||||||
|
|
||||||
|
string CASAJson = System.Text.Encoding.UTF8.GetString(byteFichero);
|
||||||
|
|
||||||
|
objetoLicitacionUrban = System.Text.Json.JsonSerializer.Deserialize<bdHerramientaCACOA.LicitacionesURBAN>(CASAJson);
|
||||||
|
|
||||||
|
if ((simu.FechaModificacion != null && simu.FechaModificacion < fechaActVar) || (simu.FechaModificacion == null && simu.FechaCreacion < fechaActVar))
|
||||||
|
{
|
||||||
|
actualizado = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextoSuperior = "Modificando simulación \"" + simu.Descripcion + "\"";
|
||||||
|
TituloBoton = "Modificar";
|
||||||
|
|
||||||
|
nombreOriginal = objetoLicitacionUrban.NombreSimulacion;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
idUser = obtenerID.Value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error durante la inicialización: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void guardarUrban()
|
||||||
|
{
|
||||||
|
//HACER
|
||||||
|
// para evitar loops
|
||||||
|
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoLicitacionUrban);
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == HerramientaCASA.UtilidadesCASA.obtenerTipoSimulacion(HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBANDSIMP)).idEnumeracion;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(idSimulador))
|
||||||
|
{
|
||||||
|
if (bd.simulaciones.Any(x => x.Descripcion == objetoLicitacionUrban.NombreSimulacion && x.idTipoSimulacion == idtipoSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crearSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var listadoSimulacionesExistentes = bd.simulaciones.Where(x => x.Descripcion != nombreOriginal && x.idTipoSimulacion == idtipoSimulacion).ToList();
|
||||||
|
|
||||||
|
if (listadoSimulacionesExistentes.Any(x => x.Descripcion == objetoLicitacionUrban.NombreSimulacion))
|
||||||
|
{
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Danger,
|
||||||
|
Message = $"Ya existe una simulación con el mismo nombre.",
|
||||||
|
});
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actualizarSimulacion(jsonObjeto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void crearSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
int idSimulacionCreada = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBANDSIMP, jsonObjeto, objetoLicitacionUrban.NombreSimulacion, "licitacionesUrban.json", idUser);
|
||||||
|
string link = "/LicitacionesURBAN?idSimulador=" + tsUtilidades.crypt.FEncS(idSimulacionCreada.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Licitación creada correctamente.",
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
private void actualizarSimulacion(string jsonObjeto)
|
||||||
|
{
|
||||||
|
UtilidadesCASA.actualziarObjeto(bd, jsonObjeto, objetoLicitacionUrban.NombreSimulacion, idSimulador);
|
||||||
|
cerrarPopupGuardar();
|
||||||
|
mensajes.Add(new ToastMessage
|
||||||
|
{
|
||||||
|
Type = ToastType.Primary,
|
||||||
|
Message = $"Licitación actualizada correctamente.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clonarUrban()
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.RellenarCamposExtra(bd);
|
||||||
|
|
||||||
|
objetoLicitacionUrban.NombreSimulacion = objetoLicitacionUrban.NombreSimulacion + " (Act:" + DateTime.Now + ")";
|
||||||
|
string jsonObjeto = Newtonsoft.Json.JsonConvert.SerializeObject(objetoLicitacionUrban);
|
||||||
|
var id = UtilidadesCASA.crearObjeto(bd, HerramientaCASA.UtilidadesCASA.TiposSimulaciones.URBANDSIMP, jsonObjeto, objetoLicitacionUrban.NombreSimulacion, "licitacionesUrban.json", idUser);
|
||||||
|
|
||||||
|
var link = "/LicitacionesUrban?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
|
||||||
|
Navigation.NavigateTo(link, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CalcularTabla(string idProvincia)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.idProvincia = idProvincia;
|
||||||
|
objetoLicitacionUrban.Enumerados.ListaCDCI = objetoLicitacionUrban.CalcularTabla(idProvincia);
|
||||||
|
objetoLicitacionUrban.CalcularLicitacion();
|
||||||
|
RefreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void PlazoPresentacionDocumentosCambiado(double e)
|
||||||
|
{
|
||||||
|
objetoLicitacionUrban.PlazoPresentacionDocumentos = e;
|
||||||
|
|
||||||
|
objetoLicitacionUrban.CalcularLicitacion();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlarMeses(string meses)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (double.TryParse(meses, out var valor))
|
||||||
|
{
|
||||||
|
string parseado = meses.ToString().Replace(",", ".");
|
||||||
|
objetoLicitacionUrban.PlazoPresentacionDocumentos = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlazoPresentacionDocumentosCambiado(objetoLicitacionUrban.PlazoPresentacionDocumentos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task abrirPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupGuardar()
|
||||||
|
{
|
||||||
|
await popupGuardar.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
48
HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor
Normal file
48
HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
@page "/ClaveGenerada"
|
||||||
|
@using HerramientaCASA.Components.Layout
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@layout LoginLayout
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
|
||||||
|
|
||||||
|
<div class="back">
|
||||||
|
<div class="div-center">
|
||||||
|
<div class="content">
|
||||||
|
<img src="Content/Imagenes/CACOA-6.png" height="49" />
|
||||||
|
<h4 class="mt-5">Clave Generada correctamente</h4>
|
||||||
|
<hr />
|
||||||
|
<p>Se ha generado su clave para utilizar la herramienta.Guarde su clave y contraseña en un lugar seguro. NO PUEDE RECUPERARSE</p>
|
||||||
|
<form id="formLogin">
|
||||||
|
<p><b>Clave:</b><span style="padding-left:15px;">@claveUsuario</span></p>
|
||||||
|
<button @onclick="@irPanelControl" type="button" class="btnBlue"> Acceder a la herramienta </button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private int? claveUsuario = 0;
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
var obtenerId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
claveUsuario = obtenerId.Value;
|
||||||
|
|
||||||
|
if (claveUsuario == 0 || claveUsuario == null)
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/", forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task irPanelControl()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/PanelControl", forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
101
HerramientaCASA/Components/Pages/Login/Login.razor
Normal file
101
HerramientaCASA/Components/Pages/Login/Login.razor
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
@page "/"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@layout LoginLayout
|
||||||
|
@inject IHttpContextAccessor HttpContextAccessor
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
|
||||||
|
<div class="fondo">
|
||||||
|
<div class="back">
|
||||||
|
<div class="div-center">
|
||||||
|
<div class="content">
|
||||||
|
<img src="Content/Imagenes/CACOA-6.png" height="49" />
|
||||||
|
<h4 class="mt-2">Acceso a la Herramienta</h4>
|
||||||
|
<hr />
|
||||||
|
<EditForm Model="login" FormName="loginForm" OnValidSubmit="Acceder" >
|
||||||
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="exampleInputEmail1">Clave de acceso</label>
|
||||||
|
<input type="number" class="form-control" @bind-value="@login.codigo" placeholder="0000000000000" />
|
||||||
|
<ValidationMessage For="() => login.codigo" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Password</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<PasswordInput Class="form-control" @bind-Value="@login.password" />
|
||||||
|
</div>
|
||||||
|
<ValidationMessage For="() => login.password" />
|
||||||
|
</div>
|
||||||
|
<div class="form-check" style="gap:10px;">
|
||||||
|
<input type="checkbox" class="form-check-input" id="Recuerdame" />
|
||||||
|
<label class="form-check-label" for="Recuerdame">Recordarme</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<small class="form-text text-muted">Si es la primera vez que utiliza la herramienta, <a href="NuevoAcceso" class="mt-2">cree una nueva clave de acceso</a></small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<p class="form-text text-muted" style="color:red !important">@mensajeError</p>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btnBlue"> Acceder </button>
|
||||||
|
</EditForm>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
private LoginVM login = new LoginVM();
|
||||||
|
private string mensajeError = "";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
await ProtectedSessionStore.SetAsync("idUsuario", 0);
|
||||||
|
await ProtectedSessionStore.SetAsync("EsAdmin", false);
|
||||||
|
|
||||||
|
// Limpiar almacenamiento local o sesión si se está utilizando
|
||||||
|
// if (HttpContextAccessor?.HttpContext?.Session != null)
|
||||||
|
// {
|
||||||
|
// HttpContextAccessor.HttpContext.Session.Clear();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Acceder()
|
||||||
|
{
|
||||||
|
//if (login.codigo == -534610 && login.password == "sRg1406.")
|
||||||
|
if (login.codigo == -1 && login.password == "-1")
|
||||||
|
{
|
||||||
|
await ProtectedSessionStore.SetAsync("idUsuario", -1);
|
||||||
|
await ProtectedSessionStore.SetAsync("EsAdmin", true);
|
||||||
|
|
||||||
|
Navigation.NavigateTo("/PanelControlConf", forceLoad: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var usuario = bd.usuarios.FirstOrDefault(x => x.Codigo == login.codigo && x.Contrasena == login.password);
|
||||||
|
|
||||||
|
if (usuario == null)
|
||||||
|
{
|
||||||
|
mensajeError = "Usuario no encontrado en la base de datos.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
await ProtectedSessionStore.SetAsync("idUsuario", usuario.idUsuario);
|
||||||
|
await ProtectedSessionStore.SetAsync("EsAdmin", false);
|
||||||
|
|
||||||
|
|
||||||
|
Navigation.NavigateTo("/PanelControl", forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor
Normal file
70
HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
@page "/NuevoAcceso"
|
||||||
|
@using HerramientaCASA.Components.Layout
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@layout LoginLayout
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
|
||||||
|
|
||||||
|
<div class="back">
|
||||||
|
<div class="div-center">
|
||||||
|
<div class="content">
|
||||||
|
<img src="Content/Imagenes/CACOA-6.png" height="49" />
|
||||||
|
<h4 class="mt-2">Crear Clave de acceso</h4>
|
||||||
|
<hr />
|
||||||
|
<p>Se va a generar una clave de acceso para acceder a la herramienta, tenga en cuenta que como no se almacena ningún dato de caracter personal le recomendamos que guarde la clave y contraseña para poder utilizarla.</p>
|
||||||
|
<form id="formLogin">
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="exampleInputPassword1">Cree una contraseña para su clave:</label>
|
||||||
|
<PasswordInput placeholder="Introduzca una contraseña" Class="form-control" @bind-Value="@nuevaPassword" />
|
||||||
|
</div>
|
||||||
|
<p style="color:red !important">@mensajeError</p>
|
||||||
|
<button @onclick="@Generar" type="button" class="btnBlue"> Generar </button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private string? nuevaPassword = "";
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
private string mensajeError = "";
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Generar()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nuevaPassword))
|
||||||
|
{
|
||||||
|
mensajeError = "Debe introducir una nueva contraseña.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var nuevoAcceso = new usuarios();
|
||||||
|
nuevoAcceso.Contrasena = nuevaPassword;
|
||||||
|
nuevoAcceso.FechaCreacion = DateTime.Now;
|
||||||
|
nuevoAcceso.FechaUltimoAcceso = DateTime.Now;
|
||||||
|
|
||||||
|
bd.usuarios.Add(nuevoAcceso);
|
||||||
|
bd.SaveChanges();
|
||||||
|
|
||||||
|
nuevoAcceso.Codigo = nuevoAcceso.idUsuario;
|
||||||
|
bd.SaveChanges();
|
||||||
|
|
||||||
|
await ProtectedSessionStore.SetAsync("idUsuario", nuevoAcceso.idUsuario);
|
||||||
|
|
||||||
|
|
||||||
|
Navigation.NavigateTo("/ClaveGenerada", forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
HerramientaCASA/Components/Pages/MisSimulaciones.razor
Normal file
55
HerramientaCASA/Components/Pages/MisSimulaciones.razor
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
|
||||||
|
@page "/MisSimulaciones"
|
||||||
|
|
||||||
|
<div class ="container-fluid pt-3">
|
||||||
|
<Tabs>
|
||||||
|
<Tab Title="CASA – Edificación" Name="tabCASA" Active>
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="CASA"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Licitaciones Edificación" Name="tabConcursoCASA">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="LICITACIONCASA"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Licitaciones Bajas" Name="tabBajas">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="BAJAS"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
<Tab Title="Simulaciones URBAN" Name="tbURBAND">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="URBAND"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
|
||||||
|
<Tab Title="Licitaciones URBAN" Name="tbURBAND">
|
||||||
|
<Content>
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="URBANDSIMP"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</Content>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
67
HerramientaCASA/Components/Pages/PanelControl.razor
Normal file
67
HerramientaCASA/Components/Pages/PanelControl.razor
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
@page "/PanelControl"
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row" style="height: calc(100vh - 54px);">
|
||||||
|
<div class="col-6 d-flex align-items-center justify-content-center colorAMenu dive">
|
||||||
|
<a href="HerramientaCASASimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">
|
||||||
|
Servicios de Arquitectura
|
||||||
|
Edificación
|
||||||
|
</h4>
|
||||||
|
<p style="text-align: center;">Cree una simulación completa</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 d-flex align-items-center justify-content-center colorBMenu dive">
|
||||||
|
<a href="LicitacionCASASimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">Licitaciones - Edificación</h4>
|
||||||
|
<p style="text-align: center;">Cree una simulación simplificada</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 d-flex align-items-center justify-content-center colorCMenu dive">
|
||||||
|
<a href="HerramientaURBANSimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">
|
||||||
|
Servicios de Arquitectura
|
||||||
|
Urbanismo
|
||||||
|
</h4>
|
||||||
|
<p style="text-align: center;">Servicios de Arquitectura – Urbanismo</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6 d-flex align-items-center justify-content-center colorDMenu dive">
|
||||||
|
<a href="LicitacionUrbanSimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">Licitaciones - Urbanismo</h4>
|
||||||
|
<p style="text-align: center;">Licitaciones Urbanismo</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 d-flex align-items-center justify-content-center colorEMenu dive">
|
||||||
|
<a href="MisSimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">Mis simulaciones</h4>
|
||||||
|
<p style="text-align: center;">Revise sus simulaciones creadas anteriormente</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@* <div class="col-6 d-flex align-items-center justify-content-center colorCMenu dive">
|
||||||
|
<a href="BajasSimulaciones">
|
||||||
|
<div>
|
||||||
|
<h4 class="text-center">Licitaciones - Bajas</h4>
|
||||||
|
<p style="text-align: center;">Calcule las semanas de producción</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div> *@
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||||
|
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||||
|
|
||||||
|
@inject UserState UserState
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<Grid TItem="simulaciones"
|
||||||
|
Class="tablaCACOA table"
|
||||||
|
Data="listadoSimulaciones"
|
||||||
|
AllowFiltering="false"
|
||||||
|
PageSize="10"
|
||||||
|
Height="100"
|
||||||
|
EmptyText="No hay registros."
|
||||||
|
PageSizeSelectorVisible="false"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn TItem="simulaciones" HeaderTextAlignment="Alignment.Center" Class="columna40Ancho" HeaderText="Descripción">
|
||||||
|
<a href="@Redirigir(context.idSimulacion,context.idTipoSimulacion)" class="enlaceCACOA">@context.Descripcion</a>
|
||||||
|
</GridColumn>
|
||||||
|
@* <GridColumn TItem="simulaciones" HeaderText="Tipo simulación">
|
||||||
|
@context.idTipoSimulacionNavigation.Descripcion
|
||||||
|
</GridColumn>
|
||||||
|
*@
|
||||||
|
<GridColumn TItem="simulaciones" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Fecha Creación">
|
||||||
|
@context.FechaCreacion @* .ToString("dd-MM-yyyy") *@
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="simulaciones" HeaderTextAlignment="Alignment.Center" Class="text-end" HeaderText="Fecha Modificación">
|
||||||
|
@context.FechaModificacion
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
<GridColumn TItem="simulaciones" Class="botonesTabla" HeaderText="">
|
||||||
|
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" style="cursor: pointer;">
|
||||||
|
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||||
|
</span>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string TipoSimulacion { get; set; } = "";
|
||||||
|
private Modal popupConfirmarBorrado = default!;
|
||||||
|
public tsHerramientasCACOA bd;
|
||||||
|
private string mensajeError = "";
|
||||||
|
List<simulaciones> listadoSimulaciones = new List<simulaciones>();
|
||||||
|
private simulaciones itemSeleccionado { get; set; } = new simulaciones();
|
||||||
|
|
||||||
|
private int idUser = 0;
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: true);
|
||||||
|
|
||||||
|
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||||
|
idUser = obtenerID.Value;
|
||||||
|
|
||||||
|
listadoSimulaciones = bd.simulaciones.Include(x => x.idTipoSimulacionNavigation).Include(x => x.idFicheroJSONNavigation).Where(x => x.idCodigo == idUser && x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA." + TipoSimulacion).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Redirigir(int id, int idTipoSimulacion)
|
||||||
|
{
|
||||||
|
string link = "";
|
||||||
|
|
||||||
|
switch (obtenerTipoSimulacion(idTipoSimulacion))
|
||||||
|
{
|
||||||
|
case "CASA":
|
||||||
|
link = "/HerramientaCASAS?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
break;
|
||||||
|
case "BAJAS":
|
||||||
|
link = "/Bajas?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
break;
|
||||||
|
case "LICITACION CASA":
|
||||||
|
link = "/LicitacionCASA?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
break;
|
||||||
|
case "URBAND":
|
||||||
|
link = "/HerramientaURBAN?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
break;
|
||||||
|
case "URBAND SIMPLIFICADA":
|
||||||
|
link = "/LicitacionesURBAN?idSimulador=" + tsUtilidades.crypt.FEncS(id.ToString(), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*", 875421649);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string obtenerTipoSimulacion(int idTipoSimulacion)
|
||||||
|
{
|
||||||
|
string tipo = bd.enumeraciones.First(x => x.idEnumeracion == idTipoSimulacion).Descripcion;
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task BorrarItem()
|
||||||
|
{
|
||||||
|
bd.simulaciones.Remove(itemSeleccionado);
|
||||||
|
bd.SaveChanges();
|
||||||
|
// Se tiene que crear otro contexto para que no falle
|
||||||
|
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: true);
|
||||||
|
listadoSimulaciones = bd.simulaciones.Include(x => x.idTipoSimulacionNavigation).Include(x => x.idFicheroJSONNavigation).Where(x => x.idCodigo == idUser && x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA." + TipoSimulacion).ToList();
|
||||||
|
StateHasChanged();
|
||||||
|
cerrarPopupConfirmarBorrado();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////// PopUp eliminar registro
|
||||||
|
private async Task abrirPopupConfirmarBorrado( simulaciones objeto)
|
||||||
|
{
|
||||||
|
itemSeleccionado = objeto;
|
||||||
|
await popupConfirmarBorrado.ShowAsync();
|
||||||
|
}
|
||||||
|
private async Task cerrarPopupConfirmarBorrado()
|
||||||
|
{
|
||||||
|
await popupConfirmarBorrado.HideAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
@page "/BajasSimulaciones"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pt-3">
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<div>
|
||||||
|
<div class="container-fluid align-items-center">
|
||||||
|
<div class="mb-5">
|
||||||
|
<button @onclick="@(() => irNuevaSimulacion())" class="btnBlue ms-auto"> <i class="fas fa-plus pe-1"></i>Crear Nueva baja</button>
|
||||||
|
</div>
|
||||||
|
<b>Simulaciones bajas guardadas</b>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="BAJAS"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void irNuevaSimulacion()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/Bajas", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
@page "/HerramientaURBANSimulaciones"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState userState
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pt-3">
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<div>
|
||||||
|
<div class="container-fluid align-items-center">
|
||||||
|
<div class="mb-5">
|
||||||
|
<button @onclick="@(() => irNuevaSimulacion())" class="btnBlue ms-auto"><i class="fas fa-plus pe-1"></i>Crear Nueva simulación URBAN</button>
|
||||||
|
</div>
|
||||||
|
<b>Simulaciones URBAN guardadas</b>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="URBAND"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void irNuevaSimulacion()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/HerramientaURBAN", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
@page "/HerramientaCASASimulaciones"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState userState
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pt-3">
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<div>
|
||||||
|
<div class="container-fluid align-items-center">
|
||||||
|
<div class="mb-5">
|
||||||
|
<button @onclick="@(() => irNuevaSimulacion())" class="btnBlue ms-auto"><i class="fas fa-plus pe-1"></i>Crear Nueva simulación CASA</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<b>Ver simulaciones CASA guardadas</b>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="CASA"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void irNuevaSimulacion()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/HerramientaCASAS", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
@page "/LicitacionCASASimulaciones"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState userState
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pt-3">
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<div>
|
||||||
|
<div class="container-fluid align-items-center">
|
||||||
|
<div class="mb-5">
|
||||||
|
<button @onclick="@(() => irNuevaSimulacion())" class="btnBlue ms-auto"> <i class="fas fa-plus pe-1"></i> Crear Nueva licitación CASA</button>
|
||||||
|
</div>
|
||||||
|
<b>Licitaciones CASA guardadas</b>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="LICITACIONCASA"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void irNuevaSimulacion()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/LicitacionCASA", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
@page "/LicitacionUrbanSimulaciones"
|
||||||
|
@using HerramientaCASA.Model
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
@using System.Text.Json
|
||||||
|
@using System.Text
|
||||||
|
@using bdHerramientaCACOA.db
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject UserState userState
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pt-3">
|
||||||
|
<div class="CajaTab p-2">
|
||||||
|
<div>
|
||||||
|
<div class="container-fluid align-items-center">
|
||||||
|
<div class="mb-5">
|
||||||
|
<button @onclick="@(() => irNuevaSimulacion())" class="btnBlue ms-auto"><i class="fas fa-plus pe-1"></i> Crear Nueva licitación URBAN</button>
|
||||||
|
</div>
|
||||||
|
<b>Licitaciones URBAN guardadas</b>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs TipoSimulacion="URBANDSIMP"></HerramientaCASA.Components.Pages.Simulaciones.SimulacionesTabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void irNuevaSimulacion()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/LicitacionesURBAN", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
6
HerramientaCASA/Components/Routes.razor
Normal file
6
HerramientaCASA/Components/Routes.razor
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<Router AppAssembly="typeof(Program).Assembly">
|
||||||
|
<Found Context="routeData">
|
||||||
|
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
|
||||||
|
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||||
|
</Found>
|
||||||
|
</Router>
|
||||||
16
HerramientaCASA/Components/_Imports.razor
Normal file
16
HerramientaCASA/Components/_Imports.razor
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
@using System.Net.Http
|
||||||
|
@using System.Net.Http.Json
|
||||||
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||||
|
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||||
|
@using Microsoft.JSInterop
|
||||||
|
@using HerramientaCASA
|
||||||
|
@using HerramientaCASA.Components
|
||||||
|
@using BlazorBootstrap
|
||||||
|
@using HerramientaCASA.ViewModel
|
||||||
|
@using bdHerramientaCACOA
|
||||||
|
@using bdHerramientaCACOA.dbcontext
|
||||||
|
@using HerramientaCASA.Components.Layout
|
||||||
|
@using bdHerramientaCACOA.extensiones_string
|
||||||
29
HerramientaCASA/HerramientaCASA.csproj
Normal file
29
HerramientaCASA/HerramientaCASA.csproj
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<SccProjectName>SAK</SccProjectName>
|
||||||
|
<SccProvider>SAK</SccProvider>
|
||||||
|
<SccAuxPath>SAK</SccAuxPath>
|
||||||
|
<SccLocalPath>SAK</SccLocalPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Blazor.Bootstrap" Version="3.3.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Components\Pages\Comun\Despacho\" />
|
||||||
|
<Folder Include="wwwroot\Scripts\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\bdHerramientaCACOA\bdHerramientaCACOA.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
45
HerramientaCASA/Model/UserState.cs
Normal file
45
HerramientaCASA/Model/UserState.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
namespace HerramientaCASA.Model
|
||||||
|
{
|
||||||
|
public class UserState
|
||||||
|
{
|
||||||
|
private readonly object _lock = new object();
|
||||||
|
private int _idUser;
|
||||||
|
private bool _esAdmin;
|
||||||
|
public int idUser
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
return _idUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_idUser = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EsAdmin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
return _esAdmin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_esAdmin = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
106
HerramientaCASA/Program.cs
Normal file
106
HerramientaCASA/Program.cs
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
using bdHerramientaCACOA.dbcontext;
|
||||||
|
using HerramientaCASA.Components;
|
||||||
|
using HerramientaCASA.Model;
|
||||||
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
|
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||||
|
using System.Globalization;
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Services.AddRazorComponents()
|
||||||
|
.AddInteractiveServerComponents();
|
||||||
|
|
||||||
|
builder.Services.AddAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||||
|
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||||
|
});
|
||||||
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("es-ES");
|
||||||
|
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("es-ES");
|
||||||
|
|
||||||
|
builder.Services.AddRazorPages()
|
||||||
|
.AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Necesario para ver porqu<71> est<73> fallando ciertas cosas que dan el error Circuit
|
||||||
|
builder.Services.AddServerSideBlazor().AddCircuitOptions(option => { option.DetailedErrors = true; });
|
||||||
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
builder.Services.AddDistributedMemoryCache();
|
||||||
|
|
||||||
|
builder.Services.AddSession(options =>
|
||||||
|
{
|
||||||
|
options.IdleTimeout = TimeSpan.FromHours(1);
|
||||||
|
options.Cookie.HttpOnly = true;
|
||||||
|
options.Cookie.IsEssential = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddBlazorBootstrap();
|
||||||
|
builder.Services.AddAntiforgery();
|
||||||
|
builder.Services.AddSingleton<UserState>();
|
||||||
|
builder.Services.AddScoped<ProtectedSessionStorage>();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||||
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializar las cadenas de conexi<78>n
|
||||||
|
var connectionStrings = builder.Configuration.GetSection("ConnectionStrings");
|
||||||
|
var writeConnectionString = connectionStrings["WriteConnection"];
|
||||||
|
var readOnlyConnectionString = connectionStrings["ReadOnlyConnection"];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(writeConnectionString) || string.IsNullOrEmpty(readOnlyConnectionString))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Las cadenas de conexi<78>n no est<73>n configuradas correctamente.");
|
||||||
|
}
|
||||||
|
|
||||||
|
tsHerramientasCACOA.EstableceCBD(writeConnectionString, readOnlyConnectionString);
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
app.UseSession();
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.UseAntiforgery();
|
||||||
|
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
var userState = context.RequestServices.GetService<UserState>();
|
||||||
|
var path = context.Request.Path;
|
||||||
|
|
||||||
|
if (path == "/" ||
|
||||||
|
path.StartsWithSegments("/_blazor") ||
|
||||||
|
path.StartsWithSegments("/Content") ||
|
||||||
|
path.StartsWithSegments("/Scripts") ||
|
||||||
|
path.StartsWithSegments("/favicon.ico") ||
|
||||||
|
path.StartsWithSegments("/_framework"))
|
||||||
|
{
|
||||||
|
await next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//// Redirigir al home si no hay token y la ruta no es p<>blica
|
||||||
|
//if (userState?.idUser == 0)
|
||||||
|
//{
|
||||||
|
// Console.WriteLine($"Redirigiendo al home desde: {path}");
|
||||||
|
// context.Response.Redirect("/");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Continuar con la solicitud
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.MapRazorComponents<App>()
|
||||||
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
38
HerramientaCASA/Properties/launchSettings.json
Normal file
38
HerramientaCASA/Properties/launchSettings.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:62617",
|
||||||
|
"sslPort": 44367
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:5145",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7275;http://localhost:5145",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
548
HerramientaCASA/UtilidadesCASA.cs
Normal file
548
HerramientaCASA/UtilidadesCASA.cs
Normal file
@@ -0,0 +1,548 @@
|
|||||||
|
using bdHerramientaCACOA;
|
||||||
|
using bdHerramientaCACOA.db;
|
||||||
|
using bdHerramientaCACOA.dbcontext;
|
||||||
|
using BlazorBootstrap;
|
||||||
|
using HerramientaCASA.Model;
|
||||||
|
using HerramientaCASA.ViewModel;
|
||||||
|
using System.Text;
|
||||||
|
using static HerramientaCASA.Components.Pages.ConfiguracionPages.ConvenioColectivo;
|
||||||
|
|
||||||
|
namespace HerramientaCASA
|
||||||
|
{
|
||||||
|
public class UtilidadesCASA
|
||||||
|
{
|
||||||
|
public static int crearObjeto(tsHerramientasCACOA bd, TiposSimulaciones tipoSimulacion, string jsonObjeto, string descripcion, string nombreFichero, int idUsuario)
|
||||||
|
{
|
||||||
|
int idtipoFichero = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.JSON").idEnumeracion;
|
||||||
|
int idtipoSimulacion = bd.enumeraciones.First(x => x.Codigo == obtenerTipoSimulacion(tipoSimulacion)).idEnumeracion;
|
||||||
|
|
||||||
|
bdHerramientaCACOA.db.ficheros ficheroCASA = new bdHerramientaCACOA.db.ficheros()
|
||||||
|
{
|
||||||
|
FechaCreacion = DateTime.Now,
|
||||||
|
idTipo = idtipoFichero,
|
||||||
|
Fichero = Encoding.UTF8.GetBytes(jsonObjeto),
|
||||||
|
NombreFichero = nombreFichero
|
||||||
|
};
|
||||||
|
|
||||||
|
bdHerramientaCACOA.db.simulaciones simulacion = new bdHerramientaCACOA.db.simulaciones()
|
||||||
|
{
|
||||||
|
|
||||||
|
idCodigo = idUsuario,
|
||||||
|
idTipoSimulacion = idtipoSimulacion,
|
||||||
|
Descripcion = descripcion,
|
||||||
|
idFicheroJSONNavigation = ficheroCASA,
|
||||||
|
FechaCreacion = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
|
bd.simulaciones.Add(simulacion);
|
||||||
|
bd.SaveChanges();
|
||||||
|
return simulacion.idSimulacion;
|
||||||
|
}
|
||||||
|
public static void actualziarObjeto(tsHerramientasCACOA bd, string jsonObjeto, string descripcion, string idSimulacion)
|
||||||
|
{
|
||||||
|
simulaciones simulacionObtenida = bd.simulaciones.First(x => x.idSimulacion == int.Parse(idSimulacion));
|
||||||
|
|
||||||
|
ficheros ficheroObtenido = bd.ficheros.First(x => x.idFichero == simulacionObtenida.idFicheroJSON);
|
||||||
|
|
||||||
|
ficheroObtenido.Fichero = Encoding.UTF8.GetBytes(jsonObjeto);
|
||||||
|
|
||||||
|
simulacionObtenida.FechaModificacion = DateTime.Now;
|
||||||
|
simulacionObtenida.Descripcion = descripcion;
|
||||||
|
|
||||||
|
bd.ficheros.Update(ficheroObtenido);
|
||||||
|
bd.simulaciones.Update(simulacionObtenida);
|
||||||
|
|
||||||
|
bd.SaveChanges();
|
||||||
|
}
|
||||||
|
public static string obtenerTipoSimulacion(TiposSimulaciones simulacion)
|
||||||
|
{
|
||||||
|
string tipoSimulacion = "";
|
||||||
|
|
||||||
|
switch (simulacion)
|
||||||
|
{
|
||||||
|
case TiposSimulaciones.CASA:
|
||||||
|
tipoSimulacion = "TIPOHERRAMIENTA.CASA";
|
||||||
|
break;
|
||||||
|
case TiposSimulaciones.BAJA:
|
||||||
|
tipoSimulacion = "TIPOHERRAMIENTA.BAJAS";
|
||||||
|
break;
|
||||||
|
case TiposSimulaciones.LICITACIONCASA:
|
||||||
|
tipoSimulacion = "TIPOHERRAMIENTA.LICITACIONCASA";
|
||||||
|
break;
|
||||||
|
case TiposSimulaciones.URBAN:
|
||||||
|
tipoSimulacion = "TIPOHERRAMIENTA.URBAND";
|
||||||
|
break;
|
||||||
|
case TiposSimulaciones.URBANDSIMP:
|
||||||
|
tipoSimulacion = "TIPOHERRAMIENTA.URBANDSIMP";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
return tipoSimulacion;
|
||||||
|
}
|
||||||
|
public static void guardarEnumeracion(tsHerramientasCACOA bd, enumeraciones nuevaEnumeracion, string codigo, bool nuevoElemento = true, enumeraciones enumeracionObtenida = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (nuevoElemento)
|
||||||
|
{
|
||||||
|
|
||||||
|
int grupoEnum = (int)bd.enumeraciones.First(x => x.Codigo.Contains(codigo)).idGrupoEnumeracion;
|
||||||
|
|
||||||
|
nuevaEnumeracion.Descripcion = nuevaEnumeracion.ValorAlfabetico1.ToUpper();
|
||||||
|
nuevaEnumeracion.Codigo = codigo + "." + nuevaEnumeracion.ValorAlfabetico1.ToUpper();
|
||||||
|
nuevaEnumeracion.Codigo = nuevaEnumeracion.Codigo.Trim().Replace(" ", "");
|
||||||
|
|
||||||
|
nuevaEnumeracion.idGrupoEnumeracion = grupoEnum;
|
||||||
|
bd.enumeraciones.Add(nuevaEnumeracion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enumeracionObtenida.ValorAlfabetico1 = nuevaEnumeracion.ValorAlfabetico1;
|
||||||
|
enumeracionObtenida.ValorNumerico1 = nuevaEnumeracion.ValorNumerico1;
|
||||||
|
enumeracionObtenida.ValorNumerico2 = nuevaEnumeracion.ValorNumerico2;
|
||||||
|
enumeracionObtenida.Descripcion = nuevaEnumeracion.ValorAlfabetico1.ToUpper();
|
||||||
|
//enumeracionObtenida.Codigo = codigo + "." + nuevaEnumeracion.ValorAlfabetico1.ToUpper();
|
||||||
|
//enumeracionObtenida.Codigo = nuevaEnumeracion.Codigo.Trim().Replace(" ", "");
|
||||||
|
|
||||||
|
bd.enumeraciones.Update(enumeracionObtenida);
|
||||||
|
}
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eliminarEnumeracion(tsHerramientasCACOA bd, enumeraciones enumeracionObtenida)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.enumeraciones.Remove(enumeracionObtenida);
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void actualizarFactorCorrecion(tsHerramientasCACOA bd, factorescorreccion factorCorrecc, factorescorreccion facturaEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
factorCorrecc.Descripcion = facturaEdit.Descripcion;
|
||||||
|
factorCorrecc.Coeficiente = facturaEdit.Coeficiente;
|
||||||
|
|
||||||
|
bd.factorescorreccion.Update(factorCorrecc);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void crearFactorCorrecion(tsHerramientasCACOA bd, factorescorreccion factorCorrecc)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string descripcion = factorCorrecc.Descripcion;
|
||||||
|
factorCorrecc.Descripcion = descripcion;
|
||||||
|
|
||||||
|
bd.factorescorreccion.Add(factorCorrecc);
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eliminarFactorCorrecion(tsHerramientasCACOA bd, factorescorreccion factorObtenido)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Comprobamos si es el ultimo de su especie
|
||||||
|
var total = bd.factorescorreccion.Where(x => x.idEnumeracion == factorObtenido.idEnumeracion).Count();
|
||||||
|
|
||||||
|
var idenu = factorObtenido.idEnumeracion;
|
||||||
|
bd.factorescorreccion.Remove(factorObtenido);
|
||||||
|
bd.SaveChanges();
|
||||||
|
if (total == 1)
|
||||||
|
{
|
||||||
|
var enu = bd.enumeraciones.First(x => x.idEnumeracion == idenu);
|
||||||
|
bd.enumeraciones.Remove(enu);
|
||||||
|
}
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void actualizarCosteDespachoProfesional(tsHerramientasCACOA bd, costedespachoprofesional coste, costedespachoprofesional costeEdit)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// coste.numTrabajadores = costeEdit.numTrabajadores;
|
||||||
|
// coste.HorasProduccionAnuales = costeEdit.HorasProduccionAnuales;
|
||||||
|
// coste.CosteMinimoPersonal = costeEdit.CosteMinimoPersonal;
|
||||||
|
// coste.CosteMaxPersonal = costeEdit.CosteMaxPersonal;
|
||||||
|
// coste.CosteDirectoMedio = costeEdit.CosteDirectoMedio;
|
||||||
|
// coste.CostesDirectos = costeEdit.CostesDirectos;
|
||||||
|
// coste.CostesIndirectos = costeEdit.CostesIndirectos;
|
||||||
|
// coste.TotalDespachoProfesional = costeEdit.TotalDespachoProfesional;
|
||||||
|
|
||||||
|
// bd.costedespachoprofesional.Update(coste);
|
||||||
|
|
||||||
|
// var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
// cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
// bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//public static void crearCosteDespachoProfesional(tsHerramientasCACOA bd, costedespachoprofesional coste)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// //string descripcion = factorCorrecc.Descripcion;
|
||||||
|
// //factorCorrecc.Descripcion = descripcion;
|
||||||
|
|
||||||
|
// bd.costedespachoprofesional.Add(coste);
|
||||||
|
|
||||||
|
// var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
// cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
// bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static void eliminarCosteDespachoProfesional(tsHerramientasCACOA bd, costedespachoprofesional costeObtenido)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// bd.costedespachoprofesional.Remove(costeObtenido);
|
||||||
|
// var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
// cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
// bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static void actualizarTipologias(tsHerramientasCACOA bd, tipologias tipologiaObtenida, tipologias tipologiaEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tipologiaObtenida.Descripcion = tipologiaEdit.Descripcion;
|
||||||
|
tipologiaObtenida.CoeficienteUso = tipologiaEdit.CoeficienteUso;
|
||||||
|
|
||||||
|
bd.tipologias.Update(tipologiaObtenida);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void crearTipologia(tsHerramientasCACOA bd, tipologias tipologiaObtenida)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string descripcion = tipologiaObtenida.Descripcion;
|
||||||
|
tipologiaObtenida.Descripcion = descripcion;
|
||||||
|
|
||||||
|
bd.tipologias.Add(tipologiaObtenida);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void actualizarConvenioColectivo(tsHerramientasCACOA bd, conveniocolectivo convcol, conveniocolectivo concolEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
convcol.CosteAnualTrabajador = concolEdit.CosteAnualTrabajador;
|
||||||
|
|
||||||
|
bd.conveniocolectivo.Update(convcol);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void actualizarConvenioColectivo(tsHerramientasCACOA bd, ConvenioProvincia concolEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var gradSup = bd.conveniocolectivo.First(x => x.idConvenioColectivo == concolEdit.idGradoSup);
|
||||||
|
gradSup.CosteAnualTrabajador = concolEdit.valorGradoSup;
|
||||||
|
var gradMed = bd.conveniocolectivo.First(x => x.idConvenioColectivo == concolEdit.idGradoMedio);
|
||||||
|
gradSup.CosteAnualTrabajador = concolEdit.valorGradoMed;
|
||||||
|
var delin = bd.conveniocolectivo.First(x => x.idConvenioColectivo == concolEdit.idDelinPro);
|
||||||
|
gradSup.CosteAnualTrabajador = concolEdit.valorDelinPro;
|
||||||
|
var admin = bd.conveniocolectivo.First(x => x.idConvenioColectivo == concolEdit.idAdmin);
|
||||||
|
gradSup.CosteAnualTrabajador = concolEdit.valorAdmin;
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eliminarTipologia(tsHerramientasCACOA bd, tipologias tipologiaObtenida)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.tipologias.Remove(tipologiaObtenida);
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void actualizarTipoProyecto(tsHerramientasCACOA bd, tipoproyectos proyecto, tipoproyectos proyectoEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proyecto.Descripcion = proyectoEdit.Descripcion;
|
||||||
|
proyecto.Abreviatura = proyectoEdit.Abreviatura;
|
||||||
|
proyecto.idTipoDocumento = proyectoEdit.idTipoDocumento;
|
||||||
|
|
||||||
|
|
||||||
|
bd.tipoproyectos.Update(proyecto);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void crearTipoProyecto(tsHerramientasCACOA bd, tipoproyectos proyecto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.tipoproyectos.Add(proyecto);
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eliminarTipoProyecto(tsHerramientasCACOA bd, tipoproyectos proyecto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Comprobamos si es el ultimo de su especie
|
||||||
|
var total = bd.tipoproyectos.Where(x => x.idTipoDocumento == proyecto.idTipoDocumento).Count();
|
||||||
|
|
||||||
|
var idenu = proyecto.idTipoDocumento;
|
||||||
|
bd.tipoproyectos.Remove(proyecto);
|
||||||
|
bd.SaveChanges();
|
||||||
|
if (total == 1)
|
||||||
|
{
|
||||||
|
var enu = bd.enumeraciones.First(x => x.idEnumeracion == idenu);
|
||||||
|
bd.enumeraciones.Remove(enu);
|
||||||
|
}
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void actualizarDocumentacion(tsHerramientasCACOA bd, documentacion docu, documentacion docuEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
docu.Descripcion = docuEdit.Descripcion;
|
||||||
|
docu.CoeficienteHoras = docuEdit.CoeficienteHoras;
|
||||||
|
docu.Checkeable = docuEdit.Checkeable;
|
||||||
|
|
||||||
|
bd.documentacion.Update(docu);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void crearDocumentacion(tsHerramientasCACOA bd, documentacion docu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.documentacion.Add(docu);
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eliminarDocumentacion(tsHerramientasCACOA bd, documentacion docu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.documentacion.Remove(docu);
|
||||||
|
bd.SaveChanges();
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void actualizarProyecto_Documentacion(tsHerramientasCACOA bd, tipoproyecto_documentacion docu, v_tipoproyecto_documentacion docuEdit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
docu.idtipoproyecto = docuEdit.idtipoproyecto;
|
||||||
|
docu.iddocumentacion = docuEdit.iddocumentacion;
|
||||||
|
docu.esMinima = docuEdit.esMinima;
|
||||||
|
docu.esOpcional = docuEdit.esOpcional;
|
||||||
|
docu.esNecesario = docuEdit.esNecesario;
|
||||||
|
docu.orden = docuEdit.orden;
|
||||||
|
|
||||||
|
bd.tipoproyecto_documentacion.Update(docu);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void crearProyecto_Documentacion(tsHerramientasCACOA bd, v_tipoproyecto_documentacion docu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tipoproyecto_documentacion proyeDocu = new tipoproyecto_documentacion()
|
||||||
|
{
|
||||||
|
idtipoproyecto = docu.idtipoproyecto,
|
||||||
|
iddocumentacion = docu.iddocumentacion,
|
||||||
|
esMinima = docu.esMinima,
|
||||||
|
esOpcional = docu.esOpcional,
|
||||||
|
esNecesario = docu.esNecesario,
|
||||||
|
orden = docu.orden,
|
||||||
|
};
|
||||||
|
|
||||||
|
bd.tipoproyecto_documentacion.Add(proyeDocu);
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void eliminarProyecto_Documentacion(tsHerramientasCACOA bd, tipoproyecto_documentacion docu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bd.tipoproyecto_documentacion.Remove(docu);
|
||||||
|
bd.SaveChanges();
|
||||||
|
|
||||||
|
var cambiarFecha = bd.enumeraciones.First(x => x.Codigo == "CW.FECHAULTMOD");
|
||||||
|
cambiarFecha.Fecha1 = DateTime.Now;
|
||||||
|
bd.enumeraciones.Update(cambiarFecha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static List<enumeraciones> devolverListadoOrdenadoEnumeracion(tsHerramientasCACOA bd, string codigoEnumeracion)
|
||||||
|
{
|
||||||
|
return bd.enumeraciones.Where(x => x.Codigo.Contains(codigoEnumeracion + ".")).OrderBy(x => x.Orden).ToList();
|
||||||
|
}
|
||||||
|
public enum TiposSimulaciones
|
||||||
|
{
|
||||||
|
CASA,
|
||||||
|
BAJA,
|
||||||
|
LICITACIONCASA,
|
||||||
|
URBAN,
|
||||||
|
URBANDSIMP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
HerramientaCASA/ViewModel/ClonarDespachoVM.cs
Normal file
11
HerramientaCASA/ViewModel/ClonarDespachoVM.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using bdHerramientaCACOA;
|
||||||
|
using bdHerramientaCACOA.HerramientaURBAN;
|
||||||
|
|
||||||
|
namespace HerramientaCASA.ViewModel
|
||||||
|
{
|
||||||
|
public class ClonarDespachoVM
|
||||||
|
{
|
||||||
|
public int idSimulacion { get; set; }
|
||||||
|
public CASA.CASADespachoProfesional despachoProf { get; set; } = new CASA.CASADespachoProfesional();
|
||||||
|
}
|
||||||
|
}
|
||||||
23
HerramientaCASA/ViewModel/ConvenioProvincia.cs
Normal file
23
HerramientaCASA/ViewModel/ConvenioProvincia.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace HerramientaCASA.ViewModel
|
||||||
|
{
|
||||||
|
public class ConvenioProvincia
|
||||||
|
{
|
||||||
|
public int id { get; set; } = 0;
|
||||||
|
|
||||||
|
public string? idProvincia { get; set; } = "";
|
||||||
|
public string? NombreProvincia { get; set; } = "";
|
||||||
|
|
||||||
|
public int idGradoSup { get; set; } = 0;
|
||||||
|
public double valorGradoSup { get; set; } = 0;
|
||||||
|
|
||||||
|
public int idGradoMedio { get; set; } = 0;
|
||||||
|
public double valorGradoMed { get; set; } = 0;
|
||||||
|
|
||||||
|
public int idDelinPro { get; set; } = 0;
|
||||||
|
public double valorDelinPro { get; set; } = 0;
|
||||||
|
|
||||||
|
public int idAdmin { get; set; } = 0;
|
||||||
|
public double valorAdmin { get; set; } = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
HerramientaCASA/ViewModel/LoginVM.cs
Normal file
12
HerramientaCASA/ViewModel/LoginVM.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace HerramientaCASA.ViewModel
|
||||||
|
{
|
||||||
|
public class LoginVM
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "El código es obligatorio.")]
|
||||||
|
public int? codigo { get; set; }
|
||||||
|
[Required(ErrorMessage = "La contraseña es obligatoria.")]
|
||||||
|
public string? password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
8
HerramientaCASA/appsettings.Development.json
Normal file
8
HerramientaCASA/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
HerramientaCASA/appsettings.json
Normal file
13
HerramientaCASA/appsettings.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"WriteConnection": "Server=77.229.174.85;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;",
|
||||||
|
"ReadOnlyConnection": "Server=77.229.174.85;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
BIN
HerramientaCASA/wwwroot/Content/Imagenes/CACOA-6.png
Normal file
BIN
HerramientaCASA/wwwroot/Content/Imagenes/CACOA-6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
BIN
HerramientaCASA/wwwroot/Content/Imagenes/logo_CACOA_alta.jpg
Normal file
BIN
HerramientaCASA/wwwroot/Content/Imagenes/logo_CACOA_alta.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
792
HerramientaCASA/wwwroot/Content/Site.css
Normal file
792
HerramientaCASA/wwwroot/Content/Site.css
Normal file
@@ -0,0 +1,792 @@
|
|||||||
|
|
||||||
|
body {
|
||||||
|
padding-top: 54px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logoCacoa {
|
||||||
|
border-radius: 10px !important;
|
||||||
|
}
|
||||||
|
.navCACOA {
|
||||||
|
background-color: rgb(215 236 239) !important;
|
||||||
|
border-bottom: 1px solid #0098a6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Fuente2 {
|
||||||
|
color: #79b6bc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlaceCACOA {
|
||||||
|
color: #004f58;
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
|
||||||
|
.UpdateCacoa {
|
||||||
|
background-color: red;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 5px;
|
||||||
|
padding-left:15px;
|
||||||
|
}
|
||||||
|
.UpdateCacoa span {
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inputTabla {
|
||||||
|
padding: 0px;
|
||||||
|
font-size: 12px;
|
||||||
|
border: 1px solid gray;
|
||||||
|
width: 100%;
|
||||||
|
/* border-bottom: 1px solid; */
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.selectTabla {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
.tablaAlter {
|
||||||
|
|
||||||
|
}
|
||||||
|
.tablaAlter tr td {
|
||||||
|
padding: 5px;
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdAlter {
|
||||||
|
font-weight: bold;
|
||||||
|
background: #ffc107;
|
||||||
|
/*color: white;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdAlterSub {
|
||||||
|
background: #ffc107;
|
||||||
|
font-size:15px;
|
||||||
|
text-align:end;
|
||||||
|
/*color: white;*/
|
||||||
|
}
|
||||||
|
.hrCasa {
|
||||||
|
color: #009fab;
|
||||||
|
height: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.w4 {
|
||||||
|
width:40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.separatorLine {
|
||||||
|
border-bottom: 2px solid lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.TituloArea {
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #a2ccd1 !important;
|
||||||
|
width: 100%;
|
||||||
|
left: 0;
|
||||||
|
top: 56px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white !important;
|
||||||
|
text-align: center;
|
||||||
|
position: sticky;
|
||||||
|
z-index: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.TituloArea a.navbar-brand {
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tituloZona {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #007782;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tituloSubZona {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textoTotal {
|
||||||
|
color: #65b7c3 !important;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Hide {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fondoSuave {
|
||||||
|
background-color: #d7ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comentario {
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comentario b {
|
||||||
|
color: darkgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comentario i {
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-nowrap th, .table-nowrap td {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-nowrap th:first-child {
|
||||||
|
position: sticky;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noSticky {
|
||||||
|
position: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tHeadBlue {
|
||||||
|
background-color: #79b6bc !important;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thLightBlue {
|
||||||
|
background-color: #a2ccd1 !important;
|
||||||
|
color: darkslategray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.darkgray {
|
||||||
|
color: darkgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnBlue {
|
||||||
|
background-color: #057381 !important;
|
||||||
|
border-color: #3d959e !important;
|
||||||
|
border-radius: 5px;
|
||||||
|
color: #fff;
|
||||||
|
padding: 5px;
|
||||||
|
border: none;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
.nomSim {
|
||||||
|
white-space: nowrap;
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabBorders {
|
||||||
|
border-left: 1px solid #dee2e6;
|
||||||
|
border-bottom: 1px solid #dee2e6;
|
||||||
|
border-right: 1px solid #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros {
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
display: flex;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros:focus-within {
|
||||||
|
box-shadow: 0 0 0 0.25em rgb(13 110 253 / 25%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros input {
|
||||||
|
border: 0;
|
||||||
|
width: calc(100% - 26px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros input:focus {
|
||||||
|
border: 0px !important;
|
||||||
|
box-shadow: 0 0 0 0 rgb(13 110 253 / 25%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros i {
|
||||||
|
padding-top: 10px;
|
||||||
|
color: #899097;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filaInvisible {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros-plaintext {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros-plaintext:focus-within {
|
||||||
|
outline: -webkit-focus-ring-color auto 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros-plaintext input {
|
||||||
|
width: calc(100% - 26px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros-plaintext input:focus-visible {
|
||||||
|
outline: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.euros-plaintext i {
|
||||||
|
padding-top: 10px;
|
||||||
|
color: #899097;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lblGuardado {
|
||||||
|
margin-right: 20px;
|
||||||
|
color: #034047;
|
||||||
|
opacity: 100;
|
||||||
|
-webkit-animation: fadeIn linear 5s forwards;
|
||||||
|
-moz-animation: fadeIn linear 5s forwards;
|
||||||
|
-o-animation: fadeIn linear 5s forwards;
|
||||||
|
-ms-animation: fadeIn linear 5s forwards;
|
||||||
|
animation: fadeIn linear 5s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-moz-keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-o-keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-ms-keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorA {
|
||||||
|
/*background-color: #a9d4db !important;*/
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorAMenu {
|
||||||
|
background-color: #a9d4db !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorB {
|
||||||
|
/*background-color: #d8ebef !important;*/
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorBMenu {
|
||||||
|
background-color: #d8ebef !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorC {
|
||||||
|
/*background-color: #65b7c3 !important;*/
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorCMenu {
|
||||||
|
background-color: #65b7c3 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorD {
|
||||||
|
background-color: #91c9d2 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorDMenu {
|
||||||
|
background-color: #91c9d2 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorE {
|
||||||
|
background-color: #4aafbb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorEMenu {
|
||||||
|
background-color: #4aafbb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorF {
|
||||||
|
background-color: #0098a6 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorFMenu {
|
||||||
|
background-color: #0098a6 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorFilasIntro {
|
||||||
|
/*background-color: #caf7f5 !important;*/
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorAMenu a, .colorBMenu a, .colorCMenu a, .colorDMenu a, .colorEMenu a, .colorFMenu a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorAMenu:hover, .colorBMenu:hover, .colorCMenu:hover, .colorDMenu:hover, .colorEMenu:hover, .colorFMenu:hover {
|
||||||
|
background-color: #057381;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorAMenu:hover a, .colorBMenu:hover a, .colorCMenu:hover a, .colorDMenu:hover a, .colorEMenu:hover a, .colorFMenu:hover a {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navScroll {
|
||||||
|
display: inline-flex !important;
|
||||||
|
flex-wrap: nowrap !important;
|
||||||
|
width: 100% !important;
|
||||||
|
overflow-x: auto !important;
|
||||||
|
overflow-y: hidden !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabScreenSize {
|
||||||
|
height: calc(100vh - 175px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control + .input-group-addon:not(:first-child) {
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group .form-control:not(:first-child), .input-group-addon:not(:first-child), .input-group-btn:not(:first-child) > .btn, .input-group-btn:not(:first-child) > .btn-group > .btn, .input-group-btn:not(:first-child) > .dropdown-toggle, .input-group-btn:not(:last-child) > .btn-group:not(:first-child) > .btn, .input-group-btn:not(:last-child) > .btn:not(:first-child) {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group-addon {
|
||||||
|
padding: .5rem .75rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.25;
|
||||||
|
color: #495057;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #79b6bc;
|
||||||
|
border: 1px solid rgba(0,0,0,.15);
|
||||||
|
border-left-color: rgba(0, 0, 0, 0.15);
|
||||||
|
border-left-style: solid;
|
||||||
|
border-left-width: 1px;
|
||||||
|
border-radius: .25rem;
|
||||||
|
border-top-left-radius: 0.25rem;
|
||||||
|
border-bottom-left-radius: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group-addon a {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maxHeight {
|
||||||
|
height: calc(100vh - 40px)
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnGuardar {
|
||||||
|
background-color: #67abb2;
|
||||||
|
border-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paqueteEmpleado {
|
||||||
|
border: 2px solid #6c757d;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tituloEmpleados {
|
||||||
|
padding-left: 10px;
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trashbtn {
|
||||||
|
font-size: 15px;
|
||||||
|
padding: 0px;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 0px;
|
||||||
|
color: #2a8a94;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixHead {
|
||||||
|
position: relative;
|
||||||
|
padding: 5px;
|
||||||
|
top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Boostrap Tweaks*/
|
||||||
|
td {
|
||||||
|
border-color: #737373 !important;
|
||||||
|
}
|
||||||
|
.headNav {
|
||||||
|
color: #65b7c3 !important;
|
||||||
|
}
|
||||||
|
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-form-label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control-plaintext {
|
||||||
|
padding: 0.375rem 0.75rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textoPorcentaje {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: bold;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
border: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
color: #3d959e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-title {
|
||||||
|
color: #3d959e;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.nav-item.active {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.top-menu {
|
||||||
|
top: 6px;
|
||||||
|
right: 52px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-menu > .navbar-nav > li {
|
||||||
|
float: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.top-menu {
|
||||||
|
margin-right: -15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-auth-menu {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*DevExpress stilos*/
|
||||||
|
.btn-secondary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #2a8a94 !important;
|
||||||
|
border-color: #057381 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dxbs-table {
|
||||||
|
}
|
||||||
|
|
||||||
|
.dxbs-table th {
|
||||||
|
background-color: #67abb2 !important;
|
||||||
|
border-color: #057381 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dxbs-fixed-header-content > a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dxbs-icon {
|
||||||
|
color: #057381;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.nav-link:hover {
|
||||||
|
color: #078b98 !important;
|
||||||
|
/* font-weight: bold; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.derecha {
|
||||||
|
text-align: end;
|
||||||
|
border-right: 1px solid #a2ccd1;
|
||||||
|
border-bottom: 1px solid #a2ccd1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ulMenu li.nav-item {
|
||||||
|
/*border-right: 2px solid #afafb0;*/
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ulMenu li.nav-item a {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ulMenu li.active a {
|
||||||
|
color: #018b98 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ulMenu li.nav-item:last-child {
|
||||||
|
border-right: 0px solid #afafb0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.ulMenu li.nav-item {
|
||||||
|
border-right: 0px solid #afafb0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.dxbs-table tbody tr td a {
|
||||||
|
color: #004f58;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-item.active.page-number a {
|
||||||
|
background-color: #2a8a94;
|
||||||
|
border: 2px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-link {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.btn.btn-link.dxbs-button {
|
||||||
|
color: darkred;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
background-color: #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back {
|
||||||
|
background: #057381;
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.div-center {
|
||||||
|
width: 400px;
|
||||||
|
height: 400px;
|
||||||
|
background-color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
margin: auto;
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 1em 2em;
|
||||||
|
border-bottom: 2px solid #ccc;
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content {
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-link.active {
|
||||||
|
color: #078b98 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formatoCampos {
|
||||||
|
flex-direction: column;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tituloLbl {
|
||||||
|
padding-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inputForm {
|
||||||
|
padding: 0px !important;
|
||||||
|
padding-left:10px !important;
|
||||||
|
/*padding-right:10px;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-check-input:checked {
|
||||||
|
background-color: #018b98;
|
||||||
|
border-color: #0098a6;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.tablaCACOA {
|
||||||
|
/*margin-top: 50px;*/
|
||||||
|
margin-top: 10px;
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA2 tr td {
|
||||||
|
padding:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA thead tr th{
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA th {
|
||||||
|
text-align: center;
|
||||||
|
background-color: #79b6bc !important;
|
||||||
|
color: white !important;
|
||||||
|
text-decoration: none !important;
|
||||||
|
/*padding: 20px;*/
|
||||||
|
/*padding-inline: 30px;*/
|
||||||
|
border-inline: solid 1px white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA th .btn-link {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA th a {
|
||||||
|
color: white !important;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA th a:hover {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablaCACOA td {
|
||||||
|
/* padding: 15px !important;
|
||||||
|
padding-inline: 30px !important;*/
|
||||||
|
border: solid 1px black;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.tdAlineadoDerecha {
|
||||||
|
text-align: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formatoMoneda {
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 5px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CajaTab {
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
border-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.botonesTabla {
|
||||||
|
width: 80px;
|
||||||
|
text-align: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alturaTitulosTabla {
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnTablasEspaciado {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
.btnBorrarGuardar {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.23em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cambiar para ver como se ve el info */
|
||||||
|
.tooltip .tooltip-inner {
|
||||||
|
background-color: #e0f0ff !important;
|
||||||
|
color: #000 !important;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna3Ancho {
|
||||||
|
width: 3%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna10Ancho {
|
||||||
|
width: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna20Ancho{
|
||||||
|
width:20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna30Ancho {
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna40Ancho {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna50Ancho {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.separadorMoneda {
|
||||||
|
margin-right: 8px;
|
||||||
|
gap:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Esto es para que el "no hay mas registros" no tenga margenes*/
|
||||||
|
.my-5 {
|
||||||
|
margin-top:0px !important;
|
||||||
|
margin-bottom:0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-check {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkTabla div {
|
||||||
|
min-height: 12px;
|
||||||
|
}
|
||||||
|
.checkGordo {
|
||||||
|
padding: 0;
|
||||||
|
width: 13px;
|
||||||
|
height: 13px;
|
||||||
|
border: 1px solid #057381 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.TituloVentana {
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #018b98;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
padding-left: 15px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
}
|
||||||
9
HerramientaCASA/wwwroot/Content/all.min.css
vendored
Normal file
9
HerramientaCASA/wwwroot/Content/all.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user