From 8c4acafadbc5d45501b7a01ad524ec424a26a3d8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 20 Apr 2021 17:14:19 +0200 Subject: [PATCH] nuovo modulo gestione load scan (da testare) --- MP-MAG/WebUserControls/cmp_LoadScan.ascx | 15 ++ MP-MAG/WebUserControls/cmp_LoadScan.ascx.cs | 210 ++++++++++++++++++ .../cmp_LoadScan.ascx.designer.cs | 53 +++++ 3 files changed, 278 insertions(+) create mode 100644 MP-MAG/WebUserControls/cmp_LoadScan.ascx create mode 100644 MP-MAG/WebUserControls/cmp_LoadScan.ascx.cs create mode 100644 MP-MAG/WebUserControls/cmp_LoadScan.ascx.designer.cs diff --git a/MP-MAG/WebUserControls/cmp_LoadScan.ascx b/MP-MAG/WebUserControls/cmp_LoadScan.ascx new file mode 100644 index 00000000..9e957a78 --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_LoadScan.ascx @@ -0,0 +1,15 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_LoadScan.ascx.cs" Inherits="MP_MAG.WebUserControls.cmp_LoadScan" %> + +<%@ Register Src="~/WebUserControls/cmp_barcode.ascx" TagPrefix="uc1" TagName="cmp_barcode" %> +<%@ Register Src="~/WebUserControls/cmp_SelPedana.ascx" TagPrefix="uc1" TagName="cmp_SelPedana" %> + +
+
+ + + +
+
+ +
+
\ No newline at end of file diff --git a/MP-MAG/WebUserControls/cmp_LoadScan.ascx.cs b/MP-MAG/WebUserControls/cmp_LoadScan.ascx.cs new file mode 100644 index 00000000..567bcdbc --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_LoadScan.ascx.cs @@ -0,0 +1,210 @@ +using MagData; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace MP_MAG.WebUserControls +{ + public partial class cmp_LoadScan : BaseUserControl + { + #region Protected Properties + + /// + /// Comando ULTIMO barcode letto + /// + protected string lastCmd + { + get + { + return hfLastBCode.Value; + } + set + { + hfLastBCode.Value = value; + lastValidCmd = value; + } + } + + /// + /// ULTIMO Comando barcode VALIDO (!="") letto + /// + protected string lastValidCmd + { + get + { + return hfLastValidBCode.Value; + } + set + { + // solo se è non nullo/vuoto + if (!string.IsNullOrEmpty(value)) + { + hfLastValidBCode.Value = value; + } + } + } + + /// + /// Pedana selezionata + /// + protected string SelPedana + { + get + { + return cmp_SelPedana.Pedana; + } + set + { + cmp_SelPedana.Pedana = value; + } + } + + #endregion Protected Properties + + #region Private Methods + + private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e) + { + bool doRaiseEv = false; + // processo evento.. + lastCmd = cmp_barcode.inputAcquired.ToUpper(); + doRaiseEv = processLastCmd(doRaiseEv); + // reset comando + cmp_barcode.inputAcquired = ""; + // aggiorno... + doUpdate(); + } + + private void Cmp_barcode_eh_doReset(object sender, EventArgs e) + { + } + + private void doUpdate() + { + } + + private bool processLastCmd(bool doRaiseEv) + { + if (string.IsNullOrEmpty(lastCmd)) doRaiseEv = true; + // processiamo barcode letto + decodedData decoData = MagDataLayer.man.decodeBcode(lastValidCmd); + switch (decoData.codeType) + { + case codeType.Command: + case codeType.Pedana: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + processSuggestion(decoData.codeType, decoData.rawData, decoData.code, decoData.codeInt); + doRaiseEv = true; + break; + + case codeType.PackList: + case codeType.Udc: + default: + cmp_barcode.showOutput("badge badge-danger", $"Codice sconosciuto: {decoData.rawData} --> ignoro"); + resetSelection(false); + doRaiseEv = true; + break; + } + + return doRaiseEv; + } + + /// + /// Processo il codice letto + /// + /// + /// + /// + /// + private void processSuggestion(codeType tipoCod, string rawData, string code, int codeInt) + { + bool allOk = false; + // processo suggerimenti + switch (tipoCod) + { + case codeType.Command: + + // verifico tipo comando + switch (rawData) + { + case "CMDRESET": + SelPedana = "ND"; + resetSelection(true); + break; + + default: + break; + } + break; + + case codeType.Pedana: + // verifico AL esista + var tabAL = MagDataLayer.man.taEAL.getByKey(rawData); + if (tabAL.Rows.Count == 0) + { + cmp_barcode.showOutput("badge badge-warning", $"Errore: Pedana non trovata: {rawData}"); + } + else + { + if (tabAL[0].Status == 0) + { + cmp_barcode.showOutput("badge badge-danger", $"Errore: AL {rawData} NON completata"); + } + else if (tabAL[0].Status == 2) + { + cmp_barcode.showOutput("badge badge-danger", $"Errore: AL {rawData} già caricato"); + } + else if (tabAL[0].Status == 1) + { + if (rawData == SelPedana) + { + // se non associata associo... + MagDataLayer.man.taEAL.updateStatus(rawData, 2); + cmp_barcode.showOutput("badge badge-success", $"Pedana {rawData} caricata su vettore"); + SelPedana = ""; + } + else + { + cmp_barcode.showOutput("badge badge-info", $"Pedana {rawData} valida, rileggere per confermare"); + SelPedana = rawData; + } + } + } + + break; + + default: + break; + } + } + + #endregion Private Methods + + #region Protected Methods + + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + SelPedana = ""; + } + // eventi barcode + cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh; + // eventi reset lotti IN + cmp_barcode.eh_doReset += Cmp_barcode_eh_doReset; ; + } + + /// + /// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload + /// + /// + protected void resetSelection(bool resetStatus) + { + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP-MAG/WebUserControls/cmp_LoadScan.ascx.designer.cs b/MP-MAG/WebUserControls/cmp_LoadScan.ascx.designer.cs new file mode 100644 index 00000000..9107f12a --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_LoadScan.ascx.designer.cs @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MP_MAG.WebUserControls +{ + + + public partial class cmp_LoadScan + { + + /// + /// cmp_barcode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::MP_MAG.WebUserControls.cmp_barcode cmp_barcode; + + /// + /// hfLastBCode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfLastBCode; + + /// + /// hfLastValidBCode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfLastValidBCode; + + /// + /// cmp_SelPedana control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::MP_MAG.WebUserControls.cmp_SelPedana cmp_SelPedana; + } +}