111 lines
3.0 KiB
C#
111 lines
3.0 KiB
C#
using EgwCoreLib.Utils;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace EgwCoreLib.Razor
|
|
{
|
|
public partial class PeriodoSel
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public DtUtils.Periodo CurrPeriodo
|
|
{
|
|
get => currPeriodo;
|
|
set
|
|
{
|
|
if (currPeriodo != value)
|
|
{
|
|
currPeriodo = value;
|
|
E_PeriodoSel.InvokeAsync(CurrPeriodo);
|
|
}
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public Dictionary<DtUtils.PeriodSet, string>? DictSelect { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<DtUtils.Periodo> E_PeriodoSel { get; set; }
|
|
|
|
[Parameter]
|
|
public string PeriodoLabel { get; set; } = "Periodo";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await E_PeriodoSel.InvokeAsync(CurrPeriodo);
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
// se fosse vuoto il dizionario lo preparo...
|
|
if (DictSelect == null || DictSelect.Count == 0)
|
|
{
|
|
// inizializzo!
|
|
DictSelect = Enum.GetValues(typeof(DtUtils.PeriodSet))
|
|
.Cast<DtUtils.PeriodSet>()
|
|
.ToDictionary(e => e, e => $"{e}");
|
|
}
|
|
|
|
}
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private DtUtils.Periodo currPeriodo { get; set; } = new DtUtils.Periodo();
|
|
|
|
private DateTime Fine
|
|
{
|
|
get => CurrPeriodo.Fine;
|
|
set
|
|
{
|
|
if (CurrPeriodo.Fine != value)
|
|
{
|
|
CurrPeriodo.Fine = value;
|
|
perSelect = $"{DtUtils.PeriodSet.Select}";
|
|
E_PeriodoSel.InvokeAsync(CurrPeriodo);
|
|
}
|
|
}
|
|
}
|
|
|
|
private DateTime Inizio
|
|
{
|
|
get => CurrPeriodo.Inizio;
|
|
set
|
|
{
|
|
if (CurrPeriodo.Inizio != value)
|
|
{
|
|
CurrPeriodo.Inizio = value;
|
|
perSelect = $"{DtUtils.PeriodSet.Select}";
|
|
E_PeriodoSel.InvokeAsync(CurrPeriodo);
|
|
}
|
|
}
|
|
}
|
|
|
|
#if false
|
|
private List<string> periodList { get => Enum.GetNames(typeof(DtUtils.PeriodSet)).ToList(); }
|
|
#endif
|
|
|
|
private string perSelect { get; set; } = "Select";
|
|
|
|
private string PerSelect
|
|
{
|
|
get => perSelect;
|
|
set
|
|
{
|
|
if (perSelect != value)
|
|
{
|
|
perSelect = value;
|
|
// effettuo preselezione...
|
|
Enum.TryParse(value, out DtUtils.PeriodSet newPer);
|
|
CurrPeriodo = new DtUtils.Periodo(newPer);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |