Exemplo n.º 1
0
        /// <summary>
        /// 取得社團相關資料
        /// </summary>
        private Dictionary <string, List <FactsObj_big> > GetClubData()
        {
            //社團ID : 社團特殊物件
            Dictionary <string, List <FactsObj_big> > dic1 = new Dictionary <string, List <FactsObj_big> >();

            //社團ID : 社團特殊物件
            Dictionary <string, List <FactsObj_big> > dic_Sort = new Dictionary <string, List <FactsObj_big> >();

            //取得本學年度的社團清單
            List <CLUBRecord> CLUBRecordList = _accessHelper.Select <CLUBRecord>(string.Format("school_year={0} and semester={1}", _SchoolYear, _Semester));

            #region 取得學生用

            List <string> CLUBIDList = new List <string>();

            foreach (CLUBRecord each in CLUBRecordList)
            {
                CLUBIDList.Add(each.UID);
            }

            List <SCJoin> SCJoinList = _accessHelper.Select <SCJoin>("ref_club_id in ('" + string.Join("','", CLUBIDList) + "')");

            List <string> StudentIDList = new List <string>();

            //社團 : 參與記錄
            Dictionary <string, List <SCJoin> > SCJDic = new Dictionary <string, List <SCJoin> >();

            foreach (SCJoin each in SCJoinList)
            {
                StudentIDList.Add(each.RefStudentID);

                if (!SCJDic.ContainsKey(each.RefClubID))
                {
                    SCJDic.Add(each.RefClubID, new List <SCJoin>());
                }
                SCJDic[each.RefClubID].Add(each);
            }

            List <StudentRecord> StudentList = Student.SelectByIDs(StudentIDList);
            Dictionary <string, StudentRecord> StudentDic = new Dictionary <string, StudentRecord>();
            foreach (StudentRecord each in StudentList)
            {
                if (!StudentDic.ContainsKey(each.ID))
                {
                    StudentDic.Add(each.ID, each);
                }
            }

            #endregion

            //取得教師資料
            Dictionary <string, TeacherCrk> TeacherDic = GetTeacher();

            //排序用
            List <string> CLUBNameSortList = new List <string>();

            foreach (CLUBRecord each in CLUBRecordList)
            {
                FactsObj_big F = new FactsObj_big(each);

                if (SCJDic.ContainsKey(each.UID))
                {
                    foreach (SCJoin scj in SCJDic[each.UID])
                    {
                        if (StudentDic.ContainsKey(scj.RefStudentID))
                        {
                            StudentRecord SR = StudentDic[scj.RefStudentID];
                            if (SR.Status == StudentRecord.StudentStatus.一般 || SR.Status == StudentRecord.StudentStatus.延修)
                            {
                                if (SR.Class != null)
                                {
                                    if (SR.Class.GradeYear.HasValue)
                                    {
                                        if (SR.Class.GradeYear.Value == 1)
                                        {
                                            F.StudentList_1.Add(SR);
                                        }
                                        else if (SR.Class.GradeYear.Value == 2)
                                        {
                                            F.StudentList_2.Add(SR);
                                        }
                                        else if (SR.Class.GradeYear.Value == 3)
                                        {
                                            F.StudentList_3.Add(SR);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //是否有老師
                if (!string.IsNullOrEmpty(each.RefTeacherID))
                {
                    if (TeacherDic.ContainsKey(each.RefTeacherID))
                    {
                        F.Teacher = TeacherDic[each.RefTeacherID]; //社團老師
                    }
                }

                //資料盒建立
                if (!dic1.ContainsKey(each.ClubCategory + "_" + each.ClubNumber))
                {
                    dic1.Add(each.ClubCategory + "_" + each.ClubNumber, new List <FactsObj_big>());
                    CLUBNameSortList.Add(each.ClubCategory + "_" + each.ClubNumber);
                }

                dic1[each.ClubCategory + "_" + each.ClubNumber].Add(F);
            }



            //排序資料
            CLUBNameSortList.Sort();
            foreach (string each in CLUBNameSortList)
            {
                dic_Sort.Add(each, dic1[each]);
            }

            return(dic_Sort);
        }
Exemplo n.º 2
0
 int SortClub(FactsObj_big a, FactsObj_big b)
 {
     return(a.社團代碼.CompareTo(b.社團代碼));
 }