public bool AddCourse(string name, Course course)
 {
     if (IsFilled())
     {
         return(false);
     }
     if (!Courses.ContainsKey(name))
     {
         Courses.Add(name, course);
         takenCredits += course.Credits;
         return(IsFilled());
     }
     return(false);
 }
Пример #2
0
        internal void Read()
        {
            Courses    = ReadCourse();
            AEIncludes = ReadAEInclude();
            Attends    = ReadCurrentSemesterAttend();
            List <JHSCETakeRecord> SCETakes = ReadSCETake();

            // 取得新竹評量樣版設定
            Util.ScorePercentageHSDict.Clear();
            Util.ScorePercentageHSDict = Util.GetScorePercentageHS();

            //清除原有的資料。
            foreach (StudentScore each in Students.Values)
            {
                each.AttendScore.Clear();
            }

            Reporter.Feedback("計算成績...", 0);
            int t1 = Environment.TickCount;

            foreach (JHSCAttendRecord Attend in Attends.Values)
            {
                if (!Students.ContainsKey(Attend.RefStudentID))
                {
                    continue;
                }
                StudentScore Student = Students[Attend.RefStudentID];

                if (!Courses.ContainsKey(Attend.RefCourseID))
                {
                    continue;
                }
                JHCourseRecord Course = Courses[Attend.RefCourseID];

                bool toSems = (Course.CalculationFlag == "1") ? true : false;

                string subjName = Course.Subject.Trim();

                // 如果科目名稱空白就不處理,因為無法計算到科目成績
                if (string.IsNullOrWhiteSpace(subjName))
                {
                    continue;
                }

                //傳入學年度,判斷103以前的學年度5:5而以後6:4比例計算
                if (!Student.AttendScore.Contains(subjName))
                {
                    Student.AttendScore.Add(subjName, new AttendScore(Attend, Course.Credit, Course.Period, toSems, Course.Domain, Course.SchoolYear));
                }
            }

            try
            {
                foreach (JHSCETakeRecord take in SCETakes)
                {
                    if (!Attends.ContainsKey(take.RefSCAttendID))
                    {
                        continue;
                    }
                    JHSCAttendRecord Attend = Attends[take.RefSCAttendID];

                    if (!Students.ContainsKey(Attend.RefStudentID))
                    {
                        continue;
                    }
                    StudentScore Student = Students[Attend.RefStudentID];

                    if (!Courses.ContainsKey(Attend.RefCourseID))
                    {
                        continue;
                    }
                    JHCourseRecord Course = Courses[Attend.RefCourseID];

                    if (!AEIncludes.ContainsKey(Course.RefAssessmentSetupID))
                    {
                        continue;
                    }
                    Dictionary <string, AEIncludeData> Include = AEIncludes[Course.RefAssessmentSetupID];

                    //沒有該次考試就不處理。
                    if (!Include.ContainsKey(take.RefExamID))
                    {
                        continue;
                    }

                    string subjName = Course.Subject.Trim();

                    // 如果科目名稱空白就不處理,因為無法計算到科目成績
                    if (string.IsNullOrWhiteSpace(subjName))
                    {
                        continue;
                    }

                    try
                    {
                        Student.AttendScore[subjName].Subscores.Add(take.RefExamID, new TakeScore(take, Include[take.RefExamID]));
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }



            Reporter.Feedback("時間:" + (Environment.TickCount - t1), 0);
        }
Пример #3
0
        private Dictionary <string, JHSCAttendRecord> ReadCurrentSemesterAttend()
        {
            Reporter.Feedback("讀取修課資料...", 0);

            List <string> studKeys = Students.Values.ToKeys();
            Dictionary <string, JHSCAttendRecord> currentAttends = new Dictionary <string, JHSCAttendRecord>();

            //分批取得資料。
            FunctionSpliter <string, JHSCAttendRecord> spliter = new FunctionSpliter <string, JHSCAttendRecord>(300, Util.MaxThread);

            spliter.Function = delegate(List <string> studKeysPart)
            {
                return(JHSCAttend.SelectByStudentIDs(studKeysPart));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                Reporter.Feedback("讀取修課資料...", Util.CalculatePercentage(studKeys.Count, progress));
            };
            List <JHSCAttendRecord> allAttends = spliter.Execute(studKeys);

            //用於檢查重覆修習科目。
            //Dictionary<string, Dictionary<string, string>> duplicate = new Dictionary<string, Dictionary<string, string>>();



            //過濾修課記錄的學年度、學期,只要本學期的成績。
            foreach (JHSCAttendRecord each in allAttends)
            {
                if (!Courses.ContainsKey(each.RefCourseID))
                {
                    continue;
                }
                JHCourseRecord course = Courses[each.RefCourseID];

                if (!course.SchoolYear.HasValue)
                {
                    continue;
                }
                if (!course.Semester.HasValue)
                {
                    continue;
                }

                if (course.SchoolYear.Value != SchoolYear)
                {
                    continue;
                }
                if (course.Semester.Value != Semester)
                {
                    continue;
                }

                currentAttends.Add(each.ID, each);


                //// 2016/5/25 穎驊新增 ,只有在該科目需要列入計算才更進一步加到currentAttends,如此一來可以濾掉科目名稱為空的社團課(不列入計算的課)
                //if (each.Course.CalculationFlag == "1")
                //{

                //    #region 檢查重覆修習科目。
                //    if (!duplicate.ContainsKey(each.RefStudentID))
                //        duplicate.Add(each.RefStudentID, new Dictionary<string, string>());

                //    if (duplicate[each.RefStudentID].ContainsKey(course.Subject.Trim()))
                //    {
                //        if (!Students.ContainsKey(each.RefStudentID)) continue;
                //        StudentScore student = Students[each.RefStudentID];


                //        //  2016/5/25 穎驊新增,針對如果同一學生同一學期有修習同一門科目名稱的課,會跳出視窗提醒。
                //        MessageBox.Show(string.Format("學生「{0}」在「{1}」學年「{2}」學期,重覆修習科目「{3}」,將使學期科目成績計算遺漏誤植,請確認並修正該科目。", student.Name, course.SchoolYear, course.Semester, course.Subject));

                //        break;

                //        //throw new ArgumentException(string.Format("學生「{0}」重覆修習科目「{1}」。", student.Name, course.Subject));
                //        //continue; //先略過不管。
                //    }
                //    duplicate[each.RefStudentID].Add(course.Subject.Trim(), null);
                //    #endregion;


                //    currentAttends.Add(each.ID, each);

                //}
            }

            return(currentAttends);
        }
 public bool ContainsCourse(string name)
 {
     return(Courses.ContainsKey(name));
 }
Пример #5
0
        internal void Read()
        {
            Courses    = ReadCourse();
            AEIncludes = ReadAEInclude();
            Attends    = ReadCurrentSemesterAttend();
            List <JHSCETakeRecord> SCETakes = ReadSCETake();

            //清除原有的資料。
            foreach (StudentScore each in Students.Values)
            {
                each.AttendScore.Clear();
            }

            Reporter.Feedback("計算成績...", 0);
            int t1 = Environment.TickCount;

            foreach (JHSCAttendRecord Attend in Attends.Values)
            {
                if (!Students.ContainsKey(Attend.RefStudentID))
                {
                    continue;
                }
                StudentScore Student = Students[Attend.RefStudentID];

                if (!Courses.ContainsKey(Attend.RefCourseID))
                {
                    continue;
                }
                JHCourseRecord Course = Courses[Attend.RefCourseID];

                bool toSems = (Course.CalculationFlag == "1") ? true : false;

                string subjName = Course.Subject.Trim();

                if (!Student.AttendScore.Contains(subjName))
                {
                    Student.AttendScore.Add(subjName, new AttendScore(Attend, Course.Credit, Course.Period, toSems, Course.Domain));
                }
            }

            foreach (JHSCETakeRecord take in SCETakes)
            {
                if (!Attends.ContainsKey(take.RefSCAttendID))
                {
                    continue;
                }
                JHSCAttendRecord Attend = Attends[take.RefSCAttendID];

                if (!Students.ContainsKey(Attend.RefStudentID))
                {
                    continue;
                }
                StudentScore Student = Students[Attend.RefStudentID];

                if (!Courses.ContainsKey(Attend.RefCourseID))
                {
                    continue;
                }
                JHCourseRecord Course = Courses[Attend.RefCourseID];

                if (!AEIncludes.ContainsKey(Course.RefAssessmentSetupID))
                {
                    continue;
                }
                Dictionary <string, AEIncludeData> Include = AEIncludes[Course.RefAssessmentSetupID];

                //沒有該次考試就不處理。
                if (!Include.ContainsKey(take.RefExamID))
                {
                    continue;
                }

                string subjName = Course.Subject.Trim();
                Student.AttendScore[subjName].Subscores.Add(take.RefExamID, new TakeScore(take, Include[take.RefExamID]));
            }

            Reporter.Feedback("時間:" + (Environment.TickCount - t1), 0);
        }
Пример #6
0
        private Dictionary <string, JHSCAttendRecord> ReadCurrentSemesterAttend()
        {
            Reporter.Feedback("讀取修課資料...", 0);

            List <string> studKeys = Students.Values.ToKeys();
            Dictionary <string, JHSCAttendRecord> currentAttends = new Dictionary <string, JHSCAttendRecord>();

            //分批取得資料。
            FunctionSpliter <string, JHSCAttendRecord> spliter = new FunctionSpliter <string, JHSCAttendRecord>(300, Util.MaxThread);

            spliter.Function = delegate(List <string> studKeysPart)
            {
                return(JHSCAttend.SelectByStudentIDs(studKeysPart));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                Reporter.Feedback("讀取修課資料...", Util.CalculatePercentage(studKeys.Count, progress));
            };
            List <JHSCAttendRecord> allAttends = spliter.Execute(studKeys);

            //用於檢查重覆修習科目。
            Dictionary <string, Dictionary <string, string> > duplicate = new Dictionary <string, Dictionary <string, string> >();

            //過濾修課記錄的學年度、學期,只要本學期的成績。
            foreach (JHSCAttendRecord each in allAttends)
            {
                if (!Courses.ContainsKey(each.RefCourseID))
                {
                    continue;
                }
                JHCourseRecord course = Courses[each.RefCourseID];

                if (!course.SchoolYear.HasValue)
                {
                    continue;
                }
                if (!course.Semester.HasValue)
                {
                    continue;
                }

                if (course.SchoolYear.Value != SchoolYear)
                {
                    continue;
                }
                if (course.Semester.Value != Semester)
                {
                    continue;
                }

                #region 檢查重覆修習科目。
                if (!duplicate.ContainsKey(each.RefStudentID))
                {
                    duplicate.Add(each.RefStudentID, new Dictionary <string, string>());
                }

                if (duplicate[each.RefStudentID].ContainsKey(course.Subject.Trim()))
                {
                    if (!Students.ContainsKey(each.RefStudentID))
                    {
                        continue;
                    }
                    StudentScore student = Students[each.RefStudentID];
                    //throw new ArgumentException(string.Format("學生「{0}」重覆修習科目「{1}」。", student.Name, course.Subject));
                    continue; //先略過不管。
                }
                duplicate[each.RefStudentID].Add(course.Subject.Trim(), null);
                #endregion ;

                currentAttends.Add(each.ID, each);
            }

            return(currentAttends);
        }