Files
ravenqbi/AyaNovaQBI/SetQBImportInventoryAccounts.cs
2022-07-04 17:45:30 +00:00

64 lines
2.5 KiB
C#

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 AyaNovaQBI
{
public partial class SetQBImportInventoryAccounts : Form
{
public SetQBImportInventoryAccounts()
{
InitializeComponent();
}
private void SetQBImportInventoryAccounts_Load(object sender, EventArgs e)
{
btnCancel.Text = util.AyaTranslations["Cancel"];
btnOK.Text = util.AyaTranslations["OK"];
//Fill combo's and select defaults
cbAsset.BindingContext = new BindingContext();//Ensure unique binding context so multiple combo boxes bound to same datasource can be selected independantly
cbAsset.DisplayMember = "FullName";
cbAsset.ValueMember = "ID";
cbAsset.DataSource = util.QBAccounts;
if (!string.IsNullOrEmpty(util.QDat.QBInventoryAssetAccountRef))
cbAsset.SelectedValue = util.QDat.QBInventoryAssetAccountRef;
cbCogs.BindingContext = new BindingContext();
cbCogs.DisplayMember = "FullName";
cbCogs.ValueMember = "ID";
cbCogs.DataSource = util.QBAccounts;
if (!string.IsNullOrEmpty(util.QDat.QBInventoryCOGSAccountRef))
cbCogs.SelectedValue = util.QDat.QBInventoryCOGSAccountRef;
cbIncome.BindingContext = new BindingContext();
cbIncome.DisplayMember = "FullName";
cbIncome.ValueMember = "ID";
cbIncome.DataSource = util.QBAccounts;
if (!string.IsNullOrEmpty(util.QDat.QBInventoryIncomeAccountReference))
cbIncome.SelectedValue = util.QDat.QBInventoryIncomeAccountReference;
}
private async void btnOK_Click(object sender, EventArgs e)
{
util.QDat.QBInventoryAssetAccountRef = cbAsset.SelectedValue.ToString();
util.QDat.QBInventoryCOGSAccountRef = cbCogs.SelectedValue.ToString();
util.QDat.QBInventoryIncomeAccountReference = cbIncome.SelectedValue.ToString();
await util.SaveIntegrationObject();
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}