コード例 #1
0
 public void Delete(Selection entity)
 {
     using (ISession session = sessionFactory.OpenSession())
     {
         session.Delete(entity);
         session.Flush();
     }
 }
コード例 #2
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;
     }
 }
コード例 #3
0
 public void Save(Selection newSelection)
 {
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     selectionDao.Save(newSelection);
 }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
 public bool ScoreStudentCourse(Selection selectedSelection)
 {
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     try
     {
         selectionDao.Update(selectedSelection);
         return true;
     }
     catch (Exception e) {
         return false;
     }
 }
コード例 #6
0
 public object Save(Selection entity)
 {
     using (ISession session = sessionFactory.OpenSession())
     {
         var id = session.Save(entity);
         session.Flush();
         return id;
     }
 }