490 lines
13 KiB
C#
490 lines
13 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Data;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
public partial class mod_elencoRichieste : ApplicationUserControl
|
|
{
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
protected string _idxGridViewExt;
|
|
protected bool _showNewBtn = false;
|
|
|
|
|
|
/// <summary>
|
|
/// aggiorna controlli datagrid e numero righe in pagina
|
|
/// </summary>
|
|
protected override void aggiornaControlliDataGL()
|
|
{
|
|
base.aggiornaControlliDataGL();
|
|
}
|
|
/// <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();
|
|
}
|
|
/// <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, true);
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selValore != null)
|
|
{
|
|
eh_selValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
|
|
grView.SelectedIndex = -1;
|
|
grView.PageIndex = 0;
|
|
grView.DataBind();
|
|
lblWarning.Visible = false;
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(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()
|
|
{
|
|
fixBtnCheck();
|
|
checkFixOds();
|
|
resetSelezione();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region area codice variabile
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
GIM_dataLayer.DS_applicazione.v_intervExpDataTable tabella = new GIM_dataLayer.DS_applicazione.v_intervExpDataTable();
|
|
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);
|
|
if (!Page.IsPostBack)
|
|
{
|
|
doUpdate();
|
|
}
|
|
_idxGridView = "numIntMtz";
|
|
hfValoreCercato.Value = memLayer.ML.StringSessionObj("valoreCercato");
|
|
((GIM_site.FullPage)this.Page.Master).eh_Search_Submit += Mod_magRic_eh_Search_Submit;
|
|
}
|
|
|
|
private void Mod_magRic_eh_Search_Submit(object sender, EventArgs e)
|
|
{
|
|
hfValoreCercato.Value = memLayer.ML.StringSessionObj("valoreCercato");
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
// se riga di dati...
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
// ottengo la riga tipizzata...
|
|
System.Data.DataRowView _drv = (System.Data.DataRowView)e.Row.DataItem;
|
|
GIM_dataLayer.DS_applicazione.v_intervExpRow riga = (GIM_dataLayer.DS_applicazione.v_intervExpRow)_drv.Row;
|
|
if (SteamWare.memLayer.ML.StringSessionObj(_idxGridView) == riga.numIntMtz.ToString())
|
|
{
|
|
grView.SelectedIndex = e.Row.RowIndex;
|
|
// salvo in session il valore selezionato...
|
|
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), SteamWare.memLayer.ML.StringSessionObj(_idxGridView));
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selValore != null)
|
|
{
|
|
eh_selValore(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// formatta il tooltip del ferma dalle...
|
|
/// </summary>
|
|
/// <param name="dataOraFermo"></param>
|
|
/// <returns></returns>
|
|
public string formatFermaDalle(object dataOraFermo)
|
|
{
|
|
return string.Format("{0}: {1:dd/MM/yy HH:mm}", traduci("inizioFermata"), dataOraFermo);
|
|
}
|
|
/// <summary>
|
|
/// restituice lo stile css dato lo stato dell'intervento
|
|
/// </summary>
|
|
/// <param name="idxStato"></param>
|
|
/// <returns></returns>
|
|
public string stileDaStato(object idxStato)
|
|
{
|
|
string answ = "semaforoRosso";
|
|
try
|
|
{
|
|
answ = TA_app.obj.taStati.getByIdxStato(Convert.ToInt32(idxStato))[0].stile;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituice lo stile css data la priorità dell'intervento
|
|
/// </summary>
|
|
/// <param name="idxStato"></param>
|
|
/// <returns></returns>
|
|
public string stileDaPrior(object idxPrior)
|
|
{
|
|
string answ = "semaforoRosso";
|
|
try
|
|
{
|
|
answ = TA_app.obj.taPrior.getByIdxPriorita(Convert.ToInt32(idxPrior))[0].stile;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce un testo trimamto a maxChar caratteri
|
|
/// </summary>
|
|
/// <param name="testo"></param>
|
|
/// <param name="maxChar"></param>
|
|
/// <returns></returns>
|
|
public string trimmaTesto(object _testo, object _maxChar)
|
|
{
|
|
string answ = "";
|
|
string testo = _testo.ToString();
|
|
int maxChar = Convert.ToInt32(_maxChar);
|
|
if (testo.Length <= maxChar)
|
|
{
|
|
answ = testo;
|
|
}
|
|
else
|
|
{
|
|
answ = string.Format("{0}...", testo.Substring(0, maxChar));
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce url contenente parametri per rendering pdf
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string formattaUrl(object idx)
|
|
{
|
|
return String.Format(memLayer.ML.confReadString("exportFormat2"), Convert.ToInt32(reportRichiesto.RichiestaIntervento), idx);
|
|
}
|
|
/// <summary>
|
|
/// prende in carico e stampa la scheda selezionata
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrendeInCarico_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
ImageButton imgBtn = (ImageButton)sender;
|
|
int idx = Convert.ToInt32(imgBtn.CommandArgument);
|
|
// loggo
|
|
logger.lg.scriviLog(string.Format("Richiesta presa in carico richiesta num {0}", idx), tipoLog.INFO);
|
|
// prende in carico la scheda...
|
|
try
|
|
{
|
|
int? newStato = 0;
|
|
TA_app.obj.taInterventiMtz.sp_setPresaInCarico(Convert.ToInt32(idx), ref newStato);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore durante presa in carico: {0}{1}", Environment.NewLine, exc), tipoLog.ERROR);
|
|
}
|
|
// SSE richiesta stampa...
|
|
if (memLayer.ML.CRB("doPrintReq"))
|
|
{
|
|
try
|
|
{
|
|
// stampo!
|
|
reportPrinter.obj.printReport(reportRichiesto.RichiestaIntervento, memLayer.ML.confReadString("stampanteRichiesteMtz"), idx.ToString());
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore durante stampa richiesta mtz num{0}: {1}{2}", idx, Environment.NewLine, exc), tipoLog.ERROR);
|
|
}
|
|
}
|
|
// update del gridView...
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// restituisce true se è una richeista solo inserita e non ancora presa in carico
|
|
/// </summary>
|
|
/// <param name="num"></param>
|
|
/// <returns></returns>
|
|
public bool isPrInCarEnabl(object num)
|
|
{
|
|
bool answ = false;
|
|
// se l'utente è BASE la presa in carico NON è permessa...
|
|
if (user_std.UtSn.diritti.Select("COD_FUNZIONE = 'GIM_SU'").Length > 0)
|
|
{
|
|
try
|
|
{
|
|
int idxStato = TA_app.obj.taInterventiMtz.getByIdx(Convert.ToInt32(num))[0].idxStato;
|
|
if (idxStato == 1)
|
|
{
|
|
answ = true;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// esegue traduzioni labels
|
|
/// </summary>
|
|
protected override void traduciObj()
|
|
{
|
|
base.traduciObj();
|
|
chkMostraIntChiusi.Text = traduci("chkMostraIntChiusi_mostra");
|
|
}
|
|
/// <summary>
|
|
/// cambia filtraggio...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void chkMostraIntChiusi_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
fixBtnCheck();
|
|
resetSelezione();
|
|
}
|
|
|
|
private void fixBtnCheck()
|
|
{
|
|
if (chkMostraIntChiusi.Checked == false)
|
|
{
|
|
chkMostraIntChiusi.Text = traduci("chkMostraIntChiusi_mostra");
|
|
}
|
|
else
|
|
{
|
|
chkMostraIntChiusi.Text = traduci("chkMostraIntChiusi_nascondi");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// sistemo filtraggio con valori selezionati
|
|
/// </summary>
|
|
private void checkFixOds()
|
|
{
|
|
// parto resettando filtro...
|
|
ods.FilterExpression = "";
|
|
// controllo SE il ddl indica TUTTI gli interventi, solo Mtz Prog o Mtz Prog Esclusa
|
|
switch (ddlFiltAmbito.SelectedValue)
|
|
{
|
|
case "MtzPre":
|
|
addToOdsFilter("(idxAmbito = 7)");
|
|
break;
|
|
case "NoMtzPre":
|
|
addToOdsFilter("(idxAmbito <> 7)");
|
|
break;
|
|
case "All":
|
|
default:
|
|
break;
|
|
}
|
|
if (!chkMostraIntChiusi.Checked)
|
|
{
|
|
addToOdsFilter("(idxStato < 3)");
|
|
}
|
|
|
|
if (memLayer.ML.isInSessionObject("idxTipo_filt"))
|
|
{
|
|
addToOdsFilter("(idxTipo = {0})");
|
|
}
|
|
if (memLayer.ML.isInSessionObject("idxImpianto_filt"))
|
|
{
|
|
addToOdsFilter("(idxImpianto = {1})");
|
|
}
|
|
if (memLayer.ML.isInSessionObject("idxMacchina_filt"))
|
|
{
|
|
addToOdsFilter("(idxMacchina = {2})");
|
|
}
|
|
// controllo se sta selezionando una CATENA di int mtz prg
|
|
if (memLayer.ML.QSS("idxIntPro") != "")
|
|
{
|
|
// se è un numero...
|
|
int idxIntPro = 0;
|
|
try
|
|
{
|
|
idxIntPro = Convert.ToInt32(memLayer.ML.QSS("idxIntPro"));
|
|
if (idxIntPro > 0)
|
|
{
|
|
ddlFiltAmbito.SelectedIndex = 1;
|
|
// aggiungo codice idxIntPro
|
|
addToOdsFilter(string.Format("(idxIntPro = {0})", memLayer.ML.QSS("idxIntPro")));
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
|
|
// bind dati!
|
|
ods.DataBind();
|
|
}
|
|
|
|
protected void addToOdsFilter(string expression)
|
|
{
|
|
if (ods.FilterExpression != "")
|
|
{
|
|
|
|
ods.FilterExpression += " AND ";
|
|
}
|
|
ods.FilterExpression += expression;
|
|
}
|
|
/// <summary>
|
|
/// fix l'ods...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_PageIndexChanged(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
}
|
|
/// <summary>
|
|
/// determina se sia o meno un intervento dell'ambito richiesto
|
|
/// </summary>
|
|
/// <param name="_idxAmbitoGuasto">valore ambito corrente</param>
|
|
/// <param name="_tipoAmbito">idxAmbitoMtzProg/idxAmbitoRicambi</param>
|
|
/// <returns></returns>
|
|
public bool checkAmbito(object _idxAmbitoGuasto, object _tipoAmbito)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
// verifico ambito...
|
|
if (_idxAmbitoGuasto.ToString() == memLayer.ML.CRS(_tipoAmbito.ToString())) answ = true;
|
|
//int idxAmbito = Convert.ToInt32(_idxAmbitoGuasto);
|
|
//if (idxAmbito == memLayer.ML.CRI(_tipoAmbito.ToString())) answ = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void ddlFiltAmbito_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
resetSelezione();
|
|
}
|
|
|
|
protected void grView_Sorted(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
resetSelezione();
|
|
}
|
|
}
|