351 lines
11 KiB
C#
351 lines
11 KiB
C#
using AppData;
|
|
using NKC_SDK;
|
|
using System;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_batchDetail : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
public int BatchId
|
|
{
|
|
set
|
|
{
|
|
hfBatchId.Value = value.ToString();
|
|
frmView.DataBind();
|
|
cmp_batchDetailSplit.BatchId = value;
|
|
cmp_batchDetailMongo.BatchId = value;
|
|
if (BatchId > 0)
|
|
{
|
|
fixDisplayDesc();
|
|
}
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfBatchId.Value, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Abilitazione azioni button-based
|
|
/// </summary>
|
|
public bool BtnActEnab
|
|
{
|
|
get
|
|
{
|
|
return chkActEnab.Checked;
|
|
}
|
|
set
|
|
{
|
|
chkActEnab.Checked = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica possibilità avvio TASK x presenza task NON chiusi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool canStartNew
|
|
{
|
|
get
|
|
{
|
|
return ComLib.canStartNew;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica se il batch sia stato splittato
|
|
/// </summary>
|
|
public bool isSplitted
|
|
{
|
|
get => cmp_batchDetailSplit.isSplitted;
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Converte il codice stato in effettivo campo
|
|
/// </summary>
|
|
/// <param name="_status"></param>
|
|
/// <returns></returns>
|
|
public string BStatus(object _status)
|
|
{
|
|
string answ = ComLib.BatchStatusDescr(_status);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Controlla se lo stato sia uguale a quello richiesto
|
|
/// </summary>
|
|
/// <param name="_status"></param>
|
|
/// <param name="statusReq"></param>
|
|
/// <returns></returns>
|
|
public bool checkStatus(object _status, BatchStatus statusReq)
|
|
{
|
|
bool answ = false;
|
|
int status = -1;
|
|
int.TryParse(_status.ToString(), out status);
|
|
answ = (status == (int)statusReq);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Controlla se il type sia uguale a quello richiesto
|
|
/// </summary>
|
|
/// <param name="_bType"></param>
|
|
/// <param name="bTypeReq"></param>
|
|
/// <returns></returns>
|
|
public bool checkType(object _bType, BatchType bTypeReq)
|
|
{
|
|
bool answ = false;
|
|
int bType = -1;
|
|
int.TryParse(_bType.ToString(), out bType);
|
|
answ = (bType == (int)bTypeReq);
|
|
return answ;
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
frmView.DataBind();
|
|
fixDisplayDesc();
|
|
if (divSplit.Visible)
|
|
{
|
|
cmp_batchDetailSplit.doUpdate(false);
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// verifica se il batch sia di tipo ancestor (da splittare su macchine)
|
|
/// </summary>
|
|
protected bool BatchIsAncestor
|
|
{
|
|
get
|
|
{
|
|
return ComLib.BType(BatchId) == BatchType.Ancestor;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Accetta Nesting
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtAccept_Click(object sender, EventArgs e)
|
|
{
|
|
// registro accettazione Nesting
|
|
DLMan.taBL.acceptBatch(BatchId, DLMan.CodSoggCurrUser);
|
|
raiseEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Riporta nesting a stato ESTIMATED
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtResetNest_Click(object sender, EventArgs e)
|
|
{
|
|
// ri-assegnazione ordini/kit a batch ancestor
|
|
DLMan.taOLT.setBatchSplit(BatchId, false);
|
|
// registro reset Nesting
|
|
DLMan.taBL.refuseNesting(BatchId, DLMan.CodSoggCurrUser);
|
|
// elimino gli errori vecchi della richiesta
|
|
DS_App.BatchListDataTable batchTab = DLMan.taBL.getByKey(BatchId);
|
|
if (batchTab != null && batchTab.Rows.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
var bRow = (DS_App.BatchListRow)batchTab.Rows[0];
|
|
DLMan.taEL.deteteByParent("", bRow.EnvNum);
|
|
// cerco se ci siano batch descendant...
|
|
var childBatch = DLMan.taBL.getDescendByKey(BatchId);
|
|
if (childBatch != null && childBatch.Count > 0)
|
|
{
|
|
foreach (var item in childBatch)
|
|
{
|
|
DLMan.taEL.deteteByParent("", item.EnvNum);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Instance.Error($"Eccezione in eliminazione EL precedenti{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void lbtSendEstim_Click(object sender, EventArgs e)
|
|
{
|
|
// invia a redis una richiesta...
|
|
ComLib.sendMaterials();
|
|
ComLib.sendBatchReq(BatchId, "Estimation", 3, false, 0, false);
|
|
|
|
// ri-assegnazione ordini/kit a batch ancestor
|
|
if (BatchIsAncestor)
|
|
{
|
|
DLMan.taOLT.setBatchSplit(BatchId, false);
|
|
// registro reset Nesting
|
|
DLMan.taBL.refuseNesting(BatchId, DLMan.CodSoggCurrUser);
|
|
// resetto i batch child a 0 se presenti
|
|
resetChildBatch();
|
|
// elimino gli orderExtTree
|
|
DLMan.taOLT.deleteByBatch(BatchId);
|
|
}
|
|
// elimino gli errori vecchi della richiesta
|
|
DS_App.BatchListDataTable batchTab = DLMan.taBL.getByKey(BatchId);
|
|
if (batchTab != null && batchTab.Rows.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
var bRow = (DS_App.BatchListRow)batchTab.Rows[0];
|
|
DLMan.taEL.deteteByParent("", bRow.EnvNum);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Instance.Error($"Eccezione in eliminazione EL precedenti{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
|
|
// registro su DB nesting iniziato...
|
|
DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.EstimationRequested, "", 0);
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void lbtSendNesting_Click(object sender, EventArgs e)
|
|
{
|
|
// invia a redis a a richiesta...
|
|
ComLib.sendMaterials();
|
|
// controllo SE SIA un batch ANCESTOR --> invio il PRIMO batch da calcolare...
|
|
if (BatchIsAncestor)
|
|
{
|
|
// effettuo VERA ri-assegnazione ordini/kit a nuovi batch
|
|
DLMan.taOLT.setBatchSplit(BatchId, true);
|
|
bool fatto = ComLib.checkSendBatchSplit(BatchId);
|
|
}
|
|
else
|
|
{
|
|
// invio il batch corrente, SENZA richiesta PNG
|
|
ComLib.sendBatchReq(BatchId, "Nesting", 2, false, 1, false);
|
|
// registro su DB nesting iniziato...
|
|
DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.NestRequested, "", -1);
|
|
}
|
|
// elimino gli errori vecchi della richiesta
|
|
DS_App.BatchListDataTable batchTab = DLMan.taBL.getByKey(BatchId);
|
|
if (batchTab != null && batchTab.Rows.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
var bRow = (DS_App.BatchListRow)batchTab.Rows[0];
|
|
DLMan.taEL.deteteByParent("", bRow.EnvNum);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Instance.Error($"Eccezione in eliminazione EL precedenti{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void lbtStopEstim_Click(object sender, EventArgs e)
|
|
{
|
|
// resetto richiesta
|
|
ComLib.resetBatchReq();
|
|
// registro su DB nesting iniziato...
|
|
DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.Imported, "", -1);
|
|
if (BatchIsAncestor)
|
|
{
|
|
resetChildBatch();
|
|
}
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void lbtStopNesting_Click(object sender, EventArgs e)
|
|
{
|
|
// resetto richiesta
|
|
ComLib.resetBatchReq();
|
|
// registro su DB nesting iniziato...
|
|
DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.EstimationDone, "", -1);
|
|
if (BatchIsAncestor)
|
|
{
|
|
var tabDesc = ComLib.BatchDescendant(BatchId);
|
|
if (tabDesc != null && tabDesc.Count > 0)
|
|
{
|
|
foreach (var item in tabDesc)
|
|
{
|
|
DLMan.taBL.updateStatus(item.BatchID, (int)BatchStatus.EstimationDone, "", -1);
|
|
}
|
|
}
|
|
}
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// sistemo buttons
|
|
cmp_batchDetailSplit.BtnEnabled = BtnActEnab;
|
|
}
|
|
cmp_batchDetailSplit.eh_doReset += Cmp_batchDetailSplit_eh_doReset;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Effettua divisione evitando zeri a den...
|
|
/// </summary>
|
|
/// <param name="num"></param>
|
|
/// <param name="den"></param>
|
|
/// <returns></returns>
|
|
protected double ratioProt(double num, double den)
|
|
{
|
|
den = den == 0 ? 1 : den;
|
|
return num / den;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private void Cmp_batchDetailSplit_eh_doReset(object sender, EventArgs e)
|
|
{
|
|
frmView.DataBind();
|
|
fixDisplayDesc();
|
|
}
|
|
|
|
private void fixDisplayDesc()
|
|
{
|
|
divSplit.Visible = BatchIsAncestor;
|
|
cmp_batchDetailMongo.Visible = !BatchIsAncestor;
|
|
}
|
|
|
|
private void resetChildBatch()
|
|
{
|
|
var tabDesc = ComLib.BatchDescendant(BatchId);
|
|
if (tabDesc != null && tabDesc.Count > 0)
|
|
{
|
|
foreach (var item in tabDesc)
|
|
{
|
|
DLMan.taBL.updateStatus(item.BatchID, (int)BatchStatus.Imported, "", -1);
|
|
// elimino order tree eventuale...
|
|
DLMan.taOLT.deleteByBatch(item.BatchID);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |