Beispiel #1
0
        private void loadData()
        {
            BLL_NoticeBoard bll = new BLL_NoticeBoard();
            DataTable       dt  = new DataTable();

            dt = bll.GetList(1, "", " create_time desc").Tables[0];
            foreach (DataRow item in dt.Rows)
            {
                ltlContent.Text    = item["notice_content"].ToString();
                ltlCreateTime.Text = pfunction.ConvertToLongDateTime(item["create_time"].ToString(), "yyyy年MM月dd日");
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(notice_id))
         {
             BLL_NoticeBoard   bll   = new BLL_NoticeBoard();
             Model_NoticeBoard model = new Model_NoticeBoard();
             model = bll.GetModel(notice_id);
             model.notice_title   = this.txt_title.Text.TrimEnd();
             model.notice_content = this.txt_content.Value;
             model.create_time    = DateTime.Now;
             model.start_time     = Convert.ToDateTime(this.txtStartTime.Value);
             model.end_time       = Convert.ToDateTime(this.txtEndTime.Value);
             if (bll.Update(model))
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改成功', { time: 1000, icon: 1},function(){parent.loadData();parent.layer.close(index)})})})</script>");
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改失败', {icon: 2})})})</script>");
                 return;
             }
         }
         else
         {
             BLL_NoticeBoard   bll   = new BLL_NoticeBoard();
             Model_NoticeBoard model = new Model_NoticeBoard();
             model.notice_title   = this.txt_title.Text.TrimEnd();
             model.notice_content = this.txt_content.Value;
             model.notice_id      = Guid.NewGuid().ToString();
             model.create_time    = DateTime.Now;
             model.start_time     = Convert.ToDateTime(this.txtStartTime.Value);
             model.end_time       = Convert.ToDateTime(this.txtEndTime.Value);
             model.create_userid  = loginUser.SysUser_ID;
             if (bll.Add(model))
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('添加成功', { time: 1000, icon: 1},function(){parent.loadData();parent.layer.close(index)})})})</script>");
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('添加失败', {icon: 2})})})</script>");
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 公告
 /// </summary>
 private void noticeBoard()
 {
     try
     {
         BLL_NoticeBoard bll = new BLL_NoticeBoard();
         DataTable       dt  = new DataTable();
         dt = bll.GetList(1, "", " create_time desc").Tables[0];
         foreach (DataRow item in dt.Rows)
         {
             if (Convert.ToDateTime(item["start_time"]) <= DateTime.Now && Convert.ToDateTime(item["end_time"]) > DateTime.Now)
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "login", "<script>layer.open({type: 2,title: false,closeBtn: false,shade: false,area:['600px','80%'],content: 'noticeBoard.aspx'});</script>");
             }
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #4
0
 public static string delete(string notice_id)
 {
     try
     {
         BLL_NoticeBoard bll = new BLL_NoticeBoard();
         if (bll.Delete(notice_id))
         {
             return("1");
         }
         else
         {
             return("");
         }
     }
     catch (Exception ex)
     {
         return("");
     }
 }
 private void LoadData()
 {
     try
     {
         BLL_NoticeBoard   bll   = new BLL_NoticeBoard();
         Model_NoticeBoard model = new Model_NoticeBoard();
         model = bll.GetModel(notice_id);
         if (model != null)
         {
             this.txt_title.Text     = model.notice_title;
             this.txt_content.Value  = model.notice_content;
             this.txtStartTime.Value = pfunction.ConvertToLongDateTime(model.start_time.ToString(), "yyyy-MM-dd HH:mm");
             this.txtEndTime.Value   = pfunction.ConvertToLongDateTime(model.end_time.ToString(), "yyyy-MM-dd HH:mm");
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #6
0
        public static string GetList(string key, int PageIndex, int PageSize)
        {
            try
            {
                key       = key.Filter();
                PageIndex = Convert.ToInt32(PageIndex.ToString().Filter());
                DataTable     dt          = new DataTable();
                List <object> listReturn  = new List <object>();
                string        strSql      = string.Empty;
                string        strSqlCount = string.Empty;
                string        strWhere    = "1=1 ";

                if (!string.IsNullOrEmpty(key))
                {
                    strWhere += " and notice_title like '%" + key + "%'";
                }
                BLL_NoticeBoard bll = new BLL_NoticeBoard();
                dt = bll.GetListByPage(strWhere, "create_time desc", ((PageIndex - 1) * PageSize + 1), (PageIndex * PageSize)).Tables[0];
                int rCount = bll.GetRecordCount(strWhere);
                int inum   = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    inum++;
                    listReturn.Add(new
                    {
                        inum           = (i + 1),
                        notice_id      = dt.Rows[i]["notice_id"].ToString(),
                        notice_title   = dt.Rows[i]["notice_title"].ToString(),
                        notice_content = pfunction.GetSubstring(dt.Rows[i]["notice_content"].ToString(), 200, true),
                        create_time    = pfunction.ConvertToLongDateTime(dt.Rows[i]["create_time"].ToString(), "yyyy-MM-dd HH:mm:ss"),
                        start_time     = pfunction.ConvertToLongDateTime(dt.Rows[i]["start_time"].ToString(), "yyyy-MM-dd HH:mm"),
                        end_time       = pfunction.ConvertToLongDateTime(dt.Rows[i]["end_time"].ToString(), "yyyy-MM-dd HH:mm"),
                    });
                }

                if (inum > 0)
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "null",
                        PageIndex = PageIndex,
                        PageSize = PageSize,
                        TotalCount = rCount,
                        list = listReturn
                    }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "暂无数据"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new
                {
                    err = "error"//ex.Message.ToString()
                }));
            }
        }