using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using ETS_Data; using NLog; namespace ETS_WS.WebUserControls { public partial class mod_filtroRicerca : System.Web.UI.UserControl { protected int pageSize { get { int answ = 10; try { answ = utils.obj.IntSessionObj("srcPageSize"); if (answ <= 0) { answ = utils.obj.confReadInt("srcPageSize"); } } catch { answ = utils.obj.confReadInt("srcPageSize"); } return answ; } } protected Logger lg = LogManager.GetCurrentClassLogger(); /// /// evento richiesta salvataggio files /// public event EventHandler eh_reqSearch; /// /// evento richiesta update page size /// public event EventHandler eh_pageResize; /// /// caricamento pagina /// /// /// protected void Page_Load(object sender, EventArgs e) { tacCommesse.eh_valSelezionato += new EventHandler(tacCommesse_eh_valSelezionato); tacFasi.eh_valSelezionato += new EventHandler(tacFasi_eh_valSelezionato); tacFonti.eh_valSelezionato += new EventHandler(tacFonti_eh_valSelezionato); tacRedattore.eh_valSelezionato += new EventHandler(tacRedattore_eh_valSelezionato); mod_periodoAnalisi1.eh_doUpdate += new EventHandler(mod_periodoAnalisi1_eh_doUpdate); if (!Page.IsPostBack) { // imposto filtro redattore chkRedattore.Checked = true; tacRedattore.valore = utils.obj.currUserNomeCognome; tacRedattore.label = utils.obj.currUserNomeCognome; tacRedattore.Visible = true; ddlPageSize.SelectedValue = pageSize.ToString(); saveFiltInSession(); displayResults(); } btnUpdate.Visible = !utils.obj.confReadBool("instantUpdate"); if (btnUpdate.Visible && btnUpdate.Enabled) { btnUpdate.Focus(); } } /// /// salvo ricerca redattore /// /// /// void tacRedattore_eh_valSelezionato(object sender, EventArgs e) { updateVisual(); } /// /// cambiato periodo /// /// /// void mod_periodoAnalisi1_eh_doUpdate(object sender, EventArgs e) { updateVisual(); } /// /// salvo ricerca fonte /// /// /// void tacFonti_eh_valSelezionato(object sender, EventArgs e) { updateVisual(); } /// /// salvo ricerca fase /// /// /// void tacFasi_eh_valSelezionato(object sender, EventArgs e) { updateVisual(); } /// /// salvo ricerca commessa /// /// /// void tacCommesse_eh_valSelezionato(object sender, EventArgs e) { updateVisual(); } /// /// modificato valore filtro InOut /// /// /// protected void rblInOut_SelectedIndexChanged(object sender, EventArgs e) { utils.obj.setSessionVal("srcInOut", rblInOut.SelectedValue); updateVisual(); } /// /// aggiorna tutti i valori visualizzati /// private void updateVisual() { // mostro button update btnUpdate.Enabled = true; saveFiltInSession(); // aggiorno label num records displayResults(); // verifico due condizioni x dare update: che NON ci siano valori in ricerca libera o che sia richiesto in webconfig... if (utils.obj.confReadBool("instantUpdate") || txtSearchAll.Text.Trim() == "") { raiseUpdate(); } } /// /// mostra num risultati ricerca /// private void displayResults() { DateTime inizio = Convert.ToDateTime(utils.obj.StringSessionObj("_inizio")); DateTime fine = Convert.ToDateTime(utils.obj.StringSessionObj("_fine")); string commessa = utils.emptyToStar(utils.obj.StringSessionObj("srcCommessa")); string fase = utils.emptyToStar(utils.obj.StringSessionObj("srcFase")); string fonte = utils.emptyToStar(utils.obj.StringSessionObj("srcFonte")); string InOut = utils.emptyToStar(utils.obj.StringSessionObj("srcInOut")); string redattore = utils.emptyToStar(utils.obj.StringSessionObj("srcRedattore")); string ricercaLibera = utils.emptyToStar(txtSearchAll.Text.Trim()); // ricerca! lblTotRec.Text = utils.obj.taDoc.getBySearch_Count_only(inizio, fine, WebShipUtils.mng.userCanSeeRed, commessa, fase, fonte, InOut, redattore, ricercaLibera).ToString(); } /// /// salvo la ricerca libera... /// /// /// protected void txtSearchAll_TextChanged(object sender, EventArgs e) { updateVisual(); } /// /// imposto visibilità campo ricerca da selezione check /// /// /// protected void chkCommessa_CheckedChanged(object sender, EventArgs e) { if (chkCommessa.Checked) { tacCommesse.contextKey = string.Format("{0}#{1}", utils.obj.StringSessionObj("_inizio"), utils.obj.StringSessionObj("_fine")); chkCommessa.Text = "Elim. Comm."; tacCommesse.setFocus(); } else { chkCommessa.Text = "Filtra Commessa"; } tacCommesse.Visible = chkCommessa.Checked; updateVisual(); } /// /// imposto visibilità campo ricerca da selezione check /// /// /// protected void chkFase_CheckedChanged(object sender, EventArgs e) { if (chkFase.Checked) { tacFasi.contextKey = string.Format("{0}#{1}", utils.obj.StringSessionObj("_inizio"), utils.obj.StringSessionObj("_fine")); chkFase.Text = "Elim. Fase"; tacFasi.setFocus(); } else { chkFase.Text = "Filtra Fase"; } tacFasi.Visible = chkFase.Checked; updateVisual(); } /// /// imposto visibilità campo ricerca da selezione check /// /// /// protected void chkFonte_CheckedChanged(object sender, EventArgs e) { if (chkFonte.Checked) { tacFonti.contextKey = string.Format("{0}#{1}", utils.obj.StringSessionObj("_inizio"), utils.obj.StringSessionObj("_fine")); chkFonte.Text = "Elim. Da/A"; tacFonti.setFocus(); } else { chkFonte.Text = "Filtra Da/A"; } tacFonti.Visible = chkFonte.Checked; updateVisual(); } /// /// imposto visibilità campo ricerca da selezione check /// /// /// protected void chkInOut_CheckedChanged(object sender, EventArgs e) { if (chkInOut.Checked) { chkInOut.Text = "Elim. In/Out"; } else { chkInOut.Text = "Filtra In/Out"; } rblInOut.Visible = chkInOut.Checked; updateVisual(); } /// /// imposto visibilità campo ricerca da selezione check /// /// /// protected void chkRedattore_CheckedChanged(object sender, EventArgs e) { if (chkRedattore.Checked) { tacRedattore.contextKey = string.Format("{0}#{1}", utils.obj.StringSessionObj("_inizio"), utils.obj.StringSessionObj("_fine")); chkRedattore.Text = "Elim. Redattore"; tacRedattore.setFocus(); } else { chkRedattore.Text = "Filtra Redattore"; } tacRedattore.Visible = chkRedattore.Checked; updateVisual(); } /// /// selezionata nuova dim pagina /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { utils.obj.setSessionVal("srcPageSize", ddlPageSize.SelectedValue); if (eh_pageResize != null) { eh_pageResize(this, new EventArgs()); } } /// /// salva in sessione le richieste di filtraggio selezionate /// private void saveFiltInSession() { // salvo valori selezionati utils.obj.setSessionVal("srcSearchAll", txtSearchAll.Text.Trim()); if (chkCommessa.Checked) { utils.obj.setSessionVal("srcCommessa", tacCommesse.valore); } else { utils.obj.emptySessionVal("srcCommessa"); } if (chkFase.Checked) { utils.obj.setSessionVal("srcFase", tacFasi.valore); } else { utils.obj.emptySessionVal("srcFase"); } if (chkFonte.Checked) { utils.obj.setSessionVal("srcFonte", tacFonti.valore); } else { utils.obj.emptySessionVal("srcFonte"); } if (chkInOut.Checked) { utils.obj.setSessionVal("srcInOut", rblInOut.SelectedValue); } else { utils.obj.emptySessionVal("srcInOut"); } if (chkRedattore.Checked) { utils.obj.setSessionVal("srcRedattore", tacRedattore.valore); } else { utils.obj.emptySessionVal("srcRedattore"); } } /// /// richiede update valori /// /// /// protected void btnUpdate_Click(object sender, EventArgs e) { raiseUpdate(); } /// /// richiesta update moduli dipendenti /// private void raiseUpdate() { // salvo tutte le conf di visualizzazione saveFiltInSession(); // aggiorno tutto btnUpdate.Enabled = false; if (eh_reqSearch != null) { eh_reqSearch(this, new EventArgs()); } } } }