private void pictOK_Click(object sender, EventArgs e) { try { //if (textTitular.Text.Equals("")) throw new Exception("Campo Titular Incompleto."); if (tURL.Text.Trim().Equals("")) { throw new Exception("Imagen Requerida."); } String titular = textTitular.Text; ImagenesDB.WePassEntities1 contexto = new ImagenesDB.WePassEntities1(); ImagenesDB.Noticias n = new ImagenesDB.Noticias(); n.titular = titular; n.fechaPublicacion = DateTime.Today; ImageConverter _imageConverter = new ImageConverter(); n.imagen = (byte[])_imageConverter.ConvertTo(pict.Image, typeof(byte[])); contexto.Noticias.Add(n); contexto.SaveChanges(); this.Close(); } catch (Exception ex) { DialogResult emCierreDialog; string mensaje = "Se ha producido un error. " + ex.Message; string caption = "Lo sentimos..."; MessageBoxButtons buttons = MessageBoxButtons.OK; emCierreDialog = MessageBox.Show(mensaje, caption, buttons); } }
private void CargarImagen() { table.Controls.Clear(); ImagenesDB.Noticias n = noticias[i]; CartelNoticias cartel = new CartelNoticias(n); table.Controls.Add(cartel, 0, 0); //table.RowCount = table.RowCount + 1; }
public CartelNoticias(ImagenesDB.Noticias n) { InitializeComponent(); this.n = n; MemoryStream m_MemoryStream = new MemoryStream(n.imagen); this.pictureBox1.Image = Image.FromStream(m_MemoryStream); this.pictureBox1.Controls.Add(lTitular); this.lTitular.Text = n.titular; }
public CNoticia(ImagenesDB.Noticias n) { InitializeComponent(); this.n = n; MemoryStream m_MemoryStream = new MemoryStream(n.imagen); this.pictImage.BackgroundImage = Image.FromStream(m_MemoryStream); this.lNoticia.Text = n.titular; this.lFecha.Text = n.fechaPublicacion.ToShortDateString(); }
private void bBorrarNoticia_Click(object sender, EventArgs eventArgs, ImagenesDB.Noticias n) { DialogResult emCierreDialog; string mensaje = "¿Está seguro de que quiere eliminarla?"; string caption = "¡AVISO!"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; emCierreDialog = MessageBox.Show(mensaje, caption, buttons); if (emCierreDialog == DialogResult.Yes) { ImagenesDB.WePassEntities1 contexto = new ImagenesDB.WePassEntities1(); var listaNoticias = contexto.Noticias; n = contexto.Noticias.First(x => x.idNoticia == n.idNoticia); listaNoticias.Remove(n); contexto.SaveChanges(); cargarNoticias(); } }