protected void btnGuardarNotificacion_Click(object sender, EventArgs e) { String textoValidacion = validarNotificacion(false); if (textoValidacion.Equals("")) { Stream fs = upFileNotificacion.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); ARCHIVO archivo = new ARCHIVO(); archivo = archivo.addArchivo(Path.GetFileName(upFileNotificacion.PostedFile.FileName), Path.GetExtension(upFileNotificacion.PostedFile.FileName).Substring(1), bytes); if (archivo.ARCHIVOID != 0) { NOTIFICACION notificacion = new NOTIFICACION(); notificacion.addNotificacion(txtNombreNotificacion.Text, txtDescripcionNotificacion.Text, archivo.ARCHIVOID, Convert.ToInt32(lblInstitucionId.Text)); cargarNotificaciones(); lblSucess.Text = "Se creo Correctamente la Notificacion"; pnlSucess.Visible = true; } else { lblError.Text = "El archivo es demasiado pesado"; pnlError.Visible = true; } } else { lblError.Text = textoValidacion; pnlError.Visible = true; } }
private void editarNotificacion(int notificacionId) { NOTIFICACION notificacion = new NOTIFICACION(); notificacion = notificacion.obtainNotificacionById(notificacionId); lblArchivoId.Text = notificacion.ARCHIVOID.ToString(); lblArchivo.Text = "Archivo Anterior: " + notificacion.ARCHIVO.NOMBRE; edit(); }
public Notificacion(byte remitente, string titulo, string mensaje, string redireccion) { objectNotification = new NOTIFICACION() { empleado_remitente = remitente, titulo = titulo, mensaje = mensaje, redireccion = redireccion }; }
private void cargarNotificaciones() { NOTIFICACION notificacion = new NOTIFICACION(); List <NOTIFICACION> notificaciones = notificacion.obtainAllNotificaciones(); if (notificaciones != null && notificaciones.Count() > 0) { gridNotificaciones.DataSource = notificaciones; gridNotificaciones.DataBind(); } limpiar(); }
public ActionResult Remove(int id) { EMPLEADO empleado = this.empleado(); NOTIFICACION notificacion = db.NOTIFICACIONs.Single(n => n.empleado_receptor == empleado.id_empleado && n.id_notificacion == id);; notificacion.eliminado = 1; db.SaveChanges(); return(Json(new { valid = true })); }
public ActionResult MarkAsRead(int id) { EMPLEADO empleado = this.empleado(); NOTIFICACION notificacion = db.NOTIFICACIONs.Single(n => n.empleado_receptor == empleado.id_empleado && n.id_notificacion == id);; notificacion.leido = 1; notificacion.fecha_lectura = DateTime.Now; db.SaveChanges(); return(Json(new { valid = true })); }
public ActionResult View(int id) { EMPLEADO empleado = this.empleado(); NOTIFICACION notificacion = db.NOTIFICACIONs.Single(n => n.empleado_receptor == empleado.id_empleado && n.id_notificacion == id); if (notificacion.leido == 0) { notificacion.leido = 1; notificacion.fecha_lectura = DateTime.Now; db.SaveChanges(); } return(Redirect(notificacion.redireccion)); }
public int deleteNotificacion(int notificacionId) { int result = 0; NOTIFICACION notificacionDelete = obtainNotificacionById(notificacionId); if (notificacionDelete != null) { int archivoId = Convert.ToInt32(notificacionDelete.ARCHIVOID); Datos.NOTIFICACIONs.Remove(notificacionDelete); result = Datos.SaveChanges(); ARCHIVO archivo = new ARCHIVO(); archivo.deleteArchivo(archivoId); } return(result); }
protected void btnEliminarNotificacion_Click(object sender, EventArgs e) { String textoValidacion = validarNotificacion(true); if (textoValidacion.Equals("")) { NOTIFICACION notificacion = new NOTIFICACION(); notificacion.deleteNotificacion(Convert.ToInt32(lblNotificacionId.Text)); cargarNotificaciones(); lblSucess.Text = "Se elimino Correctamente la Notificacion"; pnlSucess.Visible = true; } else { lblError.Text = textoValidacion; pnlError.Visible = true; } }
protected void btnEditarNotificacion_Click(object sender, EventArgs e) { String textoValidacion = validarNotificacion(true); if (textoValidacion.Equals("")) { ARCHIVO archivo = new ARCHIVO(); archivo = archivo.obtainArchivoById(Convert.ToInt32(lblArchivoId.Text)); if (!archivo.NOMBRE.Equals(upFileNotificacion.PostedFile.FileName)) { Stream fs = upFileNotificacion.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); archivo = archivo.refreshArchivo(Convert.ToInt32(lblArchivoId.Text),Path.GetFileName(upFileNotificacion.PostedFile.FileName), Path.GetExtension(upFileNotificacion.PostedFile.FileName).Substring(1), bytes); } if (archivo.ARCHIVOID != 0) { NOTIFICACION notificacion = new NOTIFICACION(); notificacion.refreshNotificacion(Convert.ToInt32(lblNotificacionId.Text), txtNombreNotificacion.Text, txtDescripcionNotificacion.Text, archivo.ARCHIVOID, Convert.ToInt32(lblInstitucionId.Text)); cargarNotificaciones(); lblSucess.Text = "Se edito Correctamente la Notificacion"; pnlSucess.Visible = true; } else { lblError.Text = "El archivo es demasiado pesado o el formato no es valido"; pnlError.Visible = true; } } else { lblError.Text = textoValidacion; pnlError.Visible = true; } }
public NOTIFICACION addNotificacion(String nombre, String descripcion, int archivoId, int institucionId) { NOTIFICACION notificacion = new NOTIFICACION(); try { notificacion.NOTIFICACIONID = 0; notificacion.NOMBRE = nombre; notificacion.DESCRIPCION = descripcion; notificacion.ARCHIVOID = archivoId; notificacion.INSTITUCIONID = institucionId; Datos.NOTIFICACIONs.Add(notificacion); Datos.SaveChanges(); } catch (Exception ex) { string x = ex.Message; } return(notificacion); }
public NOTIFICACION addNotificacion(String nombre, String descripcion, int archivoId, int institucionId) { NOTIFICACION notificacion = new NOTIFICACION(); try { notificacion.NOTIFICACIONID = 0; notificacion.NOMBRE = nombre; notificacion.DESCRIPCION = descripcion; notificacion.ARCHIVOID= archivoId; notificacion.INSTITUCIONID = institucionId; Datos.NOTIFICACIONs.Add(notificacion); Datos.SaveChanges(); } catch (Exception ex) { string x = ex.Message; } return notificacion; }
private void cargarNotificaciones() { NOTIFICACION notificacion = new NOTIFICACION(); List<NOTIFICACION> notificaciones = notificacion.obtainAllNotificaciones(); if (notificaciones != null && notificaciones.Count() > 0) { gridNotificaciones.DataSource = notificaciones; gridNotificaciones.DataBind(); } limpiar(); }