private async void ConvertCurrency(string amount, string date) { ComboBoxItem from = CurrenciesFrom.SelectedItem as ComboBoxItem; try { fromCurrency = (from.Content as String).Substring(0, 3); } catch { return; } ComboBoxItem to = CurrenciesTo.SelectedItem as ComboBoxItem; toCurrency = (to.Content as String).Substring(0, 3); if ((fromCurrency != lastFromCurrency || toCurrency != lastToCurrency) && (fromCurrency != toCurrency) || (date != lastDate)) { lastDate = date; exchangeRate = await erdp.GetExchangeRate(fromCurrency, toCurrency, date); lastFromCurrency = fromCurrency; lastToCurrency = toCurrency; } if (fromCurrency == toCurrency) { AmountToText = amount; } // Checks if AmountFrom textbox is empty or not else if (double.TryParse(amount, out double result)) { if (result * exchangeRate > 0.01) { AmountToText = string.Format("{0:#,###0.00}", result * exchangeRate); } else { decimal resultInDecimal = (decimal)(result * exchangeRate); AmountToText = resultInDecimal.ToString(); } } else { AmountToText = ""; } AmountFrom.Focus(FocusState.Programmatic); }
public List <AmountFrom> getList() { String sql = "select * from ICVoucherTField where FTplType = 801"; List <AmountFrom> lst = new List <AmountFrom>(); foreach (DataRow row in DbHelper.getInstance().Query(sql).Tables[0].Rows) { AmountFrom amtf = new AmountFrom(); amtf.Field = Convert.ToString(row["FField"]); amtf.FieldName = Convert.ToString(row["FFieldName"]); amtf.InterID = Convert.ToInt32(row["FInterID"]); lst.Add(amtf); } return(lst); }
private void TextBox_OnBeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs e) { // Checks maximum AmountFrom length and allows only digits and dots if (e.NewText.Length < 11 && e.NewText.All(c => char.IsDigit(c) || c == '.')) { if (AmountFrom.Text.Length == 0) { AmountFrom.Select(e.NewText.Length, 0); //Sets cursor at the end of textbox } ConvertCurrency(e.NewText, DatePicker.PlaceholderText); } else { e.Cancel = true; } }
private async void getCurrencies() { CurrencyDataProvider cdp = new CurrencyDataProvider(); Dictionary <string, Models.Currency> currencies; try { currencies = await cdp.GetCurrencies(); } catch { return; } ComboBoxItem currenciesFrom; ComboBoxItem currenciesTo; foreach (var cur in currencies.OrderBy(e => e.Value.CurrencyName)) { if (cur.Value.CurrencySymbol == null) { currenciesFrom = new ComboBoxItem { Content = cur.Key + " " + cur.Value.CurrencyName }; currenciesTo = new ComboBoxItem { Content = cur.Key + " " + cur.Value.CurrencyName }; } else { currenciesFrom = new ComboBoxItem { Content = cur.Key + " " + cur.Value.CurrencyName + " (" + cur.Value.CurrencySymbol + ")" }; currenciesTo = new ComboBoxItem { Content = cur.Key + " " + cur.Value.CurrencyName + " (" + cur.Value.CurrencySymbol + ")" }; } CurrenciesFrom.Items.Add(currenciesFrom); CurrenciesTo.Items.Add(currenciesTo); } CurrenciesFrom.SelectedIndex = 156; CurrenciesTo.SelectedIndex = 143; AmountFrom.Focus(FocusState.Programmatic); }
public override int GetHashCode() { unchecked { var hashCode = (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Currency != null ? Currency.GetHashCode() : 0); hashCode = (hashCode * 397) ^ AmountFrom.GetHashCode(); hashCode = (hashCode * 397) ^ AmountTo.GetHashCode(); hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PaymentDateFrom.GetHashCode(); hashCode = (hashCode * 397) ^ PaymentDateTo.GetHashCode(); hashCode = (hashCode * 397) ^ TransferredAtFrom.GetHashCode(); hashCode = (hashCode * 397) ^ TransferredAtTo.GetHashCode(); hashCode = (hashCode * 397) ^ CreatedAtFrom.GetHashCode(); hashCode = (hashCode * 397) ^ CreatedAtTo.GetHashCode(); hashCode = (hashCode * 397) ^ UpdatedAtFrom.GetHashCode(); hashCode = (hashCode * 397) ^ UpdatedAtTo.GetHashCode(); hashCode = (hashCode * 397) ^ (BeneficiaryId != null ? BeneficiaryId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ConversionId != null ? ConversionId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ WithDeleted.GetHashCode(); hashCode = (hashCode * 397) ^ (PaymentGroupId != null ? PaymentGroupId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UniqueRequestId != null ? UniqueRequestId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Scope != null ? Scope.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BuyCurrency != null ? BuyCurrency.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SellCurrency != null ? SellCurrency.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ClientBuyAmountFrom.GetHashCode(); hashCode = (hashCode * 397) ^ ClientBuyAmountTo.GetHashCode(); hashCode = (hashCode * 397) ^ ClientSellAmountFrom.GetHashCode(); hashCode = (hashCode * 397) ^ ClientSellAmountTo.GetHashCode(); hashCode = (hashCode * 397) ^ PartnerBuyAmountFrom.GetHashCode(); hashCode = (hashCode * 397) ^ PartnerBuyAmountTo.GetHashCode(); hashCode = (hashCode * 397) ^ PartnerSellAmountFrom.GetHashCode(); hashCode = (hashCode * 397) ^ PartnerSellAmountTo.GetHashCode(); hashCode = (hashCode * 397) ^ (ClientStatus != null ? ClientStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PartnerStatus != null ? PartnerStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ConversionDateFrom.GetHashCode(); hashCode = (hashCode * 397) ^ ConversionDateTo.GetHashCode(); hashCode = (hashCode * 397) ^ SettlementDateFrom.GetHashCode(); hashCode = (hashCode * 397) ^ SettlementDateTo.GetHashCode(); return(hashCode); } }