private void updateBalanceInfo() { if (cbAccount.SelectedItem != null) { MoneyDataSet.AccountsRow account = cbAccount.SelectedItem as MoneyDataSet.AccountsRow; MoneyDataSet.CurrenciesRow currency = account.CurrenciesRow; lblCurrency.Visible = false; numBalance.Visible = false; lblCurrency.Text = CultureInfo.CreateSpecificCulture(currency.CurrencyCulture).NumberFormat.CurrencySymbol; if (currency.IsSymbolAfterAmount) { tlpBalance.SetCellPosition(lblCurrency, new TableLayoutPanelCellPosition(2, 0)); tlpBalance.SetCellPosition(numBalance, new TableLayoutPanelCellPosition(0, 0)); lblCurrency.TextAlign = ContentAlignment.MiddleLeft; lblCurrency.Dock = DockStyle.Left; } else { tlpBalance.SetCellPosition(lblCurrency, new TableLayoutPanelCellPosition(0, 0)); tlpBalance.SetCellPosition(numBalance, new TableLayoutPanelCellPosition(1, 0)); lblCurrency.TextAlign = ContentAlignment.MiddleRight; lblCurrency.Dock = DockStyle.Right; } numBalance.Value = (decimal)account.Balance; numBalance.Select(0, Int32.MaxValue); lblCurrency.Visible = true; numBalance.Visible = true; } }
private void openCurrency(MoneyDataSet.CurrenciesRow currency) { CurrencyForm form = new CurrencyForm(currency); if (form.ShowDialog(this) == DialogResult.OK) { fillCurrencies(); } }
private void btnOk_Click(object sender, EventArgs e) { if (numExchangeRate.Value == 0) { MessageBox.Show(Resources.Labels.NonZeroExchangeRateText, Resources.Labels.ErrorSavingTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (existingItem != null) { if (existingItem.ID.StartsWith(Consts.Keeper.UserMetadataPrefix)) { existingItem.Title = tbTitle.Text.Trim(); existingItem.CurrencyCulture = tbCulture.Text.Trim(); existingItem.IsSymbolAfterAmount = cbIsSymbolAfterAmount.Checked; } existingItem.ExchangeRate = (double)numExchangeRate.Value; existingItem.SortOrder = (int)numSortOrder.Value; } else { String ID = tbID.Text.Trim().ToUpper(); if (keeper.DataSet.Currencies.FindByID(ID) != null) { MessageBox.Show(String.Format(Resources.Labels.RecordExistFormat, ID), Resources.Labels.ErrorSavingTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!ID.StartsWith(Consts.Keeper.UserMetadataPrefix)) { MessageBox.Show(String.Format(Resources.Labels.UserIDShouldHavePrefixFormat, Consts.Keeper.UserMetadataPrefix), Resources.Labels.ErrorSavingTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MoneyDataSet.CurrenciesRow currency = keeper.DataSet.Currencies.NewCurrenciesRow(); currency.ID = ID; currency.Title = tbTitle.Text.Trim(); currency.CurrencyCulture = tbCulture.Text.Trim(); currency.ExchangeRate = (double)numExchangeRate.Value; currency.SortOrder = (int)numSortOrder.Value; currency.IsSymbolAfterAmount = cbIsSymbolAfterAmount.Checked; keeper.DataSet.Currencies.AddCurrenciesRow(currency); } keeper.DataSet.AcceptChanges(); if (keeper.GetDefaultCurrency() == null) { MessageBox.Show(Resources.Labels.NoDefaultCurrencyText, Resources.Labels.NoDefaultCurrencyTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.DialogResult = DialogResult.OK; this.Close(); }
private void updateDestinationAmount() { if (template.HasDestinationAccount) { MoneyDataSet.CurrenciesRow source = cbSourceCurrency.SelectedItem as MoneyDataSet.CurrenciesRow; MoneyDataSet.CurrenciesRow destination = cbDestinationCurrency.SelectedItem as MoneyDataSet.CurrenciesRow; double amount = ((double)numSourceAmount.Value) * source.ExchangeRate / destination.ExchangeRate; numDestinationAmount.Value = (decimal)amount; numDestinationAmount.Select(0, Int32.MaxValue); } }
private void updateDestinationCurrency() { if ((template.HasDestinationAccount) && (cbDestinationAccount.SelectedItem != null)) { MoneyDataSet.AccountsRow account = cbDestinationAccount.SelectedItem as MoneyDataSet.AccountsRow; MoneyDataSet.CurrenciesRow currency = account.CurrenciesRow; lblDestinationCurrency.Visible = false; numDestinationAmount.Visible = false; CultureInfo culture = account.CurrenciesRow.CurrencyCultureInfo; lblDestinationBalance.Text = String.Format(culture, Resources.Labels.BalanceFormat, account.Balance); lblDestinationCurrency.Text = culture.NumberFormat.CurrencySymbol; if (destinationAccountSelected != null) { numDestinationAmount.Value = (decimal)(((double)numDestinationAmount.Value) * destinationAccountSelected.CurrenciesRow.ExchangeRate / currency.ExchangeRate); numDestinationAmount.Select(0, Int32.MaxValue); } if (currency.IsSymbolAfterAmount) { tlpDestination.SetCellPosition(lblDestinationCurrency, new TableLayoutPanelCellPosition(2, 6)); tlpDestination.SetCellPosition(numDestinationAmount, new TableLayoutPanelCellPosition(0, 6)); lblDestinationCurrency.TextAlign = ContentAlignment.MiddleLeft; lblDestinationCurrency.Dock = DockStyle.Left; } else { tlpDestination.SetCellPosition(lblDestinationCurrency, new TableLayoutPanelCellPosition(0, 6)); tlpDestination.SetCellPosition(numDestinationAmount, new TableLayoutPanelCellPosition(1, 6)); lblDestinationCurrency.TextAlign = ContentAlignment.MiddleRight; lblDestinationCurrency.Dock = DockStyle.Right; } lblDestinationCurrency.Visible = true; numDestinationAmount.Visible = true; destinationAccountSelected = account; } }
public CurrencyForm(MoneyDataSet.CurrenciesRow existingItem) { InitializeComponent(); this.keeper = MoneyDataKeeper.Instance; this.existingItem = existingItem; }