예제 #1
0
        protected override void PrepareDataBackground()
        {
            List <JHSCETakeRecord> scetakes = JHSCETake.SelectByCourseAndExam(Courses.Values.ToKeys(), ExamId);

            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //將學生的成績清除,並新增一個 Token 用來放成績。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
                each.Scores.Add(ThisToken, new ScoreCollection());
            }

            foreach (JHSCETakeRecord take in scetakes) //特別注意 take.Score 是 Extensions 裡面的 Score 不是實體欄位的 Score。
            {
                if (!take.Score.HasValue)
                {
                    continue;                       //沒有成績就不處理。
                }
                JHSCAttendRecord attend;
                JHCourseRecord   course;
                RatingStudent    student;

                if (!SCAttends.TryGetValue(take.RefSCAttendID, out attend))
                {
                    continue;  //找不到該修課記錄。
                }
                if (!Courses.TryGetValue(take.RefCourseID, out course))
                {
                    continue;  //找不到該課程。
                }
                if (!dicstuds.TryGetValue(attend.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                ScoreCollection scores  = student.Scores[ThisToken];
                string          subject = course.Subject;

                if (!SelectedSubjects.Contains(subject))
                {
                    continue; //不在處理的科目清單中。
                }
                if (scores.Contains(subject))
                {
                    throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject));
                }

                scores.Add(subject, take.Score.Value);
            }
        }
예제 #2
0
        /// <summary>
        /// 更新畫面
        /// </summary>
        private void ReLoad()
        {
            _dirtyCellList.Clear();
            lblSave.Visible = false;
            _SceTakeDic.Clear();

            ExamComboBoxItem cboitem = _cboSelectedItem as ExamComboBoxItem;

            _RunningExamId   = cboitem.Value + "";
            _RunningExamName = cboitem.DisplayText;

            List <JHSCETakeRecord> records = JHSCETake.SelectByCourseAndExam(_course.ID, _RunningExamId);

            foreach (JHSCETakeRecord record in records)
            {
                if (!_SceTakeDic.ContainsKey(record.RefStudentID))
                {
                    _SceTakeDic.Add(record.RefStudentID, new SCETakeRecord(record));
                }
            }

            foreach (DataGridViewRow row in dgv.Rows)
            {
                //學生ID
                string sid = row.Tag + "";

                //Cell初值設定
                row.Cells[chInputScore.Index].Value           = "";
                row.Cells[chInputAssignmentScore.Index].Value = "";

                //有紀錄則填值
                if (_SceTakeDic.ContainsKey(sid))
                {
                    row.Cells[chInputScore.Index].Value           = _SceTakeDic[sid].ExamScore;
                    row.Cells[chInputAssignmentScore.Index].Value = _SceTakeDic[sid].RegularScore;
                }

                //將Cell的值填入tag作dirty判斷
                row.Cells[chInputScore.Index].Tag           = row.Cells[chInputScore.Index].Value;
                row.Cells[chInputAssignmentScore.Index].Tag = row.Cells[chInputAssignmentScore.Index].Value;

                //文字顏色修正
                FixTextColor(row.Cells[chInputScore.Index]);
                FixTextColor(row.Cells[chInputAssignmentScore.Index]);
            }

            pictureBox1.Visible = false;
        }
예제 #3
0
        protected override void PrepareDataBackground()
        {
            FunctionSpliter <string, JHSCETakeRecord> selectData = new FunctionSpliter <string, JHSCETakeRecord>(500, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSCETake.SelectByCourseAndExam(ps, ExamId));
            };
            List <JHSCETakeRecord> scetakes = selectData.Execute(Courses.Values.ToKeys());

            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //將學生的成績清除,並新增一個 Token 用來放成績。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
                each.Scores.Add(ScoreType.Domain.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.Subject.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.SummaryDomain.Regulation(Token), new ScoreCollection());
            }

            //記錄每一位學生的領域成績。
            Dictionary <string, DomainScoreCalculator> domainscores = new Dictionary <string, DomainScoreCalculator>();

            //計算領域成績。
            foreach (JHSCETakeRecord take in scetakes) //特別注意 take.Score 是 Extensions 裡面的 Score 不是實體欄位的 Score。
            {
                if (!take.Score.HasValue)
                {
                    continue;                       //沒有成績就不處理。
                }
                JHSCAttendRecord attend;
                JHCourseRecord   course;
                RatingStudent    student;

                if (!SCAttends.TryGetValue(take.RefSCAttendID, out attend))
                {
                    continue;  //找不到該修課記錄。
                }
                if (!dicstuds.TryGetValue(attend.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                if (!Courses.TryGetValue(take.RefCourseID, out course))
                {
                    continue;  //找不到該課程。
                }
                ScoreItem subject = new ScoreItem(course.Subject.Trim(), ScoreType.Subject);
                ScoreItem domain  = new ScoreItem(course.Domain.Trim(), ScoreType.Domain);

                //--- Subject
                ProcessSubject(subject, student, take);

                //--- Domain
                ProcessDomain(domainscores, take, course, student, subject, domain);
            }

            foreach (KeyValuePair <string, DomainScoreCalculator> eachStudent in domainscores)
            {
                string studentId = eachStudent.Key;                   //學生編號。
                DomainScoreCalculator calculator = eachStudent.Value; //領域成績。

                foreach (DomainScore eachDomain in calculator.Domains)
                {
                    dicstuds[studentId].Scores[ScoreType.Domain.Regulation(Token)].Add(eachDomain.Name, eachDomain.GetScore());
                }
            }
        }
예제 #4
0
        public MainForm()
        {
            //GetSubjectList();
            InitializeComponent();
            InitializeSemester();
            this.Text        = Global.ReportName;
            this.MinimumSize = this.Size;
            this.MaximumSize = this.Size;

            _config = new Config(Global.ReportName);

            _data       = new List <ClassExamScoreData>();
            _courseDict = new Dictionary <string, JHCourseRecord>();
            _exams      = new List <JHExamRecord>();
            //_ecMapping = new Dictionary<string, List<string>>();
            _courseList = new List <string>();

            cbExam.DisplayMember = "Name";
            cbSource.Items.Add("定期");
            cbSource.Items.Add("定期加平時");
            cbSource.SelectedIndex = 0;

            cbExam.Items.Add("");
            _exams = JHExam.SelectAll();
            foreach (var exam in _exams)
            {
                cbExam.Items.Add(exam);
            }
            cbExam.SelectedIndex = 0;

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate(object sender, DoWorkEventArgs e)
            {
                JHExamRecord exam = e.Argument as JHExamRecord;
                #region 取得試別
                //_ecMapping.Clear();
                //_exams = JHExam.SelectAll();
                //List<string> examIDs = new List<string>();
                //foreach (JHExamRecord exam in _exams)
                //{
                //    examIDs.Add(exam.ID);
                //_ecMapping.Add(exam.ID, new List<string>());
                //}
                #endregion

                #region 取得課程
                _courseDict.Clear();
                List <JHCourseRecord> courseList = JHCourse.SelectBySchoolYearAndSemester(_runningSchoolYear, _runningSemester);
                List <string>         courseIDs  = new List <string>();
                foreach (JHCourseRecord course in courseList)
                {
                    courseIDs.Add(course.ID);
                    _courseDict.Add(course.ID, course);
                }
                #endregion

                #region 取得評量成績
                //StudentID -> ClassExamScoreData
                Dictionary <string, ClassExamScoreData> scMapping = new Dictionary <string, ClassExamScoreData>();
                List <string> ids = new List <string>();
                _classes = JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource);

                // 排序
                if (_classes.Count > 1)
                {
                    _classes = DAL.DALTransfer.ClassRecordSortByDisplayOrder(_classes);
                }

                // TODO: 這邊要排序
                //List<K12.Data.ClassRecord> c = new List<K12.Data.ClassRecord>(_classes);
                //c.Sort();
                //_classes = new List<JHClassRecord>(c);
                //((List<K12.Data.ClassRecord>)_classes).Sort();

                _data.Clear();
                foreach (JHClassRecord cla in _classes)
                {
                    ClassExamScoreData classData = new ClassExamScoreData(cla);
                    foreach (JHStudentRecord stu in classData.Students)
                    {
                        scMapping.Add(stu.ID, classData);
                    }
                    _data.Add(classData);
                }

                //foreach (string examID in examIDs)
                //{

                _courseList.Clear();
                if (courseIDs.Count > 0)
                {
                    // TODO: JHSCETake 需要提供 SelectBy 課程IDs and 試別IDs 嗎?
                    foreach (JHSCETakeRecord sce in JHSCETake.SelectByCourseAndExam(courseIDs, exam.ID))
                    {
                        // TODO: 下面前兩個判斷應該可以拿掉
                        //if (!examIDs.Contains(sce.RefExamID)) continue; //試別無效
                        //if (!courseIDs.Contains(sce.RefCourseID)) continue; //課程無效
                        if (!scMapping.ContainsKey(sce.RefStudentID))
                        {
                            continue;                                           //學生編號無效
                        }
                        if (string.IsNullOrEmpty(_courseDict[sce.RefCourseID].RefAssessmentSetupID))
                        {
                            continue;                                                                          //課程無評量設定
                        }
                        if (!_courseList.Contains(sce.RefCourseID))
                        {
                            _courseList.Add(sce.RefCourseID);
                        }
                        //if (!_ecMapping[sce.RefExamID].Contains(sce.RefCourseID))
                        //    _ecMapping[sce.RefExamID].Add(sce.RefCourseID);

                        ClassExamScoreData classData = scMapping[sce.RefStudentID];
                        classData.AddScore(sce);
                    }
                }
                //}
                #endregion
            };
            _worker.RunWorkerCompleted += delegate
            {
                string running = _runningSchoolYear + "_" + _runningSemester;
                string current = (int)cboSchoolYear.SelectedItem + "_" + (int)cboSemester.SelectedItem;
                if (running != current)
                {
                    if (!_worker.IsBusy)
                    {
                        _runningSchoolYear = (int)cboSchoolYear.SelectedItem;
                        _runningSemester   = (int)cboSemester.SelectedItem;

                        RunWorker();
                    }
                }
                else
                {
                    FillData();
                    ControlEnabled = true;
                }
            };

            RunWorker();
        }
예제 #5
0
        protected override void PrepareDataBackground()
        {
            List <JHSCETakeRecord> scetakes = JHSCETake.SelectByCourseAndExam(Courses.Values.ToKeys(), ExamId);

            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //將學生的成績清除,並新增一個 Token 用來放成績。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
                each.Scores.Add(ThisToken, new ScoreCollection());
            }

            //記錄每一位學生的領域成績。
            Dictionary <string, DomainScoreCalculator> domainscores = new Dictionary <string, DomainScoreCalculator>();

            //計算領域成績。
            foreach (JHSCETakeRecord take in scetakes) //特別注意 take.Score 是 Extensions 裡面的 Score 不是實體欄位的 Score。
            {
                if (!take.Score.HasValue)
                {
                    continue;                       //沒有成績就不處理。
                }
                JHSCAttendRecord attend;
                JHCourseRecord   course;
                RatingStudent    student;

                if (!SCAttends.TryGetValue(take.RefSCAttendID, out attend))
                {
                    continue;  //找不到該修課記錄。
                }
                if (!dicstuds.TryGetValue(attend.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                if (!Courses.TryGetValue(take.RefCourseID, out course))
                {
                    continue;  //找不到該課程。
                }
                if (!course.Credit.HasValue)
                {
                    continue;                          //如果課程沒有權重就不處理。
                }
                string  domain  = course.Domain.Trim();
                string  subject = course.Subject.Trim();
                decimal weight  = course.Credit.Value;

                if (!SelectedDomains.Contains(domain))
                {
                    continue; //不在處理的領域清單中。
                }
                if (!domainscores.ContainsKey(attend.RefStudentID))
                {
                    domainscores.Add(attend.RefStudentID, new DomainScoreCalculator());
                }

                if (domainscores[attend.RefStudentID].Contains(course.Subject.Trim()))
                {
                    throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject));
                }

                domainscores[attend.RefStudentID].Add(domain, subject, take.Score.Value, weight);
            }

            foreach (KeyValuePair <string, DomainScoreCalculator> eachStudent in domainscores)
            {
                string studentId = eachStudent.Key;                   //學生編號。
                DomainScoreCalculator calculator = eachStudent.Value; //領域成績。

                foreach (DomainScore eachDomain in calculator.Domains)
                {
                    dicstuds[studentId].Scores[ThisToken].Add(eachDomain.Name, eachDomain.GetScore());
                }
            }
        }