using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UniMarc
{
    public partial class UC_SelectGrade : UserControl
    {
        public UC_SelectGrade()
        {
            InitializeComponent();
        }
       
        public string GradeName
        {
            get
            {
                if(Grade == 0) return "A";
                else if (Grade == 1) return "B";
                else if (Grade == 2) return "C";
                else if (Grade == 3) return "D";
                else if (Grade == 4) return "E";
                else return "";
            }
            set
            {
                if (value == "A") Grade = 0;
                else if (value == "B") Grade = 1;
                else if (value == "C") Grade = 2;
                else if (value == "D") Grade = 3;
                else if (value == "E") Grade = 4;
                else Grade = -1;
            }
        }
        public int Grade
        {
            get
            {
                if (radA.Checked) return 0;
                else if (radB.Checked) return 1;
                else if (radC.Checked) return 2;
                else if (radD.Checked) return 3;
                else if (radE.Checked) return 4;
                else return -1;
            }
            set
            {
                if (value == -1)
                {
                    radA.Checked = false;
                    radB.Checked = false;
                    radC.Checked = false;
                    radD.Checked = false;
                    radE.Checked = false;
                }
                else if (value == 0) radA.Checked = true;
                else if (value == 1) radB.Checked = true;
                else if (value == 2) radC.Checked = true;
                else if (value == 3) radD.Checked = true;
                else if (value == 4) radE.Checked = true;
            }
        }
    }
}