Beispiel #1
0
        public List <T_BG_Position> GetlistByLvlAndDepartmentId(long positionId, long departmentId)
        {
            try
            {
                //PredicateGroup pmain = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
                //pmain.Predicates.Add(Predicates.Field<T_BG_Position>(f => f.PositionId, Operator.Eq, positionId));
                //pmain.Predicates.Add(Predicates.Field<T_BG_Position>(f => f.IsDel, Operator.Eq, 0));

                T_BG_Position position = GetByPositionId(positionId);
                if (position == null)
                {
                    return(null);
                }
                string sql = @"
								SELECT {0}
								FROM [POS].[dbo].[T_BG_Position]
								WHERE DepartmentId=@DepartmentId and Lvl<@Lvl
                                ";
                sql = string.Format(sql, Colnum);
                DynamicParameters dynParams = new DynamicParameters();
                dynParams.Add("@DepartmentId", departmentId);
                dynParams.Add("@Lvl", position.Lvl);
                return(_bgPositionRepository.QueryList(sql, dynParams).ToList());
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 员工调动审核
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckPosition()
        {
            long positionId = LoginHelper.PositionId;

            T_BG_Position position = _bgPositionService.GetByPositionId(positionId);

            if (position == null || position.Lvl < 4)
            {
                ViewBag.errorCode    = "E001";
                ViewBag.errorMessage = position == null?"登录用户发生未知错误!":"您无权审核员工调动!";
            }
            List <BgChangeUserPositionExtend> list = _bgChangeUserPositionExtendService.GetList(position.DepartmentId, position.Lvl);

            return(View("~/Views/User/CheckPositionForMainPage.cshtml", list));
        }
Beispiel #3
0
        /// <summary>
        /// 添加或者修改用户
        /// </summary>
        /// <returns></returns>
        public JsonResult AddOrUpdateUser()
        {
            JsonUserAddUserEntity json = new JsonUserAddUserEntity();
            string   realname          = CommonHelper.GetPostValue("realname");
            int      gender            = CommonHelper.GetPostValue("gender").ToInt(-1);
            long     positionId        = CommonHelper.GetPostValue("positionId").ToLong(-1);
            DateTime entryDate         = CommonHelper.GetPostValue("entryDate").ToDateTime(DateTime.MaxValue);
            string   identity          = CommonHelper.GetPostValue("identity");
            string   phone             = CommonHelper.GetPostValue("phone");
            long     educationId       = CommonHelper.GetPostValue("educationId").ToLong(-1);
            long     householdId       = CommonHelper.GetPostValue("householdId").ToLong(-1);
            string   school            = CommonHelper.GetPostValue("school");
            string   email             = CommonHelper.GetPostValue("email");
            string   emergency         = CommonHelper.GetPostValue("emergency");
            string   address           = CommonHelper.GetPostValue("address");
            string   remark            = CommonHelper.GetPostValue("remark");
            int      add = CommonHelper.GetPostValue("add").ToInt(0);      //0=添加 1=修改
            long     id  = CommonHelper.GetPostValue("id").ToLong(-1);

            if ((string.IsNullOrEmpty(realname) || gender == -1 || positionId == -1 || entryDate == DateTime.MaxValue || string.IsNullOrEmpty(identity) || householdId == -1 || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emergency) || string.IsNullOrEmpty(address)) || (add == 1 && id < 0))
            {
                json.ErrorCode    = "E001";
                json.ErrorMessage = "参数不全!";
                return(Json(json));
            }

            realname  = HttpUtility.UrlDecode(realname);
            school    = HttpUtility.UrlDecode(school);
            emergency = HttpUtility.UrlDecode(emergency);
            address   = HttpUtility.UrlDecode(address);
            remark    = HttpUtility.UrlDecode(remark);

            T_BG_User user = null;

            if (add == 0)
            {
                user = new T_BG_User();
            }
            else
            {
                user = _bgUserService.GetUserById(id);
                if (user == null)
                {
                    json.ErrorCode    = "E003";
                    json.ErrorMessage = "未获得该修改对象!";
                    return(Json(json));
                }
            }

            T_BG_Position p = _bgPositionService.GetByPositionId(positionId);

            if (p == null)
            {
                json.ErrorCode    = "E003";
                json.ErrorMessage = "未获得该修改员工职位信息!";
                return(Json(json));
            }

            user.RealName    = realname;
            user.Gender      = gender;
            user.PositionId  = positionId;
            user.EntryDate   = entryDate;
            user.IP          = identity;
            user.Phone       = phone;
            user.EducationId = educationId;
            user.HouseholdId = householdId;
            user.School      = school;
            user.Email       = email;
            user.Emergency   = emergency;
            user.Address     = address;
            user.Remark      = remark;
            user.Lvl         = p.Lvl;

            bool result = false;

            if (add == 0)
            {
                user.DepartmentId = LoginHelper.DepartmentId;
                user.Status       = 0;
                user.AddTime      = DateTime.Now;
                user.IsDel        = 0;
                user.AreaId       = LoginHelper.AreaId;
                user.ShopID       = LoginHelper.ShopID;        //这个后期可能需要修改
                user.RoleID       = 2;
                result            = _bgUserService.Add(user);
            }
            else
            {
                result = _bgUserService.Update(user);
            }

            if (result)
            {
                json.ErrorCode    = "E000";
                json.ErrorMessage = "成功!";
            }
            else
            {
                json.ErrorCode    = "E002";
                json.ErrorMessage = "数据库操作失败!";
            }
            return(Json(json));
        }