428 lines
13 KiB
C#
428 lines
13 KiB
C#
using MagData;
|
|
using Newtonsoft.Json;
|
|
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_prtSemilav : BaseUserControl
|
|
{
|
|
/// <summary>
|
|
/// Comando barcode letto
|
|
/// </summary>
|
|
protected string lastCmd
|
|
{
|
|
get
|
|
{
|
|
return hfLastBCode.Value;
|
|
}
|
|
set
|
|
{
|
|
hfLastBCode.Value = value;
|
|
lastValidCmd = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ULTIMO Comando barcode VALIDO (!="") letto
|
|
/// </summary>
|
|
protected string lastValidCmd
|
|
{
|
|
get
|
|
{
|
|
return hfLastValidBCode.Value;
|
|
}
|
|
set
|
|
{
|
|
// solo se è !=""
|
|
if (value != "")
|
|
{
|
|
hfLastValidBCode.Value = value;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Elenco dei lotti selezionati (riporta a sottocomponenti)
|
|
/// </summary>
|
|
public List<string> lottiSel
|
|
{
|
|
get
|
|
{
|
|
return cmp_semiLavLottiIn.lottiSel;
|
|
}
|
|
set
|
|
{
|
|
cmp_semiLavLottiIn.lottiSel = value;
|
|
cmp_semiLavLottiOut.lottiSel = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
lottiSel = new List<string>();
|
|
}
|
|
cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh;
|
|
cmp_barcode.eh_doReset += Cmp_barcode_eh_doReset;
|
|
cmp_semiLavLottiIn.eh_doReset += Cmp_semiLavLottiIn_eh_doReset;
|
|
}
|
|
|
|
private void Cmp_semiLavLottiIn_eh_doReset(object sender, EventArgs e)
|
|
{
|
|
lottiSel = new List<string>();
|
|
}
|
|
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// Processo il codice letto
|
|
/// </summary>
|
|
/// <param name="tipoCod"></param>
|
|
/// <param name="rawData"></param>
|
|
/// <param name="codeInt"></param>
|
|
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, "E");
|
|
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;
|
|
}
|
|
}
|
|
#if false
|
|
/// <summary>
|
|
/// Mostra o nasconde dettaglio su ITEM letto
|
|
/// </summary>
|
|
/// <param name="showItem"></param>
|
|
/// <param name="itemRow"></param>
|
|
/// <param name="showError"></param>
|
|
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
|
|
/// <summary>
|
|
/// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload
|
|
/// </summary>
|
|
/// <param name="resetStatus"></param>
|
|
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()
|
|
{
|
|
#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 <b>C{cartRow.CartIndex}</b> ({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>B{binRow.BinIndex}</b> ({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
|
|
}
|
|
}
|
|
} |