175 lines
4.7 KiB
C#
175 lines
4.7 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
public partial class mod_ricercaGenerica : ApplicationUserControl
|
|
{
|
|
|
|
#region gestione eventi
|
|
|
|
public event EventHandler eh_nuovaRicerca;
|
|
|
|
#endregion
|
|
|
|
# region area protected
|
|
|
|
#region area ricerche dettaglio specifiche
|
|
|
|
protected bool _cercaMatricole = false;
|
|
protected bool _cercaUsername = false;
|
|
//protected bool _cercaManufacturer = false;
|
|
//protected bool _cercaCategorie = false;
|
|
protected bool _cercaModelli = false;
|
|
protected bool _cercaMag = false;
|
|
|
|
#endregion
|
|
|
|
protected override void Page_Load(object sender, EventArgs e)
|
|
{
|
|
base.Page_Load(sender, e);
|
|
updateText();
|
|
btnCerca.Text = traduci("lblCerca");
|
|
}
|
|
/// <summary>
|
|
/// cambiato valore in ricerca
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtCerca_TextChanged(object sender, EventArgs e)
|
|
{
|
|
salvaCerca();
|
|
}
|
|
/// <summary>
|
|
/// pressione del button di ricerca
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCerca_Click(object sender, EventArgs e)
|
|
{
|
|
salvaCerca();
|
|
}
|
|
/// <summary>
|
|
/// testo ricerca trimmato da spazi
|
|
/// </summary>
|
|
protected string testoRicerca
|
|
{
|
|
get
|
|
{
|
|
return txtCerca.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtCerca.Text = value;
|
|
}
|
|
}
|
|
|
|
protected void salvaCerca()
|
|
{
|
|
if (testoRicerca == "")
|
|
{
|
|
SteamWare.memLayer.ML.emptySessionVal("valoreCercato");
|
|
SteamWare.memLayer.ML.emptySessionVal("listaMatricoleSearch");
|
|
}
|
|
else
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("valoreCercato", testoRicerca);
|
|
// verifico ricerche accessorie
|
|
if (_cercaMatricole)
|
|
{
|
|
salvaCercaMatricole();
|
|
}
|
|
if (_cercaUsername)
|
|
{
|
|
salvaCercaUsername();
|
|
}
|
|
// raise dell'evento
|
|
if (eh_nuovaRicerca != null)
|
|
{
|
|
eh_nuovaRicerca(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ricerca utenti e salva lista matricole x SQL IN
|
|
/// </summary>
|
|
protected void salvaCercaMatricole()
|
|
{
|
|
// salvo anche l'elenco delle matricole compatibili...
|
|
DataLayer_AnagGen.UTENTEDataTable righeUtenti = DataWrap.DW.taUtente.getByRicercaNomeCognome(testoRicerca);
|
|
string listaMatricoleSearch = "";
|
|
foreach (DataLayer_AnagGen.UTENTERow riga in righeUtenti)
|
|
{
|
|
listaMatricoleSearch += string.Format("'{0}', ", riga.MATRICOLA);
|
|
}
|
|
if (listaMatricoleSearch.Length > 0)
|
|
{
|
|
listaMatricoleSearch = listaMatricoleSearch.Remove(listaMatricoleSearch.Length - 2);
|
|
}
|
|
SteamWare.memLayer.ML.setSessionVal("listaMatricoleSearch", listaMatricoleSearch);
|
|
}
|
|
/// <summary>
|
|
/// ricerca utenti e salva lista username x SQL IN
|
|
/// </summary>
|
|
protected void salvaCercaUsername()
|
|
{
|
|
// salvo anche l'elenco delle matricole compatibili...
|
|
DataLayer_AnagGen.UTENTEDataTable righeUtenti = DataWrap.DW.taUtente.getByRicercaNomeCognome(testoRicerca);
|
|
string listaUsernameSearch = "";
|
|
foreach (DataLayer_AnagGen.UTENTERow riga in righeUtenti)
|
|
{
|
|
listaUsernameSearch += string.Format("'{0}', ", riga.USER_NAME);
|
|
}
|
|
if (listaUsernameSearch.Length > 0)
|
|
{
|
|
listaUsernameSearch = listaUsernameSearch.Remove(listaUsernameSearch.Length - 2);
|
|
}
|
|
SteamWare.memLayer.ML.setSessionVal("listaUsernameSearch", listaUsernameSearch);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
/// <summary>
|
|
/// aggiorna il testo cercato
|
|
/// </summary>
|
|
public void updateText()
|
|
{
|
|
if (SteamWare.memLayer.ML.StringSessionObj("valoreCercato") != "" && !Page.IsPostBack)
|
|
{
|
|
testoRicerca = SteamWare.memLayer.ML.StringSessionObj("valoreCercato");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// indica se generare da stringa search un elenco delle matricole corrispondenti
|
|
/// </summary>
|
|
public bool cercaMatricole
|
|
{
|
|
get
|
|
{
|
|
return _cercaMatricole;
|
|
}
|
|
set
|
|
{
|
|
_cercaMatricole = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica se generare da stringa search un elenco di username corrispondenti
|
|
/// </summary>
|
|
public bool cercaUsername
|
|
{
|
|
get
|
|
{
|
|
return _cercaUsername;
|
|
}
|
|
set
|
|
{
|
|
_cercaUsername = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|