Files
NKC/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs
T
Samuele E. Locatelli 9cf952075e iniziato pagina StackLoad
2019-09-03 12:59:07 +02:00

145 lines
3.7 KiB
C#

using AppData;
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_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)
{
// processo evento..
lastCmd = cmp_barcode.inputAcquired.ToUpper();
// processiamo barcode letto
decodedData decoData = DataLayer.man.decodeBcode(lastCmd);
switch (decoData.codeType)
{
case codeType.UNK:
cmp_barcode.showOutput("text-danger", "Unknown Data");
break;
case codeType.Item:
cmp_barcode.showOutput("text-warning", "Item - ignored");
break;
case codeType.Material:
cmp_barcode.showOutput("badge badge-warning", $"Material - ignored, {decoData.description}");
break;
case codeType.Sheet:
cmp_barcode.showOutput("badge badge-warning", "Sheet - ignored");
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", $"STACK NOT FOUND, {decoData.description}");
}
else
{
}
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");
break;
default:
break;
}
// reset comando
cmp_barcode.inputAcquired = "";
// aggiorno...
doUpdate();
}
public void doUpdate()
{
//repCtrl.DataBind();
//checkPrint();
}
protected void frmView_DataBound(object sender, EventArgs e)
{
cmp_stackNextloading.BatchId = BatchIdCurr;
}
}
}