using AppData;
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_batchDetailSplitInfo : BaseUserControl
    {
        #region Public Properties

        public int BatchId
        {
            set
            {
                hfBatchId.Value = value.ToString();
                frmView.DataBind();
                cmp_batchDetailMongo.BatchId = value;
            }
            get
            {
                int answ = 0;
                int.TryParse(hfBatchId.Value, out answ);
                return answ;
            }
        }

        #endregion Public Properties

        #region Protected Methods

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

        #endregion Protected Methods

        #region Public Methods

        /// <summary>
        /// Converte il codice stato in effettivo campo
        /// </summary>
        /// <param name="_status"></param>
        /// <returns></returns>
        public string BStatus(object _status)
        {
            string answ = ComLib.BatchStatusDescr(_status);
            return answ;
        }

        /// <summary>
        /// Codice CSS in base a status...
        /// </summary>
        /// <param name="_status"></param>
        /// <returns></returns>
        public string cssByStatus(object _status)
        {
            string answ = "text-muted";
            int status = -1;
            int.TryParse(_status.ToString(), out status);
            switch (status)
            {
                case 1:
                    answ = "font-weight-bold text-info";
                    break;

                case 2:
                    answ = "font-weight-bold text-primary";
                    break;

                case 3:
                    answ = "font-weight-bold text-warning";
                    break;

                case 4:
                    answ = "font-weight-bold text-danger";
                    break;

                case 5:
                    answ = "font-weight-bold text-success";
                    break;

                case 6:
                    answ = "font-weight-bold text-secondary";
                    break;

                default:
                    break;
            }
            return answ;
        }

        /// <summary>
        /// Codice CSS in base a BatchType...
        /// </summary>
        /// <param name="_BatchType"></param>
        /// <returns></returns>
        public string cssIconByType(object _BatchType)
        {
            string answ = "fa fa-circle-thin";
            int status = -1;
            int.TryParse(_BatchType.ToString(), out status);
            switch (status)
            {
                case 0:
                    answ = "fa fa-file-text-o";
                    break;

                case 1:
                    answ = "fa fa-file-text";
                    break;

                case 2:
                    answ = "fa fa-scissors";
                    break;

                default:
                    break;
            }
            return answ;
        }

        /// <summary>
        /// Determina se sia visibile previewin base a BatchType...
        /// </summary>
        /// <param name="_BatchType"></param>
        /// <returns></returns>
        public bool hasPreviewByType(object _BatchType)
        {
            bool answ = false;
            int status = -1;
            int.TryParse(_BatchType.ToString(), out status);
            switch (status)
            {
                case 0:
                case 2:
                    answ = true;
                    break;

                case 1:
                default:
                    answ = false;
                    break;
            }
            return answ;
        }

        /// <summary>
        /// Verifica se sia visualizzabile preview dato stato
        /// </summary>
        /// <param name="_status"></param>
        /// <returns></returns>
        public bool isPreviewVisible(object _status)
        {
            bool answ = false;
            int status = -1;
            int.TryParse(_status.ToString(), out status);
            // solo stati 4 (nesting done), 5 (approvato), 6 (eliminazione logica)
            if (status > 3 && status < 7)
            {
                answ = true;
            }
            return answ;
        }

        /// <summary>
        /// Tooltip in base a BatchType...
        /// </summary>
        /// <param name="_BatchType"></param>
        /// <returns></returns>
        public string tooltipByType(object _BatchType)
        {
            string answ = "-";

            answ = traduci($"tooltipBatchType_{_BatchType}");
            return answ;
        }

        #endregion Public Methods
    }
}