public BE.BE_Categoria BuscarCategoriaPorID(int id) { DataSet ds = new DataSet(); Hashtable filtros = new Hashtable(); filtros.Add("@id", id); ds = sqlHelper.Leer("categoria_BuscarPorID", filtros); BE.BE_Categoria categoria = new BE.BE_Categoria(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { categoria.ID = int.Parse(item["id_categoria"].ToString()); categoria.NOMBRE = item["nombre"].ToString(); } } } return(categoria); }
public List <BE.BE_Categoria> Listar(Hashtable filtros) { DataSet ds = new DataSet(); ds = sqlHelper.Leer("categoria_leer", filtros); List <BE.BE_Categoria> listado = new List <BE.BE_Categoria>(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { BE.BE_Categoria unaCate = new BE.BE_Categoria(); unaCate.ID = int.Parse(item["id_categoria"].ToString()); unaCate.NOMBRE = item["nombre"].ToString(); listado.Add(unaCate); } } } return(listado); }
protected void btnGuardar_Click(object sender, EventArgs e) { try { //LiteralHTML.Text = txtEditor.Text; BE.BE_Noticia unaNoti = new BE.BE_Noticia(); BE.BE_Categoria categoria = new BE.BE_Categoria(); categoria.ID = int.Parse(DDCategorias.SelectedItem.Value); categoria.NOMBRE = DDCategorias.SelectedItem.Text; unaNoti.CATEGORIA = categoria; unaNoti.TITULO = TxtTitulo.Text; unaNoti.CUERPO = WebUtility.HtmlEncode(txtEditor.Text); if (TxtFechaCreacion.Text != "") { unaNoti.FECHACREACION = DateTime.Parse(TxtFechaCreacion.Text); } else { unaNoti.FECHACREACION = DateTime.Now; } unaNoti.FECHAMODIFICACION = DateTime.Now; if (ChkHabilitado.Checked) { unaNoti.HABILITADO = 1; } else { unaNoti.HABILITADO = 0; } if (HFIdNoticia.Value != "") { unaNoti.ID = int.Parse(HFIdNoticia.Value); gestorNoticia.ActualizarNoticia(unaNoti); } else { unaNoti.ID = gestorNoticia.ObtenerUltimoIDNoticia(); gestorNoticia.InsertarNoticia(unaNoti); } MostrarNoticia(unaNoti); ModalPopUpMensajes.Show(); LabelMensaje.Text = "Noticia Guardada con exito."; } catch (Exception ex) { ModalPopUpMensajes.Show(); LabelMensaje.Text = "Error al guardar en la base de datos."; } }