private void btnEditar_Click(object sender, EventArgs e) { CadastroNoticia a = new CadastroNoticia(); a.setId(int.Parse(txtId.Text)); a.setTitulo(txtTitulo.Text); a.setDescricao(txtDesc.Text); foreach (string h in clTags.CheckedItems) { d.setNome(h.ToString()); consultaDao.associarTag(d, a); } consultaDao.atualizarNoticia(a); listarTable(); txtId.Clear(); txtDesc.Clear(); txtTitulo.Clear(); txtAtt.Clear(); foreach (int i in clTags.CheckedIndices) { clTags.SetItemCheckState(i, CheckState.Unchecked); } }
private void button1_Click(object sender, EventArgs e) { if (txtNome.Text != "" && txtDesc.Text != "") { d.setNome(txtNome.Text); d.setDesc(txtDesc.Text); b.criarTag(d); MessageBox.Show("Registro inserido com sucesso!"); txtNome.Clear(); txtDesc.Clear(); } }
private void btnCad_Click(object sender, EventArgs e) { if (!(txtTitulo.Text == "" || txtDesc.Text == "")) { a.setTitulo(txtTitulo.Text); a.setDescricao(txtDesc.Text); c.criarNoticia(a); foreach (string a in clTags.CheckedItems) { d.setNome(a.ToString()); c.associarTag(d); } } MessageBox.Show("Registro inserido com sucesso!"); }
private void btnEditar_Click(object sender, EventArgs e) { CadastroTags a = new CadastroTags(); a.setId(int.Parse(txtId.Text)); a.setNome(txtNome.Text); a.setDesc(txtDesc.Text); consultaDao.atualizarTag(a); listarTable(); txtId.Clear(); txtNome.Clear(); txtDesc.Clear(); }
public CadastroTags listarTags(int id) { conn = classeConexão.obterConexao(); if (conn.State == ConnectionState.Open) { SqlCommand cmd = new SqlCommand("select * from Tags where idTags = @id", conn); SqlDataReader reader; cmd.Parameters.AddWithValue("@id", id); reader = cmd.ExecuteReader(); try { CadastroTags a = new CadastroTags(); if (reader.Read()) { a.setId(int.Parse(reader[0].ToString())); a.setNome(reader[1].ToString()); a.setDesc(reader[2].ToString()); return(a); } else { return(null); } } catch (Exception error) { MessageBox.Show("Erro: " + error); return(null); } finally { reader.Close(); cmd.Dispose(); classeConexão.fecharConexao(); } } else { return(null); } }
private void btnCad_Click(object sender, EventArgs e) { if (!(txtTitulo.Text == "" || txtDesc.Text == "" || txtLink.Text == "")) { a.setTitulo(txtTitulo.Text); a.setDescricao(txtDesc.Text); a.setLink(txtLink.Text); c.criarNoticia(a); foreach (string h in clTags.CheckedItems) { d.setNome(h.ToString()); c.associarTag(d, a); } txtDesc.Clear(); txtLink.Clear(); txtTitulo.Clear(); } else { MessageBox.Show("Erro", "preencha todas os campos"); } MessageBox.Show("Registro inserido com sucesso!"); }