コード例 #1
0
        public ActionResult RemoveUser(int cid, int uid)
        {
            var sqlstr = "update px_class_user set removed=1 where class_id=@class_id and user_id=@user_id";
            var i      = sqlExecuter.Execute(sqlstr, new MySqlParameter("@class_id", cid), new MySqlParameter("@user_id", uid));


            var edit = classesinfoService.GetClassesInfoForEdit(new NullableIdDto <long> {
                Id = cid
            }).ClassesInfo;
            var count = classuserService.GetAll().Where(t => t.ClassId == cid).Count();

            edit.MemberCount = count;
            //更新班级成员数量
            classesinfoService.UpdateClassesInfoAsync(edit);

            //判断课程班级表有当前班级没用如果有要更新课程人员表保持一致和手机签到一样
            var dto = cbtservic.GetAll().FirstOrDefault(t => t.BusinessId == cid && t.type == 2);

            if (dto != null && dto.type != 4)
            {
                cpservic.DeleteCourseBoundPersonnel(new EntityDto <long> {
                    Id = dto.Id
                });
            }
            return(Success());
        }
        /// <summary>
        /// 班级数量加1
        /// </summary>
        private void SetCourseCount(int classId)
        {
            var classed = classInfolService.GetClassesInfoForEdit(new NullableIdDto <long>()
            {
                Id = classId
            });

            if (classed != null)
            {
                var date = _courseBoundConfigureTypeRepository.GetAll()
                           .Where(c => c.type == (int)ConfigureType.Class && c.BusinessId == classed.ClassesInfo.Id);
                classed.ClassesInfo.CourseCount += date.Count();
                classInfolService.UpdateClassesInfoAsync(classed.ClassesInfo);
            }
        }
コード例 #3
0
        private void SetMemberCount(int classId)
        {
            ClassesInfoEditDto classInfo = new ClassesInfoEditDto();

            classInfo = classesInfoAppService.GetClassesInfoEditById(new EntityDto <long>()
            {
                Id = classId
            });
            classInfo.MemberCount = CountMembers(classId);
            classesInfoAppService.UpdateClassesInfoAsync(classInfo);
        }
コード例 #4
0
        public ActionResult CheckIn(int CourseId)
        {
            int    uId      = int.Parse(CookieHelper.GetCookieValue("UserId").ToString());
            string UserName = CookieHelper.GetCookieValue("DisplayName").ToString();
            var    dto      = courseBoundService.GetCourseBoundUserByCourseId(CourseId).FirstOrDefault(t => t.AccountSysNo == uId).MapTo <CourseBoundPersonnelEditDto>();

            ViewBag.Stauts = 0;
            if (dto != null)
            {
                if (dto.CheckIN == true)
                {
                    ViewBag.Stauts = 1;
                }
                else
                {
                    dto.CheckIN = true;
                    courseBoundService.UpdateCourseBoundPersonnel(dto);
                    //更新课程表签到人数
                    var cdto = courseService.GetCourseInfoEditById(new EntityDto <long> {
                        Id = dto.CourseId
                    });
                    cdto.CheckinNum++;
                    courseService.UpdateCourseInfo(cdto);
                    ViewBag.Stauts = 2;
                }
            }
            else//不是已绑定到课程的人员
            {
                courseBoundService.CreateCourseBoundPersonnel(new CourseBoundPersonnelEditDto {
                    CourseId = CourseId, AccountSysNo = uId, CheckIN = true, IsBound = false, AccountUserName = UserName
                });
                ViewBag.Stauts = 2;
            }
            //查到线下培训课程所对就的班级
            var configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrByType(CourseId, (int)ConfigureType.Class);

            if (configu != null)
            {
                //班级人员关联关系数据添加
                var classUser = new ClassUserEditDto();
                classUser.ClassId = configu.BusinessId;
                classUser.UserId  = uId;
                classuserService.CreateClassUser(classUser);
                //把人员添加到班级中
                var classInfo = _classesInfoAppService.GetClassesInfoForEdit(new NullableIdDto <long>()
                {
                    Id = configu.BusinessId
                });
                classInfo.ClassesInfo.MemberCount++;
                _classesInfoAppService.UpdateClassesInfoAsync(classInfo.ClassesInfo);
            }
            return(View());
        }
コード例 #5
0
        public ActionResult Remove(int Id)
        {
            var boundData = cdjService.GetClassDepJobById(new EntityDto <long> {
                Id = Id
            });                                                                            //绑定的数据

            if (boundData != null)
            {
                cdjService.DeleteClassDepJob(new EntityDto <long>()
                {
                    Id = Convert.ToInt32(boundData.Id)
                });

                //只能移除部门和岗位不重复的人
                var userids = UnRepeatUser(boundData);
                foreach (var item in userids)
                {
                    var sqlstr = "update px_class_user set removed=1 where class_id=@class_id and user_id=@user_id";
                    var i      = sqlExecuter.Execute(sqlstr, new MySqlParameter("@class_id", boundData.ClassId), new MySqlParameter("@user_id", item));
                    //判断课程班级表有当前班级没用如果有要更新课程人员表保持一致和手机签到一样
                    var dto = cbtservic.GetAll().FirstOrDefault(t => t.BusinessId == boundData.ClassId && t.type == 2);
                    if (dto != null && dto.type != 4)
                    {
                        cpservic.DeleteCourseBoundPersonnel(new EntityDto <long> {
                            Id = dto.Id
                        });
                    }
                }
                //更新班级成员数量
                var edit = classService.GetClassesInfoForEdit(new NullableIdDto <long> {
                    Id = boundData.ClassId
                }).ClassesInfo;
                var count = classUserService.GetAll().Where(t => t.ClassId == boundData.ClassId).Count();
                edit.MemberCount = count;
                classService.UpdateClassesInfoAsync(edit);
            }
            return(Success());
        }
コード例 #6
0
        public JsonResult SingleUpCourse(int courseId)
        {
            //课程对像
            var courseDate = _courseInfoAppService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = courseId
            });                                                                                               //课程数据

            if (courseDate != null)
            {
                int userId    = int.Parse(CookieHelper.GetCookieValue("UserId").ToString());
                var user      = _userAccountService.GetUserAccountBySysNo(userId);                                                            //查询用户数据
                var boundData = _courseBoundPersonnelAppService.GetCourseBoundByUserIdOrCourseId(user.SysNO, Convert.ToInt32(courseDate.Id)); //绑定数据
                if (boundData == null)
                {
                    //增加人员
                    var create = new CourseBoundPersonnelEditDto();
                    create.AccountSysNo    = user.SysNO;
                    create.AccountUserName = user.DisplayName;
                    create.CourseId        = Convert.ToInt32(courseDate.Id);
                    create.CourseName      = courseDate.CourseName;
                    _courseBoundPersonnelAppService.CreateCourseBoundPersonnel(create);
                }


                var configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrType((int)courseDate.Id, (int)ConfigureType.Personal, user.SysNO);
                //增加关系
                if (configu == null)
                {
                    var createConfigure = new CourseBoundConfigureTypeEditDto();
                    createConfigure.CourseId     = (int)courseDate.Id;
                    createConfigure.CourseName   = courseDate.CourseName;
                    createConfigure.type         = (int)ConfigureType.Personal;
                    createConfigure.BusinessId   = user.SysNO;
                    createConfigure.BusinessName = user.DisplayName;
                    _courseBoundConfigureTypeAppService.CreateCourseBoundConfigureType(createConfigure);
                }
                //如果是线个考试则把人员配置到班级中
                if (courseDate.Type == 4)
                {
                    //查到线下培训课程所对就的班级
                    configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrByType((int)courseDate.Id, (int)ConfigureType.Class);
                    if (configu != null)
                    {
                        //班级人员关联关系数据添加
                        var classUser = new ClassUserEditDto();
                        classUser.ClassId = configu.BusinessId;
                        classUser.UserId  = userId;
                        _classUserAppService.CreateClassUser(classUser);
                        //把人员添加到班级中
                        var classInfo = _classesInfoAppService.GetClassesInfoForEdit(new NullableIdDto <long>()
                        {
                            Id = configu.BusinessId
                        });
                        classInfo.ClassesInfo.MemberCount++;
                        _classesInfoAppService.UpdateClassesInfoAsync(classInfo.ClassesInfo);
                    }
                }
            }
            return(Json(courseDate, JsonRequestBehavior.AllowGet));
        }