155 lines
3.7 KiB
C#
155 lines
3.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using NKC.Data.DTO;
|
|
using REMAN.Data;
|
|
|
|
namespace REMAN.Pages
|
|
{
|
|
public partial class Materials : ComponentBase, IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
private List<MaterialDTO> ListRecords = null!;
|
|
private List<MaterialDTO> SearchRecords = null!;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int _currPage { get; set; } = 1;
|
|
|
|
private int _numRecord { get; set; } = 10;
|
|
|
|
private int currPage
|
|
{
|
|
get => _currPage;
|
|
set
|
|
{
|
|
if (_currPage != value)
|
|
{
|
|
_currPage = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int MatIdSel
|
|
{
|
|
get
|
|
{
|
|
return AppMService.MatIdSel;
|
|
}
|
|
set
|
|
{
|
|
AppMService.MatIdSel = value;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
private int numRecord
|
|
{
|
|
get => _numRecord;
|
|
set
|
|
{
|
|
if (_numRecord != value)
|
|
{
|
|
_numRecord = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
|
|
protected MessageService AppMService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected RDataService DataService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
protected int totalCount
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (SearchRecords != null)
|
|
{
|
|
answ = SearchRecords.Count;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await DataService.MaterialsGetAll();
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
//SelPlantId = 0;
|
|
//SelTranspId = 0;
|
|
//AppMService.ShowSearch = false;
|
|
//AppMService.PageName = "Fornitore";
|
|
//AppMService.PageIcon = "fas fa-industry pr-2";
|
|
//AppMService.EA_SearchUpdated += OnSeachUpdated;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected void ResetData()
|
|
{
|
|
//DataService.rollBackEdit(currRecord);
|
|
}
|
|
|
|
protected void Select(MaterialDTO selRecord)
|
|
{
|
|
MatIdSel = selRecord.MatID;
|
|
// rimando a remnants
|
|
NavManager.NavigateTo($"Remnants");
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
//AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |