using MongoDB.Driver;
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 CartDetIRK : BasePage
    {
        #region Public Properties

        public int CartID
        {
            get
            {
                int answ = 0;
                int.TryParse(hfCartID.Value, out answ);
                return answ;
            }
            set
            {
                hfCartID.Value = value.ToString();
                cmp_cartDetIRK.CartID = value;
            }
        }

        /// <summary>
        /// Queue selezionata
        /// </summary>
        public string currQueue
        {
            get
            {
                return "queueIRKGroup";
            }
        }

        /// <summary>
        /// Verifica se sia da mostrare pagina MissingInAction
        /// </summary>
        public bool showPartMIA
        {
            get
            {
                bool answ = false;
                try
                {
                    answ = DLMan.taIL.getMissingByCart(CartID).Count > 0;
                }
                catch
                { }
                return answ;
            }
        }

        #endregion Public Properties

        #region Private Methods

        private void doUpdate()
        {
            // definisco se mostrare PartMIA
            hlPartMIA.Visible = showPartMIA;
            // fix link!
            hlPartMIA.NavigateUrl = $"~/site/PartMIA?CartID={CartID}";
        }

        #endregion Private Methods

        #region Protected Methods

        protected void lbtPrint_Click(object sender, EventArgs e)
        {
            // invio SINGOLO record in stampa
            DLMan.stampaDoc(CartID.ToString(), currQueue, tipoDocumento.docCartIRKSum, Request.UserHostName);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ((SiteContent)this.Master).showSearch = false;
            }
            CartID = memLayer.ML.QSI("CartID");
            cmp_cartDetIRK.PlaceCod = "ND";
            doUpdate();
        }

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

        #endregion Protected Methods
    }
}