using SteamWare;
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_partMIA_byPLID : BaseUserControl
    {
        #region Protected Properties

        /// <summary>
        /// PackListID richiesta
        /// </summary>
        protected int reqPLID
        {
            get
            {
                int answ = 0;
                try
                {
                    answ = memLayer.ML.QSI("PLID");
                }
                catch
                { }
                return answ;
            }
        }

        #endregion Protected Properties

        #region Public Properties

        public int numRow
        {
            get
            {
                return grView.PageSize;
            }
            set
            {
                grView.PageSize = value;
            }
        }

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

        public bool showFull
        {
            get
            {
                bool answ = false;
                bool.TryParse(hfShowFull.Value, out answ);
                return answ;
            }
            set
            {
                hfShowFull.Value = value.ToString();
                grView.DataBind();
            }
        }

        #endregion Public Properties

        #region Protected Methods

        protected void grView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ItemId = 0;
            int.TryParse(grView.SelectedValue.ToString(), out ItemId);
            if (ItemId > 0)
            {
                // resetto item selezionato...
                DLMan.taIL.updateStatus(ItemId, 990, PlaceCod);
                lgInfo($"cmp_partMIA_byPLID | SCRAP | Status --> 990 | itemIdSelected: {ItemId} | PlaceCod: {PlaceCod}");
                grView.SelectedIndex = -1;
                grView.DataBind();
                raiseEvent();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            PLID = reqPLID;
            PlaceCod = "ND";
        }

        #endregion Protected Methods

        #region Public Methods

        public bool checkVisible(object _statusID)
        {
            bool answ = false;
            int StatusID = 0;
            int.TryParse(_statusID.ToString(), out StatusID);
            answ = StatusID < 900;
            return answ;
        }

        public void doUpdate()
        {
            grView.DataBind();
        }

        #endregion Public Methods
    }
}