//更新推荐 public static int UpdateRecomm(RecArticlescs arc) { string sql = string.Format("update [dbo].[RecArticles] set ArticleId={0},PosId={1},Weight={2} where Id='{3}'", arc.ArticleId, arc.PosId, arc.Weight, arc.Id); int count = DBHelper.ExecuteNonQuery(sql); return(count); }
//编辑推荐 public ActionResult Edit(string Id) { List <Articles> list = ArticleService.GetArticlesAll(); RecArticlescs arc = RecommendService.GetRecomById(Id); ViewBag.A = list; ViewBag.B = arc; return(View()); }
public ActionResult Edit(RecArticlescs arc) { int count = RecommendService.UpdateRecomm(arc); if (count >= 1) { return(Json(new UIResult(true, "编辑成功"))); } else { return(Json(new UIResult(false, "编辑失败"))); } }
//根据Id获取推荐 public static RecArticlescs GetRecomById(string Id) { RecArticlescs art = null; string sql = string.Format("select a.*,b.Title from [dbo].[RecArticles] a join [dbo].[Articles] b on b.Id=ArticleId where a.Id={0}", Id); using (SqlDataReader dr = DBHelper.ExecuteReader(sql)) { while (dr.Read()) { art = new RecArticlescs { Id = dr["Id"].ToString(), ArticleId = dr["ArticleId"].ToString(), PosId = dr["PosId"].ToString(), Weight = dr["Weight"].ToString(), Title = dr["Title"].ToString(), }; } } return(art); }