public ActionResult GetCostTypePage(int pageIndex = 1, int pageSize = 10, string name = "", int spendType = -1)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Fail,
                Message    = ""
            };
            var userId = CurrentModel.UserId;

            if (userId < 1)
            {
                resultMode.Message = "登录失效,请重新登录";
            }
            else
            {
                var server   = new CostTypeService();
                var dataList = server.GetList(spendType, new List <long> {
                    userId
                }, pageIndex, pageSize, out var count, name);
                resultMode.Data       = new { count, dataList };
                resultMode.ResultCode = ResponceCodeEnum.Success;
            }

            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));
        }
        public ActionResult GetCostType(int spendType)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Fail,
                Message    = ""
            };
            var server = new CostTypeService();
            var userId = CurrentModel.UserId;
            var data   = server.GetList(spendType, new List <long> {
                userId
            }, 1, 100000, out _);

            resultMode.Data       = data;
            resultMode.ResultCode = ResponceCodeEnum.Success;
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
        public ActionResult InitCostTypeModel()
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };
            var userId    = CurrentModel.UserId;
            var server    = new CostTypeService();
            var modelList = server.GetList(-1, new List <long> {
                userId
            }, 1, 10, out _);

            if (modelList != null && modelList.Count > 0)
            {
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                resultMode.Message    = "已经初始化过";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            server.InitCostType(userId);
            resultMode.ResultCode = ResponceCodeEnum.Success;
            resultMode.Message    = "初始化成功";
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }