コード例 #1
0
        /// <summary>
        /// 档案类型操作
        /// </summary>
        /// <param name="value">传递过来的名字</param>
        /// <param name="type">1-增、2-改、3-删</param>
        /// <returns></returns>
        public ActionResult RecordTypeProcess(string value, int type)
        {
            //增加
            if (type == 1)
            {
                if (!SelectTypeNameService.GetByWhere(" where SelectTypeNameString=@SelectTypeNameString",
                                                      new { SelectTypeNameString = value }).Any())
                {
                    var id = SelectTypeNameService.CreateModelReturnId(new SelectTypeName()
                    {
                        SelectTypeNameString = value
                    });
                    return(Json(new { state = true, data = $"SelectType_{id}" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(ErrorTip($"添加失败,失败原因:已存在相同名称的条目!")));
                    //return Json(new {status = false, msg = $"添加失败,失败原因:"}, JsonRequestBehavior.AllowGet);
                }
            }
            //编辑
            else if (type == 2)
            {
                var name = string.IsNullOrEmpty(Request["name"])?new string[0]:Request["name"].Split('_');
                if (name.Length == 0)
                {
                    return(Json(ErrorTip($"编辑失败,失败原因:未传递被更改条目的名称!")));
                }
                else
                {
                    var result =
                        SelectTypeNameService.UpdateModel(new SelectTypeName()
                    {
                        Id = int.Parse(name[1]), SelectTypeNameString = value
                    })
                            ? SuccessTip($"编辑成功!")
                            : ErrorTip($"编辑失败!");

                    return(Json(result));
                }
            }
            //删除
            else
            {
                var name = string.IsNullOrEmpty(Request["name"]) ? new string[0] : Request["name"].Split('_');
                if (name.Length == 0)
                {
                    return(Json(ErrorTip($"编辑失败,失败原因:未传递被更改条目的名称!")));
                }
                else
                {
                    var result = SelectTypeNameService.DeleteModel(int.Parse(name[1])) ? SuccessTip($"删除成功!") : ErrorTip($"删除失败!");

                    return(Json(result));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 新增档案类型
        /// </summary>
        /// <param name="recordTypeName">档案类型名称</param>
        /// <returns>档案类型编号</returns>
        public ActionResult InsertRecordType(string recordTypeName)
        {
            if (!SelectTypeNameService.GetByWhere(" where SelectTypeNameString=@SelectTypeNameString",
                                                  new { SelectTypeNameString = recordTypeName }).Any())
            {
                var id = SelectTypeNameService.CreateModelReturnId(new SelectTypeName()
                {
                    SelectTypeNameString = recordTypeName
                });
                return(Json(new { state = true, Id = $"{id}" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(ErrorTip($"添加失败,失败原因:已存在相同名称的条目!")));
                //return Json(new {status = false, msg = $"添加失败,失败原因:"}, JsonRequestBehavior.AllowGet);
            }

            //return Json(new {state = true, Id = 3, msg = "操作成功!"}, JsonRequestBehavior.AllowGet);
        }