From 2dc63b83e361a78f40cb5a5f6d73b79592d92b77 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 10 Jul 2020 08:04:54 +0200 Subject: [PATCH] Check ODL presente x macchina + basePbj --- MP-TAB/MP-TAB.csproj | 5 +- .../MpTabControl.cs => MpTabPage.cs} | 22 +- MP-TAB/WebUserControls/MpTabUserControl.cs | 64 ++ MP-TAB/WebUserControls/cmp_ST_detail.ascx | 21 +- MP-TAB/WebUserControls/cmp_ST_detail.ascx.cs | 25 +- .../cmp_ST_detail.ascx.designer.cs | 9 + MP-TAB/WebUserControls/cmp_ST_objView.ascx.cs | 2 +- MP-TAB/WebUserControls/mod_confProd.ascx.cs | 957 +++++++++--------- .../WebUserControls/mod_dettMacchina.ascx.cs | 16 +- MP-TAB/fixODL.aspx.cs | 367 ++++--- 10 files changed, 759 insertions(+), 729 deletions(-) rename MP-TAB/{WebUserControls/MpTabControl.cs => MpTabPage.cs} (56%) create mode 100644 MP-TAB/WebUserControls/MpTabUserControl.cs diff --git a/MP-TAB/MP-TAB.csproj b/MP-TAB/MP-TAB.csproj index baec53d9..d30f4c8b 100644 --- a/MP-TAB/MP-TAB.csproj +++ b/MP-TAB/MP-TAB.csproj @@ -804,6 +804,9 @@ MappaStato.aspx + + ASPXCodeBehind + ODL.aspx ASPXCodeBehind @@ -1191,7 +1194,7 @@ mod_turni.ascx - + ASPXCodeBehind diff --git a/MP-TAB/WebUserControls/MpTabControl.cs b/MP-TAB/MpTabPage.cs similarity index 56% rename from MP-TAB/WebUserControls/MpTabControl.cs rename to MP-TAB/MpTabPage.cs index 74fa8cbb..17c8a26b 100644 --- a/MP-TAB/WebUserControls/MpTabControl.cs +++ b/MP-TAB/MpTabPage.cs @@ -4,12 +4,12 @@ using System.Collections.Generic; using System.Linq; using System.Web; -namespace MoonProTablet.WebUserControls +namespace MoonProTablet { - public class MpTabControl : System.Web.UI.UserControl + public class MpTabPage : System.Web.UI.Page { /// - /// idxMacchina + /// idxMacchina corrente /// public string idxMacchina { @@ -23,14 +23,18 @@ namespace MoonProTablet.WebUserControls } } /// - /// effettua traduzione del lemma + /// idxODL corrente /// - /// - /// - public string traduci(object _lemma) + public int idxODL { - _lemma = _lemma == null ? "":_lemma; - return user_std.UtSn.Traduci(_lemma.ToString()); + get + { + return memLayer.ML.IntSessionObj("idxODL"); + } + set + { + memLayer.ML.setSessionVal("idxODL", value); + } } } } \ No newline at end of file diff --git a/MP-TAB/WebUserControls/MpTabUserControl.cs b/MP-TAB/WebUserControls/MpTabUserControl.cs new file mode 100644 index 00000000..8b96b4ba --- /dev/null +++ b/MP-TAB/WebUserControls/MpTabUserControl.cs @@ -0,0 +1,64 @@ +using SteamWare; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace MoonProTablet.WebUserControls +{ + public class MpTabUserControl : System.Web.UI.UserControl + { + /// + /// idxMacchina corrente in sessione + /// + public string idxMacchina + { + get + { + return memLayer.ML.StringSessionObj("idxMacchina"); + } + set + { + memLayer.ML.setSessionVal("idxMacchina", value); + } + } + /// + /// Sotto sistema (macchina) selezionato in sessione + /// + public string subMaccSel + { + get + { + return memLayer.ML.StringSessionObj("subMaccSel"); + } + set + { + memLayer.ML.setSessionVal("subMaccSel", value); + } + } + /// + /// idxOdl corrente in sessione + /// + public int idxOdl + { + get + { + return memLayer.ML.IntSessionObj("idxODL"); + } + set + { + memLayer.ML.setSessionVal("idxODL", value); + } + } + /// + /// effettua traduzione del lemma + /// + /// + /// + public string traduci(object _lemma) + { + _lemma = _lemma == null ? "":_lemma; + return user_std.UtSn.Traduci(_lemma.ToString()); + } + } +} \ No newline at end of file diff --git a/MP-TAB/WebUserControls/cmp_ST_detail.ascx b/MP-TAB/WebUserControls/cmp_ST_detail.ascx index f5184de8..3dda2cd5 100644 --- a/MP-TAB/WebUserControls/cmp_ST_detail.ascx +++ b/MP-TAB/WebUserControls/cmp_ST_detail.ascx @@ -2,26 +2,7 @@ <%@ Register Src="~/WebUserControls/cmp_ST_objView.ascx" TagPrefix="uc1" TagName="cmp_ST_objView" %> - - -<%-- - - - - - - - - - - - - - - - - ---%> + diff --git a/MP-TAB/WebUserControls/cmp_ST_detail.ascx.cs b/MP-TAB/WebUserControls/cmp_ST_detail.ascx.cs index 8fadb586..e53fdd42 100644 --- a/MP-TAB/WebUserControls/cmp_ST_detail.ascx.cs +++ b/MP-TAB/WebUserControls/cmp_ST_detail.ascx.cs @@ -7,11 +7,32 @@ using System.Web.UI.WebControls; namespace MoonProTablet.WebUserControls { - public partial class cmp_ST_detail : MpTabControl + public partial class cmp_ST_detail : MpTabUserControl { protected void Page_Load(object sender, EventArgs e) { - + fixWarning(); + } + /// + /// check ODL presente + /// + private void fixWarning() + { + if (idxMacchina == "") + { + lblWarning.Text = traduci("MancaMacchina"); + lblWarning.Visible = true; + } + else if (idxOdl == 0) + { + lblWarning.Text = traduci("MancaOdl"); + lblWarning.Visible = true; + } + else + { + lblWarning.Text = ""; + lblWarning.Visible = false; + } } public string CodArticolo diff --git a/MP-TAB/WebUserControls/cmp_ST_detail.ascx.designer.cs b/MP-TAB/WebUserControls/cmp_ST_detail.ascx.designer.cs index 51ccc490..25e22655 100644 --- a/MP-TAB/WebUserControls/cmp_ST_detail.ascx.designer.cs +++ b/MP-TAB/WebUserControls/cmp_ST_detail.ascx.designer.cs @@ -14,6 +14,15 @@ namespace MoonProTablet.WebUserControls public partial class cmp_ST_detail { + /// + /// Controllo lblWarning. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.Label lblWarning; + /// /// Controllo repDetail. /// diff --git a/MP-TAB/WebUserControls/cmp_ST_objView.ascx.cs b/MP-TAB/WebUserControls/cmp_ST_objView.ascx.cs index 77bc0850..ecea8b7a 100644 --- a/MP-TAB/WebUserControls/cmp_ST_objView.ascx.cs +++ b/MP-TAB/WebUserControls/cmp_ST_objView.ascx.cs @@ -7,7 +7,7 @@ using System.Web.UI.WebControls; namespace MoonProTablet.WebUserControls { - public partial class cmp_ST_objView : MpTabControl + public partial class cmp_ST_objView : MpTabUserControl { public string dataType { diff --git a/MP-TAB/WebUserControls/mod_confProd.ascx.cs b/MP-TAB/WebUserControls/mod_confProd.ascx.cs index 67f161d7..377b494f 100644 --- a/MP-TAB/WebUserControls/mod_confProd.ascx.cs +++ b/MP-TAB/WebUserControls/mod_confProd.ascx.cs @@ -5,517 +5,492 @@ using System.Web.UI; namespace MoonProTablet.WebUserControls { - public partial class mod_confProd : System.Web.UI.UserControl - { - /// - /// indica conferma con rettifica (evento 121) - /// - protected bool confRett = memLayer.ML.CRB("confRett"); - /// - /// Oggetto datalayer specifico - /// - DataLayer DataLayerObj = new DataLayer(); - /// - /// registrato nuovo valore - /// - public event EventHandler eh_inserting; - /// - /// registrato nuovo valore - /// - public event EventHandler eh_newVal; - /// - /// registrato nuovo valore - /// - public event EventHandler eh_reset; - /// - /// Data-Ora ultimo update valori produzione - /// - public DateTime dtReqUpdate + public partial class mod_confProd : MpTabUserControl { - get - { - DateTime answ = DateTime.Now; - DateTime.TryParse(memLayer.ML.StringSessionObj("dtReqUpdate"), out answ); - return answ; - } - set - { - memLayer.ML.setSessionVal("dtReqUpdate", value); - } - } - /// - /// Dati produzioen rilevati - /// - public DS_ProdTempi.StatoProdRow datiProdAct; - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - checkAll(); - if (isMulti) + /// + /// indica conferma con rettifica (evento 121) + /// + protected bool confRett = memLayer.ML.CRB("confRett"); + /// + /// Oggetto datalayer specifico + /// + DataLayer DataLayerObj = new DataLayer(); + /// + /// registrato nuovo valore + /// + public event EventHandler eh_inserting; + /// + /// registrato nuovo valore + /// + public event EventHandler eh_newVal; + /// + /// registrato nuovo valore + /// + public event EventHandler eh_reset; + /// + /// Data-Ora ultimo update valori produzione + /// + public DateTime dtReqUpdate { - // sollevo evento! - if (eh_reset != null) - { - eh_reset(this, new EventArgs()); - } + get + { + DateTime answ = DateTime.Now; + DateTime.TryParse(memLayer.ML.StringSessionObj("dtReqUpdate"), out answ); + return answ; + } + set + { + memLayer.ML.setSessionVal("dtReqUpdate", value); + } } - } - } - /// - /// Reset parametri x calcolo pezzi (no pezzi lasciati, dataora attuale...) - /// - private void resetParam() - { - dtReqUpdate = DateTime.Now; - numPzLasciati = 0; - } - - /// - /// Aggiorno valori produzione alla data richiesta... - /// - /// - public void doUpdate() - { - datiProdAct = DataLayerObj.taStatoProd.GetData(idxMacchina, dtReqUpdate)[0]; - // aggiorno visualizzazione... - numPzProdotti = datiProdAct.PzTotODL; - numPz2Rec = datiProdAct.Pz2RecTot; - numPzScaConf = datiProdAct.PzConfScarto; - numPzBuoniConf = datiProdAct.PzConfBuoni; - numPzProdotti2Rec = datiProdAct.Pz2RecTot; - numPzScarto2Rec = datiProdAct.Pz2RecScarto; - } - /// - /// Numero pezzi PRODOTTI GLOBALI - /// - protected int numPzProdotti - { - set - { - lblPzTotODL.Text = value.ToString(); - } - } - /// - /// Numero pezzi da LASCIARE non dichiarati - /// - protected int numPzLasciati - { - set - { - txtNumLasciati.Text = value.ToString(); - } - get - { - int answ = 0; - try + /// + /// Dati produzioen rilevati + /// + public DS_ProdTempi.StatoProdRow datiProdAct; + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) { - answ = Convert.ToInt32(txtNumLasciati.Text); + if (!Page.IsPostBack) + { + checkAll(); + if (isMulti) + { + // sollevo evento! + if (eh_reset != null) + { + eh_reset(this, new EventArgs()); + } + } + } } - catch - { } - return answ; - } - } - /// - /// Numero pezzi PRODOTTI da ultima conferma - /// - protected int numPz2Rec - { - set - { - lblPz2RecTot.Text = value.ToString(); - } - } - /// - /// Numero pezzi SCARTO già confermati - /// - protected int numPzScaConf - { - set - { - lblPzConfScarto.Text = value.ToString(); - } - } - /// - /// Numero pezzi BUONI già confermati - /// - protected int numPzBuoniConf - { - set - { - lblPzConfBuoni.Text = value.ToString(); - } - } - /// - /// Numero pezzi PRODOTTI da registrare - /// da ultima conferma - protected int numPzProdotti2Rec - { - set - { - txtNumPezzi.Text = value.ToString(); - } - get - { - int answ = 0; - try + /// + /// Reset parametri x calcolo pezzi (no pezzi lasciati, dataora attuale...) + /// + private void resetParam() { - answ = Convert.ToInt32(txtNumPezzi.Text); + dtReqUpdate = DateTime.Now; + numPzLasciati = 0; } - catch - { } - return answ; - } - } - /// - /// Numero pezzi SCARTATI da registrare - /// - protected int numPzScarto2Rec - { - set - { - lblPz2RecScarto.Text = value.ToString(); - memLayer.ML.setSessionVal("lblPz2RecScarto", value); - } - get - { - int answ = 0; - try + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + public void doUpdate() { - answ = memLayer.ML.IntSessionObj("lblPz2RecScarto"); + datiProdAct = DataLayerObj.taStatoProd.GetData(idxMacchinaSel, dtReqUpdate)[0]; + // aggiorno visualizzazione... + numPzProdotti = datiProdAct.PzTotODL; + numPz2Rec = datiProdAct.Pz2RecTot; + numPzScaConf = datiProdAct.PzConfScarto; + numPzBuoniConf = datiProdAct.PzConfBuoni; + numPzProdotti2Rec = datiProdAct.Pz2RecTot; + numPzScarto2Rec = datiProdAct.Pz2RecScarto; } - catch - { } - return answ; - } - } - /// - /// Numero pezzi confermati (buoni - scarto) - /// - protected int numPzConfermati - { - get - { - return numPzProdotti2Rec - numPzScarto2Rec; - } - } - private void checkAll() - { - checkConfig(); - fixSelMacc(); - checkOdl(); - lblOut.Text = ""; - switchBtnConferma(false); - lbtShowConfProd.Visible = odlOk; - lblConfProd.Visible = !odlOk; - } - /// - /// verifica config x modalità permesse - /// - private void checkConfig() - { - // verifico SE sia permesso gestire i "Pezzi lasciati" in macchina... - lblNumLasciati.Visible = memLayer.ML.cdvb("enablePzProdLasciati"); - txtNumLasciati.Visible = memLayer.ML.cdvb("enablePzProdLasciati"); - } - - /// - /// 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 DataLayerObj.isMulti(idxMacchinaSession); - } - } - - /// - /// Se la machcina è MULTI --> mostro selettore - /// - private void fixSelMacc() - { - divSelMacc.Visible = isMulti; - if (isMulti) - { - // salvo selezione submacc - ddlSubMacc.DataBind(); - subMaccSel = ddlSubMacc.SelectedValue; - } - } - /// - /// 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; - // se ODL > 0 è ok!!! - answ = (idxOdl > 0); - return answ; - } - } - /// - /// ODL correntemente sulla macchina - /// - cerca in Redis (TTL 5 sec) - /// - altrimenti recupera da DB... - /// - protected int idxOdl - { - get - { - // userò ODL del turno - int answ = 0; - // cerco da redis... - int.TryParse(DataLayerObj.currODL(idxMacchina, true), out answ); - return answ; - } - } - - /// - /// idx macchina selezionata - /// - public string idxMacchina - { - get - { - string answ = memLayer.ML.StringSessionObj("IdxMacchina"); - // verifoc: se multi uso selettore tendina... - if (isMulti) + /// + /// Numero pezzi PRODOTTI GLOBALI + /// + protected int numPzProdotti { - if (ddlSubMacc.SelectedValue == "") - { - ddlSubMacc.DataBind(); - } - if (ddlSubMacc.SelectedValue != "") - { - answ = ddlSubMacc.SelectedValue; - } + set + { + lblPzTotODL.Text = value.ToString(); + } } - 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(!divInnovazioni.Visible); - } - - /// - /// determina comportamento btn conferma - /// - private void switchBtnConferma(bool showConf) - { - // aggiorno valori rilevati - resetParam(); - doUpdate(); - divInnovazioni.Visible = showConf; - if (showConf) - { - // continuo update - lbtSalva.Visible = showConf; - try + /// + /// Numero pezzi da LASCIARE non dichiarati + /// + protected int numPzLasciati { - updatePzBuoni(); - // sollevo evento! - if (eh_inserting != null) - { - eh_inserting(this, new EventArgs()); - } + set + { + txtNumLasciati.Text = value.ToString(); + } + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(txtNumLasciati.Text); + } + catch + { } + return answ; + } } - catch + /// + /// Numero pezzi PRODOTTI da ultima conferma + /// + protected int numPz2Rec { - txtNumPezzi.Text = "0"; - logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}", idxMacchina), tipoLog.ERROR); + set + { + lblPz2RecTot.Text = value.ToString(); + } } - } - if (showConf) - { - lblShowConfProd.Text = "Nascondi Conferma"; - } - else - { - lblShowConfProd.Text = "Mostra Conferma"; - // sollevo evento! - if (eh_reset != null) + /// + /// Numero pezzi SCARTO già confermati + /// + protected int numPzScaConf { - eh_reset(this, new EventArgs()); + set + { + lblPzConfScarto.Text = value.ToString(); + } } - } - } - - /// - /// salvo produzione - /// - /// - /// - protected void lbtSalva_Click(object sender, EventArgs e) - { - // effettua conferma con conf da DB del tipo (giorni / turni / periodo - bool fatto = effettuaConfermaProd(); - // refresh tabella dati tablet... - DataLayerObj.taMSE.forceRecalc(0, idxMacchina); - // mostro output - lblOut.Text = string.Format("Confermata la produzione per {0} pezzi! (+{1} pz scarto) alle {2:yyyy-MM-dd HH:mm:ss}", numPzConfermati, numPzScarto2Rec, dtReqUpdate); - // cambio button conferma... - switchBtnConferma(!txtNumPezzi.Enabled); - // sollevo evento! - if (eh_newVal != null) - { - eh_newVal(this, new EventArgs()); - } - doUpdate(); - } - /// - /// Registra conferma produzione in modalità nuova (con rettifica pezzi lasciati) o legacy (con anticipo periodo) - /// - private bool effettuaConfermaProd() - { - bool fatto = false; - if (confRett) - { - // confermo al netto dei pezzi lasciati... - fatto = DataLayerObj.confermaProdMacchinaFull(idxMacchina, memLayer.ML.CRI("modoConfProd"), numPzConfermati - numPzLasciati, numPzLasciati, numPzScarto2Rec, dtReqUpdate); - } - else - { - fatto = DataLayerObj.confermaProdMacchina(idxMacchina, memLayer.ML.CRI("modoConfProd"), numPzConfermati, numPzScarto2Rec, dtReqUpdate); - } - return fatto; - } - - /// - /// update post modifica pz buoni - /// - /// - /// - protected void txtNumPezzi_TextChanged(object sender, EventArgs e) - { - lblOut.Text = ""; - updatePzBuoni(); - } - /// - /// aggiorna visualizzazione pz buoni /prodotti - scarti) - /// - private void updatePzBuoni() - { - if (confRett) - { - // cambio le qta di pezzi confermati... - lblPz2RecBuoni.Text = (numPzConfermati - numPzLasciati).ToString(); - } - else - { - // se ho dei pezzi lasciati RICALCOLO la data... - if (numPzLasciati > 0) + /// + /// Numero pezzi BUONI già confermati + /// + protected int numPzBuoniConf { - // calcolo la data.. - DS_ProdTempi.TempiCicloRilevatiDataTable tab = DataLayerObj.taTempiCicloRilevati.getLastPzByMaccQta(idxMacchina, DateTime.Now, numPzLasciati); - if (tab.Rows.Count > 0) - { - dtReqUpdate = tab[0].DataOraRif.AddSeconds(1); - } - // aggiorno - doUpdate(); + set + { + lblPzConfBuoni.Text = value.ToString(); + } } - lblPz2RecBuoni.Text = numPzConfermati.ToString(); - } - // aggiorno la data calcolo + pezzi buoni... - lblDtRec.Text = dtReqUpdate.ToString(); - } - /// - /// Update pz lasciati --> aggiorno! - /// - /// - /// - protected void txtNumLasciati_TextChanged(object sender, EventArgs e) - { - lblOut.Text = ""; - 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 + /// + /// Numero pezzi PRODOTTI da registrare + /// da ultima conferma + protected int numPzProdotti2Rec { - ddlSubMacc.SelectedValue = subMaccSel; + set + { + txtNumPezzi.Text = value.ToString(); + } + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(txtNumPezzi.Text); + } + catch + { } + return answ; + } + } + /// + /// Numero pezzi SCARTATI da registrare + /// + protected int numPzScarto2Rec + { + set + { + lblPz2RecScarto.Text = value.ToString(); + memLayer.ML.setSessionVal("lblPz2RecScarto", value); + } + get + { + int answ = 0; + try + { + answ = memLayer.ML.IntSessionObj("lblPz2RecScarto"); + } + catch + { } + return answ; + } + } + /// + /// Numero pezzi confermati (buoni - scarto) + /// + protected int numPzConfermati + { + get + { + return numPzProdotti2Rec - numPzScarto2Rec; + } + } + private void checkAll() + { + updateOdl(); + checkConfig(); + fixSelMacc(); + checkOdl(); + lblOut.Text = ""; + switchBtnConferma(false); + lbtShowConfProd.Visible = odlOk; + lblConfProd.Visible = !odlOk; + } + /// + /// verifica config x modalità permesse + /// + private void checkConfig() + { + // verifico SE sia permesso gestire i "Pezzi lasciati" in macchina... + lblNumLasciati.Visible = memLayer.ML.cdvb("enablePzProdLasciati"); + txtNumLasciati.Visible = memLayer.ML.cdvb("enablePzProdLasciati"); } - catch - { } - } - } - /// - /// Sotto sistema (macchina) selezionato - /// - public string subMaccSel - { - get - { - return memLayer.ML.StringSessionObj("subMaccSel"); - } - set - { - memLayer.ML.setSessionVal("subMaccSel", value); - } - } - } + /// + /// 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 DataLayerObj.isMulti(idxMacchina); + } + } + + /// + /// Se la machcina è MULTI --> mostro selettore + /// + private void fixSelMacc() + { + divSelMacc.Visible = isMulti; + if (isMulti) + { + // salvo selezione submacc + ddlSubMacc.DataBind(); + subMaccSel = ddlSubMacc.SelectedValue; + } + updateOdl(); + } + /// + /// 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; + // se ODL > 0 è ok!!! + answ = (idxOdl > 0); + return answ; + } + } + /// + /// ODL correntemente sulla macchina + /// - cerca in Redis (TTL 5 sec) + /// - altrimenti recupera da DB... + /// + protected void updateOdl() + { + // userò ODL del turno + int answ = 0; + // cerco da redis... + int.TryParse(DataLayerObj.currODL(idxMacchinaSel, true), out answ); + // salvo! + idxOdl = answ; + } + + /// + /// idx macchina selezionata + /// + public string idxMacchinaSel + { + 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); + } + } + /// + /// cambio stato visibilità pannello e testo button + /// + /// + /// + protected void lbtShowConfProd_Click(object sender, EventArgs e) + { + switchBtnConferma(!divInnovazioni.Visible); + } + + /// + /// determina comportamento btn conferma + /// + private void switchBtnConferma(bool showConf) + { + // aggiorno valori rilevati + resetParam(); + doUpdate(); + divInnovazioni.Visible = showConf; + if (showConf) + { + // continuo update + lbtSalva.Visible = showConf; + try + { + updatePzBuoni(); + // 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}", idxMacchinaSel), tipoLog.ERROR); + } + } + if (showConf) + { + lblShowConfProd.Text = "Nascondi Conferma"; + } + else + { + lblShowConfProd.Text = "Mostra Conferma"; + // sollevo evento! + if (eh_reset != null) + { + eh_reset(this, new EventArgs()); + } + } + } + + /// + /// salvo produzione + /// + /// + /// + protected void lbtSalva_Click(object sender, EventArgs e) + { + // effettua conferma con conf da DB del tipo (giorni / turni / periodo + bool fatto = effettuaConfermaProd(); + // refresh tabella dati tablet... + DataLayerObj.taMSE.forceRecalc(0, idxMacchinaSel); + // mostro output + lblOut.Text = string.Format("Confermata la produzione per {0} pezzi! (+{1} pz scarto) alle {2:yyyy-MM-dd HH:mm:ss}", numPzConfermati, numPzScarto2Rec, dtReqUpdate); + // cambio button conferma... + switchBtnConferma(!txtNumPezzi.Enabled); + // sollevo evento! + if (eh_newVal != null) + { + eh_newVal(this, new EventArgs()); + } + doUpdate(); + } + /// + /// Registra conferma produzione in modalità nuova (con rettifica pezzi lasciati) o legacy (con anticipo periodo) + /// + private bool effettuaConfermaProd() + { + bool fatto = false; + if (confRett) + { + // confermo al netto dei pezzi lasciati... + fatto = DataLayerObj.confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati - numPzLasciati, numPzLasciati, numPzScarto2Rec, dtReqUpdate); + } + else + { + fatto = DataLayerObj.confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati, numPzScarto2Rec, dtReqUpdate); + } + return fatto; + } + + /// + /// update post modifica pz buoni + /// + /// + /// + protected void txtNumPezzi_TextChanged(object sender, EventArgs e) + { + lblOut.Text = ""; + updatePzBuoni(); + } + /// + /// aggiorna visualizzazione pz buoni /prodotti - scarti) + /// + private void updatePzBuoni() + { + if (confRett) + { + // cambio le qta di pezzi confermati... + lblPz2RecBuoni.Text = (numPzConfermati - numPzLasciati).ToString(); + } + else + { + // se ho dei pezzi lasciati RICALCOLO la data... + if (numPzLasciati > 0) + { + // calcolo la data.. + DS_ProdTempi.TempiCicloRilevatiDataTable tab = DataLayerObj.taTempiCicloRilevati.getLastPzByMaccQta(idxMacchinaSel, DateTime.Now, numPzLasciati); + if (tab.Rows.Count > 0) + { + dtReqUpdate = tab[0].DataOraRif.AddSeconds(1); + } + // aggiorno + doUpdate(); + } + lblPz2RecBuoni.Text = numPzConfermati.ToString(); + } + // aggiorno la data calcolo + pezzi buoni... + lblDtRec.Text = dtReqUpdate.ToString(); + } + /// + /// Update pz lasciati --> aggiorno! + /// + /// + /// + protected void txtNumLasciati_TextChanged(object sender, EventArgs e) + { + lblOut.Text = ""; + updatePzBuoni(); + } + protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) + { + subMaccSel = ddlSubMacc.SelectedValue; + // salvo ODL + DataLayerObj.taMSE.getByIdxMaccAndSub(idxMacchinaSel, subMaccSel); + //altri controlli + 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 + { } + } + } + + } } \ No newline at end of file diff --git a/MP-TAB/WebUserControls/mod_dettMacchina.ascx.cs b/MP-TAB/WebUserControls/mod_dettMacchina.ascx.cs index 045a3307..892fb067 100644 --- a/MP-TAB/WebUserControls/mod_dettMacchina.ascx.cs +++ b/MP-TAB/WebUserControls/mod_dettMacchina.ascx.cs @@ -5,7 +5,7 @@ using System.Web.UI; namespace MoonProTablet.WebUserControls { - public partial class mod_dettMacchina : System.Web.UI.UserControl + public partial class mod_dettMacchina : MpTabUserControl { /// /// Oggetto datalayer specifico @@ -15,20 +15,6 @@ namespace MoonProTablet.WebUserControls /// fatto refresh --> chiedo remove modal (se c'è) /// public event EventHandler eh_reqRemoveModal; - /// - /// idx macchina selezionata - /// - public string idxMacchina - { - get - { - return memLayer.ML.StringSessionObj("IdxMacchina"); - } - set - { - memLayer.ML.setSessionVal("IdxMacchina", value); - } - } public bool showDisegno(object _codArticolo) { diff --git a/MP-TAB/fixODL.aspx.cs b/MP-TAB/fixODL.aspx.cs index a8e87b55..0cdf3bf6 100644 --- a/MP-TAB/fixODL.aspx.cs +++ b/MP-TAB/fixODL.aspx.cs @@ -5,209 +5,196 @@ using System.Web.UI; namespace MoonProTablet { - public partial class fixODL : System.Web.UI.Page - { - /// - /// Oggetto datalayer specifico - /// - DataLayer DataLayerObj = new DataLayer(); - /// - /// Caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) + public partial class fixODL : MpTabPage { - if (!Page.IsPostBack) - { - fixSelMacc(); - hfIdxMacchina.Value = idxMacchina; - fixBtnImpostaODL(); - DateTime adesso = DateTime.Now; - hfDataTo.Value = adesso.ToString(); - hfDataFrom.Value = adesso.AddMonths(-1).ToString(); - } - } + /// + /// Oggetto datalayer specifico + /// + DataLayer DataLayerObj = new DataLayer(); + /// + /// Caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + fixSelMacc(); + hfIdxMacchina.Value = idxMacchinaSel; + fixBtnImpostaODL(); + DateTime adesso = DateTime.Now; + hfDataTo.Value = adesso.ToString(); + hfDataFrom.Value = adesso.AddMonths(-1).ToString(); + } + } + /// + /// idx macchina selezionata + /// + public string idxMacchinaSel + { + 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); + } + } + /// + /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) + /// + protected bool isMulti + { + get + { + bool answ = false; + answ = DataLayerObj.isMulti(idxMacchina); + return answ; + } + } + 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) + { + subMaccSel = ddlSubMacc.SelectedValue; + checkAll(); + } - /// - /// idx macchina selezionata - /// - public string idxMacchinaSession - { - get - { - return memLayer.ML.StringSessionObj("IdxMacchina"); - } - set - { - memLayer.ML.setSessionVal("IdxMacchina", value); - } - } - /// - /// idx macchina selezionata - /// - public string idxMacchina - { - get - { - string answ = idxMacchinaSession; - // verifico: se multi uso selettore tendina... - if (isMulti) + private void checkAll() { - if (ddlSubMacc.SelectedValue == "") - { - ddlSubMacc.DataBind(); - } - if (ddlSubMacc.SelectedValue != "") - { - answ = ddlSubMacc.SelectedValue; - } + fixSelMacc(); + hfIdxMacchina.Value = idxMacchinaSel; } - return answ; - } - set - { - memLayer.ML.setSessionVal("IdxMacchina", value); - } - } - /// - /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) - /// - protected bool isMulti - { - get - { - bool answ = false; - answ = DataLayerObj.isMulti(idxMacchinaSession); - return answ; - } - } - protected void ddlSubMacc_DataBound(object sender, EventArgs e) - { - // se ho in memoria un valore LO REIMPOSTO... - if (subMaccSel != "") - { - // provo a preselezionare... - try + /// + /// Se la machcina è MULTI --> mostro selettore + /// + private void fixSelMacc() { - ddlSubMacc.SelectedValue = subMaccSel; + divSelMacc.Visible = isMulti; + if (isMulti) + { + // salvo selezione submacc + ddlSubMacc.DataBind(); + subMaccSel = ddlSubMacc.SelectedValue; + } } - catch - { } - } - } - protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) - { - subMaccSel = ddlSubMacc.SelectedValue; - checkAll(); - } - - private void checkAll() - { - fixSelMacc(); - hfIdxMacchina.Value = idxMacchina; - } - /// - /// Se la machcina è MULTI --> mostro selettore - /// - private void fixSelMacc() - { - divSelMacc.Visible = isMulti; - if (isMulti) - { - // salvo selezione submacc - ddlSubMacc.DataBind(); - subMaccSel = ddlSubMacc.SelectedValue; - } - } - /// - /// Sotto sistema (macchina) selezionato - /// - public string subMaccSel - { - get - { - return memLayer.ML.StringSessionObj("subMaccSel"); - } - set - { - memLayer.ML.setSessionVal("subMaccSel", value); - } - } - private void fixBtnImpostaODL() - { - // verifico se selezionato un ODL sorgente... - lbtSetODL.Visible = idxODL > 0; - } - /// - /// idx macchina selezionata - /// - public int idxODL - { - get - { - int answ = 0; - try + /// + /// Sotto sistema (macchina) selezionato + /// + public string subMaccSel { - answ = Convert.ToInt32(ddlODL.SelectedValue); + get + { + return memLayer.ML.StringSessionObj("subMaccSel"); + } + set + { + memLayer.ML.setSessionVal("subMaccSel", value); + } + } + private void fixBtnImpostaODL() + { + // verifico se selezionato un ODL sorgente... + lbtSetODL.Visible = idxOdlSel > 0; + // salvo in sessione... + idxODL = idxOdlSel; + } + /// + /// idx macchina selezionata + /// + public int idxOdlSel + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(ddlODL.SelectedValue); + } + catch + { } + return answ; + } } - catch - { } - return answ; - } - } - protected void ddlODL_SelectedIndexChanged(object sender, EventArgs e) - { - fixBtnImpostaODL(); - } - /// - /// Verifica (su tab config) se sia abilitata la gestione flusso RPO (Richieste - Promesse - ODL) - /// - protected bool enableRPO - { - get - { - return memLayer.ML.cdvb("enableRPO"); - } - } - /// - /// Registra attivazione ODL per macchina corrente... - /// - /// - /// - protected void lbtSetODL_Click(object sender, EventArgs e) - { - if (idxMacchina != "" && idxODL > 0) - { - if (enableRPO) + protected void ddlODL_SelectedIndexChanged(object sender, EventArgs e) { - // registro ODL retroattivamente... - DataLayerObj.taODL.inizioSetupPromessaPostuma(idxODL, DataLayerObj.MatrOpr, idxMacchina); + fixBtnImpostaODL(); } - else + /// + /// Verifica (su tab config) se sia abilitata la gestione flusso RPO (Richieste - Promesse - ODL) + /// + protected bool enableRPO { - // registro ODL retroattivamente... - DataLayerObj.taODL.insPostumo(idxODL, idxMacchina); + get + { + return memLayer.ML.cdvb("enableRPO"); + } + } + /// + /// Registra attivazione ODL per macchina corrente... + /// + /// + /// + protected void lbtSetODL_Click(object sender, EventArgs e) + { + if (idxMacchinaSel != "" && idxOdlSel > 0) + { + if (enableRPO) + { + // registro ODL retroattivamente... + DataLayerObj.taODL.inizioSetupPromessaPostuma(idxOdlSel, DataLayerObj.MatrOpr, idxMacchinaSel); + } + else + { + // registro ODL retroattivamente... + DataLayerObj.taODL.insPostumo(idxOdlSel, idxMacchinaSel); + } + } + // controllo: se il nuovo ODL è stato registrato --> rimando a pagina ODL/Attrezzaggio... + bool odlOk = false; + try + { + // ricalcolo MSE + DataLayerObj.taMSE.getByRefreshData(0); + // verifico! + int idxODL = DataLayerObj.taMSE.getByIdxMacchina(idxMacchinaSel)[0].idxODL; + odlOk = (idxODL > 0); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore recupero ODL corrente da confermare per la macchina {0}{1}{2}", idxMacchinaSel, Environment.NewLine, exc), tipoLog.ERROR); + } + // forzo COMUNQUE redirect... + Response.Redirect("ODL"); } - } - // controllo: se il nuovo ODL è stato registrato --> rimando a pagina ODL/Attrezzaggio... - bool odlOk = false; - try - { - // ricalcolo MSE - DataLayerObj.taMSE.getByRefreshData(0); - // verifico! - int idxODL = DataLayerObj.taMSE.getByIdxMacchina(idxMacchina)[0].idxODL; - odlOk = (idxODL > 0); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore recupero ODL corrente da confermare per la macchina {0}{1}{2}", idxMacchina, Environment.NewLine, exc), tipoLog.ERROR); - } - // forzo COMUNQUE redirect... - Response.Redirect("ODL"); } - } } \ No newline at end of file