176 lines
4.7 KiB
C#
176 lines
4.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class FixOdl
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> E_RefreshData { get; set; }
|
|
|
|
[Parameter]
|
|
public string IdxMaccCurr { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected bool enableRPO = true;
|
|
protected int NumRecPage = 5;
|
|
protected int PageNum = 1;
|
|
protected int TotalCount = 0;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string btnCss
|
|
{
|
|
get => showFixOdl ? "bg-dark border-warning border-2 text-light" : "btn-warning";
|
|
}
|
|
|
|
protected string faCss
|
|
{
|
|
get => showFixOdl ? "fa-chevron-up" : "fa-chevron-down";
|
|
}
|
|
|
|
protected List<ODLExpModel> ListComplete { get; set; } = new List<ODLExpModel>();
|
|
protected List<ODLExpModel> ListPaged { get; set; } = new List<ODLExpModel>();
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected NavigationManager NavMan { get; set; } = null!;
|
|
|
|
protected bool ShowAll
|
|
{
|
|
get => showAll;
|
|
set
|
|
{
|
|
if (showAll != value)
|
|
{
|
|
showAll = value;
|
|
IdxOdlSel = 0;
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await ReloadData();
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
protected string txtBtnFixOdl { get => showFixOdl ? "Nascondi Fix" : "Fix ODL"; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
enableRPO = SMServ.GetConfBool("enableRPO");
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected void SaveNumRec(int newNum)
|
|
{
|
|
NumRecPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected void SavePage(int newNum)
|
|
{
|
|
PageNum = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected async Task SetupOdl()
|
|
{
|
|
await Task.Delay(1);
|
|
if (!string.IsNullOrEmpty(IdxMaccCurr) && IdxOdlSel > 0)
|
|
{
|
|
if (enableRPO)
|
|
{
|
|
// registro ODL retroattivamente...
|
|
await TabDServ.OdlSetupPromPostuma(IdxOdlSel, MServ.MatrOpr, IdxMaccCurr);
|
|
}
|
|
else
|
|
{
|
|
// registro ODL retroattivamente...
|
|
await TabDServ.OdlSetupPostumo(IdxOdlSel, IdxMaccCurr);
|
|
}
|
|
await E_RefreshData.InvokeAsync(true);
|
|
}
|
|
|
|
// redirect
|
|
//NavMan.NavigateTo(NavMan.Uri, true);
|
|
}
|
|
|
|
protected void toggleFixOdl()
|
|
{
|
|
showFixOdl = !showFixOdl;
|
|
}
|
|
|
|
protected void UpdateTable()
|
|
{
|
|
// esegue paginazione
|
|
if (TotalCount > NumRecPage)
|
|
{
|
|
ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList();
|
|
}
|
|
else
|
|
{
|
|
ListPaged = ListComplete;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool showAll = false;
|
|
private bool showFixOdl = true;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int IdxOdlSel { get; set; } = 0;
|
|
private List<vSelOdlModel> ListSelODL { get; set; } = new List<vSelOdlModel>();
|
|
private int numDayOdl { get; set; } = 30;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
if (!string.IsNullOrEmpty(IdxMaccCurr))
|
|
{
|
|
ListSelODL = await TabDServ.VSOdlGetUnused(IdxMaccCurr, ShowAll, numDayOdl);
|
|
DateTime dateTo = DateTime.Today.AddDays(1);
|
|
DateTime dateFrom = dateTo.AddMonths(-1);
|
|
ListComplete = await TabDServ.OdlListByMaccPeriodo(IdxMaccCurr, dateFrom, dateTo);
|
|
TotalCount = ListComplete.Count;
|
|
// esegue paginazione
|
|
UpdateTable();
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |