using System;
using System.Web.UI.WebControls;

namespace NKC_WF.WebUserControls
{
    public partial class cmp_BP_bunkList : BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// Batch corrente...
        /// </summary>
        public int BatchId
        {
            set
            {
                hfBatchID.Value = value.ToString();
            }
            get
            {
                int answ = 0;
                int.TryParse(hfBatchID.Value, out answ);
                return answ;
            }
        }

        protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            // recupero argomento = Takt...
            try
            {
                string stack = e.CommandArgument.ToString();
                //lblStack.Text = stack;
            }
            catch
            { }
        }
        protected void grView_SelectedIndexChanged(object sender, EventArgs e)
        {
            checkVisibility();
            raiseEvent();
        }
        /// <summary>
        /// comando reset
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtReset_Click(object sender, EventArgs e)
        {
            resetSelezione();
        }

        private void checkVisibility()
        {
            //divSelected.Visible = StackIdSel > 0;
            //grView.Visible = !divSelected.Visible;
            //// imposto css titolo...
            //string titleClass = "row font-weight-bold";
            //if (divSelected.Visible)
            //{
            //  titleClass += " table-info";
            //}
            //divTitle.Attributes.Remove("class");
            //divTitle.Attributes.Add("class", titleClass);
        }
        public void resetSelezione()
        {
            //lblStack.Text = "";
            grView.SelectedIndex = -1;
            grView.DataBind();
            checkVisibility();
            raiseEvent();
        }
        /// <summary>
        /// Indice selezionato
        /// </summary>
        public int selIndex
        {
            get
            {
                return grView.SelectedIndex;
            }
            set
            {
                grView.SelectedIndex = value;
                grView.DataBind();
            }
        }
        /// <summary>
        /// BunkId selezionato
        /// </summary>
        public int BunkIdSel
        {
            get
            {
                int answ = 0;
                try
                {
                    if (grView != null)
                    {
                        if (grView.SelectedValue != null)
                        {
                            int.TryParse(grView.SelectedValue.ToString(), out answ);
                        }
                    }
                }
                catch
                { }
                return answ;
            }
        }
        /// <summary>
        /// Num totale bunks
        /// </summary>
        public int numBunks
        {
            get
            {
                return grView.Rows.Count;
            }
        }
    }
}