291 lines
7.1 KiB
C#
291 lines
7.1 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_confProd : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_inserting;
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_newVal;
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_reset;
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
checkAll();
|
|
}
|
|
}
|
|
|
|
private void checkAll()
|
|
{
|
|
fixSelMacc();
|
|
lblOut.Text = "";
|
|
switchBtnConferma(false);
|
|
btnShowConfProd.Visible = odlOk;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
|
|
/// </summary>
|
|
protected bool isMulti
|
|
{
|
|
get
|
|
{
|
|
return DataLayer.isMulti(idxMacchinaSession);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Se la machcina è MULTI --> mostro selettore
|
|
/// </summary>
|
|
private void fixSelMacc()
|
|
{
|
|
divSelMacc.Visible = isMulti;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica ODL OK (ovvero caricato x macchina...)
|
|
/// </summary>
|
|
protected bool odlOk
|
|
{
|
|
get
|
|
{
|
|
bool answ = true;
|
|
// carico i dati preliminari: ODL
|
|
int idxOdl = 0; // userò ODL del turno
|
|
try
|
|
{
|
|
idxOdl = DataLayer.obj.taODL.getByMacchina(idxMacchina)[0].IdxODL;
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore a recuperare ODL per la macchina {0}", idxMacchina), tipoLog.ERROR);
|
|
}
|
|
// se ODL > 0 è ok!!!
|
|
answ = (idxOdl > 0);
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
string answ = memLayer.ML.StringSessionObj("IdxMacchina");
|
|
// verifoc: 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>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchinaSession
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// cambio stato visibilità pannello e testo button
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnShowConfProd_Click(object sender, EventArgs e)
|
|
{
|
|
switchBtnConferma(!txtNumPezzi.Enabled);
|
|
}
|
|
/// <summary>
|
|
/// determina comportamento btn conferma
|
|
/// </summary>
|
|
private void switchBtnConferma(bool showConf)
|
|
{
|
|
txtNumPezzi.Enabled = showConf;
|
|
txtNumScarti.Enabled = showConf;
|
|
btnSalva.Visible = showConf;
|
|
DS_ProdTempi.stp_PzProd_getByMacchinaRow rigaProd;
|
|
rigaProd = DataLayer.obj.taPzProd2conf.GetData(idxMacchina)[0];
|
|
try
|
|
{
|
|
txtNumPezzi.Text = rigaProd.pezziNonConfermati.ToString();
|
|
txtNumScarti.Text = "0";
|
|
txtPzBuoni.Text = numPzConfermati.ToString();
|
|
// sollevo evento!
|
|
if (eh_inserting != null)
|
|
{
|
|
eh_inserting(this, new EventArgs());
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
txtNumPezzi.Text = "0";
|
|
logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}", idxMacchina), tipoLog.ERROR);
|
|
}
|
|
if (showConf)
|
|
{
|
|
btnShowConfProd.Text = "Nascondi Conferma";
|
|
}
|
|
else
|
|
{
|
|
btnShowConfProd.Text = "Mostra Conferma";
|
|
// sollevo evento!
|
|
if (eh_reset != null)
|
|
{
|
|
eh_reset(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero pezzi PRODOTTI
|
|
/// </summary>
|
|
protected int numPzProdotti
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(txtNumPezzi.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero pezzi SCARTATI
|
|
/// </summary>
|
|
protected int numPzScarto
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(txtNumScarti.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero pezzi confermati (buoni - scarto)
|
|
/// </summary>
|
|
protected int numPzConfermati
|
|
{
|
|
get
|
|
{
|
|
return numPzProdotti - numPzScarto;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo produzione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSalva_Click(object sender, EventArgs e)
|
|
{
|
|
if (memLayer.ML.CRI("modoConfProd") == 2)
|
|
{
|
|
confermaPerTurni();
|
|
}
|
|
else
|
|
{
|
|
confermaPerGiorni();
|
|
}
|
|
// refresh tabella dati tablet...
|
|
DataLayer.obj.taMSE.getByRefreshData(memLayer.ML.confReadInt("refrMSE_0"));
|
|
// mostro output
|
|
lblOut.Text = string.Format("Confermata la produzione per {0} pezzi! ({1} scarto)", numPzConfermati, numPzScarto);
|
|
// cambio button conferma...
|
|
switchBtnConferma(!txtNumPezzi.Enabled);
|
|
// sollevo evento!
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua conferma per giorni della produzione
|
|
/// </summary>
|
|
private void confermaPerGiorni()
|
|
{
|
|
DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), numPzConfermati, numPzScarto);
|
|
}
|
|
/// <summary>
|
|
/// effettua conferma per turni della produzione
|
|
/// </summary>
|
|
private void confermaPerTurni()
|
|
{
|
|
DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), numPzConfermati, numPzScarto);
|
|
}
|
|
/// <summary>
|
|
/// update post modifica pz buoni
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtNumPezzi_TextChanged(object sender, EventArgs e)
|
|
{
|
|
updatePzBuoni();
|
|
}
|
|
/// <summary>
|
|
/// aggiorna visualizzazione pz buoni /prodotti - scarti)
|
|
/// </summary>
|
|
private void updatePzBuoni()
|
|
{
|
|
txtPzBuoni.Text = numPzConfermati.ToString();
|
|
}
|
|
/// <summary>
|
|
/// update post modifica pz scarto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtNumScarti_TextChanged(object sender, EventArgs e)
|
|
{
|
|
updatePzBuoni();
|
|
}
|
|
|
|
protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
checkAll();
|
|
}
|
|
}
|
|
} |