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_byCartID : BaseUserControl
    {
        #region Protected Properties

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

        #endregion Protected Properties

        #region Public Properties

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

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

        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_byCartID | SCRAP | Status --> 990 | itemIdSelected: {ItemId} | PlaceCod: {PlaceCod}");
                grView.SelectedIndex = -1;
                grView.DataBind();
                raiseEvent();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            CartID = reqCartID;
            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
    }
}