From 745b5ac6a7559d54feb0a570944c2f83f785a120 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 14 Dec 2023 12:48:58 +0100 Subject: [PATCH 1/3] KIT SCARTI: - metodo gestione delete kit scarti - metodo edit Qty --- MP-TAB-SERV/Components/ScrapMan.razor.cs | 2 + MP.Data/Controllers/MpTabController.cs | 48 +++++++++ .../DatabaseModels/RegistroScartiKitModel.cs | 1 + MP.Data/Services/TabDataService.cs | 97 ++++++++++++++----- 4 files changed, 124 insertions(+), 24 deletions(-) diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index 6d23dc6d..e2df7839 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -116,6 +116,7 @@ namespace MP_TAB_SERV.Components protected async Task ShowKitDetail(RegistroScartiModel currItem) { + isProcessing = true; // deve essere != null in primis... if (currItem != null) { @@ -134,6 +135,7 @@ namespace MP_TAB_SERV.Components selItem = null; } } + isProcessing = false; } protected void UpdateTable() diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 2162756a..f04927a0 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1603,6 +1603,54 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Elimina scarti KIT dato record parent (e lo resetta) + /// + /// + /// + public bool RegScartiKitDelete(RegistroScartiModel parentRec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina); + var DtRif = new SqlParameter("@DataOra", parentRec.DataOra); + var Causale = new SqlParameter("@Causale", parentRec.Causale); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_RSK_Delete @IdxMacchina, @DataOra, @Causale", IdxMacc, DtRif, Causale); + + answ = dbResult != 0; + } + return answ; + } + /// + /// Aggiorna un record scarti KIT ( SE ESISTE...) + /// + /// + /// + public RegistroScartiKitModel RegScartiKitUpdateQty(RegistroScartiKitModel currRec) + { + RegistroScartiKitModel dbResult = new RegistroScartiKitModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetRegScartiKit + .Where(x => x.IdxMacchina == currRec.IdxMacchina && x.DataOra == currRec.DataOra && x.Causale == currRec.Causale && x.CodArticolo == currRec.CodArticolo) + .FirstOrDefault(); + + // aggiorno solo QTY + if (dbResult != null) + { + dbResult.Qta = currRec.Qta; + dbCtx.Entry(dbResult).State = EntityState.Modified; + dbCtx.SaveChanges(); + } + } + return dbResult; + } + /// /// Elenco scarti KIT dato record parent /// diff --git a/MP.Data/DatabaseModels/RegistroScartiKitModel.cs b/MP.Data/DatabaseModels/RegistroScartiKitModel.cs index ed84ff8b..1980ca3a 100644 --- a/MP.Data/DatabaseModels/RegistroScartiKitModel.cs +++ b/MP.Data/DatabaseModels/RegistroScartiKitModel.cs @@ -22,6 +22,7 @@ namespace MP.Data.DatabaseModels public string Operatore { get; set; } = ""; public int Qta { get; set; } = 0; + public int QtaMax { get; set; } = 0; public string Note { get; set; } = ""; public int MatrOpr { get; set; } = 0; public DateTime? DataOraProdRec { get; set; } = null; diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 0e93a842..4132f126 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -2122,6 +2122,54 @@ namespace MP.Data.Services return result; } + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + public async Task RegScartiInsert(RegistroScartiModel newRec) + { + bool answ = false; + try + { + // inserisco evento + answ = await dbTabController.RegScartiInsert(newRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiInsert | macchina: {newRec.IdxMacchina} | DataOra: {newRec.DataOra} | Causale: {newRec.Causale} | MatrOpr: {newRec.MatrOpr} | Qta {newRec.Qta} | Note: {newRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Elimina elenco RSK da parent + /// + /// + /// + public async Task RegScartiKitDelete(RegistroScartiModel ParentRec) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.RegScartiKitDelete(ParentRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiKitDelete | macchina: {ParentRec.IdxMacchina} | DataOra: {ParentRec.DataOra} | Causale: {ParentRec.Causale} | MatrOpr: {ParentRec.MatrOpr} | Qta {ParentRec.Qta} | Note: {ParentRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + /// /// Restituisce elenco RSK filtrato x parent /// @@ -2158,30 +2206,6 @@ namespace MP.Data.Services return result; } - /// - /// Aggiunta record RegistroScarti - /// - /// - /// - public async Task RegScartiInsert(RegistroScartiModel newRec) - { - bool answ = false; - try - { - // inserisco evento - answ = await dbTabController.RegScartiInsert(newRec); - // reset cache eventi/commenti - await FlushCache("RegScarti"); - await FlushCache("RegScartiKit"); - } - catch (Exception exc) - { - string logMsg = $"Eccezione in RegScartiInsert | macchina: {newRec.IdxMacchina} | DataOra: {newRec.DataOra} | Causale: {newRec.Causale} | MatrOpr: {newRec.MatrOpr} | Qta {newRec.Qta} | Note: {newRec.Note}{Environment.NewLine}{exc}"; - Log.Error(logMsg); - } - return answ; - } - /// /// Split record RegistroScarti --> RegistroScartiKit /// @@ -2206,6 +2230,31 @@ namespace MP.Data.Services return answ; } + /// + /// Update qty record singolo articolo di un KIT Scarti + /// + /// + /// + public async Task RegScartiKitUpdateQty(RegistroScartiKitModel editRec) + { + bool answ = false; + try + { + // aggiorno record + var updRec = dbTabController.RegScartiKitUpdateQty(editRec); + answ = updRec.Qta == editRec.Qta; + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiKitUpdateQty | macchina: {editRec.IdxMacchina} | DataOra: {editRec.DataOra} | Causale: {editRec.Causale} | MatrOpr: {editRec.MatrOpr} | Qta {editRec.Qta} | Note: {editRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + /// /// Resetta (rileggendo) i dati della macchina /// From 9c5a0c57e99e52bcffc2a1a8b56d6675c142434b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 14 Dec 2023 12:58:29 +0100 Subject: [PATCH 2/3] Ok delete kit intero --- MP-TAB-SERV/Components/ScrapKitMan.razor | 9 +++++++-- MP-TAB-SERV/Components/ScrapKitMan.razor.cs | 20 ++++++++++++++++++++ MP-TAB-SERV/Components/ScrapMan.razor | 4 ++-- MP-TAB-SERV/Components/ScrapMan.razor.cs | 19 ++++++++++++++----- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor b/MP-TAB-SERV/Components/ScrapKitMan.razor index f52bad9a..638ca44f 100644 --- a/MP-TAB-SERV/Components/ScrapKitMan.razor +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor @@ -6,8 +6,13 @@ - diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs index 3d1f352c..a5dceec4 100644 --- a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.Data.Services; using NLog; @@ -9,6 +10,9 @@ namespace MP_TAB_SERV.Components { #region Public Properties + [Parameter] + public EventCallback E_Updated { get; set; } + [Parameter] public RegistroScartiModel ParentKit { get; set; } = null!; @@ -16,6 +20,9 @@ namespace MP_TAB_SERV.Components #region Protected Properties + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + protected List ListComplete { get; set; } = new List(); protected List ListPaged { get; set; } = new List(); @@ -27,6 +34,19 @@ namespace MP_TAB_SERV.Components #region Protected Methods + protected async Task DeleteKitSplit() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il dettaglio del KIT scartato?")) + return; + + if (ParentKit != null) + { + await TabDServ.RegScartiKitDelete(ParentKit); + await ReloadData(); + await E_Updated.InvokeAsync(true); + } + } + protected override async Task OnParametersSetAsync() { await ReloadData(); diff --git a/MP-TAB-SERV/Components/ScrapMan.razor b/MP-TAB-SERV/Components/ScrapMan.razor index c9045a34..15404ad7 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor +++ b/MP-TAB-SERV/Components/ScrapMan.razor @@ -8,7 +8,7 @@ @if (enableScarti) {
- +
} else @@ -127,7 +127,7 @@ {
} diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index e2df7839..9040d15d 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -21,7 +21,7 @@ namespace MP_TAB_SERV.Components /// Aggiorno valori produzione alla data richiesta... /// /// - public async Task doUpdate() + protected async Task ReloadData() { isProcessing = true; await Task.Delay(1); @@ -36,6 +36,15 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); } + protected async Task ForceReload(bool DoClose) + { + if (DoClose) + { + selItem = null; + } + await ReloadData(); + } + #endregion Public Methods #region Protected Properties @@ -67,7 +76,7 @@ namespace MP_TAB_SERV.Components DateTime fine = DateTime.Today.AddDays(1); DateTime inizio = fine.AddDays(-8); CurrPeriodo = new Periodo(inizio, fine); - await doUpdate(); + await ReloadData(); } } @@ -93,7 +102,7 @@ namespace MP_TAB_SERV.Components isProcessing = true; await Task.Delay(1); IdxMaccSel = selIdxMacc; - await doUpdate(); + await ReloadData(); isProcessing = false; await Task.Delay(1); } @@ -103,7 +112,7 @@ namespace MP_TAB_SERV.Components isProcessing = true; await Task.Delay(1); IdxOdl = selIdxOdl; - await doUpdate(); + await ReloadData(); isProcessing = false; await Task.Delay(1); } @@ -111,7 +120,7 @@ namespace MP_TAB_SERV.Components protected async Task SetPeriodo(Periodo newPeriodo) { CurrPeriodo = newPeriodo; - await doUpdate(); + await ReloadData(); } protected async Task ShowKitDetail(RegistroScartiModel currItem) From fb4754f8aca5d8fca15f5d6fff720a080c34ec30 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 14 Dec 2023 13:11:40 +0100 Subject: [PATCH 3/3] Modifica qty inserita: non va da provare... --- MP-TAB-SERV/Components/ScrapKitMan.razor | 20 ++++++++++++++++++++ MP-TAB-SERV/Components/ScrapKitMan.razor.cs | 11 +++++++++++ MP-TAB-SERV/Components/ScrapMan.razor | 20 +++++++++++--------- MP-TAB-SERV/Components/ScrapMan.razor.cs | 1 + MP-TAB-SERV/MP-TAB-SERV.csproj | 2 +- MP-TAB-SERV/Resources/ChangeLog.html | 2 +- MP-TAB-SERV/Resources/VersNum.txt | 2 +- MP-TAB-SERV/Resources/manifest.xml | 2 +- 8 files changed, 47 insertions(+), 13 deletions(-) diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor b/MP-TAB-SERV/Components/ScrapKitMan.razor index 638ca44f..ccc9be39 100644 --- a/MP-TAB-SERV/Components/ScrapKitMan.razor +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor @@ -41,12 +41,32 @@
+
+ @if (item.Qta <= 0) + { + + } + else + { + + } +
@item.Qta
×pz
+
+ @if (item.Qta >= item.QtaMax) + { + + } + else + { + + } +
diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs index a5dceec4..6d554b82 100644 --- a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs @@ -64,6 +64,17 @@ namespace MP_TAB_SERV.Components ListPaged = ListComplete; } } + /// + /// Modifica qty del record + /// + /// + /// + /// + protected async Task modQty(RegistroScartiKitModel currItem, int delta) + { + currItem.Qta += delta; + await TabDServ.RegScartiKitUpdateQty(currItem); + } #endregion Protected Methods diff --git a/MP-TAB-SERV/Components/ScrapMan.razor b/MP-TAB-SERV/Components/ScrapMan.razor index 15404ad7..ba4c722d 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor +++ b/MP-TAB-SERV/Components/ScrapMan.razor @@ -77,21 +77,23 @@ @item.Qta
- + @if (item.Tipo == "KIT") {
× - + } + else + { + + + }
} else diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index 9040d15d..6128ee3c 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -144,6 +144,7 @@ namespace MP_TAB_SERV.Components selItem = null; } } + await ReloadData(); isProcessing = false; } diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 9e717cc6..752a02b0 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2312.1412 + 6.16.2312.1413 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index fe09f92f..a1d18744 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2312.1412

+

Versione: 6.16.2312.1413


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 7c19e07a..098ff125 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2312.1412 +6.16.2312.1413 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 0f924aed..eaa29062 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2312.1412 + 6.16.2312.1413 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false
- Esplosione scarti KIT + +
+ Esplosione scarti KIT +
+
+ +
- +