private void BtnBuscarPremio_Click(object sender, RoutedEventArgs e) //Buscar Premio { p = new Premio(); try { p.Descricao = txtPremio.Text; p = PremioDAO.BuscarPremio(p); if (p != null) //Premio encontrado { txtPremio.IsEnabled = false; txtPremio.Text = p.Descricao; lbPremioEncontrado.Content = "Premio encontrado!"; btnBuscarPremio.IsEnabled = false; // Desativa botao buscar if (txtFilme.IsEnabled == false) { btnCadastrarPremioFilme.IsEnabled = true; // ativa botão Cadastrar } } else { //Filme não encontrado txtPremio.Text = ""; throw new Exception("Premio não encontrado!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnCadastrarPremio_Click(object sender, RoutedEventArgs e) { try { Premio p = new Premio(); p.Descricao = txtDescricaoPremio.Text; if (txtDescricaoPremio.Text.Equals("")) { throw new Exception("É Obrigatório o campo DESCRIÇÃO!"); } if (PremioDAO.BuscarPremio(p) != null) { throw new Exception("Premio já está cadastrado!"); } PremioDAO.CadastrarPremio(p); MessageBox.Show("Premio cadastrado com sucesso"); LimparFormulario(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }