50d65eebaa
- renaming classi gestione DbModels in - spostamento anagrafica flussi da auth a generale
329 lines
11 KiB
C#
329 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.INVE;
|
|
using MP.INVE.Shared;
|
|
using MP.INVE.Components;
|
|
using MP.INVE.Data;
|
|
using MP.Data.DbModels;
|
|
using System.Runtime.CompilerServices;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
|
|
using NLog.Targets;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class ProcSuggestion
|
|
{
|
|
[Inject]
|
|
private MiDataService MIService { get; set; } = null!;
|
|
[Inject]
|
|
public IJSRuntime JSRuntime { get; set; } = null!;
|
|
[Inject]
|
|
public NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public string lastScan { get; set; } = "";
|
|
[Parameter]
|
|
public string userScan { get; set; } = null!;
|
|
[Parameter]
|
|
public int sessID { get; set; } = 0;
|
|
[Parameter]
|
|
public string magID { get; set; } = "";
|
|
|
|
private string tipo { get; set; } = "";
|
|
private string canMod = "false";
|
|
public string lastScanCheck { get; set; } = "";
|
|
|
|
protected AnagUdcModel? udc;
|
|
protected AnagLottoModel? lottoInterno;
|
|
protected AnagLottiArca? lottoEsterno;
|
|
protected List<AnagLottiArca>? listLottiEsterni;
|
|
protected ScanDataModel? alreadyScan;
|
|
|
|
protected AnagUdcModel? currUdc;
|
|
protected AnagLottoModel? currLottoInterno;
|
|
protected AnagLottiArca? currLottoEsterno;
|
|
protected bool alertScan;
|
|
protected bool isScannedLotto;
|
|
protected bool firstMsg = false;
|
|
protected bool isKnown = false;
|
|
protected bool canSave = true;
|
|
protected string oldArt = "";
|
|
protected bool isQtaSbagliata = false;
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
await Task.Delay(1);
|
|
if (firstRender)
|
|
{
|
|
firstMsg = true;
|
|
}
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
isKnown = false;
|
|
currLottoInterno = null;
|
|
currUdc = null;
|
|
alreadyScan = null;
|
|
isQtaSbagliata = false;
|
|
|
|
// se il valore scansionato � != null...
|
|
if (string.IsNullOrEmpty(lastScan))
|
|
{
|
|
firstMsg = true;
|
|
await Task.Delay(1);
|
|
}
|
|
else
|
|
{
|
|
if (lastScan.StartsWith("S"))
|
|
{
|
|
lastScanCheck = lastScan.Substring(1);
|
|
}
|
|
else
|
|
{
|
|
lastScanCheck = lastScan;
|
|
}
|
|
firstMsg = false;
|
|
await MIService.ConfigResetCache();
|
|
var result = await MIService.tryGetConfig("MAG_SmartUdcEdit");
|
|
int sessIDSearch = 0;
|
|
|
|
if (lastScanCheck.Contains("MFI") && lastScanCheck.Length == 14)
|
|
{
|
|
sessIDSearch = sessID;
|
|
}
|
|
var scansioneClone = MIService.ScanByUdcSession(lastScan, sessID);
|
|
if (scansioneClone != null)
|
|
{
|
|
//isScannedLotto = scansioneClone.ScanValue.StartsWith("M2");
|
|
isKnown = false;
|
|
if (scansioneClone.IsUnique)
|
|
{
|
|
isKnown = true;
|
|
canSave = false;
|
|
}
|
|
alreadyScan = scansioneClone;
|
|
lottoScan = alreadyScan.Lotto;
|
|
oldArt = alreadyScan.CodArticolo;
|
|
articoloScan = alreadyScan.CodArticolo;
|
|
quantitaScan = Math.Round(alreadyScan.Qty, 2);
|
|
noteScan = alreadyScan.Note;
|
|
|
|
}
|
|
else
|
|
{
|
|
if (result != null)
|
|
{
|
|
canMod = result;
|
|
}
|
|
await Task.Delay(1);
|
|
udc = MIService.IsUDC(lastScanCheck);
|
|
|
|
if (udc != null)
|
|
{
|
|
if (udc.Qta > 0)
|
|
{
|
|
var udcString = udc.UDC.Substring(2, 3);
|
|
if (udcString == "MFI")
|
|
{
|
|
|
|
isKnown = true;
|
|
canSave = true;
|
|
currUdc = udc;
|
|
tipo = "U";
|
|
lottoScan = udc.lottoNav.Lotto;
|
|
oldArt = udc.lottoNav.CodArt;
|
|
articoloScan = udc.lottoNav.CodArt;
|
|
quantitaScan = Math.Round(udc.Qta, 2);
|
|
noteScan = udc.Note;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
isQtaSbagliata = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
if (lastScan.StartsWith("M") && lastScan.Length == 10)
|
|
{
|
|
lottoInterno = MIService.LottoInterno(lastScan);
|
|
}
|
|
else
|
|
{
|
|
listLottiEsterni = MIService.LottoEsterno("", lastScan, magID);
|
|
if (listLottiEsterni.Count == 1)
|
|
{
|
|
lottoEsterno = listLottiEsterni.FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
if (lottoInterno != null)
|
|
{
|
|
canSave = true;
|
|
tipo = "LI";
|
|
currLottoInterno = lottoInterno;
|
|
lottoScan = lottoInterno.Lotto;
|
|
oldArt = lottoInterno.CodArt;
|
|
articoloScan = lottoInterno.CodArt;
|
|
quantitaScan = 0;
|
|
}
|
|
else
|
|
{
|
|
if (lottoEsterno != null)
|
|
{
|
|
canSave = true;
|
|
tipo = "LE";
|
|
currLottoEsterno = lottoEsterno;
|
|
if (lottoEsterno.Cd_ARLotto != null)
|
|
{
|
|
lottoScan = lottoEsterno.Cd_ARLotto;
|
|
}
|
|
oldArt = lottoEsterno.Cd_AR;
|
|
articoloScan = lottoEsterno.Cd_AR;
|
|
quantitaScan = 0;
|
|
noteScan = "";
|
|
}
|
|
else
|
|
{
|
|
canSave = true;
|
|
tipo = "S";
|
|
#if false
|
|
currLottoInterno = null;
|
|
currUdc = null;
|
|
alreadyScan = null;
|
|
#endif
|
|
lottoScan = lastScan;
|
|
articoloScan = "";
|
|
quantitaScan = 0;
|
|
noteScan = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected bool isForced = false;
|
|
protected decimal qtaLotto = 0;
|
|
protected async void insertScan()
|
|
{
|
|
|
|
var artExists = await MIService.artBySearch(articoloScan);
|
|
|
|
if (artExists != null)
|
|
{
|
|
var force = false;
|
|
if (articoloScan != oldArt)
|
|
{
|
|
force = true;
|
|
}
|
|
var lottoSave = lastScan;
|
|
var known = false;
|
|
var unique = false;
|
|
if (currUdc != null)
|
|
{
|
|
lottoSave = currUdc.Lotto;
|
|
known = true;
|
|
unique = true;
|
|
}
|
|
else if (currLottoEsterno != null || currLottoInterno != null)
|
|
{
|
|
|
|
known = true;
|
|
unique = false;
|
|
}
|
|
|
|
ScanDataModel newScan = new ScanDataModel()
|
|
{
|
|
DtScan = DateTime.Now,
|
|
UserScan = userScan,
|
|
ScanValue = lastScan,
|
|
IsForced = force,
|
|
CodArticolo = articoloScan,
|
|
Lotto = lottoSave,
|
|
RifExt = "",
|
|
Qty = quantitaScan,
|
|
Note = noteScan,
|
|
IsKnown = known,
|
|
IsUnique = unique,
|
|
InveSessID = sessID
|
|
};
|
|
await MIService.InsertNewScansione(newScan);
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
else
|
|
{
|
|
await JSRuntime.InvokeVoidAsync("alert", $"Articolo errato: {articoloScan} non trovato in anagrafica");
|
|
}
|
|
}
|
|
|
|
|
|
protected async void updateScansione(ScanDataModel modScan)
|
|
{
|
|
var alertUpdate = await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler modificare la seguente scansione {modScan.ScanValue}?");
|
|
if (alertUpdate)
|
|
{
|
|
if (alreadyScan != null)
|
|
{
|
|
modScan.CodArticolo = alreadyScan.CodArticolo;
|
|
modScan.Qty = alreadyScan.Qty;
|
|
modScan.Note = alreadyScan.Note;
|
|
}
|
|
await MIService.UpdateScan(modScan);
|
|
}
|
|
}
|
|
|
|
public void resetAll()
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
|
|
protected string reqArtMod = "disabilita";
|
|
protected string reqQtaMod = "disabilita";
|
|
protected string _lotto = "";
|
|
protected string lottoScan
|
|
{
|
|
get => _lotto;
|
|
set => _lotto = value.Trim();
|
|
}
|
|
protected string _articolo = "";
|
|
protected string articoloScan
|
|
{
|
|
get => _articolo;
|
|
set => _articolo = value.Trim();
|
|
}
|
|
protected decimal _qta = 0;
|
|
protected decimal quantitaScan
|
|
{
|
|
get => _qta;
|
|
set => _qta = value;
|
|
}
|
|
protected string _note = "";
|
|
protected string noteScan
|
|
{
|
|
get => _note;
|
|
set => _note = value.Trim();
|
|
}
|
|
|
|
protected void cssDisableArt()
|
|
{
|
|
reqArtMod = "";
|
|
}
|
|
protected void cssDisableQta()
|
|
{
|
|
reqQtaMod = "";
|
|
}
|
|
}
|
|
} |