Пример #1
0
        /// <summary>
        /// 某个用户的课程信息
        /// </summary>
        /// <param name="id"></param>
        public ActionResult CourseInfo(int id)
        {
            UserCourseViewData viewData = new UserCourseViewData();
            viewData.user = GetUser();
            int userID = viewData.user.UserID;

            //以往班级
            viewData.ClassList = (from c in CQGJ.Classes
                                  from s in CQGJ.Student
                                  where s.Classes == c && s.User.UserID == userID && c.Status == 3 //修改刘涛, status=2为开班中,3为结束
                                  select c).ToList();
            //现在班级
            viewData.CureentClassesList = (from c in CQGJ.Classes
                                           from s in CQGJ.Student
                                           where s.Classes == c && s.User.UserID == userID && c.Status == 2 //修改刘涛, status=2为开班中,3为结束
                                           select c).ToList();

            viewData.course = (from c in CQGJ.Course where c.CourseID == id select c).First();

            //所在班级
            foreach (Classes c in viewData.CureentClassesList)
            {
                if (c.ClassID == viewData.course.Classes.ClassID)
                {
                    viewData.Classes = c;
                }
            }
            int ClassID = viewData.Classes.ClassID;
            // int TID = viewData.Classes.Teacher
            viewData.ClassBBS = (from b in CQGJ.BBS where b.Classes.ClassID == ClassID select b).First();

            ClassID = viewData.Classes.ClassID;
            viewData.courselist = (from c in CQGJ.Course where c.Classes.ClassID == ClassID select c).ToList();
            for (int i = 0; i < viewData.courselist.Count; ++i)
            {
                if (viewData.courselist[i].CourseID == viewData.course.CourseID)
                {
                    viewData.courselist.Remove(viewData.courselist[i]);
                    i = viewData.courselist.Count + 100;
                }
            }
            viewData.learnlist = (from l in CQGJ.LearnGain where l.CourseResult.Course.CourseID == id && l.CourseResult.Student.User.UserID == userID select l).ToList();
            viewData.paperlist = (from p in CQGJ.Paper where p.CourseResult.Course.CourseID == id && p.CourseResult.Student.User.UserID == userID select p).ToList();

            viewData.Classlearnlist = (from l in CQGJ.LearnGain where l.CourseResult.Course.CourseID == id select l).ToList();
            viewData.Classpaperlist = (from p in CQGJ.Paper where p.CourseResult.Course.CourseID == id select p).ToList();
            if (viewData.course.CoursewareID1 != null && viewData.course.CoursewareID1 != 0)
            {
                int iwareID = (int)viewData.course.CoursewareID1;
                viewData.courseware1 = (from w in CQGJ.Courseware
                                        where w.CoursewareID == iwareID
                                        select w).First();
            }

            if (viewData.course.CoursewareID2 != null && viewData.course.CoursewareID2 != 0)
            {
                int iwareID = (int)viewData.course.CoursewareID2;
                viewData.courseware2 = (from w in CQGJ.Courseware
                                        where w.CoursewareID == iwareID
                                        select w).First();
            }

            if (viewData.course.BookID1 != null && viewData.course.BookID1 != 0)
            {
                int ibookID = (int)viewData.course.BookID1;
                viewData.book1 = (from b in CQGJ.Book
                                  where b.BookID == ibookID
                                  select b).First();

            }
            if (viewData.course.BookID2 != null && viewData.course.BookID2 != 0)
            {
                int ibookID = (int)viewData.course.BookID2;
                viewData.book2 = (from b in CQGJ.Book
                                  where b.BookID == ibookID
                                  select b).First();
            }

            if (viewData.ClassBBS != null)
            {
                int BBSID = viewData.ClassBBS.BBSID;
                //班级论坛帖子
                viewData.BBSItemList = (from b in CQGJ.BBSItem
                                        orderby b.SubmitTime descending
                                        where b.BBS.BBSID == BBSID && b.ParentID == -1
                                        select b).Take(10).ToList();
            }
            viewData.user = GetUser();
            return View("Course", viewData);
        }
