327 lines
7.6 KiB
C#
327 lines
7.6 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_regScarti : System.Web.UI.UserControl
|
|
{
|
|
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_newVal;
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_reset;
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
DataLayer DataLayerObj = new DataLayer();
|
|
/// <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();
|
|
fixData();
|
|
checkOdl();
|
|
lblOut.Text = "";
|
|
switchBtnConferma(true);
|
|
lbtShowScarti.Visible = odlOk;
|
|
lblConfScarti.Visible = !odlOk;
|
|
}
|
|
|
|
private void fixData()
|
|
{
|
|
DateTime adesso = DateTime.Now;
|
|
txtData.Text = adesso.ToString("yyyy-MM-dd");
|
|
txtOra.Text = adesso.ToString("HH:mm");
|
|
numPzScarto = 1;
|
|
}
|
|
/// <summary>
|
|
/// Num pezzi scarto
|
|
/// </summary>
|
|
protected int numPzScarto
|
|
{
|
|
set
|
|
{
|
|
txtNumPz.Text = value.ToString();
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(txtNumPz.Text, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifica se abbia un ODL ATTIVO
|
|
/// </summary>
|
|
private void checkOdl()
|
|
{
|
|
lbtShowScarti.Visible = odlOk;
|
|
lblConfScarti.Visible = !odlOk;
|
|
lblMancaODL.Visible = !odlOk;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Se la machcina è MULTI --> mostro selettore
|
|
/// </summary>
|
|
private void fixSelMacc()
|
|
{
|
|
divSelMacc.Visible = isMulti;
|
|
fixSelMaccScarti();
|
|
}
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
|
|
/// </summary>
|
|
protected bool isMulti
|
|
{
|
|
get
|
|
{
|
|
return DataLayerObj.isMulti(idxMacchinaSession);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
|
|
/// </summary>
|
|
/// <summary>
|
|
/// restituisce css disabled SE odl NON OK...
|
|
/// </summary>
|
|
public string cssBtnConf
|
|
{
|
|
get
|
|
{
|
|
return odlOk ? "" : "disabled";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifica ODL OK (ovvero caricato x macchina...)
|
|
/// </summary>
|
|
public bool odlOk
|
|
{
|
|
get
|
|
{
|
|
bool answ = true;
|
|
// carico i dati preliminari: ODL
|
|
int idxOdl = 0; // userò ODL del turno
|
|
try
|
|
{
|
|
idxOdl = DataLayerObj.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 lbtShowContr_Click(object sender, EventArgs e)
|
|
{
|
|
switchBtnConferma(!divDetail.Visible);
|
|
}
|
|
/// <summary>
|
|
/// determina comportamento btn conferma
|
|
/// </summary>
|
|
private void switchBtnConferma(bool showConf)
|
|
{
|
|
divDetail.Visible = showConf;
|
|
if (showConf)
|
|
{
|
|
lblShowScarti.Text = "Nascondi Registrazione SCARTI";
|
|
}
|
|
else
|
|
{
|
|
lblShowScarti.Text = "Mostra Registrazione SCARTI";
|
|
// sollevo evento!
|
|
if (eh_reset != null)
|
|
{
|
|
eh_reset(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void resetControlli()
|
|
{
|
|
txtNote.Text = "";
|
|
// nascondo!
|
|
switchBtnConferma(false);
|
|
}
|
|
|
|
protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
subMaccSel = ddlSubMacc.SelectedValue;
|
|
fixSelMaccScarti();
|
|
checkAll();
|
|
}
|
|
|
|
private void fixSelMaccScarti()
|
|
{
|
|
if (isMulti)
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchinaScarti", subMaccSel);
|
|
}
|
|
else
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchinaScarti", idxMacchinaSession);
|
|
}
|
|
}
|
|
|
|
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
|
|
{ }
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Sotto sistema (macchina) selezionato
|
|
/// </summary>
|
|
public string subMaccSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("subMaccSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("subMaccSel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo produzione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtSalva_Click(object sender, EventArgs e)
|
|
{
|
|
salvaRegScarti("ND");
|
|
}
|
|
/// <summary>
|
|
/// Effettua salvataggio in registro scarti
|
|
/// </summary>
|
|
private void salvaRegScarti(string causale)
|
|
{
|
|
// salvo registrazione scarto...
|
|
DateTime dataRif = DateTime.Now;
|
|
try
|
|
{
|
|
// ricompongo data dai 2 controlli
|
|
DateTime dateOnly;
|
|
DateTime timeOnly;
|
|
DateTime.TryParse(txtData.Text, out dateOnly);
|
|
DateTime.TryParse(txtOra.Text, out timeOnly);
|
|
dataRif = dateOnly.Add(timeOnly.TimeOfDay);
|
|
}
|
|
catch
|
|
{ }
|
|
DataLayerObj.taRS.insertQuery(idxMacchina, dataRif, causale, numPzScarto, txtNote.Text.Trim(), DataLayerObj.MatrOpr);
|
|
// sollevo evento!
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
resetControlli();
|
|
}
|
|
|
|
/// <summary>
|
|
/// rimanda alla pagina di dettaglio della macchina scelta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void hlRegistra_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lnkbtn = (LinkButton)sender;
|
|
string causale = "";
|
|
try
|
|
{
|
|
causale = lnkbtn.CommandArgument;
|
|
}
|
|
catch
|
|
{ }
|
|
// se vuoto metto ND...
|
|
causale = (causale == "") ? "ND" : causale;
|
|
salvaRegScarti(causale);
|
|
// sollevo evento!
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
protected void lbtResetNumPz_Click(object sender, EventArgs e)
|
|
{
|
|
txtNumPz.Text = "";
|
|
}
|
|
}
|
|
} |