コード例 #1
0
        public bool AddStudent(Student newStudent)
        {
            IStudentDao studentDao = new StudentDao(sessionFactory);
            ISystemUserDao systemUserDao = new SystemUserDao(sessionFactory);

            try
            {
                int studentId=(Int32)studentDao.Save(newStudent);
                //先存入Student,在存入SystemUser
                SystemUser newSystemUser = new SystemUser
                {
                    systemUserID = studentId.ToString(),
                    systemUserPassword = newStudent.studentPassword,
                    systemUserType = 1
                };
                systemUserDao.Save(newSystemUser);
                return true;
            }
            catch (Exception e) {
                return false;
            }
        }
コード例 #2
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;
        }
コード例 #3
0
 public IList<Student> GetAllStudent()
 {
     IStudentDao studentDao = new StudentDao(sessionFactory);
     try
     {
         IList<Student> studentList = studentDao.LoadAll();
         return studentList;
     }
     catch (Exception e)
     {
         return null;
     }
 }
コード例 #4
0
 public Student GetStuentByID(string userId)
 {
     int studentId = Int32.Parse(userId);
     IStudentDao studentDao = new StudentDao(sessionFactory);
     return studentDao.Get(studentId);
 }