private void Button_Click(object sender, RoutedEventArgs e) { //var str = ExchangeRatesApiServices.GetRates(TextBox.Text); // Label.Content = _exchangeRatesApiServices.GetRates(Calendar.SelectedDate.Value.Date.ToString("yyyy-MM-dd")); // = Calendar.SelectedDate.Value.Date.ToString("yyyy-MM-dd"); ArchiwumList.Items.Clear(); if (Calendar.Text != "") { if (Calendar.Text.Contains("Saturday")) { calendarDay = Calendar.SelectedDate.Value.AddDays(-1).ToString(); } if (Calendar.Text.Contains("Sunday")) { calendarDay = Calendar.SelectedDate.Value.AddDays(-2).ToString(); } else { calendarDay = Calendar.SelectedDate.Value.Date.ToString("yyyy-MM-dd"); } } _dataBaseUpdate.update(calendarDay); foreach (var name in exchangeNames) { tempDecimal = _fromDb.Get(calendarDay, name); //table. ArchiwumList.Items.Add($" {decimal.Round(tempDecimal, 2)} {name}"); // .Add($"{tempDecimal} {name}"); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (fromExchange != null && toExchange != null) { if (regex.IsMatch(toCount.Text)) { if (fromExchange == "EUR" && toExchange != "EUR") { fromValue = 1; toValue = _fromDb.Get(day, toExchange); } if (toExchange == "EUR" && fromExchange != "EUR") { fromValue = _fromDb.Get(day, fromExchange); toValue = 1; } if (toExchange == "EUR" && fromExchange == "EUR") { fromValue = 1; toValue = 1; } if (toExchange != "EUR" && fromExchange != "EUR") { fromValue = _fromDb.Get(day, fromExchange); toValue = _fromDb.Get(day, toExchange); } decimal counteDecimal = decimal.Parse(toCount.Text.Replace(".", ",")) / fromValue * toValue; counteDecimal = decimal.Round(counteDecimal, 2); Counted.Text = $" {counteDecimal} {toExchange}"; } else { MessageBox.Show("Niepoprawne dane"); } } else { MessageBox.Show("Wybierz dwie waluty"); } }