a953cbf7fd
git-svn-id: https://keyhammer.ath.cx/svn/XPS/trunk@83 43c8e981-f90d-406c-a89a-24a2c4268d51
376 lines
12 KiB
C#
376 lines
12 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Collections;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using SteamWare;
|
|
|
|
public partial class mod_ev2stati : ApplicationUserControl
|
|
{
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
protected bool _showNewBtn = true;
|
|
|
|
/// <summary>
|
|
/// imposta errore non cancellabilità per record correlati
|
|
/// </summary>
|
|
protected void setNoDeletableErrorMessage()
|
|
{
|
|
// mostro avviso di non cancellabilità...
|
|
lblWarning.Text = traduci("notDeletable_hasChild");
|
|
lblWarning.Visible = true;
|
|
grView.DataBind();
|
|
}
|
|
/// <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();
|
|
}
|
|
/// <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>
|
|
/// aggiorna controlli datagrid e numero righe in pagina
|
|
/// </summary>
|
|
protected override void aggiornaControlliDataGL()
|
|
{
|
|
base.aggiornaControlliDataGL();
|
|
grView.PageSize = _righeDataGridMed;
|
|
}
|
|
/// <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>
|
|
/// 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;
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// gestione evento richiesta 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();
|
|
}
|
|
/// <summary>
|
|
/// gestione cambio selezione valore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// salvo in session il valore selezionato...
|
|
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue);
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selValore != null)
|
|
{
|
|
eh_selValore(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#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
|
|
|
|
#region area codice variabile
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
DS_XPS.v_ev2statiDataTable tabella = new DS_XPS.v_ev2statiDataTable();
|
|
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 = "CodStato";
|
|
if (!Page.IsPostBack)
|
|
{
|
|
Mod_filtroTipoObjDest.ods = odsTipoObj;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// traduco labels
|
|
/// </summary>
|
|
protected override void traduciObj()
|
|
{
|
|
base.traduciObj();
|
|
btnShowClona.Text = traduci("btnShowClona");
|
|
btnClonaStati.Text = traduci("btnClonaStati");
|
|
}
|
|
void Mod_filtro1_eh_selValore(object sender, EventArgs e)
|
|
{
|
|
// ridisegno
|
|
}
|
|
/// <summary>
|
|
/// setta selected alla riga il cui valore key è in session
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// gestione evento inserimento nuovo record standard (se ZERO presenti)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNewFromEmpty_Click(object sender, EventArgs e)
|
|
{
|
|
// reset selezione...
|
|
resetSelezione();
|
|
DS_XPSTableAdapters.v_ev2statiTableAdapter taEv2Stato = new DS_XPSTableAdapters.v_ev2statiTableAdapter();
|
|
try
|
|
{
|
|
// creo 1 obj vuoto...
|
|
taEv2Stato.InsertQuery(memLayer.ML.StringSessionObj("CodMappa_sel"), "0", memLayer.ML.IntSessionObj("IdxTipoObj_sel"), memLayer.ML.StringSessionObj("CodEvento_sel"), "0");
|
|
grView.DataBind();
|
|
lblWarning.Visible = false;
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lblWarning.Visible = true;
|
|
lblWarning.Text = traduci("erroreSelEvStatiMappe");
|
|
SteamWare.logger.lg.scriviLog(string.Format("Errore inserimento novo valore da vuoto: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
|
|
/// <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;
|
|
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;
|
|
case "selAjax":
|
|
e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
tipoColonna = "";
|
|
}
|
|
e.InputParameters["CodMappa"] = memLayer.ML.StringSessionObj("CodMappa_sel");
|
|
e.InputParameters["IdxTipoObj"] = memLayer.ML.IntSessionObj("IdxTipoObj_sel");
|
|
e.InputParameters["CodEvento"] = memLayer.ML.StringSessionObj("CodEvento_sel");
|
|
}
|
|
/// <summary>
|
|
/// mostra pannello cloning
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnShowClona_Click(object sender, EventArgs e)
|
|
{
|
|
setClonaVisibility();
|
|
}
|
|
/// <summary>
|
|
/// imposta vilibilità pannello cloning e scritta pulsante...
|
|
/// </summary>
|
|
private void setClonaVisibility()
|
|
{
|
|
if (pnlClona.Visible)
|
|
{
|
|
btnShowClona.Text = traduci("btnShowClona");
|
|
lblWarning.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
btnShowClona.Text = traduci("btnHideClona");
|
|
}
|
|
pnlClona.Visible = !pnlClona.Visible;
|
|
}
|
|
/// <summary>
|
|
/// chiamo stored di cloning stati...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnClonaStati_Click(object sender, EventArgs e)
|
|
{
|
|
// verifico siano diverse le selezioni...
|
|
if (memLayer.ML.IntSessionObj("IdxTipoObj_sel") != Mod_filtroTipoObjDest.valoreInt)
|
|
{
|
|
try
|
|
{
|
|
DS_XPSTableAdapters.SP taSP = new DS_XPSTableAdapters.SP();
|
|
taSP.sp_clonaTransizEventi(memLayer.ML.StringSessionObj("CodMappa_sel"), memLayer.ML.StringSessionObj("CodEvento_sel"), memLayer.ML.IntSessionObj("IdxTipoObj_sel"), Mod_filtroTipoObjDest.valoreInt);
|
|
lblWarning.Visible = false;
|
|
// nascondo...
|
|
setClonaVisibility();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lblWarning.Visible = true;
|
|
lblWarning.Text = traduci("erroreSelDest");
|
|
SteamWare.logger.lg.scriviLog(string.Format("Errore cloning transizioni: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblWarning.Text = traduci("erroreSelDest");
|
|
lblWarning.Visible = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |