4fda312aac
- altri metodi tracciati - modifica json x prod - aggiunta Async vari
240 lines
9.4 KiB
Plaintext
240 lines
9.4 KiB
Plaintext
@using GWMS.UI.Components
|
|
@using GWMS.Data.DatabaseModels
|
|
@using System.Security.Claims
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@using GWMS.UI.Data
|
|
@using GWMS.Data.DTO
|
|
@using Microsoft.Extensions.Configuration
|
|
|
|
@inject MessageService AppMService
|
|
@inject GWMSDataService DataService
|
|
@inject IConfiguration Configuration
|
|
@inject IJSRuntime JSRuntime
|
|
|
|
<div class="card">
|
|
<div class="card-header bg-info text-light">
|
|
<b>Modifica</b>
|
|
</div>
|
|
<div class="card-body small p-1">
|
|
<EditForm Model="@_currItem">
|
|
<DataAnnotationsValidator />
|
|
<div class="row">
|
|
<div class="col-10 col-lg-11">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-gas-pump" aria-hidden="true"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.PlantId" class="form-control form-control-sm">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (PlantsList != null)
|
|
{
|
|
foreach (var item in PlantsList)
|
|
{
|
|
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-4">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-industry" aria-hidden="true"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.SupplierId" class="form-control form-control-sm">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (SuppliersList != null)
|
|
{
|
|
foreach (var item in SuppliersList)
|
|
{
|
|
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-4">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-truck-moving" aria-hidden="true"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.TransporterId" class="form-control form-control-sm" title="Trasportatore">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (TransportersList != null)
|
|
{
|
|
foreach (var item in TransportersList)
|
|
{
|
|
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-2">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-calendar-day"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.DayNum" class="form-control" title="Giorno">
|
|
@foreach (var itemVal in Enum.GetValues(typeof(DayOfWeek)))
|
|
{
|
|
<option>@itemVal</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-2">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="far fa-clock"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.DeliveryHour" class="form-control" title="Ora">
|
|
@for (int iHour = 0; iHour < 24; iHour++)
|
|
{
|
|
<option>@iHour</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-4">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="far fa-sticky-note"></i>
|
|
</span>
|
|
</div>
|
|
<InputText @bind-Value="_currItem.Note" class="form-control" title="Qty" />
|
|
</div>
|
|
</div>
|
|
<div class="col-2">
|
|
@if (showSave)
|
|
{
|
|
<button type="button" class="btn btn-sm btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
|
|
}
|
|
</div>
|
|
<div class="col-2">
|
|
<button type="button" class="btn btn-sm btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-2 col-lg-1">
|
|
<button type="button" class="btn btn-sm btn-danger btn-block" value="Delete" @onclick="deleteRecord">Delete <i class="fas fa-trash"></i></button>
|
|
</div>
|
|
</div>
|
|
</EditForm>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private List<PlantDetailModel> PlantsList;
|
|
private List<SupplierModel> SuppliersList;
|
|
private List<TransporterModel> TransportersList;
|
|
|
|
protected WeekPlanModel _currItem = new WeekPlanModel();
|
|
protected int _supplierId { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public WeekPlanModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem = null;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
protected bool showSave
|
|
{
|
|
get
|
|
{
|
|
bool answ = (_currItem.PlantId > 0 && _currItem.SupplierId > 0 && _currItem.TransporterId > 0);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
[Parameter]
|
|
public int SupplierId
|
|
{
|
|
get
|
|
{
|
|
return _supplierId;
|
|
}
|
|
set
|
|
{
|
|
_supplierId = value;
|
|
// condiziono visualizzazione...
|
|
var pUpd = Task.Run(async () => await ReloadAllData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (_currItem != null)
|
|
{
|
|
DataService.WeekPlanUpdateAsync(_currItem);
|
|
await DataUpdated.InvokeAsync(1);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("User null!");
|
|
}
|
|
}
|
|
|
|
private async Task deleteRecord()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare la consegna selezionata??"))
|
|
return;
|
|
|
|
if (_currItem != null)
|
|
{
|
|
DataService.WeekPlanDeleteAsync(_currItem);
|
|
await DataUpdated.InvokeAsync(1);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("User null!");
|
|
}
|
|
}
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ReloadAllData()
|
|
{
|
|
PlantsList = await DataService.PlantsListAsync();
|
|
SuppliersList = await DataService.SuppliersGetAllAsync();
|
|
TransportersList = await DataService.TransportersGetAllAsync();
|
|
}
|
|
|
|
} |