From 6c42548efac7e00b4e10e4c9eeda3569ffcf169e Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 27 Jul 2017 14:44:58 +0200 Subject: [PATCH] aggiunto metodo con expiry hash redis opzionale --- MP-Tablet/WebUserControls/mod_ODL.ascx.cs | 977 +++++++++--------- .../WebUserControls/mod_ODL.ascx.designer.cs | 107 +- 2 files changed, 542 insertions(+), 542 deletions(-) diff --git a/MP-Tablet/WebUserControls/mod_ODL.ascx.cs b/MP-Tablet/WebUserControls/mod_ODL.ascx.cs index 1dfb5258..3209c86e 100644 --- a/MP-Tablet/WebUserControls/mod_ODL.ascx.cs +++ b/MP-Tablet/WebUserControls/mod_ODL.ascx.cs @@ -5,494 +5,495 @@ using System.Web.UI; namespace MoonProTablet.WebUserControls { - public partial class mod_ODL : System.Web.UI.UserControl + public partial class mod_ODL : System.Web.UI.UserControl + { + /// + /// classe MapoDB x uso locale + /// + protected MapoDb.MapoDb controllerMapo = new MapoDb.MapoDb(); + /// + /// Determina se sia abilitato il controllo x editing + /// + public bool isEnabled { - /// - /// classe MapoDB x uso locale - /// - protected MapoDb.MapoDb controllerMapo = new MapoDb.MapoDb(); - /// - /// Determina se sia abilitato il controllo x editing - /// - public bool isEnabled - { - get - { - return memLayer.ML.BoolSessionObj(string.Format("OdlEnab_{0}", idxMacchina)); - } - set - { - memLayer.ML.setSessionVal(string.Format("OdlEnab_{0}", idxMacchina), value); - } - } - /// - /// idx macchina selezionata - /// - public int idxMacchina - { - get - { - return memLayer.ML.IntSessionObj("IdxMacchina"); - } - set - { - memLayer.ML.setSessionVal("IdxMacchina", value); - } - } - /// - /// codice odl selezionato - /// - public int idxODLSel - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(ddlODL.SelectedValue); - } - catch - { } - return answ; - } - } - /// - /// Cod articolo dell'ODL selezionato - /// - public string CodArtSel - { - get - { - string CodArticolo = ""; - try - { - CodArticolo = DataLayer.obj.taODL.getByIdx(idxODLSel, false)[0].CodArticolo; - } - catch - { } - return CodArticolo; - } - } - /// - /// avvio pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - checkBtnStatus(); - if (!Page.IsPostBack) - { - lblOut.Text = ""; - chkCloseOdl.Checked = memLayer.ML.cdvb("chkCloseOdl"); - } - } - /// - /// controlla stato bottoni abilitato - /// - private void checkBtnStatus() - { - // di default rendo abilitato / disabilitato tutto in base al valore "isEnabled" - btnShowSplitODL.Enabled = isEnabled; - btnSplitODL.Enabled = isEnabled; - chkCloseOdl.Enabled = isEnabled; - - - // condizioni booleane - bool inAttr = false; - bool currHasOdl = false; - // controllo se la macchina è in attrezzaggio... - DS_applicazione.StatoMacchineRow rigaStato = null; - try - { - rigaStato = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina.ToString())[0]; - inAttr = (rigaStato.IdxStato == 2); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in recupero dati rigaStato! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - try - { - currHasOdl = DataLayer.obj.taMSE.getByIdxMacchina(idxMacchina.ToString())[0].idxODL != 0; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in recupero dati currHasOdl! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - bool hasNewOdl = DataLayer.obj.taSelOdlFree.getUnused().Rows.Count > 1; - // sistemo buttons! - btnStartAttr.Enabled = (isEnabled && (!inAttr && hasNewOdl)); - btnStartProd.Enabled = (isEnabled && inAttr); - btnEndProd.Enabled = (isEnabled && (!inAttr && currHasOdl)); - ddlODL.Enabled = (isEnabled && (!inAttr && hasNewOdl)); - odsODL.DataBind(); - // sistemo show tempo/note attrezzaggio.. - if (inAttr) - { - showNoteTC(true); - // sistemo SOLO se non si trtta di un postback... - if (!Page.IsPostBack) - { - int idxOdl = 0; - try - { - idxOdl = DataLayer.obj.taMSE.getByIdxMacchina(idxMacchina.ToString())[0].idxODL; - updateTempoTc(idxOdl); - updateNoteTC(idxOdl); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in recupero dati ODL! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - } - } - - // verifico se l'articolo corrente sia in revisione x mostrare conferma modifica revisione... - if (CodArtSel != "") - { - bool showWarn = false; - try - { - showWarn = DataLayer.obj.taAnagArt.getByCod(CodArtSel)[0].FlagIsNew; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in recupero dati showWarn! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - divWarningArt.Visible = showWarn; - } - } - /// - /// processa evento richiesto - /// - /// - /// - /// - private void processaEvento(int idxEvento, string userMsg, int idxODL) - { - DS_applicazione.StatoMacchineRow rigaStato = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina.ToString())[0]; - // ricavo codice articolo... - string CodArticolo = DataLayer.obj.taODL.getByIdx(idxODL, false)[0].CodArticolo; - // processo evento... - MapoDb.inputComando inCmd = controllerMapo.scriviRigaEventoBarcode(idxMacchina.ToString(), idxEvento, CodArticolo, "", rigaStato.MatrOpr, rigaStato.pallet); - if (inCmd.needStatusRefresh) - { - // chiamo refresh MSE - DataLayer.obj.taMSE.getByRefreshData(memLayer.ML.confReadInt("refrMSE_0")); - } - lblOut.Text = userMsg; - // loggo USR MSG - logger.lg.scriviLog(userMsg, tipoLog.INFO); - checkBtnStatus(); - } - /// - /// valore decimal del TC richiesto... - /// - protected decimal TCRichAttr - { - get - { - decimal answ = 0; - try - { - answ = mod_tempoMSMC.tempoMC; - } - catch - { } - return answ; - } - set - { - mod_tempoMSMC.tempoMC = value; - } - } - /// - /// valore decimal del TC ASSEGNATO... - /// - protected decimal TCAssegnato(int idxODL) - { - decimal answ = 0; - // leggo idxOdl da ultimo odl attivo x macchina - DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxODL, false)[0]; - answ = rigaOdl.TCAssegnato; - return answ; - } - /// - /// dichiara inizio attrezzaggio ODL indicato.. - /// - /// - /// - protected void btnStartAttr_Click(object sender, EventArgs e) - { - confermaProdOdl(false); - if (idxODLSel > 0) - { - // se vedesse TCRich a zero lo reimposta a quello assegnato... - if (TCRichAttr == 0) - { - TCRichAttr = TCAssegnato(idxODLSel); - } - // splitto VECCHIO ODL (se è rimasto qualcosa da produrre e se ce ne è rimasto uno.......) - int idxODL = 0; - try - { - idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; - DataLayer.obj.taODL.splitODL(idxODL, idxMacchina.ToString(), TCAssegnato(idxODL), string.Format("inizio attrezzaggio, Sospensione ODL {0}, generato residuo con pari TCiclo: {1}", idxODL, TCAssegnato(idxODL)), false); - } - catch - { } - // avvio NUOVO ODL - DataLayer.obj.taODL.inizioSetup(idxODLSel, idxMacchina.ToString(), TCRichAttr, txtNote.Text); - int idxEvento = 2; // !!!HARD CODED - processaEvento(idxEvento, String.Format("Registrata inizio attrezzaggio per ODL {0}", idxODLSel), idxODLSel); - // ricarico... - Response.Redirect("~/ODL.aspx"); - } - else - { - lblOut.Text = "Selezionare un ODL valido!"; - } - } - /// - /// inizio prod - /// - /// - /// - protected void btnStartProd_Click(object sender, EventArgs e) - { - confermaProdOdl(true); - // se vedesse TCRich a zero lo reimposta a quello assegnato... - if (TCRichAttr == 0) - { - TCRichAttr = TCAssegnato(idxODLSel); - } - // leggo idxOdl da ultimo odl attivo x macchina - int idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; - int idxEvento = 1; // !!!HARD CODED - // aggiorno (se necessario) note e tempo setup - DataLayer.obj.taODL.updateSetup(idxODL, TCRichAttr, txtNote.Text); - // controllo se TC Assegnato != TCRichiesto allora invio email x verifiche... - DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxODL, false)[0]; - if (rigaOdl.TCAssegnato != TCRichAttr) - { - // invio email! - DataLayer.obj.sendWarnTcChangeReq(memLayer.ML.confReadString("_adminEmail")); - } - // processo chiusura setup - processaEvento(idxEvento, String.Format("Registrata inizio produzione per ODL {0}", idxODL), idxODL); - - // nascondo note! - showNoteTC(false); - } - /// - /// fine prod - /// - /// - /// - protected void btnEndProd_Click(object sender, EventArgs e) - { - // leggo idxOdl da ultimo odl attivo x macchina - int idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; - int idxEvento = 7; // !!!HARD CODED - - // confermo prod vecchio ODL - confermaProdOdl(false); - - - // se chk flaggato ovvero richiesta di chiudere ODL procedo come prima (chiudendo ODL senza averne altri...) - if (chkCloseOdl.Checked) - { - // aggiungo try/catch x capire se sia qui che si "impasta" in chiusura ODL - try - { - // processo - DataLayer.obj.taODL.fineProd(idxODL, idxMacchina.ToString()); - processaEvento(idxEvento, String.Format("Registrata fine produzione per ODL {0}", idxODL), idxODL); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in operazione chiusura ODL! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - Response.Redirect("~/DettaglioMacchina.aspx"); - } - } - // altrimenti split ODL x completare IN FUTURO la produzione... - else - { - try - { - // effettuo split su nuovo ODL - DataLayer.obj.taODL.splitODL(idxODL, idxMacchina.ToString(), TCAssegnato(idxODL), string.Format("Fine Produzione, Sospensione ODL {0}, generato residuo con pari TCiclo: {1}", idxODL, TCAssegnato(idxODL)), false); - - // processo chiusura setup - processaEvento(idxEvento, String.Format("Registrata fine produzione per ODL {0}, nuovo ODL per quantità residua", idxODL), idxODL); - // sistemo buttons! - bool splitOdl = false; - fixSplitBtn(splitOdl); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione in operazione Chiusura + Split ODL su nuovo! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - Response.Redirect("~/DettaglioMacchina.aspx"); - } - } - // ricarico... - Response.Redirect("~/ODL.aspx"); - } - /// - /// verifica se sia necessario confermare la prod dell'ODL precedente prima di chiudere e lo fa in automatico... - /// - /// boolean, true = deve confermare 0 pezzi (es. in setup) - private void confermaProdOdl(bool confZero) - { - // 2016.11.17 NOTA: introdotti scarti, li confermiamo SEMPRE a zero se ins etup, però da valutare SE a FINE ATTREZZAGGIO chiedere num pezzi e num scarti (saldo zero buoni) da inserire... - if (confZero) - { - // confermo produzione ZERO pezzi (in setup) - DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), 0, 0); - } - else // se NON sono in setup verifico se ho pz da confermare - { - // recupero pz da confermare - DS_ProdTempi.stp_PzProd_getByMacchinaRow rigaProd = DataLayer.obj.taPzProd2conf.GetData(idxMacchina.ToString())[0]; - if (rigaProd.pezziNonConfermati > 0) - { - DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), rigaProd.pezziNonConfermati, 0); - } - } - } - /// - /// mostra dati ed opzione x split ODL - /// - /// - /// - protected void btnShowSplitODL_Click(object sender, EventArgs e) - { - bool splitOdl = true; - fixSplitBtn(splitOdl); - // recupero current idx - int currODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; - updateTempoTc(currODL); - updateNoteTC(currODL); - } - /// - /// sistema buttons split - /// - /// - private void fixSplitBtn(bool splitOdl) - { - btnShowSplitODL.Visible = !splitOdl; - chkCloseOdl.Visible = !splitOdl; - btnSplitODL.Visible = splitOdl; - showNoteTC(splitOdl); - ddlODL.Visible = !splitOdl; - btnStartAttr.Visible = !splitOdl; - btnStartProd.Visible = !splitOdl; - btnEndProd.Visible = !splitOdl; - } - /// - /// split ODL con creazione nuovo ODL - /// - /// - /// - protected void btnSplitODL_Click(object sender, EventArgs e) - { - // chiamo stored che genera nuovo ODL, mette note e tempo, chiude vecchi e assegna nuovo... - int currODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; - int idxEvento = 1; // !!!HARD CODED - // controllo se TC è valorizzato.. - if (TCRichAttr == 0) - { - mod_tempoMSMC.checkTC(); - } - - // confermo prod vecchio ODL - confermaProdOdl(false); - - // effettuo split su nuovo ODL - DataLayer.obj.taODL.splitODL(currODL, idxMacchina.ToString(), TCRichAttr, txtNote.Text, true); - - // invio email! - DataLayer.obj.sendWarnTcChangeReq(memLayer.ML.confReadString("_adminEmail")); - // processo chiusura setup - processaEvento(idxEvento, String.Format("Registrato Riattrezzaggio ODL (old: {0})", currODL), currODL); - // sistemo buttons! - bool splitOdl = false; - fixSplitBtn(splitOdl); - } - /// - /// selezionato un ODL mostro note/tempo da validare - /// - /// - /// - protected void ddlODL_SelectedIndexChanged(object sender, EventArgs e) - { - if (ddlODL.SelectedIndex > 0) - { - showNoteTC(true); - updateTempoTc(idxODLSel); - updateNoteTC(idxODLSel); - } - else - { - showNoteTC(false); - } - } - /// - /// mostra/nasconde note - /// - private void showNoteTC(bool show) - { - // mostra/nasconde note da compilare - divTempo.Visible = show; - divNote.Visible = show; - } - /// - /// aggiorna note ODL - /// - /// - private void updateNoteTC(int idxOdl) - { - string testo = ""; - if (idxOdl > 0) - { - try - { - testo = DataLayer.obj.taODL.getByIdx(idxOdl, false)[0].Note; - } - catch - { } - } - txtNote.Text = testo; - } - - /// - /// update TC mostrato - /// - /// - private void updateTempoTc(int idxOdl) - { - // riporta TC - DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxOdl, false)[0]; - decimal TCRichAttr = 0; - if (rigaOdl.TCRichAttr > 0) - { - TCRichAttr = rigaOdl.TCRichAttr; - } - else - { - TCRichAttr = rigaOdl.TCAssegnato; - } - // mostro! - mod_tempoMSMC.tempoMC = TCRichAttr; - } - - protected void btnConfNewRevProd_Click(object sender, EventArgs e) - { - // chiamo stored x allineare revProd a revUT - string CodArticolo = DataLayer.obj.taODL.getByIdx(idxODLSel, false)[0].CodArticolo; - DataLayer.obj.taAnagArt.setNewRev(CodArticolo); - checkBtnStatus(); - } + get + { + return memLayer.ML.BoolSessionObj(string.Format("OdlEnab_{0}", idxMacchina)); + } + set + { + memLayer.ML.setSessionVal(string.Format("OdlEnab_{0}", idxMacchina), value); + } } + /// + /// idx macchina selezionata + /// + public int idxMacchina + { + get + { + return memLayer.ML.IntSessionObj("IdxMacchina"); + } + set + { + memLayer.ML.setSessionVal("IdxMacchina", value); + } + } + /// + /// codice odl selezionato + /// + public int idxODLSel + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(ddlODL.SelectedValue); + } + catch + { } + return answ; + } + } + /// + /// Cod articolo dell'ODL selezionato + /// + public string CodArtSel + { + get + { + string CodArticolo = ""; + try + { + CodArticolo = DataLayer.obj.taODL.getByIdx(idxODLSel, false)[0].CodArticolo; + } + catch + { } + return CodArticolo; + } + } + /// + /// avvio pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + checkBtnStatus(); + if (!Page.IsPostBack) + { + lblOut.Text = ""; + chkCloseOdl.Checked = memLayer.ML.cdvb("chkCloseOdl"); + chkCloseOdl.Visible = memLayer.ML.cdvb("showChkCloseOdl"); + } + } + /// + /// controlla stato bottoni abilitato + /// + private void checkBtnStatus() + { + // di default rendo abilitato / disabilitato tutto in base al valore "isEnabled" + btnShowSplitODL.Enabled = isEnabled; + btnSplitODL.Enabled = isEnabled; + chkCloseOdl.Enabled = isEnabled; + + + // condizioni booleane + bool inAttr = false; + bool currHasOdl = false; + // controllo se la macchina è in attrezzaggio... + DS_applicazione.StatoMacchineRow rigaStato = null; + try + { + rigaStato = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina.ToString())[0]; + inAttr = (rigaStato.IdxStato == 2); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati rigaStato! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + try + { + currHasOdl = DataLayer.obj.taMSE.getByIdxMacchina(idxMacchina.ToString())[0].idxODL != 0; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati currHasOdl! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + bool hasNewOdl = DataLayer.obj.taSelOdlFree.getUnused().Rows.Count > 1; + // sistemo buttons! + btnStartAttr.Enabled = (isEnabled && (!inAttr && hasNewOdl)); + btnStartProd.Enabled = (isEnabled && inAttr); + btnEndProd.Enabled = (isEnabled && (!inAttr && currHasOdl)); + ddlODL.Enabled = (isEnabled && (!inAttr && hasNewOdl)); + odsODL.DataBind(); + // sistemo show tempo/note attrezzaggio.. + if (inAttr) + { + showNoteTC(true); + // sistemo SOLO se non si trtta di un postback... + if (!Page.IsPostBack) + { + int idxOdl = 0; + try + { + idxOdl = DataLayer.obj.taMSE.getByIdxMacchina(idxMacchina.ToString())[0].idxODL; + updateTempoTc(idxOdl); + updateNoteTC(idxOdl); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati ODL! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + } + + // verifico se l'articolo corrente sia in revisione x mostrare conferma modifica revisione... + if (CodArtSel != "") + { + bool showWarn = false; + try + { + showWarn = DataLayer.obj.taAnagArt.getByCod(CodArtSel)[0].FlagIsNew; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati showWarn! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + divWarningArt.Visible = showWarn; + } + } + /// + /// processa evento richiesto + /// + /// + /// + /// + private void processaEvento(int idxEvento, string userMsg, int idxODL) + { + DS_applicazione.StatoMacchineRow rigaStato = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina.ToString())[0]; + // ricavo codice articolo... + string CodArticolo = DataLayer.obj.taODL.getByIdx(idxODL, false)[0].CodArticolo; + // processo evento... + MapoDb.inputComando inCmd = controllerMapo.scriviRigaEventoBarcode(idxMacchina.ToString(), idxEvento, CodArticolo, "", rigaStato.MatrOpr, rigaStato.pallet); + if (inCmd.needStatusRefresh) + { + // chiamo refresh MSE + DataLayer.obj.taMSE.getByRefreshData(memLayer.ML.confReadInt("refrMSE_0")); + } + lblOut.Text = userMsg; + // loggo USR MSG + logger.lg.scriviLog(userMsg, tipoLog.INFO); + checkBtnStatus(); + } + /// + /// valore decimal del TC richiesto... + /// + protected decimal TCRichAttr + { + get + { + decimal answ = 0; + try + { + answ = mod_tempoMSMC.tempoMC; + } + catch + { } + return answ; + } + set + { + mod_tempoMSMC.tempoMC = value; + } + } + /// + /// valore decimal del TC ASSEGNATO... + /// + protected decimal TCAssegnato(int idxODL) + { + decimal answ = 0; + // leggo idxOdl da ultimo odl attivo x macchina + DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxODL, false)[0]; + answ = rigaOdl.TCAssegnato; + return answ; + } + /// + /// dichiara inizio attrezzaggio ODL indicato.. + /// + /// + /// + protected void btnStartAttr_Click(object sender, EventArgs e) + { + confermaProdOdl(false); + if (idxODLSel > 0) + { + // se vedesse TCRich a zero lo reimposta a quello assegnato... + if (TCRichAttr == 0) + { + TCRichAttr = TCAssegnato(idxODLSel); + } + // splitto VECCHIO ODL (se è rimasto qualcosa da produrre e se ce ne è rimasto uno.......) + int idxODL = 0; + try + { + idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; + DataLayer.obj.taODL.splitODL(idxODL, idxMacchina.ToString(), TCAssegnato(idxODL), string.Format("inizio attrezzaggio, Sospensione ODL {0}, generato residuo con pari TCiclo: {1}", idxODL, TCAssegnato(idxODL)), false); + } + catch + { } + // avvio NUOVO ODL + DataLayer.obj.taODL.inizioSetup(idxODLSel, idxMacchina.ToString(), TCRichAttr, txtNote.Text); + int idxEvento = 2; // !!!HARD CODED + processaEvento(idxEvento, String.Format("Registrata inizio attrezzaggio per ODL {0}", idxODLSel), idxODLSel); + // ricarico... + Response.Redirect("~/ODL.aspx"); + } + else + { + lblOut.Text = "Selezionare un ODL valido!"; + } + } + /// + /// inizio prod + /// + /// + /// + protected void btnStartProd_Click(object sender, EventArgs e) + { + confermaProdOdl(true); + // se vedesse TCRich a zero lo reimposta a quello assegnato... + if (TCRichAttr == 0) + { + TCRichAttr = TCAssegnato(idxODLSel); + } + // leggo idxOdl da ultimo odl attivo x macchina + int idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; + int idxEvento = 1; // !!!HARD CODED + // aggiorno (se necessario) note e tempo setup + DataLayer.obj.taODL.updateSetup(idxODL, TCRichAttr, txtNote.Text); + // controllo se TC Assegnato != TCRichiesto allora invio email x verifiche... + DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxODL, false)[0]; + if (rigaOdl.TCAssegnato != TCRichAttr) + { + // invio email! + DataLayer.obj.sendWarnTcChangeReq(memLayer.ML.confReadString("_adminEmail")); + } + // processo chiusura setup + processaEvento(idxEvento, String.Format("Registrata inizio produzione per ODL {0}", idxODL), idxODL); + + // nascondo note! + showNoteTC(false); + } + /// + /// fine prod + /// + /// + /// + protected void btnEndProd_Click(object sender, EventArgs e) + { + // leggo idxOdl da ultimo odl attivo x macchina + int idxODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; + int idxEvento = 7; // !!!HARD CODED + + // confermo prod vecchio ODL + confermaProdOdl(false); + + + // se chk flaggato ovvero richiesta di chiudere ODL procedo come prima (chiudendo ODL senza averne altri...) + if (chkCloseOdl.Checked) + { + // aggiungo try/catch x capire se sia qui che si "impasta" in chiusura ODL + try + { + // processo + DataLayer.obj.taODL.fineProd(idxODL, idxMacchina.ToString()); + processaEvento(idxEvento, String.Format("Registrata fine produzione per ODL {0}", idxODL), idxODL); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in operazione chiusura ODL! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + Response.Redirect("~/DettaglioMacchina.aspx"); + } + } + // altrimenti split ODL x completare IN FUTURO la produzione... + else + { + try + { + // effettuo split su nuovo ODL + DataLayer.obj.taODL.splitODL(idxODL, idxMacchina.ToString(), TCAssegnato(idxODL), string.Format("Fine Produzione, Sospensione ODL {0}, generato residuo con pari TCiclo: {1}", idxODL, TCAssegnato(idxODL)), false); + + // processo chiusura setup + processaEvento(idxEvento, String.Format("Registrata fine produzione per ODL {0}, nuovo ODL per quantità residua", idxODL), idxODL); + // sistemo buttons! + bool splitOdl = false; + fixSplitBtn(splitOdl); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in operazione Chiusura + Split ODL su nuovo! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + Response.Redirect("~/DettaglioMacchina.aspx"); + } + } + // ricarico... + Response.Redirect("~/ODL.aspx"); + } + /// + /// verifica se sia necessario confermare la prod dell'ODL precedente prima di chiudere e lo fa in automatico... + /// + /// boolean, true = deve confermare 0 pezzi (es. in setup) + private void confermaProdOdl(bool confZero) + { + // 2016.11.17 NOTA: introdotti scarti, li confermiamo SEMPRE a zero se ins etup, però da valutare SE a FINE ATTREZZAGGIO chiedere num pezzi e num scarti (saldo zero buoni) da inserire... + if (confZero) + { + // confermo produzione ZERO pezzi (in setup) + DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), 0, 0); + } + else // se NON sono in setup verifico se ho pz da confermare + { + // recupero pz da confermare + DS_ProdTempi.stp_PzProd_getByMacchinaRow rigaProd = DataLayer.obj.taPzProd2conf.GetData(idxMacchina.ToString())[0]; + if (rigaProd.pezziNonConfermati > 0) + { + DataLayer.obj.confermaProdMacchina(idxMacchina.ToString(), memLayer.ML.confReadInt("modoConfProd"), rigaProd.pezziNonConfermati, 0); + } + } + } + /// + /// mostra dati ed opzione x split ODL + /// + /// + /// + protected void btnShowSplitODL_Click(object sender, EventArgs e) + { + bool splitOdl = true; + fixSplitBtn(splitOdl); + // recupero current idx + int currODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; + updateTempoTc(currODL); + updateNoteTC(currODL); + } + /// + /// sistema buttons split + /// + /// + private void fixSplitBtn(bool splitOdl) + { + btnShowSplitODL.Visible = !splitOdl; + chkCloseOdl.Visible = !splitOdl; + btnSplitODL.Visible = splitOdl; + showNoteTC(splitOdl); + ddlODL.Visible = !splitOdl; + btnStartAttr.Visible = !splitOdl; + btnStartProd.Visible = !splitOdl; + btnEndProd.Visible = !splitOdl; + } + /// + /// split ODL con creazione nuovo ODL + /// + /// + /// + protected void btnSplitODL_Click(object sender, EventArgs e) + { + // chiamo stored che genera nuovo ODL, mette note e tempo, chiude vecchi e assegna nuovo... + int currODL = DataLayer.obj.taODL.getByMacchina(idxMacchina.ToString())[0].IdxODL; + int idxEvento = 1; // !!!HARD CODED + // controllo se TC è valorizzato.. + if (TCRichAttr == 0) + { + mod_tempoMSMC.checkTC(); + } + + // confermo prod vecchio ODL + confermaProdOdl(false); + + // effettuo split su nuovo ODL + DataLayer.obj.taODL.splitODL(currODL, idxMacchina.ToString(), TCRichAttr, txtNote.Text, true); + + // invio email! + DataLayer.obj.sendWarnTcChangeReq(memLayer.ML.confReadString("_adminEmail")); + // processo chiusura setup + processaEvento(idxEvento, String.Format("Registrato Riattrezzaggio ODL (old: {0})", currODL), currODL); + // sistemo buttons! + bool splitOdl = false; + fixSplitBtn(splitOdl); + } + /// + /// selezionato un ODL mostro note/tempo da validare + /// + /// + /// + protected void ddlODL_SelectedIndexChanged(object sender, EventArgs e) + { + if (ddlODL.SelectedIndex > 0) + { + showNoteTC(true); + updateTempoTc(idxODLSel); + updateNoteTC(idxODLSel); + } + else + { + showNoteTC(false); + } + } + /// + /// mostra/nasconde note + /// + private void showNoteTC(bool show) + { + // mostra/nasconde note da compilare + divTempo.Visible = show; + divNote.Visible = show; + } + /// + /// aggiorna note ODL + /// + /// + private void updateNoteTC(int idxOdl) + { + string testo = ""; + if (idxOdl > 0) + { + try + { + testo = DataLayer.obj.taODL.getByIdx(idxOdl, false)[0].Note; + } + catch + { } + } + txtNote.Text = testo; + } + + /// + /// update TC mostrato + /// + /// + private void updateTempoTc(int idxOdl) + { + // riporta TC + DS_ProdTempi.ODLRow rigaOdl = DataLayer.obj.taODL.getByIdx(idxOdl, false)[0]; + decimal TCRichAttr = 0; + if (rigaOdl.TCRichAttr > 0) + { + TCRichAttr = rigaOdl.TCRichAttr; + } + else + { + TCRichAttr = rigaOdl.TCAssegnato; + } + // mostro! + mod_tempoMSMC.tempoMC = TCRichAttr; + } + + protected void btnConfNewRevProd_Click(object sender, EventArgs e) + { + // chiamo stored x allineare revProd a revUT + string CodArticolo = DataLayer.obj.taODL.getByIdx(idxODLSel, false)[0].CodArticolo; + DataLayer.obj.taAnagArt.setNewRev(CodArticolo); + checkBtnStatus(); + } + } } \ No newline at end of file diff --git a/MP-Tablet/WebUserControls/mod_ODL.ascx.designer.cs b/MP-Tablet/WebUserControls/mod_ODL.ascx.designer.cs index 7668179a..1fc92c74 100644 --- a/MP-Tablet/WebUserControls/mod_ODL.ascx.designer.cs +++ b/MP-Tablet/WebUserControls/mod_ODL.ascx.designer.cs @@ -1,150 +1,149 @@ //------------------------------------------------------------------------------ -// -// This code was generated by a tool. +// +// Codice generato da uno strumento. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// //------------------------------------------------------------------------------ -namespace MoonProTablet.WebUserControls -{ - - +namespace MoonProTablet.WebUserControls { + + public partial class mod_ODL { /// - /// divWarningArt control. + /// Controllo divWarningArt. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divWarningArt; /// - /// btnConfNewRevProd control. + /// Controllo btnConfNewRevProd. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnConfNewRevProd; /// - /// ddlODL control. + /// Controllo ddlODL. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.DropDownList ddlODL; /// - /// odsODL control. + /// Controllo odsODL. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.ObjectDataSource odsODL; /// - /// divNote control. + /// Controllo divNote. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divNote; /// - /// txtNote control. + /// Controllo txtNote. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.TextBox txtNote; /// - /// btnStartAttr control. + /// Controllo btnStartAttr. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnStartAttr; /// - /// divTempo control. + /// Controllo divTempo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divTempo; /// - /// mod_tempoMSMC control. + /// Controllo mod_tempoMSMC. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::MoonProTablet.WebUserControls.mod_tempoMSMC mod_tempoMSMC; /// - /// btnStartProd control. + /// Controllo btnStartProd. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnStartProd; /// - /// btnEndProd control. + /// Controllo btnEndProd. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnEndProd; /// - /// btnShowSplitODL control. + /// Controllo btnShowSplitODL. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnShowSplitODL; /// - /// chkCloseOdl control. + /// Controllo chkCloseOdl. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.CheckBox chkCloseOdl; /// - /// btnSplitODL control. + /// Controllo btnSplitODL. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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.Button btnSplitODL; /// - /// lblOut control. + /// Controllo lblOut. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// 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 lblOut; }