using AppData; using NKC_SDK; using SteamWare; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NKC_WF.WebUserControls { public partial class cmp_batchDetail : BaseUserControl { #region Protected Properties /// /// verifica se il batch sia di tipo ancestor (da splittare su macchine) /// protected bool BatchIsAncestor { get { return ComLib.BType(BatchId) == BatchType.Ancestor; } } #endregion Protected Properties #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; } } /// /// verifica possibilità avvio TASK x presenza task NON chiusi /// /// public bool canStartNew { get { return ComLib.canStartNew; } } #endregion Public Properties #region Private Methods private void fixDisplayDesc() { divSplit.Visible = BatchIsAncestor; cmp_batchDetailMongo.Visible = !BatchIsAncestor; } #endregion Private Methods #region Protected Methods /// /// Accetta Nesting /// /// /// protected void lbtAccept_Click(object sender, EventArgs e) { // registro accettazione Nesting DLMan.taBL.acceptBatch(BatchId, DLMan.CodSoggCurrUser); raiseEvent(); } /// /// Verifica se il batch sia stato splittato /// public bool isSplitted { get => cmp_batchDetailSplit.isSplitted; } /// /// Riporta nesting a stato ESTIMATED /// /// /// 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); raiseEvent(); } protected void lbtSendEstim_Click(object sender, EventArgs e) { // invia a redis una richiesta... ComLib.sendMaterials(); ComLib.sendBatchReq(BatchId, "Estimation", 3, false, 0); // 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); } // registro su DB nesting iniziato... DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.EstimationRequested, "", 0); raiseEvent(); } 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); } } } 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 ComLib.sendBatchReq(BatchId, "Nesting", 2, false, 1); // registro su DB nesting iniziato... DLMan.taBL.updateStatus(BatchId, (int)BatchStatus.NestRequested, "", -1); } 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) { cmp_batchDetailSplit.eh_doReset += Cmp_batchDetailSplit_eh_doReset; } private void Cmp_batchDetailSplit_eh_doReset(object sender, EventArgs e) { frmView.DataBind(); fixDisplayDesc(); } /// /// Effettua divisione evitando zeri a den... /// /// /// /// protected double ratioProt(double num, double den) { den = den == 0 ? 1 : den; return num / den; } #endregion Protected Methods #region Public Methods /// /// Converte il codice stato in effettivo campo /// /// /// public string BStatus(object _status) { string answ = ComLib.BatchStatusDescr(_status); return answ; } /// /// Controlla se lo stato sia uguale a quello richiesto /// /// /// /// 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; } /// /// Controlla se il type sia uguale a quello richiesto /// /// /// /// 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(); } } #endregion Public Methods } }