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

namespace NKC_WF.site
{
    public partial class BinDetIRK : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ((SiteContent)this.Master).showSearch = false;
            }
            BinID = memLayer.ML.QSI("BinID");
            doUpdate();
        }

        private void doUpdate()
        {
            // definisco se mostrare PartMIA
            hlPartMIA.Visible = showPartMIA;
            // fix link!
            hlPartMIA.NavigateUrl = $"~/site/PartMIA?CartID={BinID}";
        }
        /// <summary>
        /// Verifica se sia da mostrare pagina MissingInAction
        /// </summary>
        public bool showPartMIA
        {
            get
            {
                bool answ = false;
                try
                {
                    answ = DLMan.taIL.getMissingByCart(BinID).Count > 0;
                }
                catch
                { }
                return answ;
            }
        }

        public int BinID
        {
            get
            {
                int answ = 0;
                int.TryParse(hfBinID.Value, out answ);
                return answ;
            }
            set
            {
                hfBinID.Value = value.ToString();
                cmp_binDetIRK.BinID = value;
            }
        }
        /// <summary>
        /// Queue selezionata
        /// </summary>
        public string currQueue
        {
            get
            {
                return "queueIRKGroup";
            }
        }
        protected void lbtPrint_Click(object sender, EventArgs e)
        {
            // invio SINGOLO record in stampa
            DLMan.stampaDoc(BinID.ToString(), currQueue, tipoDocumento.docBinPre, Request.UserHostName);
        }

        protected void timerMain_Tick(object sender, EventArgs e)
        {
            cmp_binDetIRK.doUpdate();
        }
    }
}