private void btn_salvar_Click(object sender, EventArgs e) { try { DadosDaConexao dc = new DadosDaConexao(); DALConexao cx = new DALConexao(dc.StringDeConexao); BLLCandidatos bllcandidato = new BLLCandidatos(cx); MODELOCandidato p = new MODELOCandidato(); p.Idpessoa = TXTIDPESSOA.Text; p.Ideleicao = TXTIDEELICAO.Text; p.Idempresa = TXTIDEMPRESA.Text; p.Numero = TXTNUMERO.Text; p.Slogan = TXTSLOGAN.Text; p.Descricao = TXTDESCRICAO.Text; if (p.Foto != null) { IMG.Image = p.getImagem(); } bllcandidato.Incluir(p); MessageBox.Show("Candidato inserido com sucesso " + p.Ideleicao); } catch (MySqlException ex) { if (ex.Message.Contains("Duplicate")) { MessageBox.Show("Registro j'a existe no banco de dados"); } else { MessageBox.Show("Falha ao inserir errro:" + ex.Message); } } catch (Exception ex) { MessageBox.Show("Falha ao inserir errro geral:" + ex.Message); } }