5d72d21fb1
Update gestione paginazione (visibile solo dove serve) + fix calcolo di alcuni intems male filtrati
175 lines
4.0 KiB
C#
175 lines
4.0 KiB
C#
using LiMan.GLS.DatabaseModels;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiMan.UI.Pages
|
|
{
|
|
public partial class LicenseManager : ComponentBase, IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
private LicenzeAttive currRecord = null;
|
|
private List<LicenzeAttive> ListRecords;
|
|
private List<LicenzeAttive> SearchRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Protected Fields
|
|
|
|
protected int totalCount = 0;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get
|
|
{
|
|
return AppMService.PageNum;
|
|
}
|
|
set
|
|
{
|
|
AppMService.PageNum = value;
|
|
}
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int numRecord
|
|
{
|
|
get
|
|
{
|
|
return AppMService.PageSize;
|
|
}
|
|
set
|
|
{
|
|
AppMService.PageSize = value;
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMService { get; set; }
|
|
|
|
[Inject]
|
|
protected LiManDataService DataService { get; set; }
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; }
|
|
|
|
protected bool showCamera { get; set; } = false;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadAllData()
|
|
{
|
|
isLoading = true;
|
|
await Task.Delay(1);
|
|
//SearchRecords = null;
|
|
SearchRecords = await DataService.LicenzeGLSGetAll();
|
|
totalCount = SearchRecords.Count();
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// formatta testo secondo scadenza:
|
|
/// scadenza > 60gg --> verde
|
|
/// 0 < scadenza < 60 gg --> giallo
|
|
/// scadenza < 0 --> rosso
|
|
/// </summary>
|
|
/// <param name="scadenza"></param>
|
|
/// <returns></returns>
|
|
protected string cssScadenza(DateTime scadenza)
|
|
{
|
|
string answ = "text-dark";
|
|
double periodo = scadenza.Subtract(DateTime.Today).TotalDays;
|
|
if (periodo > 60)
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
else if (periodo > 0)
|
|
{
|
|
answ = "text-warning";
|
|
}
|
|
else
|
|
{
|
|
answ = "text-danger";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
protected void Edit(LicenzeAttive selRecord)
|
|
{
|
|
currRecord = selRecord;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task SetNumRec(int newNum)
|
|
{
|
|
currPage = 1;
|
|
numRecord = newNum;
|
|
await ReloadAllData();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected async Task SetCurrPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
await ReloadAllData();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void ResetData()
|
|
{
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(int IdxLic)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.IdxLic == IdxLic) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |