コード例 #1
0
ファイル: AfScriptTypeController.cs プロジェクト: radtek/SRMS
        public ActionResult Edit(BLL.FW.BF_ST_TYPE.Entity entity)
        {
            JsonResultData result = new JsonResultData();

            #region 验证
            if (string.IsNullOrEmpty(entity.NAME))
            {
                result.IsSuccess = false;
                result.Message   = "类型名称不能为空,提交失败!";

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            #endregion

            int intResult = 0;
            int intUserId = BLL.FW.SystemSession.UserID;//当前登录

            #region 封装数据
            Dictionary <string, object> dic = new Dictionary <string, object>();
            dic.Add("NAME", entity.NAME);
            dic.Add("REMARK", entity.REMARK);
            dic.Add("PID", entity.PID);
            dic.Add("UPDATE_TIME", DateTime.Now);
            dic.Add("UPDATE_UID", intUserId);
            #endregion

            try
            {
                if (entity.ID == entity.PID && entity.PID != 0)
                {
                    result.Message = "父级节点不能与当前目节点为同一级,数据提交失败!";
                }
                else
                {
                    if (entity.ID > 0) //增加与修改的判断
                    {                  //修改
                        intResult = BF_ST_TYPE.Instance.UpdateByKey(dic, entity.ID);
                    }
                    else
                    {//增加
                        dic.Add("CREATE_TIME", DateTime.Now);
                        dic.Add("CREATE_UID", intUserId);
                        intResult = BF_ST_TYPE.Instance.Add(dic);
                    }
                    result.IsSuccess = intResult > 0;
                    result.Message   = intResult > 0 ? "数据提交成功!" : "数据提交失败!";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: AfScriptTypeController.cs プロジェクト: radtek/SRMS
        /// <summary>
        /// 编辑及新增
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id = 0)
        {
            ViewBag.Result  = false;
            ViewBag.Message = string.Empty;
            BLL.FW.BF_ST_TYPE.Entity entity = new BLL.FW.BF_ST_TYPE.Entity();

            if (id > 0)
            {
                entity = BLL.FW.BF_ST_TYPE.Instance.GetEntityByKey <BLL.FW.BF_ST_TYPE.Entity>(id);
                if (entity == null)
                {
                    ViewBag.Message = "脚本类型不存在";
                    entity          = new BLL.FW.BF_ST_TYPE.Entity();
                    entity.ID       = -1;
                }
            }

            GetSelectData();//加载下拉
            ModelState.Clear();
            return(View(entity));
        }