using System; using System.Web.UI.WebControls; namespace SteamWare { /// /// 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. /// public class UserControl : System.Web.UI.UserControl { /// /// UID formattato con "_" /// public string uid { get { return this.UniqueID.Replace("$", "_").Replace("-", "_"); } } /// /// event handler generico /// public event EventHandler eh_ucev; /// /// sollevo evento selezione /// protected void raiseEvent(ucEvType evType) { // sollevo evento nuovo valore... if (eh_ucev != null) { ucEvent evento = new ucEvent(evType); eh_ucev(this, evento); } } /// /// wrapper traduzione /// /// /// public string traduci(object lemma) { string answ = ""; if (lemma != null) { if (lemma.ToString() != "") { answ = user_std.UtSn.Traduci(lemma.ToString()); } } else { answ = "--"; } return answ; } /// /// modalità operativa controllo /// public ucMode modoContr { get; set; } /// /// escape dei parametri input dell'ODS /// /// 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 { } } } /// /// indica se i caratteri vadano forzati a maiuscoli /// public bool forceUppercase { get { bool answ = false; try { answ = memLayer.ML.CRB("forceUppercase"); } catch { } return answ; } } /// /// determina se l'utente sia abilitato a scrivere nella pagina corrente (quindi modificare e cancellare...) /// 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; } } /// /// determina se l'utente sia abilitato alla pagina corrente (di base visualizzazione...) /// public bool isPageEnabled { get { return devicesAuthProxy.stObj.isPageEnabled(titolo); } } /// /// titolo pagina /// public string titolo { get { return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", ""); } } /// /// evento standard agganciabile da grView x aggiunta doppio click e singolo click (x edit e select) /// /// /// 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"; } } /// /// evento andata in editing del controllo /// /// /// protected virtual void grView_RowEditing(object sender, GridViewEditEventArgs e) { GridView grView = (GridView)sender; if (grView.EditIndex >= 0) { grView.UpdateRow(grView.EditIndex, false); } } /// /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}" /// /// verrà usato x posizione {0}, tipo "view" /// verrà usato x posizione {1}, tipo "_s.png" /// public string imgPath(tipoImg _tipo, dimImg _dimensione) { return imgPath(_tipo, _dimensione, tipoFileImg.png); } /// /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}" /// /// verrà usato x posizione {0}, tipo "view" /// verrà usato x posizione {1}, tipo "_s.png" /// tipo del file richiesto..." /// 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); } /// /// Classe help email x SteamWare.UserControl /// public class email { /// /// Email dell'account admin applicativo /// public static string adminEmail { get { return memLayer.ML.CRS("_adminEmail"); } } /// /// Email dell'account sender applicativo /// public static string senderEmail { get { return memLayer.ML.CRS("_fromEmail"); } } } /// /// Numero Righe standard /// public int righeDataGrid { get { return memLayer.ML.CRI("_righeDataGrid"); } } /// /// Numero Righe standard ANAGR /// public int righeDataGridAnagr { get { return memLayer.ML.CRI("_righeDataGridAnagr"); } } /// /// Numero Righe standard LONG /// public int righeDataGridLong { get { return memLayer.ML.CRI("_righeDataGridLong"); } } /// /// Numero Righe standard MED /// public int righeDataGridMed { get { return memLayer.ML.CRI("_righeDataGridMed"); } } /// /// Numero Righe standard SHORT /// public int righeDataGridShort { get { return memLayer.ML.CRI("_righeDataGridShort"); } } } }