示例#1
0
        public DataSet GetById(SqlConnection oConn, SqlTransaction oTran, Noticia oNoticia)
        {
            using (SqlDataAdapter adapter = new SqlDataAdapter())
            {
                using (SqlCommand oComm = new SqlCommand())
                {
                    try
                    {
                        DataSet ds = new DataSet();
                        oComm.Connection = oTran != null ? oTran.Connection : oConn;
                        oComm.Transaction = oTran;

                        oComm.CommandType = CommandType.Text;
                        oComm.CommandText = string.Format("SELECT [id],[titulo],[fecha],[cuerpo],[id_categoria] FROM {0}.{1} WHERE id=@id", Constants.esquema, Constants.tablaNoticias);

                        oComm.Parameters.AddWithValue("id",oNoticia.Id);

                        adapter.SelectCommand = oComm;
                        adapter.Fill(ds);

                        return ds;
                    }
                    finally
                    {
                    }
                }
            }
        }
示例#2
0
 protected void Publicar_Noticia(object sender, EventArgs e)
 {
     var oNoticia = new Noticia()
     {
         Titulo = txt_titulo.Text,
         Cuerpo = txt_cuerpo.Text,
         Fecha = date_fecha.SelectedDate,
         IdCategoria = int.Parse(ddl_categorias.SelectedValue)
     };
     using (NoticiaBusiness n = new NoticiaBusiness())
     {
         n.InsertNoticia(oNoticia);
     }
     lbl_resultado.Text = "Noticia publicada correctamente";            
     
 }
示例#3
0
        public void updateNoticia(Noticia oNoticia)
        {
            SqlConnection oConn = new SqlConnection(Constants.connectionString);

            oConn.Open();
            try
            {
                using (NoticiaDataAccess tDataAccess = new NoticiaDataAccess())
                {
                    tDataAccess.updateNoticia(oConn, null, oNoticia);
                }
            }
            finally
            {
                oConn.Close();
            }
        }
示例#4
0
        public DataSet GetNoticiaById(Noticia oNoticia)
        {
            SqlConnection oConn = new SqlConnection(Constants.connectionString);

            oConn.Open();
            try
            {
                using (NoticiaDataAccess tDataAccess = new NoticiaDataAccess())
                {
                    return(tDataAccess.GetById(oConn, null, oNoticia));
                }
            }
            finally
            {
                oConn.Close();
            }
        }
示例#5
0
        public void Insert(SqlConnection oConn, SqlTransaction oTran, Noticia oNoticia)
        {
            using (SqlCommand oComm = new SqlCommand())
            {
                oComm.Connection  = (oTran != null) ? oTran.Connection : oConn;
                oComm.Transaction = oTran;

                oComm.CommandType = CommandType.Text;
                oComm.CommandText = string.Format("INSERT INTO {0}.{1}(titulo,fecha,cuerpo,id_categoria,autor) VALUES (@titulo, @fecha, @cuerpo, @id_categoria, @autor)", Constants.esquema, Constants.tablaNoticias);
                oComm.Parameters.AddWithValue("@titulo", oNoticia.Titulo);
                oComm.Parameters.AddWithValue("@fecha", oNoticia.Fecha);
                oComm.Parameters.AddWithValue("@cuerpo", oNoticia.Cuerpo);
                oComm.Parameters.AddWithValue("@id_categoria", oNoticia.IdCategoria == null ? DBNull.Value : (object)oNoticia.IdCategoria);
                oComm.Parameters.AddWithValue("@cuerpo", oNoticia.Autor);

                oComm.ExecuteNonQuery();
            }
        }
示例#6
0
        public void Insert(SqlConnection oConn, SqlTransaction oTran, Noticia oNoticia)
        {
            using (SqlCommand oComm = new SqlCommand())
            {
                oComm.Connection = (oTran != null) ? oTran.Connection : oConn;
                oComm.Transaction = oTran;

                oComm.CommandType = CommandType.Text;
                oComm.CommandText = string.Format("INSERT INTO {0}.{1}(titulo,fecha,cuerpo,id_categoria) VALUES (@titulo, @fecha, @cuerpo, @id_categoria)", Constants.esquema, Constants.tablaNoticias);

                oComm.Parameters.AddWithValue("@titulo", oNoticia.Titulo);
                oComm.Parameters.AddWithValue("@fecha", oNoticia.Fecha);
                oComm.Parameters.AddWithValue("@cuerpo", oNoticia.Cuerpo);                
                oComm.Parameters.AddWithValue("@id_categoria", oNoticia.IdCategoria == null ? DBNull.Value : (object)oNoticia.IdCategoria);

                oComm.ExecuteNonQuery();
            }
        }
示例#7
0
        public void InserirNoticia(Noticia noticia)
        {
            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();

            string sql = "INSERT INTO Noticias VALUES (@titulo, @data, @texto)";

            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@titulo", noticia.Titulo);
            cmd.Parameters.AddWithValue("@data", noticia.DataPublicacao);
            cmd.Parameters.AddWithValue("@texto", noticia.Texto);

            cmd.ExecuteNonQuery();

            conn.Close();
        }
示例#8
0
        public void AtualizarNoticia(Noticia noticia)
        {
            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();

            string sql = "UPDATE Noticias SET Titulo = @titulo, DataPublicacao = @data, Texto = @texto WHERE Codigo = @cod";
            //string sql = "UPDATE Produtoss SET Descricao = @desc, ValorUnitario = @unit, PesoKG = @peso WHERE Codigo = @cod";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@cod", noticia.Codigo);
            cmd.Parameters.AddWithValue("@titulo", noticia.Titulo);
            cmd.Parameters.AddWithValue("@data", noticia.DataPublicacao);
            cmd.Parameters.AddWithValue("@texto", noticia.Texto);

            cmd.ExecuteNonQuery();

            conn.Close();
        }
示例#9
0
 private void detach_Noticia(Noticia entity)
 {
     this.SendPropertyChanging();
     entity.Seccion = null;
 }
示例#10
0
 private void attach_Noticia(Noticia entity)
 {
     this.SendPropertyChanging();
     entity.Seccion = this;
 }
示例#11
0
 partial void DeleteNoticia(Noticia instance);
示例#12
0
 partial void UpdateNoticia(Noticia instance);
示例#13
0
 partial void InsertNoticia(Noticia instance);
示例#14
0
 private void detach_Noticia(Noticia entity)
 {
     this.SendPropertyChanging();
     entity.Pelicula = null;
 }
示例#15
0
 private void attach_Noticia(Noticia entity)
 {
     this.SendPropertyChanging();
     entity.Pelicula = this;
 }