public ActionResult ModifyNewsCate() { if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 102)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation validation = new Validation(); int categoryID = validation.GetInt("categoryID"); NewsBLL newsBLL = new NewsBLL(); NewsCateObj newsCateObj = newsBLL.GetNewsCateByCateID(categoryID); if (newsCateObj != null) { newsCateObj.CategoryName = validation.Get("categoryName", false, "新闻分类名称不可为空!"); if (validation.HasError) { return(Json(new { success = false, msg = "ValidationFailed", errors = validation.GetErrors() })); } newsBLL.ModifyNewsCate(newsCateObj); return(Json(new { success = true })); } else { return(Json(new { success = false, msg = "该类别不存在!" })); } }
public ActionResult AddNewsCate() { if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 101)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation validation = new Validation(); NewsCateObj newsCateObj = new NewsCateObj(); newsCateObj.CategoryName = validation.Get("categoryName", false, "新闻分类名称不可为空!"); newsCateObj.ParentID = validation.GetInt("categoryID"); if (validation.HasError) { return(Json(new { success = false, msg = "ValidationFailed", errors = validation.GetErrors() })); } newsCateObj.Sort = DateTime.Now; NewsBLL newsBLL = new NewsBLL(); if (newsBLL.IsNewsCateExists(newsCateObj.ParentID, newsCateObj.CategoryName)) { return(Json(new { success = false, msg = "该类别已存在!" })); } newsBLL.AddNewsCate(newsCateObj); return(Json(new { success = true })); }
public ActionResult News(int id) { NewsBLL newsBLL = new NewsBLL(); NewsObj newsObj = newsBLL.GetNews(id); if (newsObj != null) { ViewBag.news = newsObj; ViewBag.nextNews = newsBLL.GetNextNews(id, newsObj.CategoryID); ViewBag.prevNews = newsBLL.GetPrevNews(id, newsObj.CategoryID); NewsCateObj newsCateObj = newsBLL.GetNewsCateByCateID(newsObj.CategoryID); int total; JsonArray cates = newsBLL.GetNewsCates(newsCateObj.ParentID); if (cates != null) { for (int i = 0; i < cates.Count; i++) { int categoryID = (int)cates[i]["categoryID"]; cates[i]["news"] = newsBLL.GetNews(categoryID, null, DateTime.MinValue, DateTime.MinValue, 1, 100, out total); } } ViewBag.cates = cates; } return(View()); }
public void ModifyNewsCate(NewsCateObj newsCateObj) { using (helper = new SqlHelper()) { helper.AddIntParameter("@CategoryID", newsCateObj.CategoryID); helper.AddStringParameter("@CategoryName", 50, newsCateObj.CategoryName); helper.AddIntParameter("@ParentID", newsCateObj.ParentID); helper.AddDateTimeParameter("@Sort", newsCateObj.Sort); helper.ExecuteNonQuery("update NewsCates set CategoryName=@CategoryName,ParentID=@ParentID,Sort=@Sort where CategoryID=@CategoryID", CommandType.Text); } }
public void AddNewsCate(NewsCateObj newsCateObj) { using (helper = new SqlHelper()) { SqlParameter idParam = helper.AddOutputParameter("@CategoryID"); helper.AddStringParameter("@CategoryName", 50, newsCateObj.CategoryName); helper.AddIntParameter("@ParentID", newsCateObj.ParentID); helper.AddDateTimeParameter("@Sort", newsCateObj.Sort); helper.ExecuteNonQuery("insert into NewsCates (CategoryName,ParentID,Sort) values (@CategoryName,@ParentID,@Sort) select @CategoryID=@@IDENTITY", CommandType.Text); newsCateObj.CategoryID = (int)idParam.Value; } }
public NewsCateObj GetNewsCateByCateID(int categoryID) { using (SqlHelper helper = new SqlHelper()) { helper.AddIntParameter("@CategoryID", categoryID); using (SqlDataReader dr = helper.ExecuteReader("select CategoryName,ParentID,Sort from NewsCates where CategoryID=@CategoryID order by Sort", CommandType.Text)) { if (dr.HasRows && dr.Read()) { NewsCateObj newsCateObj = new NewsCateObj(); newsCateObj.CategoryID = categoryID; newsCateObj.CategoryName = (string)dr[0]; newsCateObj.ParentID = (int)dr[1]; newsCateObj.Sort = (DateTime)dr[2]; return(newsCateObj); } else { return(null); } } } }
public void ModifyNewsCate(NewsCateObj newsCateObj) { dal.ModifyNewsCate(newsCateObj); }
public void AddNewsCate(NewsCateObj newsCateObj) { dal.AddNewsCate(newsCateObj); }