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_MachSelSmart : BaseUserControl
    {
        #region Public Properties

        public string currPage
        {
            get
            {
                string url = HttpContext.Current.Request.Url.PathAndQuery;
                if (url.Contains("?mach="))
                {
                    url = url.Substring(0, url.IndexOf("?mach="));
                }
                return url;
            }
        }

        public string MachineSel
        {
            get
            {
                string answ = "";
                answ = memLayer.ML.QSS("mach");
                return answ;
            }
            set
            {
                if (!string.IsNullOrEmpty(value))
                {
                    string url = $"{currPage}?mach={value}";
                    Response.Redirect(url);
                }
            }
        }

        #endregion Public Properties

        #region Private Methods

        private void checkVisibility()
        {
            string cssClass = "warning";
            if (MachineSel == "NE01")
            {
                cssClass = "dark";
            }
            else if (MachineSel == "NE02")
            {
                cssClass = "primary";
            }
            hfMachine.Value = MachineSel;
            hfMachClass.Value = cssClass;
            lbtReset.Attributes.Remove("class");
            lbtReset.Attributes.Add("class", $"btn btn-block text-center btn-{hfMachClass.Value}");
            lbtReset.DataBind();
        }

        #endregion Private Methods

        #region Protected Methods

        protected void lbtReset_Click(object sender, EventArgs e)
        {
            Response.Redirect(currPage);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            checkVisibility();
        }

        #endregion Protected Methods
    }
}