Files
Samuele Locatelli ab3ba0881e Update x gestione
- refresh dettaglio macchina
- gestione eventi disposed
2022-09-28 19:10:32 +02:00

251 lines
7.4 KiB
C#

using MapoDb;
using SteamWare;
using System;
using System.Web.UI;
namespace MoonProTablet
{
public partial class ODL : BasePage
{
#region Protected Fields
/// <summary>
/// Valore protected idxODL
/// </summary>
protected string _idxOdlAltraMacc;
/// <summary>
/// Valore protected idxODL
/// </summary>
protected string _idxOdlMacc;
#endregion Protected Fields
#region Public Properties
/// <summary>
/// Verifica se la macchina NON abbia ODL (valido, > 0)
/// </summary>
public bool emptyOdlMacc
{
get
{
return (idxOdlMacc == "" || idxOdlMacc == "0");
}
}
/// <summary>
/// idx macchina selezionata
/// </summary>
public string idxMacchinaFix
{
get
{
string answ = idxMacchina;
// verifico: se multi uso selettore tendina...
if (isMulti)
{
if (ddlSubMacc.SelectedValue == "")
{
ddlSubMacc.DataBind();
}
if (ddlSubMacc.SelectedValue != "")
{
answ = ddlSubMacc.SelectedValue;
}
}
return answ;
}
set
{
memLayer.ML.setSessionVal("IdxMacchina", value);
}
}
/// <summary>
/// IdxODL sulla macchina
/// </summary>
public string idxOdlMacc
{
get
{
if (_idxOdlMacc == null)
{
_idxOdlMacc = DataLayerObj.currODL(idxMacchinaFix, true);
}
return _idxOdlMacc;
}
set
{
_idxOdlMacc = value;
}
}
#endregion Public Properties
#region Private Methods
private void checkAll()
{
// parto: nascondo tutto...
mod_ODL1.hideAll();
fixSelMacc();
memLayer.ML.setSessionVal("TipoLink", "EditMacch");
// imposto idxMacchina x subControl...
mod_ODL1.idxMacchinaFix = idxMacchinaFix;
checkConfProd();
mod_ODL1.checkAll();
mod_ODL1.fixODL();
}
/// <summary>
/// verifica se sia necessario confermare la produzione PRIMA di operare sull'ODL
/// </summary>
private void checkConfProd()
{
// controllo ODL mancante, x cui SE ci fossero pezzi --> va fatto attrezzaggio ODL retrodatato
bool odlOk = false;
try
{
odlOk = !emptyOdlMacc;
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore recupero ODL corrente da confermare per la macchina {0}{1}{2}", idxMacchinaFix, Environment.NewLine, exc), tipoLog.ERROR);
}
// verifica se sia necessario confermare produzione
bool needConfProd = true;
int pz2conf = 0;
DS_ProdTempi.stp_PzProd_getByMacchinaRow rigaProd;
try
{
rigaProd = DataLayerObj.taPzProd2conf.GetData(idxMacchinaFix)[0];
pz2conf = rigaProd.pezziNonConfermati;
needConfProd = (pz2conf > 0 && !isSlave);
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}{1}{2}", idxMacchinaFix, Environment.NewLine, exc), tipoLog.ERROR);
}
// se necessario mostro warning...
if (needConfProd)
{
// SE mancasse ODL mostro info x poter caricare ODL retrodatato
if (odlOk)
{
lblWarningHead.Text = traduci("ConfProdBeforeContinueHead");
lblWarningBody.Text = traduci("ConfProdBeforeContinueBody");
lblNumPz2Conf.Text = string.Format("{0} pz NC", pz2conf);
}
else
{
lblWarningHead.Text = traduci("setOdlBeforeContinueHead");
lblWarningBody.Text = traduci("setOdlBeforeContinueBody");
lblNumPz2Conf.Text = string.Format("{0} pz NC", pz2conf);
}
}
divPz2Conf.Visible = needConfProd;
divWarn.Visible = needConfProd;
lbtFixOdl.Visible = !odlOk;
mod_ODL1.isEnabled = !needConfProd;
}
private void fixDisplaySlave()
{
cmp_SlaveMachine.Visible = isSlave;
mod_ODL1.Visible = !isSlave;
divSelMacc.Visible = !isSlave;
}
/// <summary>
/// Se la machcina è MULTI --> mostro selettore
/// </summary>
private void fixSelMacc()
{
divSelMacc.Visible = isMulti;
if (isMulti)
{
// salvo selezione submacc
ddlSubMacc.DataBind();
subMaccSel = ddlSubMacc.SelectedValue;
}
}
/// <summary>
/// Update controlli post richiesta refresh da child
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Mod_ODL1_eh_reqUpdate(object sender, EventArgs e)
{
// forzo update macchina...
DataLayerObj.taMSE.forceRecalc(0, idxMacchinaFix);
// update display!
ddlSubMacc.DataBind();
mod_dettMacchina1.doUpdate();
}
#endregion Private Methods
#region Protected Methods
protected void ddlSubMacc_DataBound(object sender, EventArgs e)
{
// se ho in memoria un valore LO REIMPOSTO...
if (subMaccSel != "")
{
// provo a preselezionare...
try
{
ddlSubMacc.SelectedValue = subMaccSel;
}
catch
{ }
}
}
protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e)
{
// procedo...
subMaccSel = ddlSubMacc.SelectedValue;
checkAll();
}
protected void lbtFixOdl_Click(object sender, EventArgs e)
{
Response.Redirect("~/fixODL");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
mod_dettMacchina1.doUpdate();
dtTimerOdlInt.Interval = memLayer.ML.CRI("dtTimerOdlInt");
checkAll();
}
fixDisplaySlave();
mod_ODL1.eh_reqUpdate += Mod_ODL1_eh_reqUpdate;
}
public override void Dispose()
{
mod_ODL1.eh_reqUpdate -= Mod_ODL1_eh_reqUpdate;
base.Dispose();
}
/// <summary>
/// timeout scaduto
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Timer1_Tick(object sender, EventArgs e)
{
// effettuo verifica attrezzabilità ODL
checkAll();
mod_dettMacchina1.doUpdate();
}
#endregion Protected Methods
}
}