530 lines
17 KiB
C#
530 lines
17 KiB
C#
using MagData;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
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
|
|
{
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Comando ULTIMO 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 è non nullo/vuoto
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
hfLastValidBCode.Value = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Cod Stato materiale in ingresso
|
|
/// </summary>
|
|
public string codStatoIN
|
|
{
|
|
get
|
|
{
|
|
return hfCodStatoIN.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodStatoIN.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cod Stato in uscita
|
|
/// </summary>
|
|
public string codStatoOUT
|
|
{
|
|
get
|
|
{
|
|
return hfCodStatoOUT.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodStatoOUT.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cod Flusso x UDC
|
|
/// </summary>
|
|
public string flussoUdc
|
|
{
|
|
get
|
|
{
|
|
return hfFlussoUdc.Value;
|
|
}
|
|
set
|
|
{
|
|
hfFlussoUdc.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco dei lotti selezionati (riporta a sottocomponenti)
|
|
/// </summary>
|
|
public List<string> lottiSel
|
|
{
|
|
get
|
|
{
|
|
return cmp_LottiIn.lottiSel;
|
|
}
|
|
set
|
|
{
|
|
cmp_LottiIn.lottiSel = value;
|
|
cmp_LottiOut.lottiSel = value;
|
|
cmp_ArtOut.lottiSel = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Origine
|
|
/// </summary>
|
|
public string origine
|
|
{
|
|
get
|
|
{
|
|
return hfOrigine.Value;
|
|
}
|
|
set
|
|
{
|
|
hfOrigine.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Coda di stampa attiva
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tipo di lotto
|
|
/// </summary>
|
|
public string tipoLotto
|
|
{
|
|
get
|
|
{
|
|
return hfTipoLotto.Value;
|
|
}
|
|
set
|
|
{
|
|
hfTipoLotto.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tipo Stampa
|
|
/// </summary>
|
|
public string tipoStampa
|
|
{
|
|
get
|
|
{
|
|
return lblTipoStampa.Text;
|
|
}
|
|
set
|
|
{
|
|
lblTipoStampa.Text = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Selezionato un Lotto già creato
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void cmp_ArtOut_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
// mostro button x creare NUOVA etichetta SUL LOTTO ESISTENTE
|
|
showCreaStampa(true, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset sel articolo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nascondo print lotto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void cmp_LottiOut_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
// mostro button x creare NUOVO LOTTO
|
|
showCreaStampa(false, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Print lotto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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;
|
|
tipoDocumento tipoDoc = currData.isProdFinito ? tipoDocumento.docFinito : tipoDocumento.docSemilavorato;
|
|
for (int i = 0; i < numUdc; i++)
|
|
{
|
|
// creo UDC x semilavorato..
|
|
MagDataLayer.man.taEUdc.insertQuery(cmp_LottiOut.lottoSel, flussoUdc, CodCli, CodPost, qtaUdc, 1, CodOpr, 0, 0, 0, "", 0, "");
|
|
// cheo stampa per chiave lotto...
|
|
MagDataLayer.man.taPJQ.insertQuery($"{tipoDoc}", keyParam, printQueue);
|
|
}
|
|
}
|
|
// nascondo creazione...
|
|
showCreaStampa(false, false);
|
|
cmp_LottiIn.doUpdate();
|
|
cmp_LottiOut.doUpdate();
|
|
}
|
|
|
|
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.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, "*", 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
|
|
|
|
/// <summary>
|
|
/// Caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
lottiSel = new List<string>();
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload
|
|
/// </summary>
|
|
/// <param name="resetStatus"></param>
|
|
protected void resetSelection(bool resetStatus)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mostra buttons crea/stampa lotto
|
|
/// </summary>
|
|
/// <param name="showCrea"></param>
|
|
/// <param name="showPrint"></param>
|
|
protected void showCreaStampa(bool showCrea, bool showPrint)
|
|
{
|
|
cmp_creaLottoOUT.Visible = showCrea;
|
|
cmp_printLottoOUT.Visible = showPrint;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
}
|
|
} |