Beispiel #1
0
 public bool AddOrUpdate(td_ConstructionProject entity)
 {
     if (entity.ID < 1)
     {
         dbContext.Add(entity);
     }
     return(dbContext.Update(entity, c => c.ID == entity.ID));
 }
        //添加或修改
        public JsonResult AddOrUpdate()
        {
            var sReturnModel = new ReturnMessageModel();

            #region 登录验证
            if (!Utits.IsLogin)
            {
                sReturnModel.ErrorType      = 3;
                sReturnModel.MessageContent = "登录状态已失效.";
                return(Json(sReturnModel));
            }
            #endregion
            int    id      = RequestParameters.Pint("ID");
            string DeptId  = RequestParameters.Pstring("Dept_Id");
            string xmys    = RequestParameters.Pstring("xmys");
            string zjly    = RequestParameters.Pstring("zjly");
            string xmfzr   = RequestParameters.Pstring("xmfzr");
            string fzrdwdh = RequestParameters.Pstring("fzrdwdh");
            int    fzrsj   = RequestParameters.Pint("fzrsj");
            string xmlxr   = RequestParameters.Pstring("xmlxr");
            string lxrdwdh = RequestParameters.Pstring("lxrdwdh");
            int    lxrsj   = RequestParameters.Pint("lxrsj");

            if (DeptId.Length < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败:资源提供部门不能为空.";
                return(Json(sReturnModel));
            }

            var currentUser = Utits.CurrentUser;

            #region 检查参数(暂不做处理)
            //if (ECode.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:员工号不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (WCode.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:考勤号不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Name.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:姓名不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Dept.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:部门不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Login.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:登录名不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (Role == Guid.Empty)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:角色不能为空.";
            //    return Json(sReturnModel);
            //}
            //if (id < 1 && Password.Length < 1)
            //{
            //    sReturnModel.ErrorType = 0;
            //    sReturnModel.MessageContent = "操作失败:密码不能为空.";
            //    return Json(sReturnModel);
            //}
            #endregion

            var cBll = new BLL_ConstructionProject();
            td_ConstructionProject model;
            if (id > 0)
            {
                model = cBll.GetObjectById(id);
                if (model == null)
                {
                    sReturnModel.ErrorType      = 0;
                    sReturnModel.MessageContent = "操作失败.";
                    return(Json(sReturnModel));
                }
            }

            model            = new td_ConstructionProject();
            model.ID         = id;
            model.OperatPid  = currentUser.user_Id;
            model.OperatTime = DateTime.Now;

            model.Dept_Id = DeptId;
            model.xmys    = xmys;
            model.zjly    = zjly;
            model.xmfzr   = xmfzr;
            model.fzrdwdh = fzrdwdh;
            model.fzrsj   = fzrsj;
            model.xmlxr   = xmlxr;
            model.lxrsj   = lxrsj;
            model.lxrdwdh = lxrdwdh;

            if (cBll.AddOrUpdate(model))
            {
                sReturnModel.ErrorType      = 1;
                sReturnModel.MessageContent = "操作成功.";
            }
            else
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败.";
            }
            return(Json(sReturnModel));
        }