using SteamWare;
using System;

namespace NKC_WF.WebUserControls
{
    public partial class cmp_MU_Items : BaseUserControl
    {
        /// <summary>
        /// Sheet corrente...
        /// </summary>
        public int SheetID
        {
            set
            {
                hfSheetID.Value = value.ToString();
                doUpdate();
            }
            get
            {
                int answ = 0;
                int.TryParse(hfSheetID.Value, out answ);
                return answ;
            }
        }
        /// <summary>
        /// Indica se mostrare o meno QRCode
        /// </summary>
        public bool ShowQr
        {
            set
            {
                hfShowQr.Value = value.ToString();
            }
            get
            {
                bool answ = false;
                bool.TryParse(hfShowQr.Value, out answ);
                return answ;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                numRow = 10;
            }
        }
        public void doUpdate()
        {
            grView.DataBind();
        }
        /// <summary>
        /// Dimensione QRCode
        /// </summary>
        public int qrSize
        {
            get
            {
                int answ = 32;
                int.TryParse(hfQrSize.Value, out answ);
                return answ;
            }
            set
            {
                hfQrSize.Value = value.ToString();
                doUpdate();
            }
        }
        /// <summary>
        /// Numero righe da mostrare (se 0 --> no pagiazione)
        /// </summary>
        public int numRow
        {
            get
            {
                int answ = 32;
                int.TryParse(hfNumRow.Value, out answ);
                return answ;
            }
            set
            {
                hfNumRow.Value = value.ToString();
                grView.PageSize = value;
                doUpdate();
            }
        }
        /// <summary>
        /// Calcola css da statusID
        /// </summary>
        /// <param name="_statusID"></param>
        /// <returns></returns>
        public string cssByStatus(object _statusID)
        {
            string answ = "text-secondary";
            int statusID = 0;
            int.TryParse(_statusID.ToString(), out statusID);
            switch (statusID)
            {
                case 1:
                    answ = "text-dark";
                    break;
                case 2:
                    answ = "text-warning";
                    break;
                case 3:
                    answ = "text-success";
                    break;
                case 4:
                    answ = "text-info";
                    break;
                default:
                    answ = "text-danger";
                    break;
            }
            return answ;
        }
    }
}