30dac79e7c
- completato editing con delete
208 lines
5.3 KiB
C#
208 lines
5.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListPODL
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> PagerResetReq { get; set; }
|
|
|
|
|
|
[Parameter]
|
|
public EventCallback<PODLModel> RecordSel { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(string CodArticolo)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.CodArticolo == CodArticolo) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected async Task resetSel()
|
|
{
|
|
await RecordSel.InvokeAsync(null);
|
|
}
|
|
|
|
protected bool POdlDelEnabled(int idxOdl)
|
|
{
|
|
return idxOdl == 0;
|
|
}
|
|
|
|
protected async Task selRecord(PODLModel selRec)
|
|
{
|
|
await RecordSel.InvokeAsync(selRec);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Eliminazione record selezioanto (previa conferma)
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
/// <returns></returns>
|
|
protected async Task deleteRecord(PODLModel selRec)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Eliminazione Record: sei sicuro di voler procedere?"))
|
|
return;
|
|
await Task.Delay(1);
|
|
var done = await MDService.PODLDeleteRecord(selRec);
|
|
currRecord = null;
|
|
await reloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MsgService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MsgService.EA_PageUpdated += MessageService_EA_PageUpdated;
|
|
MsgService.EA_SearchUpdated += OnSeachUpdated;
|
|
MsgService.EA_StatoSearch += MsgService_EA_StatoSearch;
|
|
ListStati = await MDService.AnagStatiComm();
|
|
await reloadData();
|
|
}
|
|
|
|
protected async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
PagerResetReq.InvokeAsync(true);
|
|
//currPage = 1;
|
|
Task task = UpdateData();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currRecord = null;
|
|
await reloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private PODLModel? currRecord = null;
|
|
|
|
private List<PODLModel>? ListRecords;
|
|
|
|
private List<PODLModel>? SearchRecords;
|
|
|
|
#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 SearchVal
|
|
{
|
|
get => string.IsNullOrEmpty(MsgService.SearchVal) ? "*" : MsgService.SearchVal;
|
|
}
|
|
|
|
private string StatoSel
|
|
{
|
|
get => MsgService.StateSel;
|
|
set => MsgService.StateSel = value;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => MsgService.totalCount;
|
|
set => MsgService.totalCount = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async void MessageService_EA_PageUpdated()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
private async void MsgService_EA_StatoSearch()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
PagerResetReq.InvokeAsync(true);
|
|
//currPage = 1;
|
|
Task task = UpdateData();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
private string tradFase(string codFase)
|
|
{
|
|
string answ = codFase;
|
|
if (ListStati != null && ListStati.Count > 0)
|
|
{
|
|
var recSel = ListStati.FirstOrDefault(x => x.value == codFase);
|
|
if (recSel != null)
|
|
{
|
|
answ = recSel.label;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
|
|
private List<ListValues>? ListStati;
|
|
|
|
private async Task reloadData()
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await MDService.ListPODLFilt(SearchVal, StatoSel);
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |