487 lines
17 KiB
C#
487 lines
17 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using GMW_data;
|
|
|
|
namespace GMW_Term.WebUserControls
|
|
{
|
|
public partial class mod_searchResults : System.Web.UI.UserControl
|
|
{
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
protected string _idxGridViewExt;
|
|
protected string _tabCache;
|
|
protected bool _showNewBtn = false;
|
|
|
|
/// <summary>
|
|
/// wrapper traduzione termini
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
|
|
/// <summary>
|
|
/// recupera i dati di un nuovo record contenuti nel footer di un gridView;
|
|
/// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
//recupero la riga footer...
|
|
DataColumnCollection colonne = colonneObj();
|
|
string nomeCol;
|
|
string tipoColonna = "";
|
|
foreach (DataColumn colonna in colonne)
|
|
{
|
|
nomeCol = colonna.ColumnName;
|
|
// cerco un textbox o quello che sia...
|
|
if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "textBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "dropDownList";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "checkBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "selAjax";
|
|
}
|
|
// in base al tipo salvo negli inputparameters dell'ODS
|
|
switch (tipoColonna)
|
|
{
|
|
case "textBox":
|
|
e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text.Trim();
|
|
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;
|
|
}
|
|
tipoColonna = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// inserisce nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblIns_click(object sender, EventArgs e)
|
|
{
|
|
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
|
|
ods.Insert();
|
|
SteamWare.memLayer.ML.emptyCacheVal(_tabCache);
|
|
}
|
|
/// <summary>
|
|
/// annulla inserimento nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblCanc_click(object sender, EventArgs e)
|
|
{
|
|
// annullo inserimento: nascondo footer, bind controlli...
|
|
grView.FooterRow.Visible = false;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
LinkButton lb;
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
lb = (LinkButton)cella.Controls[0];
|
|
lb.Text = traduci(lb.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1);
|
|
//lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord);
|
|
}
|
|
else
|
|
{
|
|
//lblNumRec.Text = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// gestione evento richeista nuovo valore (mostra footer, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
// reset selezione...
|
|
resetSelezione();
|
|
// mostro il footer oppure la riga dei dettagli x nuovo...
|
|
if (grView.FooterRow != null)
|
|
{
|
|
grView.FooterRow.Visible = true;
|
|
}
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gestione eventi
|
|
|
|
//public event EventHandler eh_resetSelezione;
|
|
public event EventHandler eh_nuovoValore;
|
|
//public event EventHandler eh_selValore;
|
|
|
|
#endregion
|
|
|
|
#region public
|
|
|
|
/// <summary>
|
|
/// definisce visibilità btnNew
|
|
/// </summary>
|
|
public bool showNewBtn
|
|
{
|
|
get
|
|
{
|
|
return _showNewBtn;
|
|
}
|
|
set
|
|
{
|
|
_showNewBtn = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua update del modulo
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// metodi al caricamento della pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
#if false
|
|
// controllo se ci sia richiesta x mostrare dettagli...
|
|
if (memLayer.ML.BoolSessionObj("showDetListaPre"))
|
|
{
|
|
memLayer.ML.emptySessionVal("showDetListaPre");
|
|
showListDetails(memLayer.ML.StringSessionObj("CodListaAttiva"));
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
GMW_data.DS_Utility.stp_ricercaFullTerminalinoDataTable tabella = new GMW_data.DS_Utility.stp_ricercaFullTerminalinoDataTable();
|
|
DataColumnCollection colonne = tabella.Columns;
|
|
return colonne;
|
|
}
|
|
/// <summary>
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_idxGridView = "TipoSearch";
|
|
|
|
aggiornaControlliDataGL();
|
|
}
|
|
/// <summary>
|
|
/// aggiorna controlli datagrid e numero righe in pagina
|
|
/// </summary>
|
|
protected void aggiornaControlliDataGL()
|
|
{
|
|
grView.PageSize = 3;
|
|
}
|
|
|
|
/// <summary>
|
|
/// gestione cambio selezione valore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
//lblWarning.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo in session che il prox comando è iniziare lista prelievo...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgAzioneLista_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
ImageButton imgb = (ImageButton)sender;
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", imgb.CommandArgument);
|
|
}
|
|
/// <summary>
|
|
/// in caso di aggiornamento verifico se sia salvato un comando inizia o completa lista prelievo...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
|
{
|
|
// carico l'idx dell'oggetto
|
|
string tipo = e.Keys["tipo"].ToString();
|
|
string valore = e.Keys["valore"].ToString();
|
|
// quale comando?
|
|
string _comando = "";
|
|
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
|
|
{
|
|
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
|
|
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
|
|
}
|
|
string CodSoggetto = MagClass.magazzino.CodSoggCurrUser;
|
|
switch (_comando)
|
|
{
|
|
case "UDC":
|
|
// salvo in sessione
|
|
memLayer.ML.setSessionVal("UDC_sel", valore);
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
// faccio redirect
|
|
Response.Redirect("~/UDC.aspx");
|
|
break;
|
|
case "Particolare":
|
|
// salvo in sessione
|
|
memLayer.ML.setSessionVal("Particolare_sel", valore);
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
// faccio redirect
|
|
Response.Redirect("~/Particolare.aspx");
|
|
break;
|
|
case "Cella":
|
|
// salvo in sessione
|
|
memLayer.ML.setSessionVal("IdxCella_sel", valore);
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
// faccio redirect
|
|
Response.Redirect("~/Cella.aspx");
|
|
break;
|
|
default:
|
|
// faccio update!
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// chiamato post modifica valore check/selezione nel selettore filtro stato
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void eh_selectedStato(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
}
|
|
/// <summary>
|
|
/// ssitema visualizzazione dal filtraggi
|
|
/// </summary>
|
|
private void checkFixOds()
|
|
{
|
|
// chiamo procedura che aggiorna ods principale
|
|
grView.SelectedIndex = -1;
|
|
updateOds();
|
|
}
|
|
/// <summary>
|
|
/// aggiorno il gridview
|
|
/// </summary>
|
|
protected void updateOds()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// chiamato post modifica valore check/selezione nel selettore filtro tipo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void eh_selectedTipo(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce URL immagine del codice da mostrare x TIPO lista
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public string pathImgTipo(object codice)
|
|
{
|
|
string answ = "";
|
|
string tipo = codice.ToString();
|
|
switch (tipo)
|
|
{
|
|
case "UDC":
|
|
answ = string.Format("~/images/Udc.jpg", codice);
|
|
break;
|
|
case "Particolare":
|
|
answ = string.Format("~/images/Part.jpg", codice);
|
|
break;
|
|
case "Cella":
|
|
answ = string.Format("~/images/Cella.jpg", codice);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce tooltip da mostrare x TIPO lista
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public string tooltipTipo(object codice)
|
|
{
|
|
return traduci(codice.ToString());
|
|
}
|
|
/// <summary>
|
|
/// wrapper per log con salvataggio dell'IP del chiamante
|
|
/// </summary>
|
|
/// <param name="_testoPre"></param>
|
|
/// <returns></returns>
|
|
public bool httpLog(string _testoPre)
|
|
{
|
|
bool answ = false;
|
|
string postazione_IP = "";
|
|
try
|
|
{
|
|
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
|
|
}
|
|
catch
|
|
{ }
|
|
logger.lg.scriviLog(postazione_IP + _testoPre);
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// wrapper per log con salvataggio dell'IP del chiamante
|
|
/// </summary>
|
|
/// <param name="_testoPre"></param>
|
|
/// <returns></returns>
|
|
public bool httpLog(string testoLog, tipoLog tipo)
|
|
{
|
|
bool answ = false;
|
|
string postazione_IP = "";
|
|
try
|
|
{
|
|
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
|
|
}
|
|
catch
|
|
{ }
|
|
logger.lg.scriviLog(postazione_IP + testoLog, tipo);
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// formatta una stringa di descrizione a aprtire dal tipo oggetto
|
|
/// </summary>
|
|
/// <param name="_tipo"></param>
|
|
/// <param name="_valore"></param>
|
|
/// <returns></returns>
|
|
public string descOggetto(object _tipo, object _valore)
|
|
{
|
|
string tipo = _tipo.ToString();
|
|
string valore = _valore.ToString();
|
|
string answ = "";
|
|
switch (tipo)
|
|
{
|
|
case "UDC":
|
|
try
|
|
{
|
|
DS_magazzino.v_UdcDetailRow rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(valore, memLayer.ML.StringSessionObj("CodCS"))[0];
|
|
answ = string.Format("<b>{0}</b> {1:##} pz M:{2} C:{3}", rigaUdc.Particolare, rigaUdc.Qta, rigaUdc.CodMag, rigaUdc.CodCella);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
httpLog(string.Format("Eccezione {0}", e), tipoLog.EXCEPTION);
|
|
answ = string.Format("{0} - {1}", tipo, valore);
|
|
}
|
|
break;
|
|
case "Particolare":
|
|
try
|
|
{
|
|
DS_magazzino.V_ParticolariOverviewRow rigaPart = MagClass.magazzino.taVParticolariOverwiew.getByParticolareFull(valore, memLayer.ML.StringSessionObj("CodCS"))[0];
|
|
answ = string.Format("UDC: <b>{0}</b> (<b>{2}</b> a mag.) - <b>{1:##}</b> pz", rigaPart.NumUDC, rigaPart.TotQta, rigaPart.NumInMag);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
httpLog(string.Format("Eccezione {0}", e), tipoLog.EXCEPTION);
|
|
answ = string.Format("{0} - {1}", tipo, valore);
|
|
}
|
|
break;
|
|
case "Cella":
|
|
try
|
|
{
|
|
DS_magazzino.V_statoCelleCapienzaAssegnatiRow rigaCelle = MagClass.magazzino.taStatoCelle.getByIdxCella(Convert.ToInt32(valore))[0];
|
|
answ = string.Format("{0} / {1}", rigaCelle.UdcAssegnati, rigaCelle.Capienza);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
httpLog(string.Format("Eccezione {0}", e), tipoLog.EXCEPTION);
|
|
answ = string.Format("{0} - {1}", tipo, valore);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
}
|
|
} |