using SteamWare; using System; using System.Web.UI.WebControls; public partial class mod_filtro : ApplicationUserControl { protected string _css; protected ObjectDataSource _ods; protected string _valore { get { return memLayer.ML.StringSessionObj(string.Format("valFiltro_{0}", this.ID)); } set { memLayer.ML.setSessionVal(string.Format("valFiltro_{0}", this.ID), value, false); } } public string txtMostraTutti { get { return memLayer.ML.StringSessionObj(string.Format("txtMostraTutti_{0}", this.ID)); } set { memLayer.ML.setSessionVal(string.Format("txtMostraTutti_{0}", this.ID), value, false); } } public string txtMostraSoloSelez { get { return memLayer.ML.StringSessionObj(string.Format("txtMostraSoloSelez_{0}", this.ID)); } set { memLayer.ML.setSessionVal(string.Format("txtMostraSoloSelez_{0}", this.ID), value, false); } } protected bool _changeCheckEnabled = true; protected bool _changeCheckVisible = true; protected bool _changeSelEnabled = true; protected string _where = ""; protected override void traduciObj() { if (_changeCheckVisible) { if (!chkFilt.Checked) { chkFilt.Text = txtMostraSoloSelez; } else { chkFilt.Text = txtMostraTutti; } } } protected void chkFilt_CheckedChanged(object sender, EventArgs e) { // cambio modalità visualizzazione del filtro... dlFilt.Visible = !dlFilt.Visible; raiseSelEvent(); } protected void raiseSelEvent() { if (!dlFilt.Visible) { memLayer.ML.setSessionVal(string.Format("valFiltro_{0}", this.ID), "", false); } else { _valore = dlFilt.SelectedValue; } if (eh_selValore != null) { eh_selValore(this, new EventArgs()); } } 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; /// /// condizione where per ridurre elementi mostrati in selettore /// public string condizione { get { return _where; } set { _where = value; } } /// /// fornisce il valore scelto o "*" se nulla selezionato /// public string valore { get { string answ = "*"; if (chkFilt.Checked) { answ = dlFilt.SelectedValue; } return answ; } set { _valore = value; fixValore(); } } /// /// primo valore di una chiave multicampo /// public string val_1 { 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 = 0; try { if (chkFilt.Checked) { answ = Convert.ToInt32(dlFilt.SelectedValue); } } catch { } return answ; } } protected void fixValore() { if (_ods != null) { dlFilt.DataSource = _ods; dlFilt.DataBind(); if (_valore != "") { dlFilt.SelectedValue = _valore; dlFilt.Visible = true; chkFilt.Checked = true; } } } public event EventHandler eh_selValore; /// /// determina se sia possibile (de)selezionare il check di filtraggio, altrimenti sempre attivo /// public bool changeCheckEnabled { get { return _changeCheckEnabled; } set { _changeCheckEnabled = value; updateChk(); } } /// /// determina se sia possibile modificare la selezione /// public bool changeSelEnabled { get { return _changeSelEnabled; } set { _changeSelEnabled = value; updateSel(); } } /// /// determina se sia possibile visibile il check di filtraggio /// public bool changeCheckVisible { get { return _changeCheckVisible; } set { _changeCheckVisible = value; updateChkLbl(); } } protected void dlFilt_SelectedIndexChanged(object sender, EventArgs e) { raiseSelEvent(); // salvo val selezionato... } /// /// oggetto ODS con cui popolare il selettore, VINCOLO abbia campi value(key) / label /// public ObjectDataSource ods { get { return _ods; } set { _ods = value; bindControlli(); } } /// /// css applicato agli elementi del controllo /// public string css { get { return _css; } set { _css = value; } } /// /// resetta il controllo (un-checked) /// public void reset() { chkFilt.Checked = false; dlFilt.Visible = false; memLayer.ML.emptySessionVal(string.Format("valFiltro_{0}", this.ID)); } }