public ActionResult InvalidCostTypeModel(long id)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };
            var userId   = CurrentModel.UserId;
            var server   = new CostTypeService();
            var oldModel = server.Get(id);

            if (oldModel == null || oldModel.UserId != userId)
            {
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                resultMode.Message    = "参数错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            oldModel.IsDel        = FlagEnum.HadOne;
            oldModel.IsValid      = FlagEnum.HadZore;
            oldModel.UpdateUserId = userId;
            oldModel.UpdateTime   = DateTime.Now;
            try
            {
                server.SaveModel(oldModel);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SaveTypeInfo(long id, string name, int sort, int spendType)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Fail,
            };

            if (string.IsNullOrEmpty(name))
            {
                resultMode.Message = "名称不能为空";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            var           userId   = CurrentModel.UserId;
            var           server   = new CostTypeService();
            CostTypeModel newModel = new CostTypeModel();

            if (id > 0)
            {
                newModel = server.Get(id);
                //验证权限
                if (newModel == null || newModel.UserId != userId)
                {
                    resultMode.Message = "非法访问";
                    return(Json(resultMode, JsonRequestBehavior.AllowGet));
                }
            }
            //验证参数
            newModel.Id           = id;
            newModel.SpendType    = spendType;
            newModel.IsDel        = FlagEnum.HadZore;
            newModel.IsValid      = FlagEnum.HadOne;
            newModel.Name         = name;
            newModel.UserId       = userId;
            newModel.CreateTime   = newModel.CreateTime < new DateTime(1900, 1, 1) ? DateTime.Now : newModel.CreateTime;
            newModel.CreateUserId = newModel.CreateUserId < 1 ? userId : newModel.CreateUserId;
            newModel.Sort         = sort;
            newModel.UpdateTime   = DateTime.Now;
            newModel.UpdateUserId = userId;

            var costTypeInfoList = server.GetList(spendType, userId, name);

            if (costTypeInfoList != null &&
                (costTypeInfoList.Count > 1 || costTypeInfoList.Count == 1 && costTypeInfoList[0].Id != id))
            {
                resultMode.Message = "类型名称已经存在";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            server.SaveModel(newModel);
            resultMode.ResultCode = ResponceCodeEnum.Success;
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }