コード例 #1
0
ファイル: List.aspx.cs プロジェクト: libao123/stuCMS
        private string GetNotice()
        {
            try
            {
                if (string.IsNullOrEmpty(Get("id")))
                {
                    return(string.Empty);
                }

                Notice_info head = new Notice_info();
                head.OID = Get("id");
                ds.RetrieveObject(head);

                StringBuilder json = new StringBuilder();//用来存放Json的
                json.Append("{");
                json.Append(Json.StringToJson(head.TITLE, "TITLE"));
                json.Append(",");
                json.Append(Json.StringToJson(head.SUB_TITLE, "SUB_TITLE"));
                json.Append(",");
                json.Append(Json.StringToJson(head.FUNCTION_ID, "FUNCTION_ID"));
                json.Append(",");
                json.Append(Json.StringToJson(head.START_TIME, "START_TIME"));
                json.Append(",");
                json.Append(Json.StringToJson(head.END_TIME, "END_TIME"));
                json.Append(",");
                json.Append(Json.StringToJson(head.ROLEID, "ROLEID"));
                json.Append("}");
                return(json.ToString());
            }
            catch (Exception ex)
            {
                LogDBHandleClass.getInstance().LogException(CValue.LOG_LEVEL_ERROR, "奖助项目设置,获得公告信息,出错:" + ex.ToString());
                return(string.Empty);
            }
        }
コード例 #2
0
        public string GetNoticeInfo(int id)
        {
            Notice_info notice_Info = db.Notice_info.Where(p => p.id == id).FirstOrDefault();

            notice_Info.Reading++;
            db.SaveChanges();

            var data = from a in db.Notice_info
                       join b in db.User_info
                       on a.Author equals b.ID
                       where a.id == id && a.State == true
                       select new
            {
                a.id,
                a.Title,
                a.NoticeContent,
                a.CreationDate,
                b.Name
            };

            JavaScriptSerializer jss = new JavaScriptSerializer();
            StringBuilder        sb  = new StringBuilder();
            string json = jss.Serialize(data).ToString();

            return(json);
        }
コード例 #3
0
 public ActionResult NoticeDelete(Notice_info notice)
 {
     try
     {
         notice       = db.Notice_info.Where(p => p.id == notice.id).FirstOrDefault();
         notice.State = false;
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
コード例 #4
0
 public ActionResult NoticeEditHandle(Notice_info notice)
 {
     ///添加公告信息
     if (notice.Title != null && notice.NoticeContent != null)
     {
         notice.CreationDate = DateTime.Now.ToString();
         notice.Author       = Convert.ToInt32(Session["UserId"].ToString());
         notice.State        = true;
         try
         {
             db.Notice_info.Add(notice);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             throw;
         }
     }
     else
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }