Пример #1
0
 public bool AddOrUpdate(td_Network entity)
 {
     if (entity.ID < 1)
     {
         dbContext.Add(entity);
     }
     return(dbContext.Update(entity, c => c.ID == entity.ID));
 }
Пример #2
0
        /// <summary>
        /// 保存信息
        /// </summary>
        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");
            int    scjhj       = RequestParameters.Pint("scjhj");
            string scjhjxh     = RequestParameters.Pstring("scjhjxh");
            string scjhjpp     = RequestParameters.Pstring("scjhjpp");
            int    ecjhj       = RequestParameters.Pint("ecjhj");
            string ecjhjxh     = RequestParameters.Pstring("ecjhjxh");
            string ecjhjpp     = RequestParameters.Pstring("ecjhjpp");
            int    lyq         = RequestParameters.Pint("lyq");
            string lyqxh       = RequestParameters.Pstring("lyqxh");
            string lyqpp       = RequestParameters.Pstring("lyqpp");
            int    gdj         = RequestParameters.Pint("gdj");
            string gdjxh       = RequestParameters.Pstring("gdjxh");
            string gdjpp       = RequestParameters.Pstring("gdjpp");
            int    llfzjh      = RequestParameters.Pint("llfzjh");
            string llfzjhxh    = RequestParameters.Pstring("llfzjhxh");
            string llfzjhpp    = RequestParameters.Pstring("llfzjhpp");
            int    wxzj        = RequestParameters.Pint("wxzj");
            string wxzjxh      = RequestParameters.Pstring("wxzjxh");
            string wxzjpp      = RequestParameters.Pstring("wxzjpp");
            int    gx          = RequestParameters.Pint("gx");
            int    wxjrd       = RequestParameters.Pint("wxjrd");
            string flwck       = RequestParameters.Pstring("flwck");
            string jrcwwwIPdzd = RequestParameters.Pstring("jrcwwwIPdzd");

            if (jrcwwwIPdzd.Length < 1)
            {
                sReturnModel.ErrorType      = 0;
                sReturnModel.MessageContent = "操作失败:接入政务外网IP地址端不能为空.";
                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_Network();
            td_Network model;
            if (id > 0)
            {
                model = cBll.GetObjectById(id);
                if (model == null)
                {
                    sReturnModel.ErrorType      = 0;
                    sReturnModel.MessageContent = "操作失败.";
                    return(Json(sReturnModel));
                }
            }

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

            model.Dept_Id     = DeptId;
            model.scjhj       = scjhj;
            model.scjhjxh     = scjhjxh;
            model.scjhjpp     = scjhjpp;
            model.ecjhj       = ecjhj;
            model.ecjhjxh     = ecjhjxh;
            model.ecjhjpp     = ecjhjpp;
            model.lyq         = lyq;
            model.lyqxh       = lyqxh;
            model.lyqpp       = lyqpp;
            model.gdj         = gdj;
            model.gdjxh       = gdjxh;
            model.gdjpp       = gdjpp;
            model.llfzjh      = llfzjh;
            model.llfzjhxh    = llfzjhxh;
            model.llfzjhpp    = llfzjhpp;
            model.wxzj        = wxzj;
            model.wxzjxh      = wxzjxh;
            model.wxzjpp      = wxzjpp;
            model.gx          = gx;
            model.wxjrd       = wxjrd;
            model.flwck       = flwck;
            model.jrcwwwIpdzd = jrcwwwIPdzd;

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