using AppData;
using System;

namespace NKC_WF
{
    public partial class MachineUnloadSmart : BasePage
    {
        #region Public Properties

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

        #endregion Public Properties

        #region Private Methods

        /// <summary>
        /// Aggiorna componente principale e child components
        /// </summary>
        private void doUpdate()
        {
            setCurrData();
            // aggiorno child
            cmp_unloadSmart.BatchId = BatchId;
        }

        /// <summary>
        /// Imposta dati correnti (Bunk / Sheet)
        /// </summary>
        private void setCurrData()
        {
            // recupero bunk corrente...
            DS_App.StackListRow currBunk = ComLib.getCurrBunk(cmp_unloadSmart.MachineSel);
            if (currBunk != null)
            {
                BatchId = currBunk.BatchID;
            }
        }

        #endregion Private Methods

        #region Protected Methods

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ((SiteMaster)this.Master).showSearch = false;
                doUpdate();
            }
        }

        #endregion Protected Methods
    }
}