using System;
using System.Windows.Forms;

namespace AyaNovaQBI
{
    public partial class SetQBImportServiceRateAccounts : Form
    {
        public SetQBImportServiceRateAccounts()
        {
            InitializeComponent();
        }

        private void SetQBImportServiceRateAccounts_Load(object sender, EventArgs e)
        {
            btnCancel.Text = util.AyaTranslations["Cancel"];
            btnOK.Text = util.AyaTranslations["OK"];

            cbIncomeAccount.DisplayMember = "FullName";
            cbIncomeAccount.ValueMember = "ID";
            cbIncomeAccount.DataSource = util.QBAccounts;
            if (!string.IsNullOrEmpty(util.QDat.QBServiceIncomeAccountRef))
                cbIncomeAccount.SelectedValue = util.QDat.QBServiceIncomeAccountRef;
        }

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

        private async void btnOK_Click(object sender, EventArgs e)
        {
            util.QDat.QBServiceIncomeAccountRef = cbIncomeAccount.SelectedValue.ToString();
            await util.SaveIntegrationObject();
            DialogResult = DialogResult.OK;
            Close();
        }
    }
}
