public void AddSubjectToLesson(Yw_CourseLesson lesson, int subjectId)
        {
            Yw_CourseSubjectRelation rel = Repository.GetDirectRelation(lesson.Ycl_Id, subjectId);

            if (rel == null)
            {
                SubjectBll subjectBll = new SubjectBll();
                Yw_Subject subject    = subjectBll.GetSubject(subjectId);

                rel = new Yw_CourseSubjectRelation();
                rel.Ysr_CourseId        = lesson.Ycl_CourseId;
                rel.Ysr_CreateTime      = DateTime.Now;
                rel.Ysr_DirectSubjectId = 0;
                rel.Ysr_IsDirect        = true;
                rel.Ysr_LessonId        = lesson.Ycl_Id;
                rel.Ysr_LessonIndex     = lesson.Ycl_Index;
                rel.Ysr_SubjectId       = subjectId;
                rel.Ysr_SubjectType     = subject.Ysj_SubjectType;
                Repository.Add(rel);

                SubjectGroupBll groupBll = new SubjectGroupBll();
                Yw_SubjectGroup group    = groupBll.GetBySubjectId(subjectId);
                if (group != null && !string.IsNullOrEmpty(group.Ysg_RelSubjectId))
                {
                    int[] subjectIds = group.Ysg_RelSubjectId.Split(',').Select(x => Convert.ToInt32(x)).ToArray();
                    Repository.CreateInDirectRelation(rel.Ysr_Id, subjectIds);
                }
            }
        }
        /// <summary>
        /// 添加题目到题目组,A,B两个题目互为主副关系。A如果与某些课时有直接关联关系,就要创建B与该课时的间接关联关系;同理B也一样。
        /// </summary>
        /// <param name="subjectId"></param>
        /// <param name="targetSubjectId"></param>
        public void AddSubjectToGroup(int subjectId, int targetSubjectId)
        {
            SubjectBll subjectBll = new SubjectBll();

            Yw_Subject subject       = subjectBll.GetSubject(subjectId);
            Yw_Subject targetSubject = subjectBll.GetSubject(targetSubjectId);

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    Repository.AddSubjectToGroup(subjectId, subject.Ysj_SubjectType, targetSubjectId);
                    Repository.AddSubjectToGroup(targetSubjectId, targetSubject.Ysj_SubjectType, subjectId);
                    scope.Complete();
                }
                catch
                {
                    RollbackTran();
                    throw;
                }
            }
        }