Esempio n. 1
0
        public frmDeposit(List <QuickbooksPaytype> availableQuickBooksPaymentTypes, DepositConfiguration depositconfig)
        {
            config = UserSettings.getInstance().Configuration;

            InitializeComponent();

            _depositconfiguration  = depositconfig;
            _depositConfigPayTypes = new BindingList <DepositConfigPayType>(_depositconfiguration.QuickBooksPaymentTypes);

            txtBoxMemo.DataBindings.Add(new Binding("Text", depositconfig, "Memo"));

            comboDepositToAccount.DataSource    = config.QuickbooksBankAccounts;
            comboDepositToAccount.DisplayMember = "Name";
            comboDepositToAccount.DataBindings.Add(new Binding("SelectedItem", _depositconfiguration, "BankAccount", false));

            if (_depositconfiguration.BankAccount == null)
            {
                _depositconfiguration.BankAccount = comboDepositToAccount.SelectedItem as QuickbooksAccount;
            }

            if (_depositconfiguration.Memo == null)
            {
                _depositconfiguration.Memo = txtBoxMemo.Text;
            }

            if (_depositconfiguration == null)
            {
                _depositconfiguration      = new DepositConfiguration();
                _depositconfiguration.Memo = "New Deposit";
            }

            _availableQuickbooksPaymentTypes           = new BindingList <QuickbooksPaytype>(availableQuickBooksPaymentTypes);
            listBoxAvailablePaymentTypes.DataSource    = _availableQuickbooksPaymentTypes;
            listBoxAvailablePaymentTypes.DisplayMember = "Name";

            columnMaximum.Items.Add(new MaxValues(Int32.MaxValue, "(no maximum)"));
            List <MaxValues> maximumValueList = new List <MaxValues>();

            maximumValueList.Add(new MaxValues(Int32.MaxValue, "(no maximum)"));
            for (int i = 1; i <= 30; i++)
            {
                maximumValueList.Add(new MaxValues(i, i.ToString()));
            }

            columnMaximum.DataSource       = maximumValueList;
            columnMaximum.DisplayMember    = "Name";
            columnMaximum.ValueMember      = "Value";
            columnMaximum.DataPropertyName = "Maximum";


            columnPaytype.DataPropertyName      = "DisplayValue";
            dataGridDeposit.AutoGenerateColumns = false;

            dataGridDeposit.DataSource = _depositConfigPayTypes;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            DepositConfiguration selectedItem = dataGridView1.SelectedRows[0].DataBoundItem as DepositConfiguration;

            _depositConfigurations.Remove(selectedItem);
        }
        public frmDeposit(List<QuickbooksPaytype> availableQuickBooksPaymentTypes, DepositConfiguration depositconfig)
        {
            config = UserSettings.getInstance().Configuration;

            InitializeComponent();

            _depositconfiguration = depositconfig;
            _depositConfigPayTypes = new BindingList<DepositConfigPayType>(_depositconfiguration.QuickBooksPaymentTypes);

            txtBoxMemo.DataBindings.Add(new Binding("Text", depositconfig, "Memo"));

            comboDepositToAccount.DataSource = config.QuickbooksBankAccounts;
            comboDepositToAccount.DisplayMember = "Name";
            comboDepositToAccount.DataBindings.Add(new Binding("SelectedItem", _depositconfiguration, "BankAccount", false));

            if (_depositconfiguration.BankAccount == null)
                _depositconfiguration.BankAccount = comboDepositToAccount.SelectedItem as QuickbooksAccount;

            if (_depositconfiguration.Memo == null)
                _depositconfiguration.Memo = txtBoxMemo.Text;

            if (_depositconfiguration == null)
            {
                _depositconfiguration = new DepositConfiguration();
                _depositconfiguration.Memo = "New Deposit";
            }

            _availableQuickbooksPaymentTypes = new BindingList<QuickbooksPaytype>(availableQuickBooksPaymentTypes);
            listBoxAvailablePaymentTypes.DataSource = _availableQuickbooksPaymentTypes;
            listBoxAvailablePaymentTypes.DisplayMember = "Name";

            columnMaximum.Items.Add(new MaxValues(Int32.MaxValue, "(no maximum)"));
            List<MaxValues> maximumValueList = new List<MaxValues>();

            maximumValueList.Add(new MaxValues(Int32.MaxValue, "(no maximum)"));
            for (int i = 1; i <= 30; i++)
                maximumValueList.Add(new MaxValues(i, i.ToString()));

            columnMaximum.DataSource = maximumValueList;
            columnMaximum.DisplayMember = "Name";
            columnMaximum.ValueMember = "Value";
            columnMaximum.DataPropertyName = "Maximum";

            columnPaytype.DataPropertyName = "DisplayValue";
            dataGridDeposit.AutoGenerateColumns = false;

            dataGridDeposit.DataSource = _depositConfigPayTypes;
        }
        private void btnAddDeposit_Click(object sender, EventArgs e)
        {
            List<QuickbooksPaytype> availableQuickbooksPayTypes = getUnconfiguredQuickbookPayTypes();
            DepositConfiguration newConfig = new DepositConfiguration();
            frmDeposit frmDeposit = new frmDeposit(availableQuickbooksPayTypes, newConfig);

            if (availableQuickbooksPayTypes.Count == 0)
            {
                MessageBox.Show("All payment types are already configured, you must remove a payment type from an existing deposit first.");
                return;
            }

            if (frmDeposit.ShowDialog() == DialogResult.OK)
            {
                _depositConfigurations.Add(newConfig);
            }
        }
        private void btnAddDeposit_Click(object sender, EventArgs e)
        {
            List <QuickbooksPaytype> availableQuickbooksPayTypes = getUnconfiguredQuickbookPayTypes();
            DepositConfiguration     newConfig = new DepositConfiguration();
            frmDeposit frmDeposit = new frmDeposit(availableQuickbooksPayTypes, newConfig);

            if (availableQuickbooksPayTypes.Count == 0)
            {
                MessageBox.Show("All payment types are already configured, you must remove a payment type from an existing deposit first.");
                return;
            }

            if (frmDeposit.ShowDialog() == DialogResult.OK)
            {
                _depositConfigurations.Add(newConfig);
            }
        }
        private void btnEditDeposit_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            List <QuickbooksPaytype> availableQuickbooksPayTypes = getUnconfiguredQuickbookPayTypes();
            DepositConfiguration     originalConfig = dataGridView1.SelectedRows[0].DataBoundItem as DepositConfiguration;
            DepositConfiguration     editedConfig   = originalConfig.Clone();
            frmDeposit frmDeposit = new frmDeposit(availableQuickbooksPayTypes, editedConfig);

            frmDeposit.Text = "Edit Deposit: " + originalConfig.Memo;
            if (frmDeposit.ShowDialog() == DialogResult.OK)
            {
                _depositConfigurations[_depositConfigurations.IndexOf(originalConfig)] = editedConfig;
                _depositConfigurations.ResetItem(_depositConfigurations.IndexOf(editedConfig));
            }
        }
        private void btnMoveDown_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            Int32 indexToMove = dataGridView1.SelectedRows[0].Index;

            if (indexToMove == dataGridView1.Rows.Count)
            {
                return;
            }

            DepositConfiguration selectedConfig = _depositConfigurations[indexToMove];

            _depositConfigurations.RemoveAt(indexToMove);
            _depositConfigurations.Insert(indexToMove + 1, selectedConfig);
            dataGridView1.Rows[indexToMove + 1].Selected = true;
            _depositConfigurations.Select((config, index) => config.Order = index);
        }