diff --git a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx index 2ee1f48..29892e1 100644 --- a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx +++ b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx @@ -1,79 +1,66 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_adminProgetti.ascx.cs" Inherits="GPW_Admin.WebUserControls.mod_adminProgetti" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <%@ Register Src="mod_filtro.ascx" TagName="mod_filtro" TagPrefix="uc1" %> -<%@ Register Src="mod_periodoAnalisi.ascx" TagName="mod_periodoAnalisi" TagPrefix="uc2" %> <%@ Register Src="mod_dettaglioProgetto.ascx" TagName="mod_dettaglioProgetto" TagPrefix="uc3" %> +<%@ Register Src="~/WebUserControls/cmp_periodoAnalisi.ascx" TagPrefix="uc1" TagName="cmp_periodoAnalisi" %> + <% if (false) { %> <% } %> -
-
- + +
+
+
-
- +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
-
+
- <%--
- -
--%> -
- -
-
- -
-
-
- - - - - - - - - - - - +
+
+ + + + + + - + + + + - - - + + + - - + + - - + + - - - + @@ -91,12 +78,12 @@ + ItemStyle-Width="60em">
-
+
@@ -152,28 +139,17 @@ + + + - - + + - - - - - - - - - + @@ -208,8 +184,12 @@ - + + + + +
diff --git a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.cs b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.cs index a5efe53..40fbd40 100644 --- a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.cs @@ -8,53 +8,227 @@ using System.Data; using SteamWare; using GPW_data; using System.ServiceModel; +using Newtonsoft.Json; namespace GPW_Admin.WebUserControls { + public class filtroProj + { + #region Public Constructors + + /// + /// Init con valori specifici + /// + /// + /// + /// + /// + /// + public filtroProj(bool fCli, intervalloDate interv, bool onlStar, bool showA, bool showE) + { + this.filtCli = fCli; + this.intAnalys = interv; + this.onlyStarred = onlStar; + this.showArch = showA; + this.showEmpty = showE; + } + + /// + /// Init con valori default + /// + public filtroProj() + { + filtCli = false; + // imposto intervallo dal 2000.01.01... + intervalloDate date = new intervalloDate(); + date.fine = DateTime.Now.Date.AddDays(1); + date.inizio = new DateTime(2000, 1, 1); + onlyStarred = false; + intAnalys = date; + showArch = false; + showEmpty = true; + } + + #endregion Public Constructors + + #region Public Properties + + public bool filtCli { get; set; } + public intervalloDate intAnalys { get; set; } + public bool onlyStarred { get; set; } + public bool showArch { get; set; } + public bool showEmpty { get; set; } + + #endregion Public Properties + } + public partial class mod_adminProgetti : System.Web.UI.UserControl { - #region area standard (non modificare) + #region Public Events - #region gestione eventi + public event EventHandler eh_nuovoValore; public event EventHandler eh_resetSelezione; - public event EventHandler eh_nuovoValore; + public event EventHandler eh_selValore; - #endregion + #endregion Public Events + + #region Protected Properties /// - /// effettua traduzione del lemma + /// Filtro attivo (formato OBJ) /// - /// - /// - public string traduci(string lemma) + protected filtroProj currFiltProjRaw { - return user_std.UtSn.Traduci(lemma); - } - - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - grView.SelectedIndex = -1; - grView.DataBind(); - mod_dettaglioProgetto1.Visible = false; - if (eh_resetSelezione != null) + get { - eh_resetSelezione(this, new EventArgs()); + filtroProj answ = new filtroProj(); + string rawData = memLayer.ML.StringSessionObj("currFiltProjRaw"); + if (!string.IsNullOrEmpty(rawData)) + { + try + { + answ = JsonConvert.DeserializeObject(rawData); + } + catch + { } + } + return answ; + } + set + { + string rawData = JsonConvert.SerializeObject(value); + memLayer.ML.setSessionVal("currFiltProjRaw", rawData); } } + + #endregion Protected Properties + + #region Public Properties + /// - /// reset della selezione + /// pagina corrente (URL finale) + /// + public string _paginaCorrente { get; set; } + + /// + /// controllo stato licenze! + /// + public bool chkLicOk + { + get + { + return (licenzeGPW.utentiAttivi <= licenzeGPW.licenzeAttive); + } + } + + /// + /// determina se siano da visualizzare i progetti già chiusi + /// + public bool showChiusi + { + get + { + return memLayer.ML.BoolSessionObj("showPrjArch"); + } + set + { + memLayer.ML.setSessionVal("showPrjArch", value); + } + } + + /// + /// determina se siano visibili SOLO progetti "Starred" + /// + public bool showOnlyStarred + { + get + { + return memLayer.ML.BoolSessionObj("showPrjStar"); + } + set + { + memLayer.ML.setSessionVal("showPrjStar", value); + } + } + + /// + /// determina se siano visibili progetti "vuoti" con zero ore caricate quindi + /// + public bool showVuoti + { + get + { + return memLayer.ML.BoolSessionObj("showPrjZeroH"); + } + set + { + memLayer.ML.setSessionVal("showPrjZeroH", value); + } + } + + #endregion Public Properties + + #region Private Methods + + /// + /// selezionato valore, filtro! /// /// /// - protected void btnReset_Click(object sender, EventArgs e) + private void filtroCli_eh_selValore(object sender, EventArgs e) { - resetSelezione(); + if (filtroCli.isChecked) + { + memLayer.ML.setSessionVal("idxCli_sel", filtroCli.valoreInt); + } + else + { + memLayer.ML.setSessionVal("idxCli_sel", 0); + } + grView.DataBind(); } + + /// + /// cambiati dati dettaglio (attivo/inattivo) + /// + /// + /// + private void mod_dettaglioProgetto1_eh_nuovoValore(object sender, EventArgs e) + { + doUpdate(); + } + + /// + /// resetta filtraggio + /// + private void resetFilter() + { + // svuoto variabili sessione + memLayer.ML.emptySessionVal("idxProgetto_sel"); + memLayer.ML.emptySessionVal("idxCli_sel"); + // genero un nuovo oggetto di default + currFiltProjRaw = new filtroProj(); + setupFilter(currFiltProjRaw); + filtroCli.reselFirst(); + } + + private void setupFilter(filtroProj currFilt) + { + // imposto + cmp_periodoAnalisi.intervalloAnalisi = currFilt.intAnalys; + showChiusi = currFilt.showArch; + showVuoti = currFilt.showEmpty; + filtroCli.isChecked = currFilt.filtCli; + // salvo ulteriori valori + filtroCli.ods = odsClienti; + } + + #endregion Private Methods + + #region Protected Methods + /// /// gestione evento richiesta nuovo valore (mostra footer, ...) /// @@ -75,26 +249,60 @@ namespace GPW_Admin.WebUserControls eh_nuovoValore(this, new EventArgs()); } } + /// - /// inserisce nuovo valore da footer + /// reset della selezione /// /// /// - protected void lblIns_click(object sender, EventArgs e) + protected void btnReset_Click(object sender, EventArgs e) { - // click su inserimento, chiamo il metodo insert dell'ObjectDataSource - ods.Insert(); + resetSelezione(); } + /// - /// annulla inserimento nuovo valore da footer + /// determina se mostrare i progetti archiviati /// /// /// - protected void lblCanc_click(object sender, EventArgs e) + protected void chkShowChiusi_CheckedChanged(object sender, EventArgs e) { - // annullo inserimento: nascondo footer, bind controlli... - grView.FooterRow.Visible = false; + showChiusi = chkShowChiusi.Checked; + filtroCli.ods = odsClienti; + grView.DataBind(); } + + protected void chkShowOnlyStarred_CheckedChanged(object sender, EventArgs e) + { + showOnlyStarred = chkShowOnlyStarred.Checked; + grView.DataBind(); + } + + /// + /// cambia impsotazione show/hide progetti con ore a zero... + /// + /// + /// + protected void chkShowVuoti_CheckedChanged(object sender, EventArgs e) + { + showVuoti = chkShowVuoti.Checked; + grView.DataBind(); + } + + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DataColumnCollection colonne = null; + using (DS_Applicazione.AnagProgettiDataTable tabella = new DS_Applicazione.AnagProgettiDataTable()) + { + colonne = tabella.Columns; + } + return colonne; + } + /// /// traduce gli header delle colonne /// @@ -105,7 +313,7 @@ namespace GPW_Admin.WebUserControls if (grView.Rows.Count > 0) { LinkButton lb; - // aggiorno gli headers + // aggiorno gli headers foreach (TableCell cella in grView.HeaderRow.Cells) { try @@ -125,191 +333,6 @@ namespace GPW_Admin.WebUserControls } } - #endregion - - #region area CUSTOM (da modificare) - - /// - /// pagina corrente (URL finale) - /// - public string _paginaCorrente { get; set; } - /// - /// determina se siano da visualizzare i progetti già chiusi - /// - public bool showChiusi - { - get - { - return memLayer.ML.BoolSessionObj("showPrjArch"); - } - set - { - memLayer.ML.setSessionVal("showPrjArch", value); - } - } - /// - /// determina se siano visibili progetti "vuoti" con zero ore caricate quindi - /// - public bool showVuoti - { - get - { - return memLayer.ML.BoolSessionObj("showPrjZeroH"); - } - set - { - memLayer.ML.setSessionVal("showPrjZeroH", value); - } - } - /// - /// determina se siano visibili SOLO progetti "Starred" - /// - public bool showOnlyStarred - { - get - { - return memLayer.ML.BoolSessionObj("showPrjStar"); - } - set - { - memLayer.ML.setSessionVal("showPrjStar", value); - } - } - /// - /// caricamento - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - grView.PageSize = utils.pageSize; - if (!Page.IsPostBack) - { - // imposto intervallo date...10 anni... - intervalloDate date = new intervalloDate(); - date.fine = DateTime.Now.Date.AddDays(1); - date.inizio = date.fine.AddYears(-20); - mod_periodoAnalisi1.intervalloAnalisi = date; - // svuoto variabili sessione - memLayer.ML.emptySessionVal("idxProgetto_sel"); - memLayer.ML.emptySessionVal("idxCli_sel"); - filtroCli.ods = odsClienti; - filtroCli.reselFirst(); - filtroCli.isChecked = false; - showChiusi = false; - showVuoti = true; - mod_dettaglioProgetto1.Visible = false; - } - filtroCli.eh_selValore += new EventHandler(filtroCli_eh_selValore); - mod_dettaglioProgetto1.eh_nuovoValore += new EventHandler(mod_dettaglioProgetto1_eh_nuovoValore); - } - /// - /// salva in variabile pagina il nome della pagina corrente - /// - protected void PagCorrente() - { - Uri MyUrl = Request.Url; - string delimStr = "/"; - char[] delimiter = delimStr.ToCharArray(); - string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); - int n = finalUrl.Length; - _paginaCorrente = finalUrl[n - 1].ToString(); - } - /// - /// cambiati dati dettaglio (attivo/inattivo) - /// - /// - /// - void mod_dettaglioProgetto1_eh_nuovoValore(object sender, EventArgs e) - { - doUpdate(); - } - /// - /// selezionato valore, filtro! - /// - /// - /// - void filtroCli_eh_selValore(object sender, EventArgs e) - { - if (filtroCli.isChecked) - { - memLayer.ML.setSessionVal("idxCli_sel", filtroCli.valoreInt); - } - else - { - memLayer.ML.setSessionVal("idxCli_sel", 0); - } - grView.DataBind(); - } - /// - /// elenco colonne del datagrid - /// - /// - protected DataColumnCollection colonneObj() - { - DataColumnCollection colonne = null; - using (DS_Applicazione.AnagProgettiDataTable tabella = new DS_Applicazione.AnagProgettiDataTable()) - { - colonne = tabella.Columns; - } - return colonne; - } - /// - /// determina se sia eliminabile il record (=non usato) - /// - /// - /// - public bool delEnabled(object idxObj) - { - bool answ = isWritable(); - // solo se ha diritti scrittura controllo - if (idxObj != null) - { - int trovati = 0; - int idxProj = 0; - _ = int.TryParse(idxObj.ToString(), out idxProj); - trovati = DataProxy.DP.taAF.getByIdxProgetto(idxProj).Count; - // controllo se ci sono record correlati... - if (trovati > 0) - { - answ = false; - } - } - return answ; - } - /// - /// evento selezione! - /// - /// - /// - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - memLayer.ML.setSessionVal("idxProgetto_sel", grView.SelectedDataKey["idxProgetto"]); - mod_dettaglioProgetto1.Visible = true; - if (eh_selValore != null) - { - eh_selValore(this, new EventArgs()); - } - } - /// - /// determina se mostrare i progetti archiviati - /// - /// - /// - protected void chkShowChiusi_CheckedChanged(object sender, EventArgs e) - { - showChiusi = chkShowChiusi.Checked; - grView.DataBind(); - } - /// - /// salvo in session che il prox comando è clonare... - /// - /// - /// - protected void imgDettFasi_Click(object sender, ImageClickEventArgs e) - { - SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "dettFasi"); - } /// /// intercetto eventuale update fittizio x rimandare a pagina dett fasi /// @@ -345,110 +368,116 @@ namespace GPW_Admin.WebUserControls // blocco update! e.Cancel = true; break; + default: // faccio update! break; } } } + /// - /// effettua update controllo - /// - public void doUpdate() - { - resetSelezione(); - } - /// - /// inverte valore booleano - /// - /// - /// - public bool invBool(object valore) - { - bool answ = true; - try - { - answ = !Convert.ToBoolean(valore); - } - catch - { } - return answ; - } - /// - /// restituisce una classe css a seconda dei valori passati: - /// green: bdgt > real - /// orange: real > bdgt*warning - /// red: real > bdgt - /// std: errore... - /// - /// - /// - /// - public string colorByVal(object real, object bdgt) - { - string answ = "badgeStd"; - try - { - double valoreReal = Convert.ToDouble(real); - double valoreBdget = Convert.ToDouble(bdgt); - double valoreWarn = Convert.ToDouble(bdgt) * Convert.ToDouble(memLayer.ML.confReadString("warningRatioPerc")) / 100; - if (valoreReal >= valoreBdget) - { - answ = "badgeRosso"; - } - else if (valoreReal >= valoreWarn) - { - answ = "badgeArancio"; - } - else - { - answ = "badgeVerde"; - } - } - catch - { - } - return "ui-corner-all " + answ; - } - /// - /// cambia impsotazione show/hide progetti con ore a zero... + /// evento selezione! /// /// /// - protected void chkShowVuoti_CheckedChanged(object sender, EventArgs e) + protected void grView_SelectedIndexChanged(object sender, EventArgs e) { - showVuoti = chkShowVuoti.Checked; - grView.DataBind(); - } - protected void chkShowOnlyStarred_CheckedChanged(object sender, EventArgs e) - { - showOnlyStarred = chkShowOnlyStarred.Checked; - grView.DataBind(); - } - /// - /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione - /// - /// - public bool isWritable() - { - bool answ = false; - if (_paginaCorrente == null) + memLayer.ML.setSessionVal("idxProgetto_sel", grView.SelectedDataKey["idxProgetto"]); + mod_dettaglioProgetto1.Visible = true; + if (eh_selValore != null) { - PagCorrente(); - } - answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente) && chkLicOk; - return answ; - } - /// - /// controllo stato licenze! - /// - public bool chkLicOk - { - get - { - return (licenzeGPW.utentiAttivi <= licenzeGPW.licenzeAttive); + eh_selValore(this, new EventArgs()); } } + + /// + /// annulla inserimento nuovo valore da footer + /// + /// + /// + protected void lblCanc_click(object sender, EventArgs e) + { + // annullo inserimento: nascondo footer, bind controlli... + grView.FooterRow.Visible = false; + } + + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + } + + /// + /// salvo in session che il prox comando è andare a dettaglio... + /// + /// + /// + protected void lbtDettFasi_Click(object sender, EventArgs e) + { + memLayer.ML.setSessionVal("nextObjCommand", "dettFasi"); + } + + protected void lbtResetFilt_Click(object sender, EventArgs e) + { + resetFilter(); + } + + /// + /// check licenze in fase di update... + /// + /// + /// + protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + { + if (!licenzeGPW.checkLicenze) + { + if (e != null) + { + // annullo insert se licenze sforate... + e.Cancel = true; + grView.EditIndex = -1; + grView.DataBind(); + } + } + } + + /// + /// salva in variabile pagina il nome della pagina corrente + /// + protected void PagCorrente() + { + Uri MyUrl = Request.Url; + string delimStr = "/"; + char[] delimiter = delimStr.ToCharArray(); + string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); + int n = finalUrl.Length; + _paginaCorrente = finalUrl[n - 1].ToString(); + } + + /// + /// caricamento + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + grView.PageSize = utils.pageSize; + if (!Page.IsPostBack) + { + // imposto filtro (precedente o da zero) + setupFilter(currFiltProjRaw); + mod_dettaglioProgetto1.Visible = false; + } + filtroCli.eh_selValore += new EventHandler(filtroCli_eh_selValore); + mod_dettaglioProgetto1.eh_nuovoValore += new EventHandler(mod_dettaglioProgetto1_eh_nuovoValore); + } + /// /// recupera i dati di un nuovo record contenuti nel footer di un gridView; /// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...) @@ -487,12 +516,15 @@ namespace GPW_Admin.WebUserControls case "textBox": e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; break; + case "dropDownList": e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; break; + case "checkBox": e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; break; + default: break; } @@ -507,26 +539,136 @@ namespace GPW_Admin.WebUserControls } } } + + #endregion Protected Methods + + #region Public Methods + /// - /// check licenze in fase di update... + /// restituisce una classe css a seconda dei valori passati: + /// green: bdgt > real + /// orange: real > bdgt*warning + /// red: real > bdgt + /// std: errore... /// - /// - /// - protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + /// + /// + /// + public string colorByVal(object real, object bdgt) { - if (!licenzeGPW.checkLicenze) + string answ = "badgeStd"; + try { - if (e != null) + double valoreReal = Convert.ToDouble(real); + double valoreBdget = Convert.ToDouble(bdgt); + double valoreWarn = Convert.ToDouble(bdgt) * Convert.ToDouble(memLayer.ML.confReadString("warningRatioPerc")) / 100; + if (valoreReal >= valoreBdget) { - // annullo insert se licenze sforate... - e.Cancel = true; - grView.EditIndex = -1; - grView.DataBind(); + answ = "badgeRosso"; } + else if (valoreReal >= valoreWarn) + { + answ = "badgeArancio"; + } + else + { + answ = "badgeVerde"; + } + } + catch + { + } + return "ui-corner-all " + answ; + } + + /// + /// determina se sia eliminabile il record (=non usato) + /// + /// + /// + public bool delEnabled(object idxObj) + { + bool answ = isWritable(); + // solo se ha diritti scrittura controllo + if (idxObj != null) + { + int trovati = 0; + int idxProj = 0; + _ = int.TryParse(idxObj.ToString(), out idxProj); + trovati = DataProxy.DP.taAF.getByIdxProgetto(idxProj).Count; + // controllo se ci sono record correlati... + if (trovati > 0) + { + answ = false; + } + } + return answ; + } + + /// + /// effettua update controllo + /// + public void doUpdate() + { + resetSelezione(); + } + + /// + /// inverte valore booleano + /// + /// + /// + public bool invBool(object valore) + { + bool answ = true; + try + { + answ = !Convert.ToBoolean(valore); + } + catch + { } + return answ; + } + + /// + /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione + /// + /// + public bool isWritable() + { + bool answ = false; + if (_paginaCorrente == null) + { + PagCorrente(); + } + answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente) && chkLicOk; + return answ; + } + + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + grView.SelectedIndex = -1; + grView.DataBind(); + mod_dettaglioProgetto1.Visible = false; + if (eh_resetSelezione != null) + { + eh_resetSelezione(this, new EventArgs()); } } + /// + /// effettua traduzione del lemma + /// + /// + /// + public string traduci(string lemma) + { + return user_std.UtSn.Traduci(lemma); + } - #endregion + #endregion Public Methods } } \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.designer.cs b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.designer.cs index 88e7b0b..680d986 100644 --- a/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.designer.cs +++ b/GPW_Admin/WebUserControls/mod_adminProgetti.ascx.designer.cs @@ -15,13 +15,13 @@ namespace GPW_Admin.WebUserControls { /// - /// Controllo mod_periodoAnalisi1. + /// Controllo cmp_periodoAnalisi. /// /// /// Campo generato automaticamente. /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// - protected global::mod_periodoAnalisi mod_periodoAnalisi1; + protected global::GPW_Admin.WebUserControls.cmp_periodoAnalisi cmp_periodoAnalisi; /// /// Controllo chkShowChiusi. @@ -32,15 +32,6 @@ namespace GPW_Admin.WebUserControls /// protected global::System.Web.UI.WebControls.CheckBox chkShowChiusi; - /// - /// Controllo filtroCli. - /// - /// - /// Campo generato automaticamente. - /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. - /// - protected global::mod_filtro filtroCli; - /// /// Controllo chkShowVuoti. /// @@ -59,6 +50,24 @@ namespace GPW_Admin.WebUserControls /// protected global::System.Web.UI.WebControls.CheckBox chkShowOnlyStarred; + /// + /// Controllo lbtResetFilt. + /// + /// + /// 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.LinkButton lbtResetFilt; + + /// + /// Controllo filtroCli. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::mod_filtro filtroCli; + /// /// Controllo grView. /// diff --git a/GPW_Admin/WebUserControls/mod_filtro.ascx b/GPW_Admin/WebUserControls/mod_filtro.ascx index 6be4ce8..725cd6c 100644 --- a/GPW_Admin/WebUserControls/mod_filtro.ascx +++ b/GPW_Admin/WebUserControls/mod_filtro.ascx @@ -1,13 +1,10 @@ <%@ Control Language="C#" AutoEventWireup="true" Inherits="mod_filtro" CodeBehind="mod_filtro.ascx.cs" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> -
-
- + +
+
+
-
- -
-
- -
-
+ + +
\ No newline at end of file diff --git a/GPW_Admin/WebUserControls/mod_filtro.ascx.cs b/GPW_Admin/WebUserControls/mod_filtro.ascx.cs index 994fc9a..8b94dfc 100644 --- a/GPW_Admin/WebUserControls/mod_filtro.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_filtro.ascx.cs @@ -12,19 +12,85 @@ using SteamWare; public partial class mod_filtro : ApplicationUserControl { + #region Protected Fields + + protected bool _changeCheckEnabled = true; + + protected bool _changeCheckVisible = true; + + protected bool _changeSelEnabled = true; + protected string _css; + + protected SteamWare.tipoVistaMod _modo = SteamWare.tipoVistaMod.editing; + protected ObjectDataSource _ods; + + protected string _where = ""; + + /// + /// nome variabile x salvataggio filtro + /// + protected string nomeFiltro = $"valFiltro_"; + + /// + /// nome variabile x salvataggio stato SHOW ALL + /// + protected string showAll = $"_showAll_"; + + /// + /// nome variabile x salvataggio stato filtro + /// + protected string showFiltro = $"_showFiltered_"; + + #endregion Protected Fields + + #region Public Events + + public event EventHandler eh_selValore; + + #endregion Public Events + + #region Protected Properties + + protected string _showAll + { + get + { + return memLayer.ML.StringSessionObj($"_showAll_{this.UniqueID}"); + } + set + { + memLayer.ML.setSessionVal($"_showAll_{this.UniqueID}", value); + traduciObj(); + } + } + + protected string _showFiltered + { + get + { + return memLayer.ML.StringSessionObj(showFiltro); + } + set + { + memLayer.ML.setSessionVal(showFiltro, value); + traduciObj(); + } + } + protected string _valore { get { - return memLayer.ML.StringSessionObj(string.Format("valFiltro_{0}", this.ID)); + return memLayer.ML.StringSessionObj(nomeFiltro); } set { - memLayer.ML.setSessionVal(string.Format("valFiltro_{0}", this.ID), value, false); + memLayer.ML.setSessionVal(nomeFiltro, value, false); } } + /// /// calcola se ci sia in sessione il valore del filtro /// @@ -35,149 +101,80 @@ public partial class mod_filtro : ApplicationUserControl bool answ = false; try { - memLayer.ML.isInSessionObject(string.Format("valFiltro_{0}", this.ID)); + memLayer.ML.isInSessionObject(nomeFiltro); } catch { } return answ; } } - protected bool _changeCheckEnabled = true; - protected bool _changeCheckVisible = true; - protected bool _changeSelEnabled = true; - protected string _where = ""; - protected string _showFiltered - { - get - { - return memLayer.ML.StringSessionObj(string.Format("_showFiltered_{0}", this.ID)); - } - set - { - memLayer.ML.setSessionVal(string.Format("_showFiltered_{0}", this.ID), value); - traduciObj(); - } - } - protected string _showAll - { - get - { - return memLayer.ML.StringSessionObj(string.Format("_showAll_{0}", this.ID)); - } - set - { - memLayer.ML.setSessionVal(string.Format("_showAll_{0}", this.ID), value); - traduciObj(); - } - } - protected override void OnInit(EventArgs e) + #endregion Protected Properties + + #region Public Properties + + /// + /// determina se sia possibile (de)selezionare il check di filtraggio, altrimenti sempre attivo + /// + public bool changeCheckEnabled { - base.OnInit(e); - if (!Page.IsPostBack) + get { - if (string.IsNullOrEmpty(_showFiltered)) _showFiltered = "mostraSoloSelez"; - if (string.IsNullOrEmpty(_showAll)) _showAll = "mostraTutti"; + return _changeCheckEnabled; + } + set + { + _changeCheckEnabled = value; + updateChk(); } } /// - /// traduzione oggetti + /// determina se sia possibile visibile il check di filtraggio /// - protected override void traduciObj() - { - if (_changeCheckVisible) - { - if (!chkFilt.Checked) - { - chkFilt.Text = traduci(_showFiltered); - } - else - { - chkFilt.Text = traduci(_showAll); - } - } - } - /// - /// get/set messaggio di attivazione filtraggio - /// - public string filterChekText + public bool changeCheckVisible { get { - return _showFiltered; + return _changeCheckVisible; } set { - _showFiltered = value; + _changeCheckVisible = value; + updateChkLbl(); } } + /// - /// get/set messaggio di disattivazione filtraggio + /// determina se sia possibile modificare la selezione /// - public string filterUnchekText + public bool changeSelEnabled { get { - return _showAll; + return _changeSelEnabled; } set { - _showAll = value; + _changeSelEnabled = value; + updateSel(); } } - protected void chkFilt_CheckedChanged(object sender, EventArgs e) - { - // cambio modalità visualizzazione del filtro... - dlFilt.Visible = !dlFilt.Visible; - raiseSelEvent(); - } - protected void raiseSelEvent() + /// + /// get/set per la larghezza della combo dropdown + /// + public int comboWidth { - if (!dlFilt.Visible) + get { - memLayer.ML.setSessionVal(string.Format("valFiltro_{0}", this.ID), "", false); + return Convert.ToInt32(dlFilt.Width); } - else + set { - _valore = dlFilt.SelectedValue; - } - if (eh_selValore != null) - { - eh_selValore(this, new EventArgs()); + dlFilt.Width = value; } } - protected void updateChk() - { - chkFilt.Enabled = _changeCheckEnabled; - if (!_changeCheckEnabled) - { - chkFilt.Checked = true; - dlFilt.Visible = true; - } - } - protected void updateSel() - { - dlFilt.Enabled = _changeSelEnabled; - } - protected void updateChkLbl() - { - chkFilt.Visible = _changeCheckVisible; - } - protected override void bindControlli() - { - updateChk(); - fixValore(); - where.Text = _where; - traduciObj(); - } - protected SteamWare.tipoVistaMod _modo = SteamWare.tipoVistaMod.editing; - protected void dlFilt_SelectedIndexChanged(object sender, EventArgs e) - { - raiseSelEvent(); - } - /// /// condizione where per ridurre elementi mostrati in selettore @@ -195,171 +192,50 @@ public partial class mod_filtro : ApplicationUserControl } /// - /// fornisce il valore scelto o "*" se nulla selezionato + /// css applicato agli elementi del controllo /// - public string valore + public string css { get { - string answ = "*"; - if (chkFilt.Checked) - { - answ = dlFilt.SelectedValue; - } - return answ; + return _css; } set { - _valore = value; - //fixValore(); + _css = value; } } /// - /// primo valore di una chiave multicampo + /// get/set messaggio di attivazione filtraggio /// - public string val_1 + public string filterChekText { get { - string answ = ""; - if (chkFilt.Checked) - { - try - { - string[] _dataKey = dlFilt.SelectedValue.Split('#'); - answ = _dataKey[0]; - } - catch - { } - } - else - { - answ = "*"; - } - return answ; - } - } - /// - /// secondo valore di una chiave multicampo - /// - public string val_2 - { - get - { - string answ = ""; - if (chkFilt.Checked) - { - try - { - string[] _dataKey = dlFilt.SelectedValue.Split('#'); - answ = _dataKey[1]; - } - catch - { } - } - else - { - answ = "*"; - } - return answ; - } - } - /// - /// fornisce il valore scelto o "0" se nulla selezionato o non valido - /// - public int valoreInt - { - get - { - int answ = -1; - try - { - if (chkFilt.Checked) - { - answ = Convert.ToInt32(dlFilt.SelectedValue); - } - } - catch - { } - return answ; - } - } - /// - /// sistema visualizzazione - /// - protected void fixValore() - { - if (_ods != null) - { - try - { - dlFilt.DataSource = _ods; - dlFilt.DataBind(); - if (!string.IsNullOrEmpty(_valore)) - { - - dlFilt.SelectedValue = _valore; - dlFilt.Visible = true; - chkFilt.Checked = true; - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - dlFilt.SelectedIndex = 0; - } - } - } - - - public event EventHandler eh_selValore; - - /// - /// determina se sia possibile (de)selezionare il check di filtraggio, altrimenti sempre attivo - /// - public bool changeCheckEnabled - { - get - { - return _changeCheckEnabled; + return _showFiltered; } set { - _changeCheckEnabled = value; - updateChk(); + _showFiltered = value; } } + /// - /// determina se sia possibile modificare la selezione + /// get/set messaggio di disattivazione filtraggio /// - public bool changeSelEnabled + public string filterUnchekText { get { - return _changeSelEnabled; + return _showAll; } set { - _changeSelEnabled = value; - updateSel(); - } - } - /// - /// determina se sia possibile visibile il check di filtraggio - /// - public bool changeCheckVisible - { - get - { - return _changeCheckVisible; - } - set - { - _changeCheckVisible = value; - updateChkLbl(); + _showAll = value; } } + /// /// get/set della checkbox /// @@ -389,22 +265,248 @@ public partial class mod_filtro : ApplicationUserControl set { _ods = value; + reselFirst(); } } + /// - /// css applicato agli elementi del controllo + /// primo valore di una chiave multicampo /// - public string css + public string val_1 { get { - return _css; + string answ = ""; + if (chkFilt.Checked) + { + try + { + string[] _dataKey = dlFilt.SelectedValue.Split('#'); + answ = _dataKey[0]; + } + catch + { } + } + else + { + answ = "*"; + } + return answ; + } + } + + /// + /// secondo valore di una chiave multicampo + /// + public string val_2 + { + get + { + string answ = ""; + if (chkFilt.Checked) + { + try + { + string[] _dataKey = dlFilt.SelectedValue.Split('#'); + answ = _dataKey[1]; + } + catch + { } + } + else + { + answ = "*"; + } + return answ; + } + } + + /// + /// fornisce il valore scelto o "*" se nulla selezionato + /// + public string valore + { + get + { + string answ = "*"; + if (chkFilt.Checked) + { + answ = dlFilt.SelectedValue; + } + return answ; } set { - _css = value; + _valore = value; } } + + /// + /// fornisce il valore scelto o "0" se nulla selezionato o non valido + /// + public int valoreInt + { + get + { + int answ = -1; + try + { + if (chkFilt.Checked) + { + answ = Convert.ToInt32(dlFilt.SelectedValue); + } + } + catch + { } + return answ; + } + } + + #endregion Public Properties + + #region Protected Methods + + protected override void bindControlli() + { + updateChk(); + fixValore(); + where.Text = _where; + traduciObj(); + } + + protected void chkFilt_CheckedChanged(object sender, EventArgs e) + { + // cambio modalità visualizzazione del filtro... + dlFilt.Visible = !dlFilt.Visible; + raiseSelEvent(); + } + + protected void dlFilt_SelectedIndexChanged(object sender, EventArgs e) + { + raiseSelEvent(); + } + + /// + /// sistema visualizzazione + /// + protected void fixValore() + { + if (_ods != null) + { + try + { + dlFilt.DataSource = _ods; + dlFilt.DataBind(); + if (!string.IsNullOrEmpty(_valore)) + { + dlFilt.SelectedValue = _valore; + dlFilt.Visible = true; + chkFilt.Checked = true; + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione:{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + dlFilt.SelectedIndex = 0; + } + } + } + + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + if (!Page.IsPostBack) + { + if (string.IsNullOrEmpty(_showFiltered)) _showFiltered = "mostraSoloSelez"; + if (string.IsNullOrEmpty(_showAll)) _showAll = "mostraTutti"; + } + } + + protected override void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + nomeFiltro = $"valFiltro_{this.UniqueID}"; + showFiltro = $"_showFiltered_{this.UniqueID}"; + } + base.Page_Load(sender, e); + } + + protected void raiseSelEvent() + { + if (!dlFilt.Visible) + { + memLayer.ML.setSessionVal(nomeFiltro, "", false); + } + else + { + _valore = dlFilt.SelectedValue; + } + if (eh_selValore != null) + { + eh_selValore(this, new EventArgs()); + } + } + + /// + /// traduzione oggetti + /// + protected override void traduciObj() + { + if (_changeCheckVisible) + { + if (!chkFilt.Checked) + { + chkFilt.Text = traduci(_showFiltered); + } + else + { + chkFilt.Text = traduci(_showAll); + } + } + } + + protected void updateChk() + { + chkFilt.Enabled = _changeCheckEnabled; + if (!_changeCheckEnabled) + { + chkFilt.Checked = true; + dlFilt.Visible = true; + } + } + + protected void updateChkLbl() + { + chkFilt.Visible = _changeCheckVisible; + } + + protected void updateSel() + { + dlFilt.Enabled = _changeSelEnabled; + } + + #endregion Protected Methods + + #region Public Methods + + /// + /// resetta e seleziona primo valore + /// + public void reselFirst() + { + try + { + dlFilt.DataBind(); + bindControlli(); + dlFilt.SelectedIndex = 0; + } + catch(Exception exc) + { + logger.lg.scriviLog($"Eccezione:{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + /// /// resetta il controllo (un-checked) /// @@ -412,35 +514,8 @@ public partial class mod_filtro : ApplicationUserControl { chkFilt.Checked = false; dlFilt.Visible = false; - memLayer.ML.emptySessionVal(string.Format("valFiltro_{0}", this.ID)); - } - /// - /// resetta e seleziona primo valore - /// - public void reselFirst() - { - dlFilt.DataBind(); - bindControlli(); - try - { - dlFilt.SelectedIndex = 0; - } - catch - { } - } - /// - /// get/set per la larghezza della combo dropdown - /// - public int comboWidth - { - get - { - return Convert.ToInt32(dlFilt.Width); - } - set - { - dlFilt.Width = value; - } + memLayer.ML.emptySessionVal(nomeFiltro); } + #endregion Public Methods } \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/mod_filtro.ascx.designer.cs b/GPW_Admin/WebUserControls/mod_filtro.ascx.designer.cs index f4cb510..dde8c97 100644 --- a/GPW_Admin/WebUserControls/mod_filtro.ascx.designer.cs +++ b/GPW_Admin/WebUserControls/mod_filtro.ascx.designer.cs @@ -1,40 +1,41 @@ //------------------------------------------------------------------------------ -// -// 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. +// //------------------------------------------------------------------------------ -public partial class mod_filtro { - +public partial class mod_filtro +{ + /// - /// chkFilt control. + /// Controllo chkFilt. /// /// - /// 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 chkFilt; - + /// - /// dlFilt control. + /// Controllo dlFilt. /// /// - /// 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::AjaxControlToolkit.ComboBox dlFilt; - + /// - /// where control. + /// Controllo where. /// /// - /// 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 where; }