Example #1
0
        /// <summary>
        /// 新增按钮
        /// </summary>
        /// <returns></returns>
        public JsonResult AddButton()
        {
            AjaxStatusModel ajax = new AjaxStatusModel(); //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;           //默认失败
            ajax.msg    = "新增失败!";                        //前台获取,用于显示提示信息
            var data = Request["data"];                   //获取前台传递的数据,主要序列化

            if (string.IsNullOrEmpty(data))
            {
                return(Json(ajax));
            }
            SYSButton btn = (SYSButton)(JsonConvert.DeserializeObject(data.ToString(), typeof(SYSButton)));

            btn.BTN_CreatedOn = DateTime.Now;
            btn.BTN_CreatedBy = UserSession.userid;
            if (ButtonData.AddButton(btn) > 0)//注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg    = "新增成功!";
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }