Beispiel #1
0
 protected void lbtnIngresaRelevantes_Click(object sender, EventArgs e)
 {
     try
     {
         NOTICIAS not = new NOTICIAS();
         foreach (GridViewRow grd_Row in grvNoticias.Rows)
         {
             Label    _lblIdNoticia = (Label)grvNoticias.Rows[grd_Row.RowIndex].FindControl("lblIdNoticia");
             CheckBox chk           = (CheckBox)grvNoticias.Rows[grd_Row.RowIndex].FindControl("chkSeleccionar");
             if (chk.Checked == true)
             {
                 not.ID_NOTICIA = _lblIdNoticia.Text;
                 //ingreso la noticia relevante con cambio de estado dentro del query
                 dal.setInNoticiaRelevante(not);
             }
         }
         string idAlerta = hfAlerta.Value;
         if (string.IsNullOrEmpty(idAlerta))
         {
             Buscar(null);
         }
         else
         {
             Buscar(idAlerta);
         }
     }
     catch (Exception ex)
     {
         divAlerta.Visible = true;
         lblInfo.Text      = ex.Message;
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            NOTICIAS nOTICIAS = db.NOTICIAS.Find(id);

            db.NOTICIAS.Remove(nOTICIAS);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Id_Local,Titulo,Descripcion,Destacado,Fecha")] NOTICIAS nOTICIAS)
 {
     if (ModelState.IsValid)
     {
         nOTICIAS.Fecha           = DateTime.Now;
         db.Entry(nOTICIAS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id_Local = new SelectList(db.LOCALES, "Id", "Nombre", nOTICIAS.Id_Local);
     return(View(nOTICIAS));
 }
        // GET: Noticias/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NOTICIAS nOTICIAS = db.NOTICIAS.Find(id);

            if (nOTICIAS == null)
            {
                return(HttpNotFound());
            }
            return(View(nOTICIAS));
        }
        // GET: Noticias/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NOTICIAS nOTICIAS = db.NOTICIAS.Find(id);

            if (nOTICIAS == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_Local = new SelectList(db.LOCALES, "Id", "Nombre", nOTICIAS.Id_Local);
            return(View(nOTICIAS));
        }
Beispiel #6
0
        void Buscar(string idAlerta)
        {
            NOTICIAS  noti = new NOTICIAS();
            DataTable dt   = new DataTable();

            noti.ID_ALERT          = idAlerta;
            noti.IdEstado          = Convert.ToInt32(ddlEstado.SelectedValue);
            noti.IdUsuarioAsignado = Convert.ToInt32(ddlUsuarioAsignado.SelectedValue);
            noti.Relevante         = Convert.ToInt32(ddlRelevante.SelectedValue);

            dt = dal.getBuscarNoticias(noti, txtFechaDesde.Text.Trim(), txtFechaHasta.Text.Trim()).Tables[0];
            Session["sessionDtNoticias"] = dt;
            grvNoticias.DataSource       = dt;
            grvNoticias.DataBind();

            divGrilla.Visible = true;
            //dt = dal.getBuscarNoticias()
        }
Beispiel #7
0
        public void setInNoticiaRelevante(NOTICIAS not)
        {
            DbCommand cmd = db.GetStoredProcCommand("stp_IngresaNoticiaRelevante");

            db.AddInParameter(cmd, "@idNoticia", DbType.String, not.ID_NOTICIA);

            try
            {
                db.ExecuteNonQuery(cmd);
            }
            catch (SqlException ex)
            {
                throw new Exception("No se pudo ingresar el archivo, " + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo ingresar el archivo, " + ex.Message, ex);
            }
        }
Beispiel #8
0
        public DataSet getBuscarNoticiasRelevantes(NOTICIAS noti, string fechaDesde, string fechaHasta)
        {
            //          @idAlert varchar(100),
            //@titulo varchar(max),@descripcion varchar(max),@fechaDesde varchar(10),
            //@fechaHasta varchar(10),@idEstado varchar(5),@relevante varchar(5),
            //@idComuna varchar(10),@idUsuarioAsignado varchar(10)
            DbCommand cmd = db.GetStoredProcCommand("stp_BuscarNoticiasRelevantes");

            db.AddInParameter(cmd, "@idAlert", DbType.String, noti.ID_ALERT);
            db.AddInParameter(cmd, "@titulo", DbType.String, noti.TITULO);
            db.AddInParameter(cmd, "@descripcion", DbType.String, noti.DESCRIPCION);
            if (fechaDesde == string.Empty)
            {
                db.AddInParameter(cmd, "@fechaDesde", DbType.String, null);
            }
            else
            {
                db.AddInParameter(cmd, "@fechaDesde", DbType.String, fechaDesde);
            }
            if (fechaHasta == string.Empty)
            {
                db.AddInParameter(cmd, "@fechaHasta", DbType.String, null);
            }
            else
            {
                db.AddInParameter(cmd, "@fechaHasta", DbType.String, fechaHasta);
            }

            if (noti.IdEstado == 0)
            {
                db.AddInParameter(cmd, "@idEstado", DbType.String, null);
            }
            else
            {
                db.AddInParameter(cmd, "@idEstado", DbType.String, noti.IdEstado);
            }
            if (noti.Relevante == 2)
            {
                db.AddInParameter(cmd, "@relevante", DbType.String, null);
            }
            else
            {
                db.AddInParameter(cmd, "@relevante", DbType.String, noti.Relevante);
            }

            db.AddInParameter(cmd, "@idComuna", DbType.String, noti.IdComuna);
            if (noti.IdUsuarioAsignado == 0)
            {
                db.AddInParameter(cmd, "@idUsuarioAsignado", DbType.String, null);
            }
            else
            {
                db.AddInParameter(cmd, "@idUsuarioAsignado", DbType.String, noti.IdUsuarioAsignado);
            }


            try
            {
                return(db.ExecuteDataSet(cmd));
            }
            catch (SqlException ex)
            {
                throw new Exception("Error en buscar las noticias relevantes, " + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("Error en buscar las noticias relevantes, " + ex.Message, ex);
            }
        }