@@ -154,8 +184,15 @@
{
|
-
-
+
+ @if (record.Tipo.Equals("KIT"))
+ {
+
+ }
+ else
+ {
+
+ }
|
@record.CodArticolo
@@ -171,7 +208,7 @@
|
@record.Azienda |
- @if (ArticoloDelEnabled(record.CodArticolo))
+ @if (ArticoloDelEnabled(record))
{
}
@@ -191,7 +228,7 @@
\ No newline at end of file
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs
index ce9bd81e..7e531d58 100644
--- a/MP.SPEC/Pages/Articoli.razor.cs
+++ b/MP.SPEC/Pages/Articoli.razor.cs
@@ -26,16 +26,6 @@ namespace MP.SPEC.Pages
GC.Collect();
}
- public async void OnSeachUpdated()
- {
- await InvokeAsync(() =>
- {
- currPage = 1;
- Task task = UpdateData();
- StateHasChanged();
- });
- }
-
#endregion Public Methods
#region Protected Properties
@@ -49,10 +39,7 @@ namespace MP.SPEC.Pages
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
- protected string searchCss
- {
- get => string.IsNullOrEmpty(searchVal) ? "btn-secondary" : "btn-primary";
- }
+ private string searchCss => string.IsNullOrEmpty(searchVal) ? "btn-secondary" : "btn-primary";
protected string SearchVal
{
@@ -62,35 +49,12 @@ namespace MP.SPEC.Pages
// salvo solo se 3+ chars
if (value.Length > 2 || string.IsNullOrEmpty(value))
{
- if (searchVal != value)
- {
- searchVal = value;
-#if false
- var pUpd = Task.Run(async () =>
- {
- ListRecords = null;
- await Task.Delay(1);
- await ReloadDataAsync();
- });
- pUpd.Wait();
-#endif
- }
+ searchVal = value;
}
}
}
- protected int totalCount
- {
- get
- {
- int answ = 0;
- if (SearchRecords != null)
- {
- answ = SearchRecords.Count;
- }
- return answ;
- }
- }
+ protected int totalCount = 0;
#endregion Protected Properties
@@ -100,30 +64,26 @@ namespace MP.SPEC.Pages
/// Crea nuovo record e va in editing...
///
///
- protected async Task addNew()
+ protected void AddNew()
{
isNewArt = true;
currRecord = new AnagArticoliModel()
{
CodArticolo = $"_NEW_{DateTime.Now:yyyyMMdd.HHmmss}",
DescArticolo = "Nuovo articolo",
- Azienda = selAzienda != "*" ? selAzienda : "MAPO",
+ Azienda = !selAzienda.Equals("*") ? selAzienda : "MAPO",
Disegno = "",
- Tipo = "ART",
+ Tipo = !selTipoArt.Equals("*") ? selTipoArt : "ART",
CurrRev = "",
ProdRev = ""
};
- await Task.Delay(1);
}
- protected async Task cancel()
- {
- currRecord = null;
- await ReloadDataAsync();
- await Task.Delay(1);
- }
-
- protected async Task cloneRecord(AnagArticoliModel selRec)
+ ///
+ /// Cloning record
+ ///
+ ///
+ protected void cloneRecord(AnagArticoliModel selRec)
{
isNewArt = true;
// creo record duplicato...
@@ -138,7 +98,6 @@ namespace MP.SPEC.Pages
ProdRev = ""
};
currRecord = newRec;
- await Task.Delay(1);
}
///
@@ -184,10 +143,10 @@ namespace MP.SPEC.Pages
currRecord = null;
}
- protected async Task resetSearch()
+ protected async Task ResetSearch()
{
SearchVal = "";
- await ReloadDataAsync();
+ await ResetDataAsync();
}
protected async Task resetSel()
@@ -204,19 +163,18 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
}
- protected async Task update(AnagArticoliModel selRec)
+ protected async Task UpdateAsync(AnagArticoliModel selRec)
{
if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?"))
return;
- await Task.Delay(1);
+
var done = await MDService.ArticoliUpdateRecord(selRec);
- currRecord = null;
- await ReloadDataAsync();
- await Task.Delay(1);
+ await ResetDataAsync();
}
- protected async Task UpdateData()
+ protected async Task ResetDataAsync()
{
+ currPage = 1;
currRecord = null;
await ReloadDataAsync();
}
@@ -239,9 +197,8 @@ namespace MP.SPEC.Pages
#region Private Properties
- private int _currPage { get; set; } = 1;
- private int _numRecord { get; set; } = 10;
- private string chkDisabled => isNewArt ? "" : "disabled";
+ private int _currPage = 1;
+ private int _numRecord = 10;
private int currPage
{
@@ -281,26 +238,14 @@ namespace MP.SPEC.Pages
if (value != _selAzienda)
{
_selAzienda = value;
-#if false
- var pUpd = Task.Run(async () =>
- {
- // svuoto cache redis...
- ConfigModel updRec = new ConfigModel()
- {
- Chiave = "AZIENDA",
- Valore = value
- };
- MDService.ConfigUpdate(updRec);
- await MDService.ConfigResetCache();
- // ricarico
- await Task.Delay(1);
- await ReloadDataAsync();
- });
- pUpd.Wait();
-#endif
}
}
}
+ ///
+ /// Tipo articolo selezionato
+ ///
+ private string selTipoArt = "*";
+
private async Task ReloadAziendaAsync()
{
isLoading = true;
@@ -313,7 +258,7 @@ namespace MP.SPEC.Pages
await MDService.ConfigUpdateAsync(updRec);
await MDService.ConfigResetCache();
// ricarico
- await ReloadDataAsync();
+ await ResetDataAsync();
}
@@ -328,9 +273,12 @@ namespace MP.SPEC.Pages
///
///
///
- private bool ArticoloDelEnabled(string codArt)
+ private bool ArticoloDelEnabled(AnagArticoliModel currRec)
{
- return MDService.ArticoloDelEnabled(codArt);
+ if (currRec.Tipo.Equals("KIT"))
+ return false;
+
+ return MDService.ArticoloDelEnabled(currRec.CodArticolo);
}
private async Task ReloadBaseData()
@@ -345,10 +293,16 @@ 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;
- SearchRecords = await MDService.ArticoliGetSearchAsync(maxNumRecord, selAzienda, SearchVal);
+ SearchRecords = await MDService.ArticoliGetSearchAsync(maxNumRecord, selTipoArt, selAzienda, SearchVal);
+ totalCount = SearchRecords.Count;
UpdateTable();
}
|