using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using GMW_data;

namespace GMW_Term.WebUserControls
{
    public partial class mod_menuLDP : System.Web.UI.UserControl
    {
        /// <summary>
        /// wrapper traduzione termini
        /// </summary>
        /// <param name="lemma"></param>
        /// <returns></returns>
        public string traduci(string lemma)
        {
            return user_std.UtSn.Traduci(lemma);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            // scrive label e text bottoni
            btn1.Text = string.Format("{0}\n[Alt+{1}]", traduci("btnTermTakeListBarcode"), 1);
            btn1.AccessKey = "1";
            btn2.Text = string.Format("{0}\n[Alt+{1}]", traduci("btnTermTakeListHome"), 3);
            btn2.AccessKey = "3";
            btn3.Text = string.Format("{0}\n[Alt+{1}]", traduci("btnTermTakeList"), 7);
            btn3.AccessKey = "7";
            btn4.Text = string.Format("{0}\n[Alt+{1}]", traduci("btnTermSmartList"), 9);
            btn4.AccessKey = "9";
            checkLavoriInCorso();
        }
        /// <summary>
        /// verifica se ci siano in corso smartList o LDP normali e disabilita il contrario
        /// </summary>
        private void checkLavoriInCorso()
        {
            bool hasSmartList = false;
            try
            {
                hasSmartList = (MagClass.magazzino.taElencoListePrelievo.getOpenByUserTipo(MagClass.magazzino.CodSoggCurrUser, "00-Smart").Rows.Count > 0);
            }
            catch
            { }
            if (hasSmartList)
            {
                // smartList attiva
                btn1.Enabled = false;
                btn3.Enabled = false;
            }
            else if (memLayer.ML.isInSessionObject("CodListaAttiva"))
            {
                // LDP tradizionale attiva
                btn4.Enabled = false;
            }
            else
            {
                // niente attivo!
                btn1.Enabled = true;
                btn3.Enabled = true;
                btn4.Enabled = true;
            }
        }

        protected void btn1_Click(object sender, EventArgs e)
        {
            Response.Redirect("UDC.aspx");
        }

        protected void btn2_Click(object sender, EventArgs e)
        {
            Response.Redirect("Home.aspx");
        }

        protected void btn3_Click(object sender, EventArgs e)
        {
            Response.Redirect("ListePrelievo.aspx");
        }

        protected void btn4_Click(object sender, EventArgs e)
        {
            Response.Redirect("SmartList.aspx");
        }
    }
}