353 lines
8.7 KiB
C#
353 lines
8.7 KiB
C#
using System;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace SteamWare
|
|
{
|
|
/// <summary>
|
|
/// Base class for every user control in the application, containing some common
|
|
/// behaviour and utility methods.
|
|
/// It is not meant to be be used directly.
|
|
/// </summary>
|
|
public class UserControl : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// UID formattato con "_"
|
|
/// </summary>
|
|
public string uid
|
|
{
|
|
get
|
|
{
|
|
return this.UniqueID.Replace("$", "_").Replace("-", "_");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// event handler generico
|
|
/// </summary>
|
|
public event EventHandler eh_ucev;
|
|
/// <summary>
|
|
/// sollevo evento selezione
|
|
/// </summary>
|
|
protected void raiseEvent(ucEvType evType)
|
|
{
|
|
// sollevo evento nuovo valore...
|
|
if (eh_ucev != null)
|
|
{
|
|
ucEvent evento = new ucEvent(evType);
|
|
eh_ucev(this, evento);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
string answ = "";
|
|
if (lemma != null)
|
|
{
|
|
if (lemma.ToString() != "")
|
|
{
|
|
answ = user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
answ = "--";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// modalità operativa controllo
|
|
/// </summary>
|
|
public ucMode modoContr { get; set; }
|
|
|
|
/// <summary>
|
|
/// escape dei parametri input dell'ODS
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
public static void escapeInputParam(ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
// escape GENERALE!!!
|
|
for (int i = 0; i < e.InputParameters.Count; i++)
|
|
{
|
|
try
|
|
{
|
|
e.InputParameters[i] = e.InputParameters[i].ToString().Replace("'", "''");
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica se i caratteri vadano forzati a maiuscoli
|
|
/// </summary>
|
|
public bool forceUppercase
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = memLayer.ML.CRB("forceUppercase");
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// determina se l'utente sia abilitato a scrivere nella pagina corrente (quindi modificare e cancellare...)
|
|
/// </summary>
|
|
public bool isWriteEnabled
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = devicesAuthProxy.stObj.isPageWriteEnabled(titolo);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore isWriteEnabled{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// determina se l'utente sia abilitato alla pagina corrente (di base visualizzazione...)
|
|
/// </summary>
|
|
public bool isPageEnabled
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.stObj.isPageEnabled(titolo);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// titolo pagina
|
|
/// </summary>
|
|
public string titolo
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// evento standard agganciabile da grView x aggiunta doppio click e singolo click (x edit e select)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected virtual void grView_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
GridView grView = (GridView)sender;
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
// single click --> edit
|
|
e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(grView, "Edit$" + e.Row.RowIndex);
|
|
e.Row.Attributes["style"] = "cursor:pointer";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// evento andata in editing del controllo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected virtual void grView_RowEditing(object sender, GridViewEditEventArgs e)
|
|
{
|
|
GridView grView = (GridView)sender;
|
|
if (grView.EditIndex >= 0)
|
|
{
|
|
grView.UpdateRow(grView.EditIndex, false);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
|
|
/// </summary>
|
|
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
|
|
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
|
|
/// <returns></returns>
|
|
public string imgPath(tipoImg _tipo, dimImg _dimensione)
|
|
{
|
|
return imgPath(_tipo, _dimensione, tipoFileImg.png);
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
|
|
/// </summary>
|
|
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
|
|
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
|
|
/// <param name="_tipoFile">tipo del file richiesto..."</param>
|
|
/// <returns></returns>
|
|
public string imgPath(tipoImg _tipo, dimImg _dimensione, tipoFileImg _tipoFile)
|
|
{
|
|
string _imgName = "unknown";
|
|
string _imgDim = "_s";
|
|
string _imgType = "png";
|
|
switch (_tipo)
|
|
{
|
|
case tipoImg.annulla:
|
|
_imgName = "cancel";
|
|
break;
|
|
case tipoImg.approva:
|
|
_imgName = "approva";
|
|
break;
|
|
case tipoImg.barcode:
|
|
_imgName = "barcode_white";
|
|
break;
|
|
case tipoImg.barcodeArancio:
|
|
_imgName = "barcode_orange";
|
|
break;
|
|
case tipoImg.clona:
|
|
_imgName = "clonaObj";
|
|
break;
|
|
case tipoImg.conferma:
|
|
_imgName = "apply";
|
|
break;
|
|
case tipoImg.elimina:
|
|
_imgName = "elimina";
|
|
break;
|
|
case tipoImg.modifica:
|
|
_imgName = "edit";
|
|
break;
|
|
case tipoImg.notepad:
|
|
_imgName = "notepad";
|
|
break;
|
|
case tipoImg.notepadPdf:
|
|
_imgName = "notepadPdf";
|
|
break;
|
|
case tipoImg.nuovo:
|
|
_imgName = "new";
|
|
break;
|
|
case tipoImg.seleziona:
|
|
_imgName = "view";
|
|
break;
|
|
case tipoImg.semaforoGiallo:
|
|
_imgName = "semaGiallo";
|
|
break;
|
|
case tipoImg.semaforoRosso:
|
|
_imgName = "semaRosso";
|
|
break;
|
|
case tipoImg.semaforoVerde:
|
|
_imgName = "semaVerde";
|
|
break;
|
|
case tipoImg.stampa:
|
|
_imgName = "print";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
switch (_dimensione)
|
|
{
|
|
case dimImg.small:
|
|
_imgDim = "_s";
|
|
break;
|
|
case dimImg.medium:
|
|
_imgDim = "_m";
|
|
break;
|
|
case dimImg.large:
|
|
_imgDim = "_l";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
switch (_tipoFile)
|
|
{
|
|
case tipoFileImg.gif:
|
|
_imgType = "gif";
|
|
break;
|
|
case tipoFileImg.jpg:
|
|
_imgType = "jpg";
|
|
break;
|
|
case tipoFileImg.png:
|
|
_imgType = "png";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return string.Format("~/images/{0}{1}.{2}", _imgName, _imgDim, _imgType);
|
|
}
|
|
/// <summary>
|
|
/// Classe help email x SteamWare.UserControl
|
|
/// </summary>
|
|
public class email
|
|
{
|
|
/// <summary>
|
|
/// Email dell'account admin applicativo
|
|
/// </summary>
|
|
public static string adminEmail
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRS("_adminEmail");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Email dell'account sender applicativo
|
|
/// </summary>
|
|
public static string senderEmail
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRS("_fromEmail");
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero Righe standard
|
|
/// </summary>
|
|
public int righeDataGrid
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("_righeDataGrid");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero Righe standard ANAGR
|
|
/// </summary>
|
|
public int righeDataGridAnagr
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("_righeDataGridAnagr");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero Righe standard LONG
|
|
/// </summary>
|
|
public int righeDataGridLong
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("_righeDataGridLong");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero Righe standard MED
|
|
/// </summary>
|
|
public int righeDataGridMed
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("_righeDataGridMed");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero Righe standard SHORT
|
|
/// </summary>
|
|
public int righeDataGridShort
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("_righeDataGridShort");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|