示例#1
0
        public override bool Fill()
        {
            SubProgress progress = new SubProgress(MainProgress, WeightTable.GetJobWeight("GetYearSubject"));

            try
            {
                Utility.StartTime("GetYearSubject");
                progress.ReportMessage("取得學年科目成績資料…");

                List <List <string> > packages = Utility.SplitGetPackage(Students, PackageSize);

                int offset = 1;
                foreach (List <string> eachPackage in packages)
                {
                    if (MainProgress.Cancellation)
                    {
                        return(false);                           //這個部份要看的必須是 MainProgress。
                    }
                    DSXmlHelper response = QueryScore.GetSchoolYearSubjectScore(true, Parameters.SchoolYear, eachPackage.ToArray());

                    foreach (XmlElement eachStudent in response.GetElements("SchoolYearSubjectScore"))
                    {
                        DSXmlHelper hlpScore  = new DSXmlHelper(eachStudent);
                        string      studentId = hlpScore.GetText("RefStudentId");
                        string      scoreId   = hlpScore.GetText("@ID");

                        if (Students.ContainsKey(studentId))
                        {
                            Student student = Students[studentId];
                            student.YearSubjects.ScoreRecordIdentity = scoreId;

                            string scoresPath = "ScoreInfo/SchoolYearSubjectScore/Subject";
                            foreach (XmlElement eachScore in eachStudent.SelectNodes(scoresPath))
                            {
                                YearSubjectScore objScore = new YearSubjectScore(eachScore);
                                if (!student.YearSubjects.AddSubject(objScore))
                                {
                                    LogDuplicateSubject(progress, student, objScore);
                                }
                            }
                        }
                    }

                    progress.ReportProgress((int)(((float)offset / packages.Count) * 100));
                    offset++;
                }

                progress.ReportProgress(100);
                Utility.EndTime("GetYearSubject");
                return(true);
            }
            catch (Exception ex)
            {
                progress.ReportException(ex);
                return(false);
            }
        }
示例#2
0
        private void ReLoad(object sender, EventArgs e)
        {
            _SubjectScoreID = "";
            _EntryScoreID1  = "";
            _EntryScoreID2  = "";

            if (!ValidateSchoolYear())
            {
                return;
            }

            #region 科目成績
            dataGridViewX1.Rows.Clear();
            DSXmlHelper _SubjectResponse = QueryScore.GetSchoolYearSubjectScore(true, comboBoxEx1.Text, _StudentID);
            if (_SubjectResponse.GetElement("SchoolYearSubjectScore") != null)
            {
                if (comboBoxEx3.Text == "")
                {
                    comboBoxEx3.Text = _SubjectResponse.GetElement("SchoolYearSubjectScore/GradeYear").InnerText;
                }
                else
                {
                    if (comboBoxEx3.Text != _SubjectResponse.GetElement("SchoolYearSubjectScore/GradeYear").InnerText)
                    {
                        MsgBox.Show("發現同一學年度出現兩筆不同成績年級之資料。");
                    }
                }

                #region 建立排名相關物件
                _subject_rating = new SubjectScoreToolTipProvider(_SubjectResponse.GetElement("SchoolYearSubjectScore/ClassRating"),
                                                                  _SubjectResponse.GetElement("SchoolYearSubjectScore/DeptRating"),
                                                                  _SubjectResponse.GetElement("SchoolYearSubjectScore/YearRating"));
                #endregion

                beforeXml.AddElement("SubjectGradeYear", "GradeYear", comboBoxEx3.Text);

                _SubjectScoreID = _SubjectResponse.GetElement("SchoolYearSubjectScore").GetAttribute("ID");
                foreach (XmlElement var in _SubjectResponse.GetElements("SchoolYearSubjectScore/ScoreInfo/SchoolYearSubjectScore/Subject"))
                {
                    beforeXml.AddElement("SubjectCollection", var);

                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewX1,
                                    var.GetAttribute("科目"),
                                    var.GetAttribute("學年成績"),
                                    var.GetAttribute("結算成績") == "" ? var.GetAttribute("學年成績") : var.GetAttribute("結算成績"),
                                    var.GetAttribute("補考成績"),
                                    var.GetAttribute("重修成績"),
                                    var.GetAttribute("校部定"),
                                    var.GetAttribute("必選修"),
                                    var.GetAttribute("識別學分數")
                                    );
                    row.Cells[0].ToolTipText = _subject_rating.GetTooltip(row);
                    dataGridViewX1.Rows.Add(row);
                }
            }
            #endregion
            #region 分項成績
            textBoxX1.Text = "";
            textBoxX2.Text = "";
            textBoxX3.Text = "";
            textBoxX4.Text = "";
            textBoxX5.Text = "";
            textBoxX6.Text = "";
            textBoxX7.Text = "";
            DSXmlHelper _EntryResponse = QueryScore.GetSchoolYearEntryScore(true, comboBoxEx1.Text, null, _StudentID);
            foreach (XmlElement var in _EntryResponse.GetElements("SchoolYearEntryScore"))
            {
                if (comboBoxEx3.Text == "")
                {
                    comboBoxEx3.Text = var.SelectSingleNode("GradeYear").InnerText;
                }
                else
                {
                    if (comboBoxEx3.Text != var.SelectSingleNode("GradeYear").InnerText)
                    {
                        MsgBox.Show("發現同一學年度出現兩筆不同成績年級之資料。");
                    }
                }
                string id = var.GetAttribute("ID");
                switch (var.SelectSingleNode("EntryGroup").InnerText)
                {
                case "學習":
                    _EntryScoreID1 = id;
                    _score_rating  = new EntryScoreToolTipProvider("學業", var);
                    break;

                case "行為":
                    _EntryScoreID2 = id;
                    _moral_rating  = new EntryScoreToolTipProvider("德行", var);
                    break;

                default:
                    throw new Exception("拎唄謀洗鰓機雷EntryGroup:  \"" + var.SelectSingleNode("EntryGroup").InnerText + "\"");
                }
                foreach (XmlNode score in var.SelectNodes("ScoreInfo/SchoolYearEntryScore/Entry"))
                {
                    XmlElement element = (XmlElement)score;
                    beforeXml.AddElement("EntryCollection", element);

                    #region 依分項填入格子
                    switch (element.GetAttribute("分項"))
                    {
                    case "學業":
                        textBoxX1.Text = element.GetAttribute("成績");

                        _score_rating.SetTooltip(textBoxX1);
                        _score_rating.SetTooltip(labelX3);
                        break;

                    case "體育":
                        textBoxX3.Text = element.GetAttribute("成績");
                        break;

                    case "國防通識":
                        textBoxX4.Text = element.GetAttribute("成績");
                        break;

                    case "健康與護理":
                        textBoxX5.Text = element.GetAttribute("成績");
                        break;

                    case "實習科目":
                        textBoxX6.Text = element.GetAttribute("成績");
                        break;

                    case "專業科目":
                        textBoxX7.Text = element.GetAttribute("成績");
                        break;

                    case "德行":
                        textBoxX2.Text = element.GetAttribute("成績");
                        _moral_rating.SetTooltip(textBoxX2);
                        _moral_rating.SetTooltip(labelX4);

                        break;

                    default:
                        //throw new Exception("拎唄謀洗鰓機雷分項: " + element.GetAttribute("分項"));
                        break;
                    }
                    #endregion
                }
            }
            #endregion
        }