using GMW_data;
using SteamWare;
using System;
using System.Web.UI;

namespace GMW
{
    public partial class sanpos_associaz_F10_F18 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // pulisco dir temp dai file dei cartellini stampati
            reportPrinter.obj.pulisciDir();

            if (!Page.IsPostBack)
            {
                updatePrinterPostazione();
                // fix css...
                Postazione.CssClass = "stileAttesa";
            }

            // update vari...
            doUpdate();
            mod_selLineaNtDt1.eh_lineSelected += mod_selLineaNtDt1_eh_doRefresh;
        }
        /// <summary>
        /// Handles the doRefresh event of the mod_selLineaNtDt1_eh control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void mod_selLineaNtDt1_eh_doRefresh(object sender, EventArgs e)
        {
            doUpdate();
        }
        /// <summary>
        /// richiesta update del controllo SAO
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mod_PostRX_DT1_eh_reqUpdate(object sender, EventArgs e)
        {
            doUpdate();
        }
        /// <summary>
        /// aggiorna messaggi e css
        /// </summary>
        private void updateMessCss()
        {
            lblWarning.Text = Postazione.warningText;
            lblMessaggi.Text = Postazione.messaggiText;
            pnlAll.CssClass = Postazione.CssClass;
        }
        /// <summary>
        /// wrapper traduzione
        /// </summary>
        /// <param name="lemma"></param>
        /// <returns></returns>
        public string traduci(object lemma)
        {
            return user_std.UtSn.Traduci(lemma.ToString());
        }
        /// <summary>
        /// update generale controlli
        /// </summary>
        private void doUpdate()
        {
            updateMessCss();
        }
        /// <summary>
        /// calcola postazione corrente (ip, name, printer)
        /// </summary>
        private void updatePrinterPostazione()
        {
            Postazione.IP = Request.UserHostName;
            Postazione.setupPrinter();
            // mostro warning se postazione non configurata...
            if (Postazione.printer == "n.d.")
            {
                lblWarning.Text = traduci("lblWarnPostNonConf");
            }
        }
    }
}
