protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { NoticeBll bll = new NoticeBll(); title = Request["navname"]; news = Request["navnews"]; if (title != "" && news != "") { DataTable dt = bll.showNotice(); foreach (DataRow item in dt.Rows) { if (item["title"].ToString() == title) { Response.Write("<script>alert('通知标题不能重复!!!');</script>"); title = ""; return; } } Notice model = new Notice(); model.Title = title; model.News = news; model.Time = Convert.ToString(DateTime.Now); int result = bll.AddNotice(model); if (result > 0) { Response.Write("<script>alert('添加成功!')window.location.href='InformList.aspx'</script>"); } } else { Response.Write("<script>alert('通知标题不能为空!!!');</script>"); } } }
/// <summary> /// 新增公告/消息 /// </summary> /// <param name="UserID">用户id</param> /// <param name="NoticeTitle">标题</param> /// <param name="NoticeConten">内容</param> /// <returns></returns> public JsonResult NoticeAdd(string UserID, string NoticeTitle, string NoticeConten) { NoticeTable notice = new NoticeTable() { UserID = Convert.ToInt32(UserID), NoticeTitle = NoticeTitle, NoticeContent = NoticeConten }; if (NoticeBll.AddNotice(notice)) { return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }