using SteamWare;
using System;

namespace NKC_WF
{
    public partial class MachineLoad : BasePage
    {
        #region Private Methods

        private void Cmp_stackLoading_eh_doRefresh(object sender, EventArgs e)
        {
            forceRefresh();
        }

        private void forceRefresh()
        {
            // verifico CI SIA la macchina...
            if (string.IsNullOrEmpty(cmp_MachSem.currMachine))
            {
                divMain.Visible = false;
            }
            else
            {
                divMain.Visible = true;
                cmp_stackLoading.doUpdate();
                int currBatchId = cmp_stackLoading.BatchIdCurr;
                hfBatchID.Value = $"{currBatchId}";
                cmp_ML_ShDet.BatchId = currBatchId;
                cmp_ML_ShDet1.BatchId = currBatchId;
                cmp_ML_ShDet2.BatchId = currBatchId;
                cmp_ML_ShDet3.BatchId = currBatchId;
                cmp_ML_ShDet.doUpdate();
                cmp_ML_ShDet1.doUpdate();
                cmp_ML_ShDet2.doUpdate();
                cmp_ML_ShDet3.doUpdate();
            }
        }

        #endregion Private Methods

        #region Protected Methods

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

        protected void timerLoad_Tick(object sender, EventArgs e)
        {
            forceRefresh();
        }

        protected void timerLong_Tick(object sender, EventArgs e)
        {
            Response.Redirect(Request.RawUrl);
        }

        #endregion Protected Methods
    }
}