public BLL.Termos PreencherPeloID(BLL.Termos te)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con.Conectar();
            cmd.CommandText = @"SELECT Id_Termos, Termos FROM Termos WHERE  Id_Termos = @idtermos";
            cmd.Parameters.AddWithValue("@idtermos", te.IdTermos);

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                dr.Read();
                te.IdTermos  = Convert.ToInt32(dr["Id_Termos"]);
                te.TermosUso = dr["Termos"].ToString();
                dr.Close();
            }
            else
            {
                te.IdTermos = 0;
            }

            con.Desconectar();
            return(te);
        }
        public void Cadastrar(BLL.Termos te)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con.Conectar();

            cmd.CommandText = @"INSERT INTO Termos(Termos) VALUES (@termos)";
            cmd.Parameters.AddWithValue("@termos", te.TermosUso);

            cmd.ExecuteNonQuery();
            con.Desconectar();
        }
        public void Atualizar(BLL.Termos te)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con.Conectar();
            cmd.CommandText = @"UPDATE Termos SET Termos = @termos WHERE Id_Termos = @idtermos";

            cmd.Parameters.AddWithValue("@idtermos", te.IdTermos);
            cmd.Parameters.AddWithValue("@termos", te.TermosUso);

            cmd.ExecuteNonQuery();
            con.Desconectar();
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.Termos    te    = new BLL.Termos();
            DAL.TermosDAL teDAL = new DAL.TermosDAL();

            te.IdTermos = 2;

            te = teDAL.PreencherPeloID(te);
            string html = "";

            html += ("<a href='" + te.TermosUso + "' target='_blank'>&nbsp termos de uso e condições.</a>");

            litTermos.Text = html;
        }