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

namespace NKC_WF.WebUserControls
{
    public partial class cmp_OtherItemsDetail : BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                currQueue = DLMan.getPrinter("PC-MACHINE-OTHERITEM");
            }
        }
        protected int qrSize
        {
            get
            {
                int answ = 64;
                int.TryParse(ddlQrSize.SelectedValue, out answ);
                return answ;
            }
        }

        protected void ddlQrSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            repDetail.DataBind();
        }

        protected void lbtPrintAll_Click(object sender, EventArgs e)
        {
            // chiamo stored x stampare OGNI cart del BATCH
            var tabOtherItems = DLMan.taOtItem.GetData();
            try
            {
                if (tabOtherItems != null && tabOtherItems.Count > 0)
                {
                    foreach (var item in tabOtherItems)
                    {
                        // invio SINGOLO record in stampa
                        DLMan.stampaDoc(item.OtherItemID.ToString(), currQueue, tipoDocumento.docOtherPart, Request.UserHostName);
                    }
                }
            }
            catch
            { }
        }

        /// <summary>
        /// Queue selezionata
        /// </summary>
        public string currQueue
        {
            get
            {
                return hfPrintQueue.Value;
            }
            set
            {
                hfPrintQueue.Value = value;
            }
        }
        protected void lbtPrintSingle_Click(object sender, EventArgs e)
        {
            // ciclo per ogni item e stampo...
            LinkButton lbt = (LinkButton)sender;
            string idReq = lbt.CommandArgument;
            DLMan.stampaDoc(idReq, currQueue, tipoDocumento.docOtherPart, Request.UserHostName);
        }
    }
}