- @if (ListRecords == null || isLoading)
+ @if (isLoading && false)
{
}
@@ -176,7 +176,7 @@
@if (currRecord != null)
{
-
+
}
|
Articolo |
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs
index 2981dbed..601fff15 100644
--- a/MP.SPEC/Pages/Articoli.razor.cs
+++ b/MP.SPEC/Pages/Articoli.razor.cs
@@ -28,20 +28,88 @@ namespace MP.SPEC.Pages
#endregion Public Methods
- #region Protected Properties
+ #region Protected Methods
+
+ protected override async Task OnInitializedAsync()
+ {
+ numRecord = 10;
+ await ReloadBaseData();
+ }
+
+ protected override async Task OnParametersSetAsync()
+ {
+ await ReloadDataAsync();
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private int _currPage = 1;
+ private int _numRecord = 10;
+ private string _selAzienda = "*";
+ private int availRecord = 1000;
+ private SelectArticoliParams currFilter = new SelectArticoliParams();
+ private AnagArticoliModel? currRecord = null;
+ private bool isLoading = false;
+ private bool isNewArt = false;
+ private List
? ListAziende;
+ private List? ListRecords;
+ private List? ListTipoArt;
+ private int maxNumRecord = 1000;
+ private List? SearchRecords;
+ private string selTipoArt = "*";
+ private int totalCount = 0;
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ ///
+ /// Verifica cablata x add tutto tranne KIT
+ ///
+ private bool CanAdd => !selTipoArt.Equals("KIT");
+
+ private int currPage
+ {
+ get => _currPage;
+ set
+ {
+ if (_currPage != value)
+ {
+ _currPage = value;
+ UpdateTable();
+ }
+ }
+ }
[Inject]
- protected IJSRuntime JSRuntime { get; set; } = null!;
+ private IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
- protected MpDataService MDService { get; set; } = null!;
+ private MpDataService MDService { get; set; } = null!;
[Inject]
- protected NavigationManager NavManager { get; set; } = null!;
+ private NavigationManager NavManager { get; set; } = null!;
+
+ private int numRecord
+ {
+ get => _numRecord;
+ set
+ {
+ if (_numRecord != value)
+ {
+ _numRecord = value;
+ UpdateTable();
+ }
+ }
+ }
private string searchCss => string.IsNullOrEmpty(searchVal) ? "btn-secondary" : "btn-primary";
- protected string SearchVal
+ private string searchVal { get; set; } = "";
+
+ private string SearchVal
{
get => searchVal;
set
@@ -54,17 +122,29 @@ namespace MP.SPEC.Pages
}
}
- protected int totalCount = 0;
+ private string selAzienda
+ {
+ get => _selAzienda;
+ set
+ {
+ if (value != _selAzienda)
+ {
+ _selAzienda = value;
+ }
+ }
+ }
- #endregion Protected Properties
+ private bool ShowCharts { get; set; } = false;
- #region Protected Methods
+ #endregion Private Properties
+
+ #region Private Methods
///
/// Crea nuovo record e va in editing...
///
///
- protected void AddNew()
+ private void AddNew()
{
isNewArt = true;
currRecord = new AnagArticoliModel()
@@ -79,11 +159,24 @@ namespace MP.SPEC.Pages
};
}
+ ///
+ /// Verifica cancellabilità record
+ ///
+ ///
+ ///
+ private bool ArticoloDelEnabled(AnagArticoliModel currRec)
+ {
+ if (currRec.Tipo.Equals("KIT"))
+ return false;
+
+ return MDService.ArticoloDelEnabled(currRec.CodArticolo);
+ }
+
///
/// Cloning record
///
///
- protected void cloneRecord(AnagArticoliModel selRec)
+ private void cloneRecord(AnagArticoliModel selRec)
{
isNewArt = true;
// creo record duplicato...
@@ -105,7 +198,7 @@ namespace MP.SPEC.Pages
///
///
///
- protected async Task deleteRecord(AnagArticoliModel selRec)
+ private async Task deleteRecord(AnagArticoliModel selRec)
{
if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione Articolo: sei sicuro di voler procedere?"))
return;
@@ -116,139 +209,16 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
}
- protected void ForceReload(int newNum)
+ private void ForceReload(int newNum)
{
numRecord = newNum;
}
- protected void ForceReloadPage(int newNum)
+ private void ForceReloadPage(int newNum)
{
currPage = newNum;
}
- protected override async Task OnInitializedAsync()
- {
- numRecord = 10;
- await ReloadBaseData();
- }
-
- protected override async Task OnParametersSetAsync()
- {
- await ReloadDataAsync();
- }
-
- protected void ResetData()
- {
- isNewArt = false;
- currRecord = null;
- }
-
- protected async Task ResetSearch()
- {
- SearchVal = "";
- await ResetDataAsync();
- }
-
- protected async Task resetSel()
- {
- isNewArt = false;
- currRecord = null;
- await ResetDataAsync();
- }
-
- protected async Task selRecord(AnagArticoliModel selRec)
- {
- isNewArt = false;
- currRecord = selRec;
- await Task.Delay(1);
- }
-
- protected async Task UpdateAsync(AnagArticoliModel selRec)
- {
- if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?"))
- return;
-
- var done = await MDService.ArticoliUpdateRecord(selRec);
- await ResetDataAsync();
- }
-
- protected async Task ResetDataAsync()
- {
- currPage = 1;
- currRecord = null;
- await MDService.FlushFusionCacheArticoli();
- await ReloadDataAsync();
- }
-
- #endregion Protected Methods
-
- #region Private Fields
-
- private string _selAzienda = "*";
- private SelectArticoliParams currFilter = new SelectArticoliParams();
- private AnagArticoliModel? currRecord = null;
- private bool isNewArt = false;
- private List? ListAziende;
- private List? ListRecords;
- private List? ListTipoArt;
- private int maxNumRecord = 1000;
- private int availRecord = 1000;
- private int totRecord = 0;
- private List? SearchRecords;
-
- #endregion Private Fields
-
- #region Private Properties
-
- private int _currPage = 1;
- private int _numRecord = 10;
-
- private int currPage
- {
- get => _currPage;
- set
- {
- if (_currPage != value)
- {
- _currPage = value;
- UpdateTable();
- }
- }
- }
-
- private bool isLoading { get; set; } = false;
-
- private int numRecord
- {
- get => _numRecord;
- set
- {
- if (_numRecord != value)
- {
- _numRecord = value;
- UpdateTable();
- }
- }
- }
-
- private string searchVal { get; set; } = "";
-
- private string selAzienda
- {
- get => _selAzienda;
- set
- {
- if (value != _selAzienda)
- {
- _selAzienda = value;
- }
- }
- }
- ///
- /// Tipo articolo selezionato
- ///
- private string selTipoArt = "*";
-
private async Task ReloadAziendaAsync()
{
isLoading = true;
@@ -264,28 +234,9 @@ namespace MP.SPEC.Pages
await ResetDataAsync();
}
-
- private bool ShowCharts { get; set; } = false;
-
- #endregion Private Properties
-
- #region Private Methods
-
- ///
- /// Verifica cancellabilità record
- ///
- ///
- ///
- private bool ArticoloDelEnabled(AnagArticoliModel currRec)
- {
- if (currRec.Tipo.Equals("KIT"))
- return false;
-
- return MDService.ArticoloDelEnabled(currRec.CodArticolo);
- }
-
private async Task ReloadBaseData()
{
+ isLoading = true;
await MDService.EnsureArtCacheLoadedAsync(true);
selAzienda = await MDService.ConfigTryGetAsync("AZIENDA");
if (string.IsNullOrEmpty(selAzienda))
@@ -296,11 +247,6 @@ namespace MP.SPEC.Pages
ListTipoArt = await MDService.AnagTipoArtLvAsync();
}
- ///
- /// Verifica cablata x add tutto tranne KIT
- ///
- private bool CanAdd => !selTipoArt.Equals("KIT");
-
private async Task ReloadDataAsync()
{
isLoading = true;
@@ -310,9 +256,55 @@ namespace MP.SPEC.Pages
UpdateTable();
}
+ private void ResetData()
+ {
+ isNewArt = false;
+ currRecord = null;
+ }
+
+ private async Task ResetDataAsync()
+ {
+ currPage = 1;
+ currRecord = null;
+ await MDService.FlushFusionCacheArticoli();
+ await ReloadDataAsync();
+ }
+
+ private async Task ResetSearch()
+ {
+ SearchVal = "";
+ await ResetDataAsync();
+ }
+
+ private async Task ResetSel()
+ {
+ isNewArt = false;
+ currRecord = null;
+ await ResetDataAsync();
+ }
+
+ private async Task selRecord(AnagArticoliModel selRec)
+ {
+ isNewArt = false;
+ currRecord = selRec;
+ await Task.Delay(1);
+ }
+
+ private async Task UpdateAsync(AnagArticoliModel selRec)
+ {
+ if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?"))
+ return;
+
+ var done = await MDService.ArticoliUpsertRecord(selRec);
+ await ResetDataAsync();
+ }
+
private void UpdateTable()
{
- ListRecords = SearchRecords?.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList() ?? new();
+ ListRecords = SearchRecords?
+ .Skip(numRecord * (currPage - 1))
+ .Take(numRecord)
+ .ToList() ?? new();
isLoading = false;
}