Files
NKC/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs
T
2020-02-07 14:28:03 +01:00

220 lines
6.4 KiB
C#

using AppData;
using NKC_SDK;
using SteamWare;
using System;
namespace NKC_WF.WebUserControls
{
public partial class cmp_stackLoading : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// svuoto input barcode...
cmp_barcode.inputAcquired = "";
lastCmd = "";
cmp_stackNextloading.BatchId = BatchIdCurr;
raiseEvent();
doUpdate();
}
cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh;
}
/// <summary>
/// Comando barcode letto
/// </summary>
protected string lastCmd
{
get
{
return hfBarcode.Value;
}
set
{
hfBarcode.Value = value;
}
}
public int BatchIdCurr
{
get
{
int answ = 0;
try
{
int.TryParse(frmView.SelectedValue.ToString(), out answ);
}
catch
{ }
return answ;
}
}
public int StackId
{
set
{
hfStackId.Value = value.ToString();
lastCmd = "";
cmp_barcode.resetMessage();
doUpdate();
}
get
{
int answ = 0;
int.TryParse(hfStackId.Value, out answ);
return answ;
}
}
private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e)
{
bool doRaiseEv = false;
// processo evento..
lastCmd = cmp_barcode.inputAcquired.ToUpper();
if (lastCmd == "") doRaiseEv = true;
// processiamo barcode letto
decodedData decoData = DataLayer.man.decodeBcode(lastCmd);
switch (decoData.codeType)
{
case codeType.UNK:
cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action");
doRaiseEv = true;
break;
case codeType.Item:
case codeType.ItemGeneric:
cmp_barcode.showOutput("text-warning", $"Item - ignored: {decoData.description}");
doRaiseEv = true;
break;
case codeType.Material:
cmp_barcode.showOutput("badge badge-warning", $"Material - ignored: {decoData.description}");
doRaiseEv = true;
break;
case codeType.Sheet:
cmp_barcode.showOutput("badge badge-warning", $"Sheet - ignored: {decoData.description}");
doRaiseEv = true;
break;
case codeType.Stack:
// verifico SE lo stack esista...
DS_App.StackListDataTable tabStack = DataLayer.man.taSTL.getByKey(decoData.codeInt);
if (tabStack.Count == 0)
{
cmp_barcode.showOutput("badge badge-danger", $"BUNK NOT FOUND: {decoData.description}");
}
else
{
// controllo sia quello RICHIESTO, eventualemtne permetteremo TUTTI quelli del giorno in ogni ordine...
if (decoData.codeInt == cmp_stackNextloading.StackIdReq)
{
cmp_barcode.showOutput("badge badge-success", $"BUNK OK, {decoData.rawData}");
ComLib.taktMLCurrStack = decoData.code;
// processo DB e salvbo che lo stack è stato caricato in MACHINE LOAD
int stackId = 0;
try
{
var tabStacks = DataLayer.man.taSTL.getByDtmx(decoData.rawData);
if (tabStack.Count == 1)
{
stackId = tabStack[0].StackID;
}
}
catch
{ }
// SE HO uno stackId valido (>0)...
if (stackId > 0)
{
DataLayer.man.taSTL.updatePos(stackId, 5);
doRaiseEv = true;
}
}
else
{
cmp_barcode.showOutput("badge badge-danger", $"WRONG BUNK, {decoData.rawData}");
}
}
//DS_App.SheetListDataTable nextTbl = DataLayer.man.taSHL.getNextByStack(StackId);
//// se tab vuota --> HO FINITO!!!!
//if (nextTbl.Count == 0)
//{
// cmp_barcode.showOutput("badge badge-warning", $"STACK IS COMPLETED, {decoData.description}");
//}
//// se ho valori --> controllo se corretto...
//else
//{
// string codReq = nextTbl[0].MatExtCode.ToString();
// if (codReq == decoData.codeInt.ToString())
// {
// cmp_barcode.showOutput("badge badge-success", $"SHEET RECORDED: {decoData.description}");
// // chiamo stored x indicare preparato
// DataLayer.man.taSHL.setPrepared(nextTbl[0].SheetID);
// }
// else
// {
// cmp_barcode.showOutput("badge badge-danger", $"WRONG SHEET: {decoData.description}");
// }
//}
//cmp_barcode.showOutput("badge badge-warning", "Stack - ignored");
break;
case codeType.Batch:
cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}");
doRaiseEv = true;
break;
default:
doRaiseEv = true;
break;
}
// reset comando
cmp_barcode.inputAcquired = "";
// aggiorno...
doUpdate();
// se richiesto faccio raiseEvent
if (doRaiseEv)
{
cmp_stackNextloading.doUpdate();
raiseEvent();
}
}
protected void checkVisibility()
{
lblLoaded.Visible = StackId != 0;
frmView.Visible = !lblLoaded.Visible;
// fix div di simulazione
divSim.Visible = (memLayer.ML.CRS("environment") == "DEV");
}
public void doUpdate()
{
//repCtrl.DataBind();
//checkPrint();
checkVisibility();
}
protected void frmView_DataBound(object sender, EventArgs e)
{
cmp_stackNextloading.BatchId = BatchIdCurr;
raiseEvent();
}
protected void lbtAdvanceProd_Click(object sender, EventArgs e)
{
// chiama stored x cambiare dt dei vari processi governati dal prod...
var currStack = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
if (currStack != null)
{
if (currStack.Count > 0)
{
int stackIdCurr = currStack[0].StackID;
DataLayer.man.taSHL.advanceInStack(stackIdCurr);
}
doUpdate();
raiseEvent();
}
}
protected void lbtAdvanceBunk_Click(object sender, EventArgs e)
{
// simula invio barcode del PROSSIMO BUNK (SE necessario)
}
}
}