using System;

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

        }
        /// <summary>
        /// Bunk corrente...
        /// </summary>
        public int BunkId
        {
            set
            {
                hfStackID.Value = value.ToString();
                grView.DataBind();
            }
            get
            {
                int answ = 0;
                int.TryParse(hfStackID.Value, out answ);
                return answ;
            }
        }
        // <summary>
        /// Indice selezionato
        /// </summary>
        public int selIndex
        {
            get
            {
                return grView.SelectedIndex;
            }
            set
            {
                grView.SelectedIndex = value;
                grView.DataBind();
            }
        }
        /// <summary>
        /// SheetId selezionato
        /// </summary>
        public int SheetIdSel
        {
            get
            {
                int answ = 0;
                try
                {
                    if (grView != null)
                    {
                        if (grView.SelectedValue != null)
                        {
                            int.TryParse(grView.SelectedValue.ToString(), out answ);
                        }
                    }
                }
                catch
                { }
                return answ;
            }
        }
        /// <summary>
        /// comando reset
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtReset_Click(object sender, EventArgs e)
        {
            resetSelezione();
        }
        public void resetSelezione()
        {
            //lblStack.Text = "";
            grView.SelectedIndex = -1;
            grView.DataBind();
            raiseEvent();
        }

        protected void grView_SelectedIndexChanged(object sender, EventArgs e)
        {
            raiseEvent();
        }
        /// <summary>
        /// Formatta in min/sec il tempo in sec decimale
        /// </summary>
        /// <param name="_timeSec"></param>
        /// <returns></returns>
        public string formatMinSec(object _timeSec)
        {
            int totSec = 0;
            string answ = "";
            int.TryParse(_timeSec.ToString().Replace(".", ""), out totSec);
            int numMin = totSec / 60;
            int numSec = totSec - (60 * numMin);
            answ = $"{numMin:00}:{numSec:00}";
            return answ;
        }

        /// <summary>
        /// Num totale Sheets
        /// </summary>
        public int numSheets
        {
            get
            {
                return grView.Rows.Count;
            }
        }
    }
}