public JsonResult AddClassGroupMember(string classId, string groupTitle, string accountIds)
        {
            try
            {
                var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt();
                var gbll = new Class_GroupBLL();
                var gmbll = new Class_GroupMemberBLL();

                var groupNameCheck = new Class_GroupBLL().GetList(" Delflag=0 and ClassId=" + param_classId + " and Title='" + groupTitle.Trim() + "'", "");
                if (groupNameCheck != null && groupNameCheck.Count > 0)
                    return Json(new { Code = 0, Msg = "班级内存在此小组名称!" }, JsonRequestBehavior.AllowGet);
                var gModel = new Class_Group();
                gModel.ClassId = param_classId;
                gModel.CreateDate = DateTime.Now;
                gModel.Display = true;
                gModel.Delflag = false;
                gModel.Title = groupTitle;
                gbll.Add(gModel);

                var ids = accountIds.Split(',');
                foreach (var item in ids)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        var gmModel = new Class_GroupMember();
                        gmModel.AccountId = item.ToInt();
                        gmModel.GroupId = gModel.Id;
                        gmModel.Delflag = false;
                        gmModel.CreateDate = DateTime.Now;
                        gmbll.Add(gmModel);
                    }
                }

                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
        //分组列表
        public ActionResult ClassGroup(string classId, int groupId = 0, int pageIndex = 1)
        {
            var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt();
            IList<Member_ClassRegister> list = new List<Member_ClassRegister>();
            int totalPage = 0;

            string where = " mb.ClassId = " + param_classId + " and  cg.ClassId= " + param_classId + " AND cgm.Delflag=0 AND mb.Delflag=0";

            if (groupId == 0)//全部组
            {
                list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister>
                .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Class_GroupMember cgm
            LEFT JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
            LEFT JOIN dbo.Member_ClassRegister mb ON cgm.AccountId=mb.AccountId", where, "cgm.CreateDate", pageIndex, out totalPage, "mb.*,CONVERT(VARCHAR,cg.ClassId)+'|'+CONVERT(VARCHAR,cg.id) AS ClassId_GroupId", 15));
            }
            if (groupId > 0)//单组
            {
                where += " and cgm.GroupId=" + groupId;
                list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister>
                .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Class_GroupMember cgm
            LEFT JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
            LEFT JOIN dbo.Member_ClassRegister mb ON cgm.AccountId=mb.AccountId", where, "cgm.CreateDate", pageIndex, out totalPage, "mb.*,CONVERT(VARCHAR,cg.ClassId)+'|'+CONVERT(VARCHAR,cg.id) AS ClassId_GroupId", 15));
            }
            if (groupId < 0)//无组
            {
                where = @" NOT EXISTS ( SELECT 1
                     FROM   dbo.Class_Group cg
                            JOIN dbo.Class_GroupMember cgm ON cg.Id = cgm.GroupId
                     WHERE  cg.ClassId = t.ClassId AND t.AccountId=cgm.AccountId
                    AND t.Status=4 AND t.ClassId=" + param_classId + " AND cg.Delflag=0 AND cgm.Delflag=0)" + " AND t.Status=4 AND t.ClassId=" + param_classId;
                list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister>
               .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Member_ClassRegister t
            LEFT JOIN dbo.Member_Account m ON t.AccountId=m.id
            ", where, "t.CreateDate", pageIndex, out totalPage, "t.*,'' AS ClassId_GroupId", 15));
            }

            var gBll = new Dianda.AP.BLL.Class_GroupBLL();
            var allGroup = gBll.GetList(" ClassId=" + param_classId + " and Delflag=0 AND Display=1", "");

            //无组人员
            //            where = @" NOT EXISTS ( SELECT 1
            //                     FROM   dbo.Class_Group cg
            //                            JOIN dbo.Class_GroupMember cgm ON cg.Id = cgm.GroupId
            //                     WHERE  cg.ClassId = t.ClassId AND t.AccountId=cgm.AccountId
            //                            AND t.Status=4 AND t.ClassId=" + classId + ")" + " AND t.Status=4 AND t.ClassId=" + classId;
            //            var noGrouper = DataTableToListHelper<Dianda.AP.Model.Member_BaseInfo>
            //           .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Member_ClassRegister t
            //LEFT JOIN dbo.Member_Account m ON t.AccountId=m.id
            //LEFT JOIN dbo.Member_BaseInfo mb ON m.Id=mb.AccountId", where, "mb.CreateDate", pageIndex, out totalPage, "mb.*,'' AS ClassId_GroupId"));
            var noGrouper = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister>
                           .ConvertToModel(new Member_ClassRegisterBLL().GetNoGroupper(param_classId));
            ViewBag.noGrouper = noGrouper;

            ViewBag.GroupList = allGroup;
            ViewBag.classId = classId;
            ViewBag.pageIndex = pageIndex;
            ViewBag.totalPage = totalPage;
            ViewBag.basecount = 15;

            var classModel = new Class_DetailBLL().GetModel(param_classId);
            if (classModel != null)
            {
                ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title;
                ViewBag.ClassName = classModel.Title;

                var traningTeacher = new Traning_TeacherBLL().GetList(" Delflag=0 AND TraningId=" + classModel.TraningId, "");
                var teacherAccount = (traningTeacher != null && traningTeacher.Count > 0) ? new PlatformManager_DetailBLL().GetModel(traningTeacher.First().PlatformManagerId.Value, "").AccountId : 0;
                ViewBag.TraningTeacher = teacherAccount;
            }

            ViewBag.ManagerId = SiteCache.Instance.ManagerId;

            return View(list);
        }
        //小组讨论
        public ActionResult ClassDiscuss(string classId, int? groupId, int unitId = 0, int pageIndex = 1, int pageIndex2 = 1)
        {
            var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt();
            int totalPage = 0;
            int totalPage2 = 0;
            var classDetail = new Class_DetailBLL().GetModel(param_classId);

            var topicList = DataTableToListHelper<Dianda.AP.Model.Course_UnitContent>
               .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"  Course_UnitContent
                INNER JOIN Course_UnitDetail ON Course_UnitContent.UnitId = Course_UnitDetail.Id"
               , @" Course_UnitDetail.Display = 1
                                                AND Course_UnitDetail.Delflag = 0
                                                AND Course_UnitContent.Display = 1
                                                AND Course_UnitContent.Delflag = 0
                                                AND Course_UnitDetail.TrainingId = " + classDetail.TraningId + @"
                                                AND UnitType = 3  ", " dbo.Course_UnitDetail.Id", 1, out totalPage, "Course_UnitContent.*", 50));

            ViewBag.topicList = topicList;

            ViewBag.currentTopic = unitId == 0 ? (topicList.Count > 0 ? topicList[0].Content : null) : new Course_UnitContentBLL().GetModel(unitId, "").Content;
            //ViewBag.currentTopicId = unitId == 0 ? (topicList.Count > 0 ? topicList[0].Id : 0) : unitId;

            //班级成员
            var allMember = new Member_ClassRegisterBLL()
                                     .GetList(" ClassId=" + param_classId + " and Delflag=0 and status=4", "")
                                     .GroupBy(s => s.AccountId);
            totalPage2 = allMember.Count();
            ViewBag.classMember = from c in allMember.Skip((pageIndex2 - 1) * 10).Take(10)
                                  select c.Key;

            var paramUnit = unitId == 0 ? (topicList.Count > 0 ? "r.UnitContent=" + topicList[0].Id : " 1=1 ") : " r.UnitContent= " + unitId;
            var where = paramUnit + " and r.ClassId=" + param_classId + " AND r.Delflag=0 AND r.ParentReplyId=0 AND r.Display=1 and r.AccountId!=0";
            if (groupId.HasValue)//有组条件
            {
                if (groupId == 0)
                {
                    where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
                }
                if (groupId == -1)
                {
                    where += @" and not exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
                }
                if (groupId > 0)
                {
                    where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0
                    AND cgm.GroupId= " + groupId + ")";
                }

            }
            else//默认全部组
            {
                where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
            }
            //Model
            var list = DataTableToListHelper<Dianda.AP.Model.Course_UnitReplyDetail>
               .ConvertToModel(PagingQueryBll.GetPagingDataTable("Course_UnitReplyDetail r", where, "r.id", pageIndex, out totalPage, "r.*", 3));

            var allGroup = new Class_GroupBLL().GetList(" ClassId=" + param_classId + " and Delflag=0 AND Display=1", "");

            ViewBag.GroupList = allGroup;
            //成员分页
            ViewBag.pageIndex2 = pageIndex2;
            ViewBag.totalPage2 = totalPage2;

            ViewBag.classId = classId;
            ViewBag.param_classId = param_classId;
            //讨论分页
            ViewBag.pageIndex = pageIndex;
            ViewBag.totalPage = totalPage;
            ViewBag.basecount = 3;

            ViewBag.accountId = SiteCache.Instance.LoginInfo.UserId;
            ViewBag.traningId = classDetail.TraningId;

            var classModel = new Class_DetailBLL().GetModel(param_classId);
            if (classModel != null)
            {
                ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title;
                ViewBag.ClassName = classModel.Title;

                var traningTeacher = new Traning_TeacherBLL().GetList(" Delflag=0 AND TraningId=" + classModel.TraningId, "");
                var teacherAccount = (traningTeacher != null && traningTeacher.Count > 0) ? new PlatformManager_DetailBLL().GetModel(traningTeacher.First().PlatformManagerId.Value, "").AccountId : 0;
                ViewBag.TraningTeacher = teacherAccount;
            }

            ViewBag.ManagerId = SiteCache.Instance.ManagerId;

            return View(list);
        }
        //删除班级小组
        public JsonResult DeleteClassGroup(string classId, int groupId)
        {
            try
            {
                var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt();
                var bll = new Class_GroupBLL();
                var model = bll.GetModel(groupId, " ClassId=" + param_classId);
                model.Delflag = true;
                bll.Update(model);

                var membll = new Class_GroupMemberBLL();
                var member = membll.GetListModel("GroupId=" + model.Id);
                foreach (var item in member)
                {
                    item.Delflag = true;
                    membll.Update(item);
                }

                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
        /// <summary>
        /// 获取[学习讨论]信息 -- 话题
        /// </summary>
        private void GetCourseUnitDetail_Topic(int iUnitContent)
        {
            var grpBll = new Class_GroupBLL();
            var ReplyBll = new Course_UnitReplyDetailBLL();
            var stbSqlWhere = new StringBuilder();
            var Topic_Reply_Dictry = new Dictionary<Course_UnitReplyDetailOther, List<Course_UnitReplyDetailOther>>();//页面绑定的字典信息
            var List_Course_UnitReplyDetail_ShowTopic = new List<Course_UnitReplyDetailOther>();//话题
            var List_Course_UnitReplyDetail_Reply = new List<Course_UnitReplyDetailOther>();//回复
            var strOrderBy = string.Empty;
            int iAccountId = 0, iClassId = 0;

            int.TryParse(Convert.ToString(Request["ClassId"]) == "" ? "0" : QueryString.Decrypt(Request["ClassId"]), out iClassId);//获取 ClassId
            iAccountId = Code.SiteCache.Instance.LoginInfo.UserId;

            //获取数据总数
            int iTopicRecordCount = ReplyBll.GetListTopicTotalCount(iClassId, iUnitContent);
            int iTopicPageSize = 10, iTopicPageIndex = 0;
            int iTopicPageCount = (int)Math.Ceiling((double)iTopicRecordCount / iTopicPageSize);
            int.TryParse(Request["pageIndex"], out iTopicPageIndex);
            if (iTopicPageIndex < 1)
                iTopicPageIndex = 1;
            else if (iTopicPageIndex > iTopicPageCount)
                iTopicPageIndex = iTopicPageCount;

            List_Course_UnitReplyDetail_ShowTopic = ReplyBll.GetListTopicOther(iTopicPageSize, iTopicPageIndex, iClassId, iUnitContent, out iTopicRecordCount);
            if (List_Course_UnitReplyDetail_ShowTopic != null && List_Course_UnitReplyDetail_ShowTopic.Count > 0)
            {
                foreach (var topicModel in List_Course_UnitReplyDetail_ShowTopic)
                {
                    List_Course_UnitReplyDetail_Reply = ReplyBll.GetListReplyOther(iClassId, iUnitContent, topicModel.CourseUnitReplyDetail.Id);
                    Topic_Reply_Dictry.Add(topicModel, List_Course_UnitReplyDetail_Reply);
                }
            }

            ViewBag.TopicRecordCount = iTopicRecordCount;
            ViewBag.TopicPageCount = iTopicPageCount;
            ViewBag.TopicPageIndex = iTopicPageIndex;
            ViewBag.TopicPageSize = iTopicPageSize;
            ViewBag.Topic_Reply_Dictry = Topic_Reply_Dictry;
        }
        /// <summary>
        /// 获取[班级分组表]信息,讨论组,[小组成员]信息
        /// </summary>
        /// <returns></returns>
        private void GetClassGroupList()
        {
            var grpBll = new Class_GroupBLL();
            var List_Class_Group_Teacher = new List<Class_GroupAll>();
            var List_Class_Group_Member = new List<Class_GroupAll>();
            int iAccountId = 0, iClassId = 0, iGroupRecordCount = 0;

            int.TryParse(Convert.ToString(Request["ClassId"]) == "" ? "0" : QueryString.Decrypt(Request["ClassId"]), out iClassId);//获取 ClassId
            iAccountId = Code.SiteCache.Instance.LoginInfo.UserId;

            //获取 [小组成员-讲师,辅导员]
            List_Class_Group_Teacher = grpBll.GetGroupList(iAccountId, iClassId);

            //获取[小组成员-组员]总条数
            iGroupRecordCount = grpBll.GetGroupList_MemberCount(iClassId, iAccountId);
            int iGroupPageSize = 10, iGroupPageIndex = 0;
            int iGroupPageCount = (int)Math.Ceiling((double)iGroupRecordCount / iGroupPageSize);
            if (!string.IsNullOrEmpty(Request["GroupPageIndex"]))
            {
                int.TryParse(QueryString.Decrypt(Request["GroupPageIndex"]), out iGroupPageIndex);
            }

            if (iGroupPageIndex < 1)
                iGroupPageIndex = 1;
            else if (iGroupPageIndex > iGroupPageCount)
                iGroupPageIndex = iGroupPageCount;
            //获取分页数据集合,获取 [小组成员-组员]
            List_Class_Group_Member.AddRange(grpBll.GetGroupList_Member(iGroupPageSize, iGroupPageIndex, iClassId, iAccountId, out iGroupRecordCount));

            ViewBag.GroupAccountId = iAccountId;
            ViewBag.GroupClassId = iClassId;
            ViewBag.GroupRecordCount = iGroupRecordCount;
            ViewBag.GroupPageCount = iGroupPageCount;
            ViewBag.GroupPageIndex = iGroupPageIndex;
            ViewBag.GroupPageSize = iGroupPageSize;
            ViewBag.List_Class_Group_Teacher = List_Class_Group_Teacher;
            ViewBag.List_Class_Group_Member = List_Class_Group_Member;
        }