private void btnPesquisar_Click(object sender, RoutedEventArgs e) { try { int Id = Convert.ToInt32(txtPesquisar.Text); inst = conexao.Instituicoes.Find(Id); txtCNPJ.Text = inst.CNPJ; txtNome.Text = inst.Nome; txtEndereco.Text = inst.Endereco; txtBairro.Text = inst.Bairro; txtCidade.Text = inst.Cidade; txtTelefone.Text = inst.Telefone; txtemail.Text = inst.Email; cbUf.Text = inst.UF; txtPesquisar.Text = "Pesquise pelo ID"; } catch { txtPesquisar.Text = "Pesquise pelo ID"; MessageBox.Show("ID inválido", "Campo Vazio", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ComboBoxInstituicao_SelectionChanged(object sender, SelectionChangedEventArgs e) { inst = (Instituicoes)ComboBoxInstituicao.SelectedItem; }