public void Delete(Selection entity)
 {
     using (ISession session = sessionFactory.OpenSession())
     {
         session.Delete(entity);
         session.Flush();
     }
 }
 //选课,生成一个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;
     }
 }
 public void Save(Selection newSelection)
 {
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     selectionDao.Save(newSelection);
 }
        protected void selectableCourseGridViewRowClick(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Int32.Parse((string)e.CommandArgument);
            if (e.CommandName == "SelectCourse")
            {
                StudentController studentController = (StudentController)Session["studentController"];
                int courseId =Int32.Parse(selectableCourseGridView.Rows[rowIndex].Cells[1].Text);
                int studentId=Int32.Parse(Session["userID"].ToString());
                Course course=studentController.GetCourseById(courseId);
                //选择课程生成一个Selection
                Selection newSelection = new Selection
                {
                    ID = new SelectionID
                    {
                        selectionStudentID=studentId,
                        selectionCourseID = courseId,
                        selectionStudyYear=course.courseStudyYear,
                        selectionTerm=course.courseTerm
                    },
                    selectionScore=-1,
                    selectionScorePermit=false

                };
                studentController.Save(newSelection);
                //刷新一次
                SetBind();
            }
        }
 public bool ScoreStudentCourse(Selection selectedSelection)
 {
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     try
     {
         selectionDao.Update(selectedSelection);
         return true;
     }
     catch (Exception e) {
         return false;
     }
 }
 public object Save(Selection entity)
 {
     using (ISession session = sessionFactory.OpenSession())
     {
         var id = session.Save(entity);
         session.Flush();
         return id;
     }
 }