Пример #1
0
        private async void LoadRates()
        {
            bool load;

            lblResultado.Text = "A atualizar taxas...";

            var connection = networkService.CherckConnection();

            if (!connection.IsSuccess)
            {
                LoadLocalRates();
                load = false;
            }
            else
            {
                await LoadApiRates();

                load = true;
            }

            if (Rates.Count == 0)
            {
                lblResultado.Text = "Não há ligação à internet" + Environment.NewLine + "e não foram previamente carregadas as taxas" +
                                    Environment.NewLine + "Tente mais tarde!";

                return;
            }

            comboBoxOrigem.DataSource    = Rates;
            comboBoxOrigem.DisplayMember = "Name";

            //Corrige bug da microsoft
            comboBoxDestino.BindingContext = new BindingContext();

            comboBoxDestino.DataSource    = Rates;
            comboBoxDestino.DisplayMember = "Name";



            lblResultado.Text = "Taxas atualizadas...";

            if (load)
            {
                lblStatus.Text = string.Format("Taxas carregadas da internet em {0:F}", DateTime.Now);
            }
            else
            {
                lblStatus.Text = string.Format("Taxas carregadas da base de dados.");
            }

            progressBar1.Value  = 100;
            btConverter.Enabled = true;
            btTroca.Enabled     = true;
        }