352 lines
12 KiB
C#
352 lines
12 KiB
C#
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();
|
|
/// <summary>
|
|
/// evento richiesta salvataggio files
|
|
/// </summary>
|
|
public event EventHandler eh_reqSearch;
|
|
/// <summary>
|
|
/// evento richiesta update page size
|
|
/// </summary>
|
|
public event EventHandler eh_pageResize;
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo ricerca redattore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void tacRedattore_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// cambiato periodo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_periodoAnalisi1_eh_doUpdate(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// salvo ricerca fonte
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void tacFonti_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// salvo ricerca fase
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void tacFasi_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// salvo ricerca commessa
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void tacCommesse_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// modificato valore filtro InOut
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void rblInOut_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
utils.obj.setSessionVal("srcInOut", rblInOut.SelectedValue);
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// aggiorna tutti i valori visualizzati
|
|
/// </summary>
|
|
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();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mostra num risultati ricerca
|
|
/// </summary>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo la ricerca libera...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtSearchAll_TextChanged(object sender, EventArgs e)
|
|
{
|
|
updateVisual();
|
|
}
|
|
/// <summary>
|
|
/// imposto visibilità campo ricerca da selezione check
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// imposto visibilità campo ricerca da selezione check
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// imposto visibilità campo ricerca da selezione check
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// imposto visibilità campo ricerca da selezione check
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// imposto visibilità campo ricerca da selezione check
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// selezionata nuova dim pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
utils.obj.setSessionVal("srcPageSize", ddlPageSize.SelectedValue);
|
|
if (eh_pageResize != null)
|
|
{
|
|
eh_pageResize(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salva in sessione le richieste di filtraggio selezionate
|
|
/// </summary>
|
|
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");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// richiede update valori
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
raiseUpdate();
|
|
}
|
|
/// <summary>
|
|
/// richiesta update moduli dipendenti
|
|
/// </summary>
|
|
private void raiseUpdate()
|
|
{
|
|
// salvo tutte le conf di visualizzazione
|
|
saveFiltInSession();
|
|
// aggiorno tutto
|
|
btnUpdate.Enabled = false;
|
|
if (eh_reqSearch != null)
|
|
{
|
|
eh_reqSearch(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
} |