Files
mapo-core/MP.SPEC/Pages/PARAMS.razor.cs
T
2022-09-14 14:34:30 +02:00

193 lines
4.7 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.SPEC.Components;
using MP.SPEC.Data;
namespace MP.SPEC.Pages
{
public partial class PARAMS
{
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MpDataService MDService { get; set; }
[Inject]
protected MessageService MsgService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
#endregion Protected Properties
#region Protected Methods
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected async Task pgResetReq(bool doReset)
{
if (doReset)
{
await pagerODL.resetCurrPage();
}
}
private MP.Data.DatabaseModels.ODLModel? currRecordOdl = null;
private MP.Data.DatabaseModels.PODLModel? currRecordPOdl = null;
/// <summary>
/// Crea nuovo record e va in editing...
/// </summary>
/// <returns></returns>
protected async Task addNew()
{
currRecordPOdl = new MP.Data.DatabaseModels.PODLModel()
{
CodArticolo = $"_NEW_{DateTime.Now:yyyyMMdd.HHmmss}"
};
await Task.Delay(1);
}
protected async Task cancel()
{
currRecordOdl = null;
currRecordPOdl = null;
await reloadData();
await Task.Delay(1);
}
protected DataPager pagerODL;
protected bool reqNew = false;
/// <summary>
/// Crea nuovo record e va in editing...
/// </summary>
/// <returns></returns>
protected async Task reqNewPODL()
{
reqNew = !reqNew;
await Task.Delay(1);
}
protected override async Task OnInitializedAsync()
{
// abilito ricerca...
MsgService.ShowSearch = true;
// resetto search
MsgService.SearchVal = "";
//ListAziende = await MDService.ElencoAziende();
//ListStati = await MDService.AnagStatiComm();
ListMacchine = await MDService.MacchineGetAll();
ListFlux = await MDService.ParametriGetFilt(selMacchina);
// carico dati
await reloadData();
}
private string currMacchina { get; set; } = "*";
private List<MP.Data.DatabaseModels.AnagGruppi>? ListAziende;
#endregion Protected Methods
#region Private Fields
private List<MP.Data.DatabaseModels.ListValues>? ListStati;
private List<MP.Data.DatabaseModels.Macchine>? ListMacchine;
private List<string>? ListFlux;
#endregion Private Fields
#region Private Properties
private int currPage
{
get => MsgService.currPage;
set => MsgService.currPage = value;
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => MsgService.numRecord;
set => MsgService.numRecord = value;
}
private string selMacchina { get; set; } = "*";
#if false
private string selStato
{
get => _selStato;
set
{
if (!_selStato.Equals(value))
{
_selStato = value;
addEnabled = selStato != "*";
////StateHasChanged();
//var pUpd = Task.Run(async () =>
//{
// //await reloadData();
// await Task.Delay(1);
// await InvokeAsync(() => StateHasChanged());
//});
//pUpd.Wait();
}
}
}
#endif
private bool addEnabled = false;
private int totalCount
{
get => MsgService.totalCount;
set => MsgService.totalCount = value;
}
#endregion Private Properties
#region Private Methods
private async Task reloadData()
{
isLoading = true;
await Task.Delay(1);
if (currMacchina != "*")
{
ListFlux = await MDService.ParametriGetFilt(selMacchina);
}
else
{
ListFlux = new List<string>();
}
isLoading = false;
}
#endregion Private Methods
}
}