using MapoDb; using SteamWare; using System; using System.Collections.Generic; namespace MP_SITE.WebUserControls { public class baseProdControl : System.Web.UI.UserControl { #region Public Events /// /// evento update /// public event EventHandler eh_doUpdate; #endregion Public Events #region Public Properties public int numRighe { get { return _numRighe; } set { _numRighe = value; } } #endregion Public Properties #region Public Methods public virtual void doUpdate() { } /// /// Conversione a bool del valore /// /// /// public bool getBool(object value) { bool answ = false; string rawVal = $"{value}".ToUpper(); // se è 1/0 --> len 1 if (rawVal.Length == 1) { answ = rawVal == "1" || rawVal == "S" || rawVal == "Y"; } else { bool.TryParse($"{value}", out answ); } return answ; } public string operatoreDaMatr(object matricola) { int matr = 0; string answ = "N.A."; try { matr = Convert.ToInt32(matricola); } catch { } // cerco in LUT... if (OprLUT.ContainsKey(matr)) { answ = OprLUT[matr]; } else { answ = _resoconti.oprDaMatr(matr); OprLUT.Add(matr, answ); } return answ; } public void reportUpdate() { // alzo l'evento d update/inserimento e ricarico cache... if (eh_doUpdate != null) { eh_doUpdate(this, new EventArgs()); } } /// /// effettua traduzione del lemma /// /// /// public string traduci(string lemma) { return user_std.UtSn.Traduci(lemma); } /// /// effettua traduzione in inglese del lemma /// /// /// public string traduciEn(string lemma) { return user_std.UtSn.TraduciEn(lemma); } #endregion Public Methods #region Internal Fields /// /// Oggetto datalayer specifico /// internal DataLayer DataLayerObj = new DataLayer(); #endregion Internal Fields #region Protected Fields protected int _numRighe = 17; protected resoconti _resoconti; protected Dictionary OprLUT = new Dictionary(); #endregion Protected Fields #region Protected Methods /// /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) /// /// /// protected bool isMulti(string idxMacchina) { return DataLayerObj.isMulti(idxMacchina); } protected virtual void Page_Load(object sender, EventArgs e) { _resoconti = new resoconti(); if (!Page.IsPostBack) { doUpdate(); } } #endregion Protected Methods } }