예제 #1
0
        //分组列表
        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 TeacherList(int trainingId)
        {
            PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL();
            Code.SiteCache cache = Code.SiteCache.Instance;
            int partitionId = cache.LoginInfo.PartitionId;
            int organId = cache.ManageOrganId;

            StringBuilder where = new StringBuilder();
            string keyWords = "";
            if (!string.IsNullOrEmpty(Request["KeyWords"]))
                keyWords = Request["KeyWords"].Trim();
            ViewBag.KeyWords = keyWords;
            if (keyWords != "")
                where.Append("A.NickName like '%" + keyWords + "'");

            DataTable dt = new UtilsBLL().GetRecursion("Organ_Detail", "Id", "ParentId", organId);
            StringBuilder organ = new StringBuilder();
            foreach (DataRow row in dt.Rows)
            {
                organ.Append(row["Id"] + ",");
            }
            organ.Append("0");

            int recordCount = bll.GetTeacherCount(partitionId, organ.ToString(), where.ToString());
            int pageSize = 15, pageIndex;
            int pageCount = (int)Math.Ceiling((double)recordCount / pageSize);
            int.TryParse(Request["PageIndex"], out pageIndex);
            if (pageCount == 0)
            {
                pageIndex = 0;
            }
            else
            {
                if (pageIndex < 1)
                    pageIndex = 1;
                else if (pageIndex > pageCount)
                    pageIndex = pageCount;
            }
            ViewBag.RecordCount = recordCount;
            ViewBag.PageCount = pageCount;
            ViewBag.PageIndex = pageIndex;
            ViewBag.PageSize = pageSize;
            ViewBag.TrainingId = trainingId;

            List<Traning_Teacher> list = new Traning_TeacherBLL().GetList("Delflag=0 and TraningId=" + trainingId, "");
            StringBuilder ids = new StringBuilder();
            foreach (var item in list)
            {
                ids.Append(item.PlatformManagerId + ",");
            }
            if (ids.Length > 0)
                ids.Remove(ids.Length - 1, 1);
            ViewBag.SelectedTeacher = list;
            ViewData["SelectedIds"] = ids.ToString();

            return View(bll.GetTeacherList(pageSize, pageIndex, "B.Id", partitionId, organ.ToString(), where.ToString()).Rows);
        }
예제 #3
0
        //小组讨论
        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 ActionResult AjaxBatchSelectTeacher(int trainingId, string ids)
        {
            PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL();
            List<string> list = new List<string>();
            if (!string.IsNullOrEmpty(ids))
            {
                list.AddRange(ids.Split(','));
            }
            DataTable dt = new Traning_TeacherBLL().GetTable("Delflag=0 and TraningId=" + trainingId, "");

            int count = 0;
            foreach (string s in list)
            {
                if (dt.Select("PlatformManagerId=" + s).Count() == 0)
                {
                    DataRow row = dt.NewRow();
                    row["Id"] = 0;
                    row["TraningId"] = trainingId;
                    row["PlatformManagerId"] = Convert.ToInt32(s);
                    row["Status"] = 1;
                    row["Delflag"] = 0;
                    row["CreateDate"] = DateTime.Now;
                    dt.Rows.Add(row);
                    count++;
                }
            }
            foreach (DataRow row in dt.Rows)
            {
                if (!list.Exists(t => t == row["PlatformManagerId"].ToString()))
                {
                    row.Delete();
                    count++;
                }
            }

            if (count == 0)
            {
                return Json(new { Result = false, Msg = "请勾选或移除教师!" }, JsonRequestBehavior.AllowGet);
            }

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    bll.BatchSelectTeacher(dt);
                    trans.Complete();

                    return Json(new { Result = true, Msg = "提交成功!" }, JsonRequestBehavior.AllowGet);
                }
                catch (Exception)
                {
                    return Json(new { Result = false, Msg = "提交失败!" }, JsonRequestBehavior.AllowGet);
                }
            }
        }