using CMS_SC_Data; using SteamWare; using System; using System.Web.UI; namespace CMS_SC { public partial class Collaudi : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ((Bootstrap)this.Master).showSearch = true; // default: nascondo dettagli e storico! showDetail = false; showHist = false; fixPaginazione(); tryGetParam(); fixPanels(); fixControls(); fixControlsPrev(); } mod_righePagStato.eh_newNum += mod_righePagStato_eh_newNum; mod_righePag.eh_newNum += mod_righePag_eh_newNum; mod_righePagPrev.eh_newNum += mod_righePagPrev_eh_newNum; mod_StatoCollaudi.eh_ucev += Mod_StatoCollaudi_eh_ucev; mod_collaudi.eh_ucev += Mod_collaudi_eh_ucev; } private void Mod_collaudi_eh_ucev(object sender, EventArgs e) { // verifico se devo fare un cambio di visibilità dettagli... ucEvent evento = (ucEvent)e; switch (evento.tipoEvento) { case ucEvType.ReqUpdateParent: mod_StatoCollaudi.doUpdate(); break; case ucEvType.Selected: case ucEvType.Reset: default: break; } } /// /// gestione eventi selezione panel stato collaudi /// /// /// private void Mod_StatoCollaudi_eh_ucev(object sender, EventArgs e) { // verifico se devo fare un cambio di visibilità dettagli... ucEvent evento = (ucEvent)e; switch (evento.tipoEvento) { case ucEvType.ReqUpdateParent: case ucEvType.Selected: showDetail = true; break; case ucEvType.Reset: default: showDetail = false; break; } // fix pannelli fixPanels(); if (showDetail) { fixControls(); fixControlsPrev(); } } /// /// sistemazione controlli paginazione /// private void fixPaginazione() { // pannello stato schede mod_righePagStato.numRowPag = 10; if (getPar("numRowPagColl_Stato") != "") { try { mod_righePagStato.numRowPag = Convert.ToInt32(getPar("numRowPagColl_Stato")); } catch { } } mod_StatoCollaudi.pageSize = mod_righePagStato.numRowPag; // pannello principale mod_righePag.numRowPag = 10; if (getPar("numRowPagColl_Main") != "") { try { mod_righePag.numRowPag = Convert.ToInt32(getPar("numRowPagColl_Main")); } catch { } } mod_collaudi.pageSize = mod_righePag.numRowPag; // pannello secondario mod_righePagPrev.numRowPag = 20; if (getPar("numRowPagColl_Sec") != "") { try { mod_righePagPrev.numRowPag = Convert.ToInt32(getPar("numRowPagColl_Sec")); } catch { } } mod_collaudiPrev.pageSize = mod_righePagPrev.numRowPag; } /// /// cerca di recuperare i 3 parametri selezionati dall'utente (SE ci sono su DB) /// private void tryGetParam() { // rileggo SE CI SONO i parametri filtrati... if (getPar("ddlDossier") != "") { ddlDossier.DataBind(); try { ddlDossier.SelectedValue = getPar("ddlDossier"); } catch { ddlDossier.SelectedIndex = 0; } } // rileggo SE CI SONO i parametri filtrati... if (getPar("ddlFase") != "") { ddlFase.DataBind(); try { ddlFase.SelectedValue = getPar("ddlFase"); } catch { ddlFase.SelectedIndex = 0; } } else { // in questo caso PRENDO dati da default attivo e salvo... calcolo revisione da fase... string fase = ""; try { var riga = DtProxy.man.taED.getByDossier(IdxDossier)[0]; fase = riga.FaseAct; } catch { } if (fase != "") { ddlFase.SelectedValue = fase; mod_StatoCollaudi.Fase = fase; } } } /// /// recupera (se c'è) da db il parametro selezionato dall'utente /// /// /// protected string getPar(string paramName) { string answ = ""; try { answ = DtProxy.man.taUsrPar.getByKey(OpAuth.currAuth.email, paramName)[0].ParValue; } catch { } return answ; } /// /// salva su DB il parametro scelto dall'utente /// /// /// protected void savePar(string paramName, string paramValue) { DtProxy.man.taUsrPar.upsert(OpAuth.currAuth.email, paramName, paramValue); } private void mod_righePagStato_eh_newNum(object sender, EventArgs e) { savePar("numRowPagColl_Stato", mod_righePagStato.numRowPag.ToString()); mod_StatoCollaudi.pageSize = mod_righePagStato.numRowPag; } void mod_righePag_eh_newNum(object sender, EventArgs e) { savePar("numRowPagColl_Main", mod_righePag.numRowPag.ToString()); mod_collaudi.pageSize = mod_righePag.numRowPag; } void mod_righePagPrev_eh_newNum(object sender, EventArgs e) { savePar("numRowPagColl_Sec", mod_righePagPrev.numRowPag.ToString()); mod_collaudiPrev.pageSize = mod_righePagPrev.numRowPag; } void mod_collaudi_eh_selezioneValore(object sender, EventArgs e) { fixControls(); } /// /// sistema pannelli PRINCIPALI /// private void fixPanels() { // tolgo css a blocco stato, main, hist divStato.Attributes.Remove("class"); // verifico SE devo mostrare detail... if (showDetail) { divStato.Attributes.Add("class", "col-md-4 fontSmall pr-0"); divMain.Visible = true; } else { divStato.Attributes.Add("class", "col-12 fontSmall pr-0"); divMain.Visible = false; } } /// /// sistema DropDownList /// private void fixControls() { string faseAct = ""; // prendo idxMacchina + fase e calcolo/salvo revisione! try { var rigaRev = DtProxy.man.taVSR.getByDF(IdxDossier, Fase)[0]; Rev = rigaRev.value; var rigaED = DtProxy.man.taED.getByDossier(IdxDossier)[0]; faseAct = rigaED.FaseAct; } catch { } savePar("ddlRev", Rev.ToString()); mod_StatoCollaudi.Rev = Rev; // verifico se sia FASE ATTIVA altrimenti NON permetto editing in collaudi... mod_collaudi.editEnabled = (Fase == faseAct); // sistemo buttons btnShowHideHist.DataBind(); btnAddNewSetMis.DataBind(); btnAddNewSetMis.Visible = addNewVisible && canEditMis; btnRemSetMis.DataBind(); btnRemSetMis.Visible = (!addNewVisible && remMisVisible) && canEditMis; // non devo inserire nulla e non ho nessuna misura inserita... // aggiorno modulo stato.. mod_StatoCollaudi.Fase = Fase; mod_StatoCollaudi.idxDossier = IdxDossier.ToString(); // rileggo SE CI SONO i parametri filtrati... if (getPar("ddlSelScheda") != "") { mod_StatoCollaudi.CodSchedaVersNum = getPar("ddlSelScheda"); } // aggiorno modulo collaudi mod_collaudi.IdxDossier = IdxDossier; mod_collaudi.CodSchedaVers = CodSchedaVers; mod_collaudi.Fase = Fase; mod_collaudi.Rev = Rev; mod_collaudi.doUpdate(); } private void fixControlsPrev() { // aggiorno modulo stato.. mod_StatoCollaudi.idxDossier = IdxDossier.ToString(); mod_StatoCollaudi.Fase = Fase; // tolgo css a blocco main divMain.Attributes.Remove("class"); // verifico SE devo mostrare storico... if (showHist) { // imposto css x mostrare 2 blocchi divMain.Attributes.Add("class", "col-md-4 fontSmall table-info pl-1"); btnShowHideHist.Text = traduci("btnHideHist"); divHist.Visible = true; // sistemo dati storici mod_collaudiPrev.IdxDossier = IdxDossier; mod_collaudiPrev.CodSchedaVers = CodSchedaVers; mod_collaudiPrev.Fase = FasePrev; mod_collaudiPrev.Rev = RevPRev; mod_collaudiPrev.doUpdate(); } else { // imposto css x mostrare solo blocco corrente e nascondo altro... divMain.Attributes.Add("class", "col-md-8 fontSmall table-info pl-1"); btnShowHideHist.Text = traduci("btnShowHist"); divHist.Visible = false; } } protected int IdxDossier { get { int answ = -1; if (ddlDossier.SelectedValue != "") { try { answ = Convert.ToInt32(ddlDossier.SelectedValue); } catch { } } return answ; } set { ddlDossier.SelectedValue = value.ToString(); } } protected string CodSchedaVers { get { return mod_StatoCollaudi.CodSchedaVersNum; } set { mod_StatoCollaudi.CodSchedaVersNum = value; } } protected string Fase { get { string answ = "-"; try { answ = ddlFase.SelectedValue; } catch { answ = "-"; } return answ; } set { ddlFase.SelectedValue = value; } } protected int Rev { get { int answ = 0; try { int.TryParse(lblRev.Text, out answ); } catch { answ = 0; } return answ; } set { lblRev.Text = value.ToString(); } } protected string FasePrev { get { string answ = "-"; try { answ = ddlFasePrev.SelectedValue; } catch { answ = "-"; } return answ; } } protected int RevPRev { get { int answ = 0; try { int.TryParse(lblRevPrev.Text, out answ); } catch { answ = 0; } return answ; } set { lblRevPrev.Text = value.ToString(); } } protected void ddlDossier_SelectedIndexChanged(object sender, EventArgs e) { // salvo! savePar("ddlDossier", ddlDossier.SelectedValue); // fix visualizzazione fixControls(); fixControlsPrev(); // tolgo selezione... mod_StatoCollaudi.resetSelezione(); } protected void ddlFase_SelectedIndexChanged(object sender, EventArgs e) { // salvo! savePar("ddlFase", ddlFase.SelectedValue); #if false // fix visualizzazione ddlDossier.DataBind(); #endif fixControls(); #if false // salvo anche dossier! savePar("ddlDossier", ddlDossier.SelectedValue); #endif // tolgo selezione... mod_StatoCollaudi.resetSelezione(); } protected void ddlFasePrev_SelectedIndexChanged(object sender, EventArgs e) { fixControlsPrev(); } /// /// wrapper traduzione /// /// /// public string traduci(string lemma) { return user_std.UtSn.Traduci(lemma); } /// /// aggiungo set misure (eventualmente) mancanti /// /// /// protected void btnAddNewSetMis_click(object sender, EventArgs e) { DtProxy.man.taMis.insMissing(IdxDossier, CodSchedaVers, Fase, Rev); mod_collaudi.doUpdate(); fixControls(); // tolgo selezione... mod_StatoCollaudi.resetSelezione(); } /// /// elimina set misure poiché VUOTE /// /// /// protected void btnRemSetMis_click(object sender, EventArgs e) { DtProxy.man.taMis.remSetMis(IdxDossier, CodSchedaVers, Fase, Rev); mod_collaudi.doUpdate(); fixControls(); // tolgo selezione... mod_StatoCollaudi.resetSelezione(); } /// /// verifico se sia possibile aggiungere records (= mancano misure x lo stato indicato...) /// public bool addNewVisible { get { bool answ = false; if (ddlDossier.SelectedValue != "") { try { answ = DtProxy.man.taMis.getNum2Ins(IdxDossier, CodSchedaVers, Fase, Rev).Rows.Count > 0; } catch (Exception exc) { logger.lg.scriviLog(string.Format("{0}", exc)); } } return answ; } } /// /// verifico se sia possibile rimuovere records (= NESSUNA misura INSERITA x lo stato indicato...) /// public bool remMisVisible { get { bool answ = false; // in primis: deve essere selezionata SINGOLA scheda... if (CodSchedaVers != "") { try { answ = DtProxy.man.taMis.getDataFilt(IdxDossier, CodSchedaVers, Fase, Rev).Select("Valoremis <> ''").Length == 0; } catch (Exception exc) { logger.lg.scriviLog(string.Format("{0}", exc)); } } return answ; } } /// /// Verifica se editing misure concesso (utente livello > collaudatore) /// public bool canEditMis { get { bool answ = false; // se ha solo 1 diritto.. ed è "User" allora NON BASTA... if (devicesAuthProxy.stObj.diritti.Rows.Count == 1) { if (!devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("CollaudatoreRole"))) { answ = true; } } else { if (devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("SuperAdminRole"))) { answ = true; } else if (devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("CapoOfficinaRole"))) { answ = true; } else if (devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("CapoGruppo"))) { answ = true; } else if (devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("AnagAdminRole"))) { answ = true; } } return answ; } } protected void ddlFase_DataBound(object sender, EventArgs e) { fixControls(); } /// /// show/hide archivio collaudi /// /// /// protected void btnShowHideHist_Click(object sender, EventArgs e) { // toggle visibilità showHist = !showHist; // fixControls(); fixControlsPrev(); } public bool showHist { get { return memLayer.ML.BoolSessionObj("showHist"); } set { memLayer.ML.setSessionVal("showHist", value); } } public bool showDetail { get { return memLayer.ML.BoolSessionObj("showDetail"); } set { memLayer.ML.setSessionVal("showDetail", value); } } protected void txtSearchMatr_TextChanged(object sender, EventArgs e) { ddlDossier.SelectedIndex = 0; ddlDossier.DataBind(); fixControls(); mod_StatoCollaudi.resetSelezione(); } protected void lbReset_Click(object sender, EventArgs e) { txtSearchMatr.Text = ""; ddlDossier.SelectedIndex = 0; ddlDossier.DataBind(); fixControls(); mod_StatoCollaudi.resetSelezione(); } } }