using System;
using System.Data;
using System.Windows.Forms;

namespace AyaNovaQBI
{
    public partial class MapSelectQBItem : Form
    {
        public MapSelectQBItem()
        {
            InitializeComponent();
        }
      
        public string SelectedQBItemName
        {
            get
            {
                if (ckNothing.Checked) return "Nothing / Remove link";
                return ((DataRowView)cbQBItems.SelectedItem).Row[0].ToString();
            }
        }

        public string SelectedQBItemId
        {
            get
            {
                if (ckNothing.Checked) return string.Empty;
                return ((DataRowView)cbQBItems.SelectedItem).Row[1].ToString();
            }
        }

        public DataTable QBItems { get; set; }
        private void MapSelectQBItem_Load(object sender, EventArgs e)
        {
            cbQBItems.DataSource = QBItems;

            cbQBItems.DisplayMember = "name";
            cbQBItems.ValueMember = "id";
            btnCancel.Text = util.AyaTranslations["Cancel"];
            btnOK.Text = util.AyaTranslations["OK"];
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void ckNothing_CheckedChanged(object sender, EventArgs e)
        {
            cbQBItems.Enabled = !ckNothing.Checked;
        }
    }
}
