コード例 #1
0
 //退课
 public bool DropCourse(int studentId, int courseId)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     Course selectedCourse = courseDao.Get(courseId);
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     SelectionID selectionID = new SelectionID {
         selectionStudentID=studentId,
         selectionCourseID=courseId,
         selectionStudyYear=selectedCourse.courseStudyYear,
          selectionTerm=selectedCourse.courseTerm
     };
     Selection selection=selectionDao.Get(selectionID);
     if (null != selection)
     {
         try
         {
             selectionDao.Delete(selection);
             return true;
         }
         catch (Exception e) {
             return false;
         }
     }
     else {
         return false;
     }
 }
コード例 #2
0
 public bool ChangeCourseDetail(Course selectedCourse)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     try
     {
         courseDao.Update(selectedCourse);
         return true;
     }
     catch (Exception e) {
         return false;
     }
 }
コード例 #3
0
 //学生就不会看到这门课
 public bool CloseCourse(int courseId, bool openFlag)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     Course selectedCourse = courseDao.Get(courseId);
     selectedCourse.courseOpenCloseFlag = openFlag;
     try
     {
         courseDao.Update(selectedCourse);
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
コード例 #4
0
        public int AddCourse(Domain.Course newCourse)
        {
            ICourseDao courseDao = new CourseDao(sessionFactory);
            try
            {
               Course havedCourse=courseDao.GetCourseByTeacherIDAndName(newCourse.courseTeacherID,newCourse.courseName);
               if (havedCourse == null)
               {
                   int courseId = (Int32)courseDao.Save(newCourse);
                   return courseId;
               }
               else {
                   return 0;
               }

            }catch (Exception e) {
                return 0;
            }
        }
コード例 #5
0
        public IList<Course> GetAllSelectableCourse(string className, string grade,int studentId)
        {
            IClassGradeCourseDao classGradeCourseDao = new ClassGradeCourseDao(sessionFactory);
            IList<ClassGradeCourse> classGradeCourseList = classGradeCourseDao.GetAllSelectableClassGradeCourse(className, grade);
            ICourseDao courseDao=new CourseDao(sessionFactory);
            for (int i = 0; i < classGradeCourseList.Count; i++) {
                Course closeCourse = courseDao.Get(classGradeCourseList[i].ID.classGradeCourseCourseId);
                //如果这一门课是关闭了,就去掉这个选课关联项
                if (false == closeCourse.courseOpenCloseFlag) {
                    classGradeCourseList.RemoveAt(i);
                    continue;
                }

                //再去掉已经选择的课程,有courseID,年级,专业,课,这门课就不用显示了
                ISelectionDao selectionDao = new SelectionDao(sessionFactory);
                IList<Selection> selectionList = selectionDao.GetSelectionByStudentId(studentId);

                for (int j = 0; j < selectionList.Count; j++)
                {
                    if (selectionList[j].ID.selectionCourseID == classGradeCourseList[i].ID.classGradeCourseCourseId)
                    {
                        classGradeCourseList.RemoveAt(i);
                        continue;
                    }
                }
            }

            IList<Course> selectableCourseList = new List<Course>();

            for (int j = 0; j < classGradeCourseList.Count; j++) {
                Course selectableCourse =courseDao.Get(classGradeCourseList[j].ID.classGradeCourseCourseId);
                selectableCourseList.Add(selectableCourse);
            }
            return selectableCourseList;
        }
コード例 #6
0
 //选课,生成一个Selection
 public bool SelectCourse(int studentId, int courseId)
 {
     //IStudentDao studentDao = new StudentDao(sessionFactory);
     ICourseDao courseDao = new CourseDao(sessionFactory);
     Course selectedCourse = courseDao.Get(courseId);
     Selection newSelection = new Selection
     {
         ID = new SelectionID {
             selectionStudentID=studentId,
             selectionCourseID=selectedCourse.courseID,
             selectionStudyYear=selectedCourse.courseStudyYear,
             selectionTerm=selectedCourse.courseTerm
         },
         selectionScorePermit=false,
         selectionScore =-1
     };
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     if (null != selectionDao.Save(newSelection))
     {
         return true;
     }
     else {
         return false;
     }
 }
コード例 #7
0
 public Course GetCourseById(int courseId)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     return courseDao.Get(courseId);
 }
コード例 #8
0
 public IList<Course> GetAllSelectedCourse(int studentId)
 {
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     IList<Selection> selectedSelectionList=selectionDao.GetSelectionByStudentId(studentId);
     ICourseDao courseDao = new CourseDao(sessionFactory);
     IList<Course> selectedCourseList = new List<Course>();
     for (int i = 0; i < selectedSelectionList.Count;i++ )
     {
         Course selectedCourse=courseDao.Get(selectedSelectionList[i].ID.selectionCourseID);
         selectedCourseList.Add(selectedCourse);
     }
     return selectedCourseList;
 }
コード例 #9
0
 public bool UpdateCourse(Course updateCourse)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     try
     {
         courseDao.Update(updateCourse);
         return true;
     }
     catch (Exception e) {
         return false;
     }
 }
コード例 #10
0
        //得到选择课程的学生表,是当前学年学期的选课的学生,往年的要专门查询查Selecion表
        public IList<Student> GetSelectCourseStudent(int courseId)
        {
            ICourseDao courseDao = new CourseDao(sessionFactory);
            Course selectedCourse = courseDao.Get(courseId);
            string studyYear = selectedCourse.courseStudyYear;
            string term = selectedCourse.courseTerm;
            ISelectionDao selectionDao = new SelectionDao(sessionFactory);
            //Selection表,是否为空?否则就是NullException
            IList<Selection> selectionList=selectionDao.GetSelectionByCourse(courseId,studyYear,term);

            //IList<Student> studentList=null;
            //(还未分配空间,一定要分配了空间给一个对象才可以用其实例方法)
            IList<Student> studentList =new List<Student>();
            IStudentDao studentDao = new StudentDao(sessionFactory);
            for (int i = 0; i < selectionList.Count; i++) {
                studentList.Add(studentDao.Get(selectionList[i].ID.selectionStudentID));
            }
            return studentList;
        }
コード例 #11
0
 public IList<Course> GetMyCourse(int teacherId)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     IList<Course> teacherCourseList = courseDao.GetMyCourse(teacherId);
     return teacherCourseList;
 }
コード例 #12
0
 public void ChangeCourseDetail()
 {
     int courseId =1000;
     ICourseDao courseDao = new CourseDao(sessionFactory);
     Course selectedCourse = courseDao.Get(courseId);
     bool success=teacherController.ChangeCourseDetail(selectedCourse);
     Assert.AreEqual(true,success);
 }