Пример #2
0
        /// <summary>
        /// 某个用户的课程信息
        /// </summary>
        /// <param name="id"></param>
        public void CourseInfo(int id)
        {
            IsLogin();

            UserCourseViewData viewData = new UserCourseViewData();

            viewData.user = (CQGJ.passport.User)HttpContext.Session["userobject"];
            int userID = viewData.user.UserID;

            userID = ToUserID(userID); //zhuanhua

            //班级通知
            //viewData.NotifyList = (from n in CQGJ.Notify where  select n).ToList();

            try
            {
                //以往班级
                viewData.ClassList = (from c in CQGJ.Classes
                                      from s in CQGJ.Student
                                      where s.Classes == c && s.User.UserID == userID && c.Status == 3 //修改刘涛, status=2为开班中,3为结束
                                      select c).ToList();

                //现在班级
                viewData.CureentClassesList = (from c in CQGJ.Classes
                                               from s in CQGJ.Student
                                               where s.Classes == c && s.User.UserID == userID && c.Status == 2 //修改刘涛, status=2为开班中,3为结束
                                               select c).ToList();
            }
            catch
            {
            }
            string str = ConfigurationManager.AppSettings["PhotoUrl"].ToString();
            viewData.URL = str;

            try
            {
                viewData.course = (from c in CQGJ.Course where c.CourseID == id select c).First();
            }
            catch
            {
                //错误
            }

            try
            {
                //所在班级
                foreach (Classes c in viewData.CureentClassesList)
                {
                    if (c.ClassID == viewData.course.Classes.ClassID)
                    {
                        viewData.Classes = c;
                    }
                }
                int ClassID = viewData.Classes.ClassID;
                // int TID = viewData.Classes.Teacher
                viewData.ClassBBS = (from b in CQGJ.BBS where b.Classes.ClassID == ClassID select b).First();

            }
            catch
            {
                ;
            }
            try
            {
                int ClassID = viewData.Classes.ClassID;
                viewData.courselist = (from c in CQGJ.Course where c.Classes.ClassID == ClassID select c).ToList();
                for (int i = 0; i < viewData.courselist.Count; ++i)
                {
                    if (viewData.courselist[i].CourseID == viewData.course.CourseID)
                    {
                        viewData.courselist.Remove(viewData.courselist[i]);
                        i = viewData.courselist.Count + 100;
                    }
                }
                viewData.learnlist = (from l in CQGJ.LearnGain where l.CourseResult.Course.CourseID == id && l.CourseResult.Student.User.UserID == userID select l).ToList();
                viewData.paperlist = (from p in CQGJ.Paper where p.CourseResult.Course.CourseID == id && p.CourseResult.Student.User.UserID == userID select p).ToList();

                viewData.Classlearnlist = (from l in CQGJ.LearnGain where l.CourseResult.Course.CourseID == id select l).ToList();
                viewData.Classpaperlist = (from p in CQGJ.Paper where p.CourseResult.Course.CourseID == id select p).ToList();
                if (viewData.course.CoursewareID1 != null && viewData.course.CoursewareID1 != 0)
                {
                    int iwareID = (int)viewData.course.CoursewareID1;
                    try
                    {
                        viewData.courseware1 = (from w in CQGJ.Courseware where w.CoursewareID == iwareID select w).First();
                    }
                    catch
                    { }
                }
                if (viewData.course.CoursewareID2 != null && viewData.course.CoursewareID2 != 0)
                {
                    int iwareID = (int)viewData.course.CoursewareID2;
                    try
                    {
                        viewData.courseware2 = (from w in CQGJ.Courseware where w.CoursewareID == iwareID select w).First();
                    }
                    catch
                    { }
                }

                if (viewData.course.BookID1 != null && viewData.course.BookID1 != 0)
                {
                    int ibookID = (int)viewData.course.BookID1;
                    try
                    {
                        viewData.book1 = (from b in CQGJ.Book where b.BookID == ibookID select b).First();
                    }
                    catch
                    { }
                }
                if (viewData.course.BookID2 != null && viewData.course.BookID2 != 0)
                {
                    int ibookID = (int)viewData.course.BookID2;
                    try
                    {
                        viewData.book2 = (from b in CQGJ.Book where b.BookID == ibookID select b).First();
                    }
                    catch
                    { }
                }
            }
            catch
            {
                ;
            }

            if (viewData.ClassBBS != null)
            {
                int BBSID = viewData.ClassBBS.BBSID;
                //班级论坛帖子
                viewData.BBSItemList = (from b in CQGJ.BBSItem
                                        orderby b.SubmitTime descending
                                        where b.BBS.BBSID == BBSID && b.ParentID == -1
                                        select b).Take(10).ToList();
            }
            viewData.user = (CQGJ.passport.User)HttpContext.Session["userobject"];

            RenderView("Course", viewData);
        }