コード例 #1
0
        public ActionResult GetModel(long id)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };
            var server = new ProcedureHistoryService();
            var data   = server.Get(id);

            resultMode.Data = data;
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult SaveProcedureResourceInfo(ProcedureHistoryModel model)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };
            var server    = new ProcedureHistoryService();
            var saveModel = new ProcedureHistoryModel();

            if (model == null)
            {
                Debug.WriteLine("请求参数为空");
                resultMode.Message    = "保存失败";
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            if (model.Id > 0)
            {
                saveModel = server.Get(model.Id);
                if (saveModel == null)
                {
                    resultMode.Message    = "该记录已经被删除";
                    resultMode.ResultCode = ResponceCodeEnum.Fail;
                    return(Json(resultMode, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                saveModel.CreateBy   = CurrentModel.Id.ToString();
                saveModel.CreateTime = DateTime.Now;
            }

            if (model.CustomerId > 0)
            {
                var userModel = new AccountService().GetSysUser(model.CustomerId);
                if (userModel == null || userModel.Id < 1)
                {
                    resultMode.Message    = "客户不存在";
                    resultMode.ResultCode = ResponceCodeEnum.Fail;
                    return(Json(resultMode, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    model.CustomerName = userModel.UserName;
                }
            }
            else
            {
                resultMode.Message    = "请选择所属客户";
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            if (!string.IsNullOrEmpty(model.ProcedureCode))
            {
                var dicModel = new SysDicService().Get(model.ProcedureCode);
                if (dicModel == null || string.IsNullOrEmpty(dicModel.Id))
                {
                    resultMode.Message    = "工序不存在";
                    resultMode.ResultCode = ResponceCodeEnum.Fail;
                    return(Json(resultMode, JsonRequestBehavior.AllowGet));
                }

                model.ProcedureName = dicModel.Lable;
            }
            else
            {
                resultMode.Message    = "请选择工序类型";
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            saveModel.Id            = model.Id;
            saveModel.IsDel         = FlagEnum.HadZore.GetHashCode();
            saveModel.ResourceUrl   = model.ResourceUrl;
            saveModel.Sort          = model.Sort;
            saveModel.Remarks       = model.Remarks;
            saveModel.CustomerId    = model.CustomerId;
            saveModel.CustomerName  = model.CustomerName;
            saveModel.ProcedureCode = model.ProcedureCode;
            saveModel.ProcedureName = model.ProcedureName;
            saveModel.ResourceName  = model.ResourceName;
            try
            {
                server.SaveModel(saveModel);
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                resultMode.Message    = "保存失败";
                resultMode.ResultCode = ResponceCodeEnum.Fail;
                resultMode.Data       = e.Message;
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
        }