예제 #1
0
        public void initData()
        {
            //Confirmation all teachers, grades and classes have loaded.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            //confirmation all course groups and locations has loaded.
            if (!CourseWeekViewModel.getInstance().mIsInitialized)
            {
                CourseWeekViewModel.getInstance().worker_initDataFromDatabase(false);
            }

            //Get the current user's id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];
            int         basicid     = 0;

            if (currentUser != null)
            {
                basicid = currentUser.id;
            }
            selectedClassid = DatabaseHelper.getClassIdByHeadTeacherId(basicid);
            classCourses    = DatabaseHelper.getClassCoursesByTeacherId(basicid);

            //find the class which the teacher has teached.
            foreach (ClassCourse cc in classCourses)
            {
                classes.Add(ClassViewModel.getInstance().getClassById(cc.classid));
            }
            courseGroups     = getCourseGroupsByClassId(selectedClassid);
            selectedCourseid = courseGroups[0].id;

            //start load  course cards.
            currentCourseCards = DatabaseHelper.getAllCourseCards(selectedClassid, selectedCourseid);
        }
예제 #2
0
        public void initData()
        {
            initWeekNo();
            //Judge ClassViewModel is initilized to get all teachers, all grades and all classes.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            //init selected grade id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];

            if (currentUser != null)
            {
                //set selectedGradeId;
                int basicId = currentUser.id;
                selectedClassId = DatabaseHelper.getClassIdByTeacherId(basicId);
            }
            if (selectedClassId == -1)
            {
                selectedClassId = ClassViewModel.getInstance().allClasses[0].id;
            }

            //init courseGroups.
            allCourseGroups = DatabaseHelper.getallCourseGroups();
            readWeeklyReportItemsFromDataBase(-1);
        }
예제 #3
0
 public static ClassViewModel getInstance()
 {
     // DoubleLock
     if (instance == null)
     {
         lock (m_lock)
         {
             if (instance == null)
             {
                 instance = new ClassViewModel();
             }
         }
     }
     return(instance);
 }
        public void worker_initDataFromDatabase(bool newMakeCourseSchedule)
        {
            initWeekNo();

            //Judge ClassViewModel is initilized to get all teachers, all grades and all classes.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            // load course groups and locations.
            justInitCourseGroupsAndLocations();

            //init selected grade id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];

            if (currentUser != null)
            {
                //set selectedGradeId;
                defaultTeacherId = currentUser.id;
                selectedClassId  = DatabaseHelper.getClassIdByTeacherId(defaultTeacherId);
            }
            if (selectedClassId == -1)
            {
                defaultTeacherId = ClassViewModel.getInstance().allTeachers[0].id;
                selectedClassId  = ClassViewModel.getInstance().allClasses[0].id;
            }

            defaultLocationId = ClassViewModel.getInstance().getClassDefaultLocationByClassId(selectedClassId);

            //1415211  14~15代表学年,2代表第二学期,11代表第十一周
            if (newMakeCourseSchedule)
            {
                oneWeekCourseWeekItems = new ObservableCollection <CourseWeekItem>();
            }
            else
            {
                oneWeekCourseWeekItems = DatabaseHelper.getOneWeekCourseWeekItems(selectedClassId, courseWeekNoForDB);
            }
            mHasSavedInMemoryHashTable = new Hashtable();
            mIsInitialized             = true;
        }