示例#1
0
 private void anoModeloFipe_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (anoModeloFipe.SelectedIndex >= 0)
     {
         botaobuscar.BackgroundImage = Properties.Resources.CarregandoParado;
         FipeQuery query = new FipeQuery();
         FipeModel model = query.QueryValuationByFipeModel(anoModeloFipe.SelectedItem as FipeModel);
         modelo.Text                 = model.Modelo;
         marca.Text                  = model.Marca;
         valorFipe.Text              = model.PrecoMedio.ToString("C2", CultureInfo.CurrentCulture);
         anoModeloTexto.Text         = model.Label;
         botaobuscar.BackgroundImage = Properties.Resources.Buscar;
     }
 }
示例#2
0
        private async void botaobuscar_Click(object sender, EventArgs e)
        {
            botaobuscar.Enabled         = false;
            botaobuscar.BackgroundImage = Properties.Resources.CarregandoParado;

            if (WebFile.HasInternet())
            {
                FipeQuery        query   = new FipeQuery();
                List <FipeModel> modelos = await query.QueryYear_modelsByFipeCode(codFipe.Text);

                if (modelos.Count > 0)
                {
                    switch (modelos[0].TipoVeiculo)
                    {
                    case FipeType.Automóvel:
                        tipo1.Checked = true;
                        break;

                    case FipeType.Moto:
                        tipo2.Checked = true;
                        break;

                    case FipeType.Caminhão:
                        tipo3.Checked = true;
                        break;
                    }
                }
                anoModeloFipe.DisplayMember = "Label";
                anoModeloFipe.ValueMember   = "Value";
                anoModeloFipe.DataSource    = modelos;
            }
            else
            {
                MessageBox.Show("Sem acesso à internet!", "Carta de Cotação",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            botaobuscar.Enabled         = true;
            botaobuscar.BackgroundImage = Properties.Resources.Buscar;
        }