From 85c994e8fdab110dea3ff310a1cb762a068101d3 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 6 Dec 2022 11:50:30 +0100 Subject: [PATCH] gestione codice "NOTO" --- MP.INVE/Components/ProcSuggestion.razor | 9 ++- MP.INVE/Components/ProcSuggestion.razor.cs | 81 ++++++++++++++++++---- 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/MP.INVE/Components/ProcSuggestion.razor b/MP.INVE/Components/ProcSuggestion.razor index 8f1271cd..8d966595 100644 --- a/MP.INVE/Components/ProcSuggestion.razor +++ b/MP.INVE/Components/ProcSuggestion.razor @@ -89,7 +89,14 @@ else if (alreadyScan != null)
- + @if (!isScannedLotto) + { + + } + else + { + + }
} diff --git a/MP.INVE/Components/ProcSuggestion.razor.cs b/MP.INVE/Components/ProcSuggestion.razor.cs index fc1dfa2f..6438f8a3 100644 --- a/MP.INVE/Components/ProcSuggestion.razor.cs +++ b/MP.INVE/Components/ProcSuggestion.razor.cs @@ -49,25 +49,40 @@ namespace MP.INVE.Components protected AnagUdcModel? currUdc; protected AnagLottoModel? currLotto; + protected bool alertScan; + protected bool isScannedLotto; protected override async Task OnParametersSetAsync() { elencoScansioni = MIService.ScanList(); var exists = elencoScansioni.Select(x => x.ScanValue).Contains(lastScan); + var scansioneClone = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); if (exists) { - var alert = await JSRuntime.InvokeAsync("confirm", $"L'oggetto {lastScan} è già stato scannerizzato, si desidera modificarlo?"); - if (alert) + if (scansioneClone != null) { - alreadyScan = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); - currUdc = null; - currLotto = null; + isScannedLotto = scansioneClone.ScanValue.StartsWith("M2"); + if (!isScannedLotto) + { + + alertScan = await JSRuntime.InvokeAsync("confirm", $"L'oggetto {lastScan} è già stato scannerizzato, si desidera modificarlo?"); + if (alertScan) + { + alreadyScan = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); + currUdc = null; + currLotto = null; + } + } + else + { + alreadyScan = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); + currUdc = null; + currLotto = null; + } } } else { - - await MIService.ConfigResetCache(); var result = await MIService.tryGetConfig("MAG_SmartUdcEdit"); if (result != null) @@ -78,8 +93,9 @@ namespace MP.INVE.Components searchRecordsUDC = MIService.ElencoUDC(); udc = searchRecordsUDC.Where(x => x.UDC == lastScan).FirstOrDefault(); - if (udc != null && !udc.UDC.Contains("MSL")) + if (udc != null && !udc.UDC.Contains("MSL")) { + currUdc = udc; tipo = "UDC"; lottoScan = udc.lottoNav.Lotto; @@ -93,10 +109,18 @@ namespace MP.INVE.Components lotto = searchRecordsLotto.Where(x => x.Lotto == lastScan).FirstOrDefault(); if (lotto != null) { - currLotto = lotto; tipo = "LOTTO"; - lottoScan = lotto.Lotto; - articoloScan = lotto.CodArt; + var alertMod = await JSRuntime.InvokeAsync("confirm", $"L'oggetto {lastScan} risulta presente nelle nostre anagrafiche con i seguenti dati: \nTipo: {tipo}\nLotto: {lotto.Lotto}\nArticolo: {lotto.CodArt} \nSi desidera modificarlo?"); + currLotto = lotto; + if (alertMod) + { + lottoScan = lotto.Lotto; + articoloScan = lotto.CodArt; + } + else + { + insertScan(); + } } else { @@ -113,8 +137,8 @@ namespace MP.INVE.Components protected decimal qtaLotto = 0; protected async void insertScan() { - var alert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler salvare la seguente scansione per la sessione {sessID}?"); - if (alert) + var alertInsert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler salvare la seguente scansione per la sessione {sessID}?"); + if (alertInsert) { if (currUdc != null) @@ -166,6 +190,33 @@ namespace MP.INVE.Components await MIService.InsertNewScansione(newScan); NavManager.NavigateTo(NavManager.Uri, true); } + else if(alreadyScan != null) + { + ScanDataModel newScan = new ScanDataModel() + { + DtScan = DateTime.Now, + UserScan = userScan, + ScanValue = lastScan, + IsForced = true, + CodArticolo = alreadyScan.CodArticolo, + Lotto = alreadyScan.Lotto, + RifExt = alreadyScan.RifExt, + Qty = alreadyScan.Qty, + Note = alreadyScan.Note, + IsKnown = true, + IsUnique = true, + InveSessID = sessID + }; + await MIService.InsertNewScansione(newScan); + NavManager.NavigateTo(NavManager.Uri, true); + } + } + else + { + currLotto = null; + currUdc = null; + alreadyScan = null; + NavManager.NavigateTo(NavManager.Uri, true); } } @@ -173,8 +224,8 @@ namespace MP.INVE.Components protected async void updateScansione(ScanDataModel modScan) { - var alert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler modificare la seguente scansione {modScan.ScanValue}?"); - if (alert) + var alertUpdate = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler modificare la seguente scansione {modScan.ScanValue}?"); + if (alertUpdate) { if (alreadyScan != null) {