Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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);
            }
        }