From 30b98a0efd2ecc16a398b5cfdcceda8e3867f434 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 5 Dec 2022 12:26:19 +0100 Subject: [PATCH] aggiunta salvataggio scansione --- MP.INVE/Components/CodeScan.razor.cs | 12 ++-- MP.INVE/Components/ProcSuggestion.razor | 32 ++++++++-- MP.INVE/Components/ProcSuggestion.razor.cs | 73 +++++++++++++++++++++- MP.INVE/Pages/Acquisizione.razor | 9 +-- MP.INVE/Pages/Acquisizione.razor.cs | 16 ++++- 5 files changed, 116 insertions(+), 26 deletions(-) diff --git a/MP.INVE/Components/CodeScan.razor.cs b/MP.INVE/Components/CodeScan.razor.cs index d0719ee2..554e61c7 100644 --- a/MP.INVE/Components/CodeScan.razor.cs +++ b/MP.INVE/Components/CodeScan.razor.cs @@ -24,26 +24,22 @@ namespace MP.INVE.Components // FIXME TODO creare evento x riportare scansione [Parameter] public EventCallback lastRawScan { get; set; } + +#if false /// /// Imposta il focus su input scansione /// protected void setFocus() { // all'apertura del componente --> focus su txtbox scan (e anche dopo input) - } + } +#endif private ElementReference target; - //protected string lastScan { get; set; } = ""; public SelectScanParams currParams = new SelectScanParams(); - - //protected string rawScan - //{ - // get => currParams.UDC; - // set => currParams.UDC = value; - //} protected string _lastScan = ""; protected string LastScan { diff --git a/MP.INVE/Components/ProcSuggestion.razor b/MP.INVE/Components/ProcSuggestion.razor index 2c48c865..9ee35e70 100644 --- a/MP.INVE/Components/ProcSuggestion.razor +++ b/MP.INVE/Components/ProcSuggestion.razor @@ -8,31 +8,51 @@
  • totalmente ignoto
  • *@ -@if (udc != null) +@if (currUdc != null) { +
    + + +
    } else { diff --git a/MP.INVE/Components/ProcSuggestion.razor.cs b/MP.INVE/Components/ProcSuggestion.razor.cs index 4085063f..e8b23569 100644 --- a/MP.INVE/Components/ProcSuggestion.razor.cs +++ b/MP.INVE/Components/ProcSuggestion.razor.cs @@ -16,6 +16,8 @@ using MP.INVE.Shared; using MP.INVE.Components; using MP.INVE.Data; using MP.Data.DatabaseModels; +using System.Runtime.CompilerServices; +using Microsoft.EntityFrameworkCore.Infrastructure.Internal; namespace MP.INVE.Components { @@ -25,19 +27,39 @@ namespace MP.INVE.Components private MiDataService MIService { get; set; } = null!; [Parameter] public string lastScan { get; set; } = null!; + //[Parameter] + //public EventCallback udcSend { get; set; } + [Parameter] + public string userScan { get; set; } = null!; + [Parameter] + public int sessID { get; set; } = 0; + [Inject] + public IJSRuntime JSRuntime { get; set; } = null!; + [Inject] + public NavigationManager NavManager { get; set; } = null!; private string tipo { get; set; } = ""; + private string canMod = "false"; - public List? searchrecords; - public AnagUdcModel? udc; + protected List? searchrecords; + protected AnagUdcModel? udc; + protected AnagUdcModel? currUdc; protected override async Task OnParametersSetAsync() { + await MIService.ConfigResetCache(); + var result = await MIService.tryGetConfig("MAG_SmartUdcEdit"); + if (result != null) + { + canMod = result; + } await Task.Delay(1); searchrecords = MIService.ElencoUDC(); udc = searchrecords.Where(x => x.UDC == lastScan).FirstOrDefault(); + if (udc != null) { + currUdc = udc; if (udc.UDC.Contains("MFI")) { tipo = "FINITO"; @@ -45,15 +67,60 @@ namespace MP.INVE.Components } } + protected bool isForced = false; + protected async void insertScan() + { + var alert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler salvare la seguente scansione per la sessione {sessID}?"); + + if (currUdc != null) + { + if (alert) + { + if((currUdc.lottoNav.CodArt != udc.lottoNav.CodArt) || (currUdc.Qta != udc.Qta)) + { + isForced = true; + } + + ScanDataModel newScan = new ScanDataModel() + { + DtScan = DateTime.Now, + UserScan = userScan, + IsForced = isForced, + CodArticolo = currUdc.lottoNav.CodArt, + Lotto = currUdc.lottoNav.Lotto, + RifExt = currUdc.lottoNav.RifExt, + Qty = currUdc.Qta, + Note = currUdc.Note, + IsKnown = true, + IsUnique = true, + InveSessID = sessID + }; + await MIService.InsertNewScansione(newScan); + NavManager.NavigateTo(NavManager.Uri, true); + } + } + else + { + NavManager.NavigateTo(NavManager.Uri, true); + } + + } + protected string reqArtMod = "disabilita"; protected string reqQtaMod = "disabilita"; protected void cssDisableArt() { - reqArtMod = ""; + reqArtMod = ""; } protected void cssDisableQta() { reqQtaMod = ""; } + + + //private void saveSel(AnagUdcModel udcToSend) + //{ + // Task.FromResult(udcSend.InvokeAsync(udcToSend)); + //} } } \ No newline at end of file diff --git a/MP.INVE/Pages/Acquisizione.razor b/MP.INVE/Pages/Acquisizione.razor index d93521cf..4d1f939f 100644 --- a/MP.INVE/Pages/Acquisizione.razor +++ b/MP.INVE/Pages/Acquisizione.razor @@ -14,14 +14,9 @@ { }*@
    - +
    - @if (rawScan != null) - { -
    - -
    - } +