Beispiel #1
0
        private void ConvertCurrency_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(this.amountBox.Text))
            {
                double         result;
                ConvertService service = new ConvertService();
                Devise         devise  = (Devise)this.deviseBox.SelectedItem;

                if (!service.TryConvert(this.amountBox.Text, devise.Taux, out result))
                {
                    this.errorText.Text       = "La valeur que vous avez tapé est invalide !";
                    this.errorText.Visibility = Visibility.Visible;
                    this.convertedBox.Text    = "";
                }
                else
                {
                    this.InitializeError();
                    this.convertedBox.Text = result.ToString();
                }
            }
            else
            {
                this.errorText.Text       = "Veuillez entrer une valeur !";
                this.errorText.Visibility = Visibility.Visible;
            }
        }