From b690b86aecfce798feb63fa6f4f472a5632a3d1e Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 29 Dec 2020 17:01:17 +0100 Subject: [PATCH] update gestione PL Scanner --- MP-MAG/SMART/PLScanner.aspx | 4 +- MP-MAG/SMART/PLScanner.aspx.cs | 366 +++++- MP-MAG/SMART/PLScanner.aspx.designer.cs | 18 + MP-MAG/WebUserControls/cmp_PackListSel.ascx | 2 +- .../WebUserControls/cmp_PackListSel.ascx.cs | 1 + MP-MAG/WebUserControls/cmp_prtFiniti.ascx.cs | 1163 +++++++++-------- MagData/Enum.cs | 50 +- MagData/MagDataLayer.cs | 27 +- 8 files changed, 1037 insertions(+), 594 deletions(-) diff --git a/MP-MAG/SMART/PLScanner.aspx b/MP-MAG/SMART/PLScanner.aspx index 12f855b..ba087bc 100644 --- a/MP-MAG/SMART/PLScanner.aspx +++ b/MP-MAG/SMART/PLScanner.aspx @@ -6,13 +6,15 @@
- +
+ +
PEDANA ATTIVA diff --git a/MP-MAG/SMART/PLScanner.aspx.cs b/MP-MAG/SMART/PLScanner.aspx.cs index bd43db5..c3a928d 100644 --- a/MP-MAG/SMART/PLScanner.aspx.cs +++ b/MP-MAG/SMART/PLScanner.aspx.cs @@ -1,4 +1,5 @@ -using System; +using MagData; +using System; using System.Collections.Generic; using System.Linq; using System.Web; @@ -9,9 +10,370 @@ namespace MP_MAG.SMART { public partial class PLScanner : System.Web.UI.Page { + #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; + } + } + } + + #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() + { +#if false + // reset grafico + icnCart.Attributes.Remove("class"); + icnCart.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); + icnBin.Attributes.Remove("class"); + icnBin.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); + icnSecOp.Attributes.Remove("class"); + icnSecOp.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); + + // in base al secondo mostro uno o altro... + if (showCart) + { + icnCart.Attributes.Remove("class"); + icnCart.Attributes.Add("class", "btn btn-sm btn-block btn-success"); + lblMessage.Text = "Item recognized"; + // controllo SE HO cart + if (currCartTab.Count == 1) + { + var cartRow = currCartTab[0]; + // imposto OUT + lblDestination.Text = $"SEND TO CART C{cartRow.CartIndex} ({cartRow.CartDtmx})"; + } + else + { + lblDestination.Text = $"ERROR SEARCHING CART: {currCartTab.Count} found!"; + } + lblDestination.CssClass = "text-success"; + } + else if (showBin) + { + icnBin.Attributes.Remove("class"); + icnBin.Attributes.Add("class", "btn btn-sm btn-block btn-primary"); + lblMessage.Text = "Item recognized"; + if (currBinTab.Count == 1) + { + var binRow = currBinTab[0]; + lblDestination.Text = $"SEND TO BIN B{binRow.BinIndex} ({binRow.BinDtmx})"; + } + else + { + lblDestination.Text = $"ERROR SEARCHING BIN: {currBinTab.Count} found!"; + } + lblDestination.CssClass = "text-primary"; + } + if (showSecOp) + { + icnSecOp.Attributes.Remove("class"); + icnSecOp.Attributes.Add("class", "btn btn-sm btn-block btn-info"); + lblMessage.Text = "Item recognized"; + lblLastBCode.Text = $"DO SEC OP: {secOp}"; + lblLastBCode.CssClass = "text-info"; + } + // fix btn reset! + lbtResetSel.Visible = (itemIdSelected != 0); +#endif + } + + private bool processLastCmd(bool doRaiseEv) + { + if (lastCmd == "") doRaiseEv = true; + // processiamo barcode letto + decodedData decoData = MagDataLayer.man.decodeBcode(lastValidCmd); + switch (decoData.codeType) + { + case codeType.UNK: + cmp_barcode.showOutput("text-danger", $"Codice sconosciuto: {decoData.rawData} --> ignoro"); + resetSelection(false); + doRaiseEv = true; + break; + + case codeType.Lotto: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.PackList: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + doRaiseEv = true; + break; + + case codeType.Pedana: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + doRaiseEv = true; + break; + + case codeType.LottoInt: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + + case codeType.Date: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.PartNumber: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.Quantity: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + + case codeType.Udc: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + //case codeType.Batch: + // cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}"); + // doRaiseEv = true; + // break; + //case codeType.Cart: + // cmp_barcode.showOutput("badge badge-success", $"Valid CR Code: {decoData.description}"); + // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //case codeType.Bin: + // cmp_barcode.showOutput("badge badge-success", $"Valid BN Code: {decoData.description}"); + // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //default: + // cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action"); + // resetSelection(false); + // break; + } + + return doRaiseEv; + } + + /// + /// Processo il codice letto + /// + /// + /// + /// + private void processSuggestion(codeType tipoCod, string rawData, int codeInt) + { + //DS_App.ItemListDataTable tabItem = null; + // processo suggerimenti x ITEM / cart / bin dato suo RawData (Dtmx) e Cod univoco (intero) + switch (tipoCod) + { + case codeType.PackList: + // FARE!!! verificare packlist valida... + if (true) + { + // seleziono PackList + cmp_PackListSel.PackListID = codeInt; + } +#if false + // IN PRIMIS cerco lotto valido + DS_Mag.ElencoLottiDataTable tabLotti; + tabLotti = MagDataLayer.man.taEL.getByKey(rawData, "*", codStatoIN); + if (tabLotti.Count == 1) + { + // se trovato cerco in elenco --> aggiungo in lista se non c'è + var currLotti = lottiSel; + if (!currLotti.Contains(rawData)) + { + currLotti.Add(rawData); + lottiSel = currLotti; + } + } +#endif + break; + + case codeType.Pedana: + // verifico e seleziono pedana + //tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); + //if (tabItem.Count == 1) + //{ + // showItemDetail(true, tabItem[0], false); + //} + //else if (tabItem.Count == 0) + //{ + // showItemDetail(false, null, true); + //} + break; + //case codeType.Item: + // tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); + // if (tabItem.Count == 1) + // { + // showItemDetail(true, tabItem[0], false); + // } + // else if (tabItem.Count == 0) + // { + // showItemDetail(false, null, true); + // } + // break; + //case codeType.ItemGeneric: + // // PRIMA CERCSE ne ho in stato 1..3 + // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 3); + // if (tabItem.Count == 0) + // { + // // se NON ne trovo cerci FINO a stato 5... + // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 5); + // } + // if (tabItem.Count == 1) + // { + // showItemDetail(true, tabItem[0], false); + // } + // else if (tabItem.Count == 0) + // { + // showItemDetail(false, null, true); + // } + // break; + //case codeType.Cart: + // // verifico NON SIA richiesto PAINT + // if (showBin) + // { + // displError("PAINT: BIN REQUESTED: please retry", true); + // } + // else + // { + // if (currCartTab.Count == 1) + // { + // // controllo se sia quello corretto + // if (rawData != currCartTab[0].CartDtmx) + // { + // displError("INCORRECT CART: please retry", true); + // } + // else + // { + // // dichiaro che è depositato + // DataLayer.man.taIL.updateStatus(itemIdSelected, 3, PlaceId); + // lblDestination.Text = $"Item {itemIdSelected} PUT IN CART {rawData}"; + // resetSelection(false); + // } + // } + // } + // break; + //case codeType.Bin: + // // verifico NON SIA richiesto PAINT + // if (showCart) + // { + // displError("NOT PAINTED: CART REQUESTED: please retry", true); + // } + // else + // { + // if (currBinTab.Count == 1) + // { + // // controllo se sia quello corretto + // if (rawData != currBinTab[0].BinDtmx) + // { + // displError("INCORRECT BIN: please retry", true); + // } + // else + // { + // // dichiaro che è depositato + // DataLayer.man.taIL.updateStatus(itemIdSelected, 4, PlaceId); + // lblDestination.Text = $"Item {itemIdSelected} PUT IN BIN {rawData}"; + // resetSelection(false); + // } + // } + // } + // break; + default: + break; + } + } + + #endregion Private Methods + + #region Protected Methods + protected void Page_Load(object sender, EventArgs e) { - + // 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) + { +#if false + if (resetStatus) + { + try + { + // SE item esiste... + var tabItem = DataLayer.man.taIL.getBySearch(itemIdSelected, itemIdSelected.ToString(), 0, 999); + if (tabItem.Count == 1) + { + // riposto item a status 1... + DataLayer.man.taIL.updateStatus(itemIdSelected, 1, PlaceId); + } + } + catch + { } + } + // elimino item sel... + itemIdSelected = 0; + resetShowData(); + ComLib.resetItemPickup(SheetID, DeviceId); +#endif + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/MP-MAG/SMART/PLScanner.aspx.designer.cs b/MP-MAG/SMART/PLScanner.aspx.designer.cs index 1132960..bcf2457 100644 --- a/MP-MAG/SMART/PLScanner.aspx.designer.cs +++ b/MP-MAG/SMART/PLScanner.aspx.designer.cs @@ -41,6 +41,24 @@ namespace MP_MAG.SMART /// protected global::MP_MAG.WebUserControls.cmp_barcode cmp_barcode; + /// + /// Controllo hfLastBCode. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.HiddenField hfLastBCode; + + /// + /// Controllo hfLastValidBCode. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.HiddenField hfLastValidBCode; + /// /// Controllo lblAL. /// diff --git a/MP-MAG/WebUserControls/cmp_PackListSel.ascx b/MP-MAG/WebUserControls/cmp_PackListSel.ascx index c4ec07d..cd7e4f6 100644 --- a/MP-MAG/WebUserControls/cmp_PackListSel.ascx +++ b/MP-MAG/WebUserControls/cmp_PackListSel.ascx @@ -5,7 +5,7 @@
- PACKLIST + PACKING LIST diff --git a/MP-MAG/WebUserControls/cmp_PackListSel.ascx.cs b/MP-MAG/WebUserControls/cmp_PackListSel.ascx.cs index d1f8794..d218c7c 100644 --- a/MP-MAG/WebUserControls/cmp_PackListSel.ascx.cs +++ b/MP-MAG/WebUserControls/cmp_PackListSel.ascx.cs @@ -22,6 +22,7 @@ namespace MP_MAG.WebUserControls set { hfPackListID.Value = $"{value}"; + lblPackListID.Text = $"{value}"; cmp_OrderList.PackListID = value; } } diff --git a/MP-MAG/WebUserControls/cmp_prtFiniti.ascx.cs b/MP-MAG/WebUserControls/cmp_prtFiniti.ascx.cs index 6225e75..e0b1c1a 100644 --- a/MP-MAG/WebUserControls/cmp_prtFiniti.ascx.cs +++ b/MP-MAG/WebUserControls/cmp_prtFiniti.ascx.cs @@ -9,568 +9,281 @@ using System.Web.UI.WebControls; namespace MP_MAG.WebUserControls { - public partial class cmp_prtFiniti : BaseUserControl - { - /// - /// Tipo Stampa - /// - public string tipoStampa + public partial class cmp_prtFiniti : BaseUserControl { - get - { - return lblTipoStampa.Text; - } - set - { - lblTipoStampa.Text = value; - } - } - /// - /// Comando ULTIMO barcode letto - /// - protected string lastCmd - { - get - { - return hfLastBCode.Value; - } - set - { - hfLastBCode.Value = value; - lastValidCmd = value; - } - } - /// - /// Coda di stampa attiva - /// - public string printQueue - { - get - { - // cerco in hidden file... - string answ = hfPrintQueue.Value; - if (string.IsNullOrEmpty(answ)) + #region Protected Properties + + /// + /// Comando ULTIMO barcode letto + /// + protected string lastCmd { - // altrimenti da currProdData - answ = currProdData.PrintQueue; - } - return answ; - } - set - { - hfPrintQueue.Value = value; - } - } - /// - /// Tipo di lotto - /// - public string tipoLotto - { - get - { - return hfTipoLotto.Value; - } - set - { - hfTipoLotto.Value = value; - } - } - /// - /// Cod Flusso x UDC - /// - public string flussoUdc - { - get - { - return hfFlussoUdc.Value; - } - set - { - hfFlussoUdc.Value = value; - } - } - /// - /// Cod Stato - /// - public string codStatoOUT - { - get - { - return hfCodStatoOUT.Value; - } - set - { - hfCodStatoOUT.Value = value; - } - } - /// - /// Cod Stato - /// - public string codStatoIN - { - get - { - return hfCodStatoIN.Value; - } - set - { - hfCodStatoIN.Value = value; - } - } - /// - /// Origine - /// - public string origine - { - get - { - return hfOrigine.Value; - } - set - { - hfOrigine.Value = 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; - } - } - } - /// - /// Elenco dei lotti selezionati (riporta a sottocomponenti) - /// - public List lottiSel - { - get - { - return cmp_LottiIn.lottiSel; - } - set - { - cmp_LottiIn.lottiSel = value; - cmp_LottiOut.lottiSel = value; - cmp_ArtOut.lottiSel = value; - } - } - /// - /// Caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - lottiSel = new List(); - cmp_creaLottoOUT.Visible = false; - cmp_printLottoOUT.Visible = false; - } - // eventi barcode - cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh; - // eventi reset lotti IN - cmp_barcode.eh_doReset += Cmp_barcode_eh_doReset; - cmp_LottiIn.eh_doReset += cmp_LottiIn_eh_doReset; - // selezione articoli - cmp_ArtOut.eh_doRefresh += cmp_ArtOut_eh_doRefresh; - cmp_ArtOut.eh_doReset += cmp_ArtOut_eh_doReset; - // selezione lotti esistenti x stampa - cmp_LottiOut.eh_doRefresh += cmp_LottiOut_eh_doRefresh; - cmp_LottiOut.eh_doReset += cmp_LottiOut_eh_doReset; - // eventi di creazione lotto e stampa - cmp_creaLottoOUT.eh_doRefresh += Cmp_creaLottoOUT_eh_doRefresh; - cmp_printLottoOUT.eh_doRefresh += Cmp_printLottoOUT_eh_doRefresh; - } - - private void Cmp_printLottoOUT_eh_doRefresh(object sender, EventArgs e) - { - // salvo richiesta stampa della quantità richiesta - int numUdc = cmp_printLottoOUT.numUdc; - decimal qtaTot = cmp_printLottoOUT.qtaTot; - if (numUdc > 0) - { - decimal qtaUdc = qtaTot / numUdc; - string keyParam = cmp_LottiOut.lottoSel; - for (int i = 0; i < numUdc; i++) - { - // creo UDC x semilavorato.. - var tabNewUDC = MagDataLayer.man.taEUdc.insertQuery(cmp_LottiOut.lottoSel, flussoUdc, CodCli, CodPost, qtaUdc, 1, CodOpr, 0, 0, 0, "", 0, ""); - if (tabNewUDC.Count == 1) - { - // cheo stampa per chiave lotto... - MagDataLayer.man.taPJQ.insertQuery(tabNewUDC[0].UDC, printQueue); - } - } - } - // nascondo creazione... - showCreaStampa(false, false); - cmp_LottiIn.doUpdate(); - cmp_LottiOut.doUpdate(); - } - - private void Cmp_creaLottoOUT_eh_doRefresh(object sender, EventArgs e) - { - MagDataLayer.man.taEL.insertQuery(tipoLotto, cmp_ArtOut.CodArtSel, codStatoOUT, origine, "", RifExt, cmp_LottiIn.elLotti); - cmp_LottiOut.doUpdate(); - } - - /// - /// Selezionato un Lotto già creato - /// - /// - /// - private void cmp_ArtOut_eh_doRefresh(object sender, EventArgs e) - { - // mostro button x creare NUOVA etichetta SUL LOTTO ESISTENTE - showCreaStampa(true, false); - } - /// - /// Reset sel articolo - /// - /// - /// - private void cmp_ArtOut_eh_doReset(object sender, EventArgs e) - { - showCreaStampa(false, false); - } - /// - /// Nascondo print lotto - /// - /// - /// - private void cmp_LottiOut_eh_doRefresh(object sender, EventArgs e) - { - // mostro button x creare NUOVO LOTTO - showCreaStampa(false, true); - } - /// - /// Print lotto - /// - /// - /// - private void cmp_LottiOut_eh_doReset(object sender, EventArgs e) - { - showCreaStampa(false, false); - } - /// - /// Mostra buttons crea/stampa lotto - /// - /// - /// - protected void showCreaStampa(bool showCrea, bool showPrint) - { - cmp_creaLottoOUT.Visible = showCrea; - cmp_printLottoOUT.Visible = showPrint; - } - - private void cmp_LottiIn_eh_doReset(object sender, EventArgs e) - { - Response.Redirect(user_std.pagCorrente); - } - - private void Cmp_barcode_eh_doReset(object sender, EventArgs e) - { - resetIcons(); - } - - 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 resetIcons() - { -#if false - lblDestination.CssClass = "text-secondary"; - lblMessage.Text = ""; - lblDestination.Text = ""; - lblLastBCode.Text = ""; - lbtCancel.Visible = false; - lbtScrapped.Visible = false; - lbtParkArea.Visible = false; - lbtResetSel.Visible = (itemIdSelected != 0); -#endif - } - private bool processLastCmd(bool doRaiseEv) - { - if (lastCmd == "") doRaiseEv = true; - // processiamo barcode letto - decodedData decoData = MagDataLayer.man.decodeBcode(lastValidCmd); - switch (decoData.codeType) - { - case codeType.UNK: - cmp_barcode.showOutput("text-danger", $"Codice sconosciuto: {decoData.rawData} --> ignoro"); - resetSelection(false); - doRaiseEv = true; - break; - case codeType.Lotto: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - case codeType.LottoInt: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - //doRaiseEv = true; - break; - case codeType.Date: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - case codeType.PartNumber: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - case codeType.Quantity: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - //doRaiseEv = true; - break; - case codeType.Udc: - cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); - //doRaiseEv = true; - break; - //case codeType.Batch: - // cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}"); - // doRaiseEv = true; - // break; - //case codeType.Cart: - // cmp_barcode.showOutput("badge badge-success", $"Valid CR Code: {decoData.description}"); - // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - // break; - //case codeType.Bin: - // cmp_barcode.showOutput("badge badge-success", $"Valid BN Code: {decoData.description}"); - // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - // break; - //default: - // cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action"); - // resetSelection(false); - // break; - } - - return doRaiseEv; - } - /// - /// Processo il codice letto - /// - /// - /// - /// - private void processSuggestion(codeType tipoCod, string rawData, int codeInt) - { - //DS_App.ItemListDataTable tabItem = null; - // processo suggerimenti x ITEM / cart / bin dato suo RawData (Dtmx) e Cod univoco (intero) - switch (tipoCod) - { - case codeType.Lotto: - // IN PRIMIS cerco lotto valido - DS_Mag.ElencoLottiDataTable tabLotti; - tabLotti = MagDataLayer.man.taEL.getByKey(rawData, "*", codStatoIN); - if (tabLotti.Count == 1) - { - // se trovato cerco in elenco --> aggiungo in lista se non c'è - var currLotti = lottiSel; - if (!currLotti.Contains(rawData)) + get { - currLotti.Add(rawData); - lottiSel = currLotti; + return hfLastBCode.Value; + } + set + { + hfLastBCode.Value = value; + lastValidCmd = value; } - } - break; - //case codeType.Item: - // tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); - // if (tabItem.Count == 1) - // { - // showItemDetail(true, tabItem[0], false); - // } - // else if (tabItem.Count == 0) - // { - // showItemDetail(false, null, true); - // } - // break; - //case codeType.ItemGeneric: - // // PRIMA CERCSE ne ho in stato 1..3 - // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 3); - // if (tabItem.Count == 0) - // { - // // se NON ne trovo cerci FINO a stato 5... - // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 5); - // } - // if (tabItem.Count == 1) - // { - // showItemDetail(true, tabItem[0], false); - // } - // else if (tabItem.Count == 0) - // { - // showItemDetail(false, null, true); - // } - // break; - //case codeType.Cart: - // // verifico NON SIA richiesto PAINT - // if (showBin) - // { - // displError("PAINT: BIN REQUESTED: please retry", true); - // } - // else - // { - // if (currCartTab.Count == 1) - // { - // // controllo se sia quello corretto - // if (rawData != currCartTab[0].CartDtmx) - // { - // displError("INCORRECT CART: please retry", true); - // } - // else - // { - // // dichiaro che è depositato - // DataLayer.man.taIL.updateStatus(itemIdSelected, 3, PlaceId); - // lblDestination.Text = $"Item {itemIdSelected} PUT IN CART {rawData}"; - // resetSelection(false); - // } - // } - // } - // break; - //case codeType.Bin: - // // verifico NON SIA richiesto PAINT - // if (showCart) - // { - // displError("NOT PAINTED: CART REQUESTED: please retry", true); - // } - // else - // { - // if (currBinTab.Count == 1) - // { - // // controllo se sia quello corretto - // if (rawData != currBinTab[0].BinDtmx) - // { - // displError("INCORRECT BIN: please retry", true); - // } - // else - // { - // // dichiaro che è depositato - // DataLayer.man.taIL.updateStatus(itemIdSelected, 4, PlaceId); - // lblDestination.Text = $"Item {itemIdSelected} PUT IN BIN {rawData}"; - // resetSelection(false); - // } - // } - // } - // break; - default: - break; - } - } -#if false - /// - /// Mostra o nasconde dettaglio su ITEM letto - /// - /// - /// - /// - private void showItemDetail(bool showItem, DS_App.ItemListRow itemRow, bool showError) - { - resetShowData(); - divItemDet.Visible = showItem; - divItemError.Visible = showError; - if (showError) - { - displError("Item not found", true); - } - if (showItem) - { - lblItemCode.Text = itemRow.ItemExtCode; - lblItemDesc.Text = itemRow.ItemDesc; - lblItemDtmx.Text = itemRow.ItemDtmx; - itemIdSelected = itemRow.ItemID; - // CONTROLLO SIA in stato 1 --> worked, 2--> selected, 100--> parked... - switch (itemRow.StatusID) - { - case 0: - displError("ERROR: Item not ready", false); - break; - case 1: - case 2: - case 100: - // salvo che è in STATO 2 (picked up) - DataLayer.man.taIL.updateStatus(itemRow.ItemID, 2, PlaceId); - // verifico cosa devo mostrare come PROX passaggio... - showCart = itemRow.ProcessesReq == ""; - showBin = (itemRow.ProcessesReq.Contains("PaintFlag")); - secOp = itemRow.PostProcList; - showSecOp = (secOp != ""); - doUpdate(); - break; - case 3: - displError("Item already on CART!", false); - break; - case 4: - // fino a concorrenza qta richiesta sposto, POI do errori - displError("ALL Item already scanned on BIN!", false); - break; - case 5: - displError("Item already at KIT STATION!", false); - break; - case 990: - displError("Item declared SCRAP!", false); - break; - case 991: - displError("Item declared SCRAP with CNC program created!", false); - break; - default: - displError("ERROR: Item status UNKNOWN!", false); - break; } - } - lbtResetSel.Visible = (itemIdSelected != 0); - } -#endif - /// - /// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload - /// - /// - protected void resetSelection(bool resetStatus) - { -#if false - if (resetStatus) - { - try - { - // SE item esiste... - var tabItem = DataLayer.man.taIL.getBySearch(itemIdSelected, itemIdSelected.ToString(), 0, 999); - if (tabItem.Count == 1) - { - // riposto item a status 1... - DataLayer.man.taIL.updateStatus(itemIdSelected, 1, PlaceId); - } - } - catch - { } - } - // elimino item sel... - itemIdSelected = 0; - resetShowData(); - ComLib.resetItemPickup(SheetID, DeviceId); -#endif - } - private void doUpdate() - { + /// + /// 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; + } + } + } + + #endregion Protected Properties + + #region Public Properties + + /// + /// Cod Stato + /// + public string codStatoIN + { + get + { + return hfCodStatoIN.Value; + } + set + { + hfCodStatoIN.Value = value; + } + } + + /// + /// Cod Stato + /// + public string codStatoOUT + { + get + { + return hfCodStatoOUT.Value; + } + set + { + hfCodStatoOUT.Value = value; + } + } + + /// + /// Cod Flusso x UDC + /// + public string flussoUdc + { + get + { + return hfFlussoUdc.Value; + } + set + { + hfFlussoUdc.Value = value; + } + } + + /// + /// Elenco dei lotti selezionati (riporta a sottocomponenti) + /// + public List lottiSel + { + get + { + return cmp_LottiIn.lottiSel; + } + set + { + cmp_LottiIn.lottiSel = value; + cmp_LottiOut.lottiSel = value; + cmp_ArtOut.lottiSel = value; + } + } + + /// + /// Origine + /// + public string origine + { + get + { + return hfOrigine.Value; + } + set + { + hfOrigine.Value = value; + } + } + + /// + /// Coda di stampa attiva + /// + public string printQueue + { + get + { + // cerco in hidden file... + string answ = hfPrintQueue.Value; + if (string.IsNullOrEmpty(answ)) + { + // altrimenti da currProdData + answ = currProdData.PrintQueue; + } + return answ; + } + set + { + hfPrintQueue.Value = value; + } + } + + /// + /// Tipo di lotto + /// + public string tipoLotto + { + get + { + return hfTipoLotto.Value; + } + set + { + hfTipoLotto.Value = value; + } + } + + /// + /// Tipo Stampa + /// + public string tipoStampa + { + get + { + return lblTipoStampa.Text; + } + set + { + lblTipoStampa.Text = value; + } + } + + #endregion Public Properties + + #region Private Methods + + /// + /// Selezionato un Lotto già creato + /// + /// + /// + private void cmp_ArtOut_eh_doRefresh(object sender, EventArgs e) + { + // mostro button x creare NUOVA etichetta SUL LOTTO ESISTENTE + showCreaStampa(true, false); + } + + /// + /// Reset sel articolo + /// + /// + /// + private void cmp_ArtOut_eh_doReset(object sender, EventArgs e) + { + showCreaStampa(false, false); + } + + 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) + { + resetIcons(); + } + + private void Cmp_creaLottoOUT_eh_doRefresh(object sender, EventArgs e) + { + MagDataLayer.man.taEL.insertQuery(tipoLotto, cmp_ArtOut.CodArtSel, codStatoOUT, origine, "", RifExt, cmp_LottiIn.elLotti); + cmp_LottiOut.doUpdate(); + } + + private void cmp_LottiIn_eh_doReset(object sender, EventArgs e) + { + Response.Redirect(user_std.pagCorrente); + } + + /// + /// Nascondo print lotto + /// + /// + /// + private void cmp_LottiOut_eh_doRefresh(object sender, EventArgs e) + { + // mostro button x creare NUOVO LOTTO + showCreaStampa(false, true); + } + + /// + /// Print lotto + /// + /// + /// + private void cmp_LottiOut_eh_doReset(object sender, EventArgs e) + { + showCreaStampa(false, false); + } + + private void Cmp_printLottoOUT_eh_doRefresh(object sender, EventArgs e) + { + // salvo richiesta stampa della quantità richiesta + int numUdc = cmp_printLottoOUT.numUdc; + decimal qtaTot = cmp_printLottoOUT.qtaTot; + if (numUdc > 0) + { + decimal qtaUdc = qtaTot / numUdc; + string keyParam = cmp_LottiOut.lottoSel; + for (int i = 0; i < numUdc; i++) + { + // creo UDC x semilavorato.. + var tabNewUDC = MagDataLayer.man.taEUdc.insertQuery(cmp_LottiOut.lottoSel, flussoUdc, CodCli, CodPost, qtaUdc, 1, CodOpr, 0, 0, 0, "", 0, ""); + if (tabNewUDC.Count == 1) + { + // cheo stampa per chiave lotto... + MagDataLayer.man.taPJQ.insertQuery(tabNewUDC[0].UDC, printQueue); + } + } + } + // nascondo creazione... + showCreaStampa(false, false); + cmp_LottiIn.doUpdate(); + cmp_LottiOut.doUpdate(); + } + + private void doUpdate() + { #if false // reset grafico icnCart.Attributes.Remove("class"); @@ -624,8 +337,342 @@ namespace MP_MAG.WebUserControls lblLastBCode.CssClass = "text-info"; } // fix btn reset! - lbtResetSel.Visible = (itemIdSelected != 0); + lbtResetSel.Visible = (itemIdSelected != 0); +#endif + } + + private bool processLastCmd(bool doRaiseEv) + { + if (lastCmd == "") doRaiseEv = true; + // processiamo barcode letto + decodedData decoData = MagDataLayer.man.decodeBcode(lastValidCmd); + switch (decoData.codeType) + { + case codeType.UNK: + cmp_barcode.showOutput("text-danger", $"Codice sconosciuto: {decoData.rawData} --> ignoro"); + resetSelection(false); + doRaiseEv = true; + break; + + case codeType.Lotto: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.LottoInt: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + + case codeType.Date: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.PartNumber: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + break; + + case codeType.Quantity: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + + case codeType.Udc: + cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); + //doRaiseEv = true; + break; + //case codeType.Batch: + // cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}"); + // doRaiseEv = true; + // break; + //case codeType.Cart: + // cmp_barcode.showOutput("badge badge-success", $"Valid CR Code: {decoData.description}"); + // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //case codeType.Bin: + // cmp_barcode.showOutput("badge badge-success", $"Valid BN Code: {decoData.description}"); + // processLottoSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //default: + // cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action"); + // resetSelection(false); + // break; + } + + return doRaiseEv; + } + + /// + /// Processo il codice letto + /// + /// + /// + /// + private void processSuggestion(codeType tipoCod, string rawData, int codeInt) + { + //DS_App.ItemListDataTable tabItem = null; + // processo suggerimenti x ITEM / cart / bin dato suo RawData (Dtmx) e Cod univoco (intero) + switch (tipoCod) + { + case codeType.Lotto: + // IN PRIMIS cerco lotto valido + DS_Mag.ElencoLottiDataTable tabLotti; + tabLotti = MagDataLayer.man.taEL.getByKey(rawData, "*", codStatoIN); + if (tabLotti.Count == 1) + { + // se trovato cerco in elenco --> aggiungo in lista se non c'è + var currLotti = lottiSel; + if (!currLotti.Contains(rawData)) + { + currLotti.Add(rawData); + lottiSel = currLotti; + } + } + break; + //case codeType.Item: + // tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); + // if (tabItem.Count == 1) + // { + // showItemDetail(true, tabItem[0], false); + // } + // else if (tabItem.Count == 0) + // { + // showItemDetail(false, null, true); + // } + // break; + //case codeType.ItemGeneric: + // // PRIMA CERCSE ne ho in stato 1..3 + // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 3); + // if (tabItem.Count == 0) + // { + // // se NON ne trovo cerci FINO a stato 5... + // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 5); + // } + // if (tabItem.Count == 1) + // { + // showItemDetail(true, tabItem[0], false); + // } + // else if (tabItem.Count == 0) + // { + // showItemDetail(false, null, true); + // } + // break; + //case codeType.Cart: + // // verifico NON SIA richiesto PAINT + // if (showBin) + // { + // displError("PAINT: BIN REQUESTED: please retry", true); + // } + // else + // { + // if (currCartTab.Count == 1) + // { + // // controllo se sia quello corretto + // if (rawData != currCartTab[0].CartDtmx) + // { + // displError("INCORRECT CART: please retry", true); + // } + // else + // { + // // dichiaro che è depositato + // DataLayer.man.taIL.updateStatus(itemIdSelected, 3, PlaceId); + // lblDestination.Text = $"Item {itemIdSelected} PUT IN CART {rawData}"; + // resetSelection(false); + // } + // } + // } + // break; + //case codeType.Bin: + // // verifico NON SIA richiesto PAINT + // if (showCart) + // { + // displError("NOT PAINTED: CART REQUESTED: please retry", true); + // } + // else + // { + // if (currBinTab.Count == 1) + // { + // // controllo se sia quello corretto + // if (rawData != currBinTab[0].BinDtmx) + // { + // displError("INCORRECT BIN: please retry", true); + // } + // else + // { + // // dichiaro che è depositato + // DataLayer.man.taIL.updateStatus(itemIdSelected, 4, PlaceId); + // lblDestination.Text = $"Item {itemIdSelected} PUT IN BIN {rawData}"; + // resetSelection(false); + // } + // } + // } + // break; + default: + break; + } + } + + private void resetIcons() + { +#if false + lblDestination.CssClass = "text-secondary"; + lblMessage.Text = ""; + lblDestination.Text = ""; + lblLastBCode.Text = ""; + lbtCancel.Visible = false; + lbtScrapped.Visible = false; + lbtParkArea.Visible = false; + lbtResetSel.Visible = (itemIdSelected != 0); +#endif + } + + #endregion Private Methods + + #region Protected Methods + + /// + /// Caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + lottiSel = new List(); + cmp_creaLottoOUT.Visible = false; + cmp_printLottoOUT.Visible = false; + } + // eventi barcode + cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh; + // eventi reset lotti IN + cmp_barcode.eh_doReset += Cmp_barcode_eh_doReset; + cmp_LottiIn.eh_doReset += cmp_LottiIn_eh_doReset; + // selezione articoli + cmp_ArtOut.eh_doRefresh += cmp_ArtOut_eh_doRefresh; + cmp_ArtOut.eh_doReset += cmp_ArtOut_eh_doReset; + // selezione lotti esistenti x stampa + cmp_LottiOut.eh_doRefresh += cmp_LottiOut_eh_doRefresh; + cmp_LottiOut.eh_doReset += cmp_LottiOut_eh_doReset; + // eventi di creazione lotto e stampa + cmp_creaLottoOUT.eh_doRefresh += Cmp_creaLottoOUT_eh_doRefresh; + cmp_printLottoOUT.eh_doRefresh += Cmp_printLottoOUT_eh_doRefresh; + } + + /// + /// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload + /// + /// + protected void resetSelection(bool resetStatus) + { +#if false + if (resetStatus) + { + try + { + // SE item esiste... + var tabItem = DataLayer.man.taIL.getBySearch(itemIdSelected, itemIdSelected.ToString(), 0, 999); + if (tabItem.Count == 1) + { + // riposto item a status 1... + DataLayer.man.taIL.updateStatus(itemIdSelected, 1, PlaceId); + } + } + catch + { } + } + // elimino item sel... + itemIdSelected = 0; + resetShowData(); + ComLib.resetItemPickup(SheetID, DeviceId); +#endif + } + + /// + /// Mostra buttons crea/stampa lotto + /// + /// + /// + protected void showCreaStampa(bool showCrea, bool showPrint) + { + cmp_creaLottoOUT.Visible = showCrea; + cmp_printLottoOUT.Visible = showPrint; + } + + #endregion Protected Methods + +#if false + /// + /// Mostra o nasconde dettaglio su ITEM letto + /// + /// + /// + /// + private void showItemDetail(bool showItem, DS_App.ItemListRow itemRow, bool showError) + { + resetShowData(); + divItemDet.Visible = showItem; + divItemError.Visible = showError; + if (showError) + { + displError("Item not found", true); + } + if (showItem) + { + lblItemCode.Text = itemRow.ItemExtCode; + lblItemDesc.Text = itemRow.ItemDesc; + lblItemDtmx.Text = itemRow.ItemDtmx; + itemIdSelected = itemRow.ItemID; + // CONTROLLO SIA in stato 1 --> worked, 2--> selected, 100--> parked... + switch (itemRow.StatusID) + { + case 0: + displError("ERROR: Item not ready", false); + break; + + case 1: + case 2: + case 100: + // salvo che è in STATO 2 (picked up) + DataLayer.man.taIL.updateStatus(itemRow.ItemID, 2, PlaceId); + // verifico cosa devo mostrare come PROX passaggio... + showCart = itemRow.ProcessesReq == ""; + showBin = (itemRow.ProcessesReq.Contains("PaintFlag")); + secOp = itemRow.PostProcList; + showSecOp = (secOp != ""); + doUpdate(); + break; + + case 3: + displError("Item already on CART!", false); + break; + + case 4: + // fino a concorrenza qta richiesta sposto, POI do errori + displError("ALL Item already scanned on BIN!", false); + break; + + case 5: + displError("Item already at KIT STATION!", false); + break; + + case 990: + displError("Item declared SCRAP!", false); + break; + + case 991: + displError("Item declared SCRAP with CNC program created!", false); + break; + + default: + displError("ERROR: Item status UNKNOWN!", false); + break; + } + } + lbtResetSel.Visible = (itemIdSelected != 0); + } #endif } - } } \ No newline at end of file diff --git a/MagData/Enum.cs b/MagData/Enum.cs index 259830d..2d1b374 100644 --- a/MagData/Enum.cs +++ b/MagData/Enum.cs @@ -6,28 +6,30 @@ using System.Threading.Tasks; namespace MagData { - /// - /// tipologia di report (FILE rdlc) gestito in stampa... - /// - public enum reportRichiesto - { - ND, - CartellinoFinitiOdette, - CartellinoPedane, - CartellinoSemilavorati - } + /// + /// Tipi di barcode gestiti + /// + public enum codeType + { + UNK = 0, + Lotto, + LottoInt, + PackList, + Pedana, + Date, + PartNumber, + Quantity, + Udc + } - /// - /// Tipi di barcode gestiti - /// - public enum codeType - { - UNK = 0, - Lotto, - LottoInt, - Date, - PartNumber, - Quantity, - Udc - } -} + /// + /// tipologia di report (FILE rdlc) gestito in stampa... + /// + public enum reportRichiesto + { + ND, + CartellinoFinitiOdette, + CartellinoPedane, + CartellinoSemilavorati + } +} \ No newline at end of file diff --git a/MagData/MagDataLayer.cs b/MagData/MagDataLayer.cs index c03e9e3..ef274b2 100644 --- a/MagData/MagDataLayer.cs +++ b/MagData/MagDataLayer.cs @@ -224,22 +224,38 @@ namespace MagData public decodedData decodeBcode(string bcValue) { decodedData answ = new decodedData(); + int codeInt = 0; answ.rawData = bcValue; if (bcValue.StartsWith("M")) { answ.codeType = codeType.LottoInt; answ.code = bcValue.Replace("M", ""); - answ.codeInt = 0; + answ.codeInt = codeInt; answ.description = $"Lotto: {answ.code}"; } + else if (bcValue.StartsWith("PED")) + { + answ.codeType = codeType.PackList; + answ.code = bcValue.Replace("PED", ""); + int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); + answ.codeInt = codeInt; + answ.description = $"Pedana: {bcValue}"; + } + else if (bcValue.StartsWith("PL")) + { + answ.codeType = codeType.PackList; + answ.code = bcValue.Replace("PL", ""); + int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); + answ.codeInt = codeInt; + answ.description = $"PackList: {answ.code}"; + } else if (bcValue.StartsWith("P")) { - // conrollo se data (6 numeri...) oppure part... + // controllo se data (6 numeri...) oppure part... if (bcValue.Length == 7) { answ.codeType = codeType.Date; answ.code = bcValue.Replace("P", ""); - int codeInt = 0; int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); answ.codeInt = 0; answ.description = $"Data YYMMDD: {answ.code}"; @@ -248,7 +264,6 @@ namespace MagData { answ.codeType = codeType.PartNumber; answ.code = bcValue.Replace("P", ""); - int codeInt = 0; int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); answ.codeInt = 0; answ.description = $"PartNumber Odette: {answ.code}"; @@ -262,7 +277,6 @@ namespace MagData { answ.codeType = codeType.Quantity; answ.code = bcValue.Replace("Q", ""); - int codeInt = 0; int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); answ.codeInt = codeInt; answ.description = $"Qty Odette: {answ.code}"; @@ -283,7 +297,6 @@ namespace MagData { answ.codeType = codeType.Udc; answ.code = bcValue.Replace("S", ""); - int codeInt = 0; answ.codeInt = codeInt; answ.description = $"UDC Odette: {answ.code}"; } @@ -297,7 +310,6 @@ namespace MagData var riga = tabLotti[0]; answ.codeType = codeType.Lotto; answ.code = bcValue; - int codeInt = 0; answ.codeInt = codeInt; answ.description = $"Lotto: {answ.code}"; } @@ -314,7 +326,6 @@ namespace MagData { answ.codeType = codeType.Udc; answ.code = bcValue; - int codeInt = 0; answ.codeInt = codeInt; answ.description = $"UDC: {answ.code}"; }