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;
     }
 }
Exemple #2
0
        public bool Add(Model_NoticeBoard model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into NoticeBoard(");
            builder.Append("notice_id,notice_title,notice_content,create_time,create_userid,start_time,end_time)");
            builder.Append(" values (");
            builder.Append("@notice_id,@notice_title,@notice_content,@create_time,@create_userid,@start_time,@end_time)");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@notice_id", SqlDbType.NChar, 0x24), new SqlParameter("@notice_title", SqlDbType.NVarChar, 200), new SqlParameter("@notice_content", SqlDbType.Text), new SqlParameter("@create_time", SqlDbType.DateTime), new SqlParameter("@create_userid", SqlDbType.NChar, 0x24), new SqlParameter("@start_time", SqlDbType.DateTime), new SqlParameter("@end_time", SqlDbType.DateTime) };
            cmdParms[0].Value = model.notice_id;
            cmdParms[1].Value = model.notice_title;
            cmdParms[2].Value = model.notice_content;
            cmdParms[3].Value = model.create_time;
            cmdParms[4].Value = model.create_userid;
            cmdParms[5].Value = model.start_time;
            cmdParms[6].Value = model.end_time;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
        public List <Model_NoticeBoard> DataTableToList(DataTable dt)
        {
            List <Model_NoticeBoard> list = new List <Model_NoticeBoard>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Model_NoticeBoard item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
 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;
     }
 }
Exemple #5
0
        public bool Update(Model_NoticeBoard model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update NoticeBoard set ");
            builder.Append("notice_title=@notice_title,");
            builder.Append("notice_content=@notice_content,");
            builder.Append("create_time=@create_time,");
            builder.Append("create_userid=@create_userid,");
            builder.Append("start_time=@start_time,");
            builder.Append("end_time=@end_time");
            builder.Append(" where notice_id=@notice_id ");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@notice_title", SqlDbType.NVarChar, 200), new SqlParameter("@notice_content", SqlDbType.Text), new SqlParameter("@create_time", SqlDbType.DateTime), new SqlParameter("@create_userid", SqlDbType.NChar, 0x24), new SqlParameter("@start_time", SqlDbType.DateTime), new SqlParameter("@end_time", SqlDbType.DateTime), new SqlParameter("@notice_id", SqlDbType.NChar, 0x24) };
            cmdParms[0].Value = model.notice_title;
            cmdParms[1].Value = model.notice_content;
            cmdParms[2].Value = model.create_time;
            cmdParms[3].Value = model.create_userid;
            cmdParms[4].Value = model.start_time;
            cmdParms[5].Value = model.end_time;
            cmdParms[6].Value = model.notice_id;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Exemple #6
0
        public Model_NoticeBoard DataRowToModel(DataRow row)
        {
            Model_NoticeBoard board = new Model_NoticeBoard();

            if (row != null)
            {
                if (row["notice_id"] != null)
                {
                    board.notice_id = row["notice_id"].ToString();
                }
                if (row["notice_title"] != null)
                {
                    board.notice_title = row["notice_title"].ToString();
                }
                if (row["notice_content"] != null)
                {
                    board.notice_content = row["notice_content"].ToString();
                }
                if ((row["create_time"] != null) && (row["create_time"].ToString() != ""))
                {
                    board.create_time = new DateTime?(DateTime.Parse(row["create_time"].ToString()));
                }
                if (row["create_userid"] != null)
                {
                    board.create_userid = row["create_userid"].ToString();
                }
                if ((row["start_time"] != null) && (row["start_time"].ToString() != ""))
                {
                    board.start_time = new DateTime?(DateTime.Parse(row["start_time"].ToString()));
                }
                if ((row["end_time"] != null) && (row["end_time"].ToString() != ""))
                {
                    board.end_time = new DateTime?(DateTime.Parse(row["end_time"].ToString()));
                }
            }
            return(board);
        }
 public bool Add(Model_NoticeBoard model)
 {
     return(this.dal.Add(model));
 }
 public bool Update(Model_NoticeBoard model)
 {
     return(this.dal.Update(model));
 }