using MapoDb; using SteamWare; using System; using System.Web.UI; namespace MoonProTablet.WebUserControls { public partial class mod_confProd : System.Web.UI.UserControl { /// /// registrato nuovo valore /// public event EventHandler eh_inserting; /// /// registrato nuovo valore /// public event EventHandler eh_newVal; /// /// registrato nuovo valore /// public event EventHandler eh_reset; /// /// caricamento pagina /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { checkAll(); } } private void checkAll() { fixSelMacc(); checkOdl(); lblOut.Text = ""; switchBtnConferma(false); lbtShowConfProd.Visible = odlOk; lblConfProd.Visible = !odlOk; } /// /// Verifica se abbia un ODL ATTIVO /// private void checkOdl() { lbtShowConfProd.Visible = odlOk; lblConfProd.Visible = !odlOk; lblMancaODL.Visible = !odlOk; } /// /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) /// protected bool isMulti { get { return DataLayer.isMulti(idxMacchinaSession); } } /// /// Se la machcina è MULTI --> mostro selettore /// private void fixSelMacc() { divSelMacc.Visible = isMulti; } /// /// restituisce css disabled SE odl NON OK... /// public string cssBtnConf { get { return odlOk ? "" : "disabled"; } } /// /// Verifica ODL OK (ovvero caricato x macchina...) /// public bool odlOk { get { bool answ = true; // carico i dati preliminari: ODL int idxOdl = 0; // userò ODL del turno try { idxOdl = DataLayer.obj.taODL.getByMacchinaAperto(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; } } /// /// idx macchina selezionata /// 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); } } /// /// idx macchina selezionata /// public string idxMacchinaSession { get { return memLayer.ML.StringSessionObj("IdxMacchina"); } set { memLayer.ML.setSessionVal("IdxMacchina", value); } } /// /// cambio stato visibilità pannello e testo button /// /// /// protected void lbtShowConfProd_Click(object sender, EventArgs e) { switchBtnConferma(!txtNumPezzi.Enabled); } /// /// determina comportamento btn conferma /// private void switchBtnConferma(bool showConf) { txtNumPezzi.Enabled = showConf; txtNumScarti.Enabled = showConf; lbtSalva.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) { lblShowConfProd.Text = "Nascondi Conferma"; } else { lblShowConfProd.Text = "Mostra Conferma"; // sollevo evento! if (eh_reset != null) { eh_reset(this, new EventArgs()); } } } /// /// Numero pezzi PRODOTTI /// protected int numPzProdotti { get { int answ = 0; try { answ = Convert.ToInt32(txtNumPezzi.Text); } catch { } return answ; } } /// /// Numero pezzi SCARTATI /// protected int numPzScarto { get { int answ = 0; try { answ = Convert.ToInt32(txtNumScarti.Text); } catch { } return answ; } } /// /// Numero pezzi confermati (buoni - scarto) /// protected int numPzConfermati { get { return numPzProdotti - numPzScarto; } } /// /// salvo produzione /// /// /// protected void lbtSalva_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()); } } /// /// effettua conferma per giorni della produzione /// private void confermaPerGiorni() { DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), numPzConfermati, numPzScarto); } /// /// effettua conferma per turni della produzione /// private void confermaPerTurni() { DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), numPzConfermati, numPzScarto); } /// /// update post modifica pz buoni /// /// /// protected void txtNumPezzi_TextChanged(object sender, EventArgs e) { updatePzBuoni(); } /// /// aggiorna visualizzazione pz buoni /prodotti - scarti) /// private void updatePzBuoni() { txtPzBuoni.Text = numPzConfermati.ToString(); } /// /// update post modifica pz scarto /// /// /// protected void txtNumScarti_TextChanged(object sender, EventArgs e) { updatePzBuoni(); } protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) { subMaccSel = ddlSubMacc.SelectedValue; checkAll(); } 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 { } } } /// /// Sotto sistema (macchina) selezionato /// public string subMaccSel { get { return memLayer.ML.StringSessionObj("subMaccSel"); } set { memLayer.ML.setSessionVal("subMaccSel", value); } } } }