示例#1
0
            public StudentRow AddStudentRow(string Name, string Age, string ClassName, bool IsChecked, string State)
            {
                StudentRow rowStudentRow = ((StudentRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    Name,
                    Age,
                    ClassName,
                    IsChecked,
                    State
                };
                rowStudentRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowStudentRow);
                return(rowStudentRow);
            }
 public void RemoveStudentRow(StudentRow row) {
     this.Rows.Remove(row);
 }
 public void AddStudentRow(StudentRow row) {
     this.Rows.Add(row);
 }
 public ApplicationRow AddApplicationRow(StudentRow parentStudentRowByFK_Application_Student, decimal Principal, decimal AnnualPercentageRate, int TotalPayments) {
     ApplicationRow rowApplicationRow = ((ApplicationRow)(this.NewRow()));
     object[] columnValuesArray = new object[] {
             null,
             null,
             Principal,
             AnnualPercentageRate,
             TotalPayments};
     if ((parentStudentRowByFK_Application_Student != null)) {
         columnValuesArray[1] = parentStudentRowByFK_Application_Student[0];
     }
     rowApplicationRow.ItemArray = columnValuesArray;
     this.Rows.Add(rowApplicationRow);
     return rowApplicationRow;
 }
 public StudentRowChangeEvent(StudentRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
示例#6
0
 public StudentRowChangeEvent(StudentRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
示例#7
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            #region 進行驗證
            if (!ValidItem())
            {
                MsgBox.Show("請選擇要列印的" + gpSubject.Text + "或" + gpDomain.Text);
                return;
            }
            #endregion
            Report._UserSelectCount = 0;

            Global.UserSelectSchoolYear = cboSchoolYear.Text;
            Global.UserSelectSemester   = cboSemester.Text;

            #region 取得使用者選取的課程(科目)編號
            List <string> courseIDs = new List <string>();
            foreach (ListViewItem item in lvSubject.Items)
            {
                if (item.Checked)
                {
                    Report._UserSelectCount++;
                    List <string> list = item.Tag as List <string>;
                    courseIDs.AddRange(list);
                }
            }
            #endregion

            #region 取得使用者選取的領域
            List <string> domains = new List <string>();
            foreach (ListViewItem item in lvDomain.Items)
            {
                Report._UserSelectCount++;
                if (item.Checked)
                {
                    domains.Add(item.Text);
                }
            }
            #endregion

            btnPrint.Enabled    = false;
            pictureBox1.Visible = true;
            pictureBox2.Visible = true;

            #region 轉換成 CourseScore、計算分數、排名
            JHExamRecord exam = cbExam.SelectedItem as JHExamRecord;
            //ScoreType type = GetScoreType();

            List <string> asIDs = new List <string>();
            Dictionary <string, string>            asMapping = new Dictionary <string, string>();
            Dictionary <string, JHAEIncludeRecord> aeDict    = new Dictionary <string, JHAEIncludeRecord>();
            foreach (string courseID in courseIDs)
            {
                string asID = _courseDict[courseID].RefAssessmentSetupID;
                asIDs.Add(asID);
                asMapping.Add(courseID, asID);
            }

            foreach (JHAEIncludeRecord record in JHAEInclude.SelectByAssessmentSetupIDs(asIDs))
            {
                if (record.RefExamID != exam.ID)
                {
                    continue;
                }
                aeDict.Add(record.RefAssessmentSetupID, record);
            }

            //ComputeScore computer = new ComputeScore(_courseDict);
            //List<ComputeMethod> methods = GetMethods(_config);
            //RankMethod rankMethod = GetRankMethod(_config);

            Rank rank = new Rank();
            // TODO: 不確定排名是否接續
            rank.Sequence = false;

            // 取得評量比例
            Global.ScorePercentageHSDict = Global.GetScorePercentageHS();

            foreach (var ced in _data)
            {
                //轉成 CourseScore
                ced.ConvertToCourseScores(courseIDs, exam.ID);
                //RankData rd = new RankData();

                foreach (string studentID in ced.Rows.Keys)
                {
                    StudentRow row = ced.Rows[studentID];

                    //計算單一評量成績
                    foreach (CourseScore courseScore in row.CourseScoreList)
                    {
                        string asID = asMapping[courseScore.CourseID];
                        if (aeDict.ContainsKey(asID))
                        {
                            courseScore.CalculateScore(new HC.JHAEIncludeRecord(aeDict[asID]), "" + cbSource.SelectedItem);
                        }
                    }
                }

                //排序班級課程ID
                ced.SortCourseIDs(courseIDs);
            }
            #endregion

            #region 產生報表
            //Report report = new Report(_data, _courseDict, exam, methods);
            Report report = new Report(_data, _courseDict, exam, domains);
            report.GenerateCompleted += new EventHandler(report_GenerateCompleted);
            report.GenerateError     += new EventHandler(report_GenerateError);
            report.Generate();
            #endregion
        }
示例#8
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            // 取得班級學生人數
            Dictionary <string, int> ClassStudCount = new Dictionary <string, int>();

            foreach (ClassExamScoreData cee in _data)
            {
                if (!ClassStudCount.ContainsKey(cee.Class.ID))
                {
                    ClassStudCount.Add(cee.Class.ID, cee.Students.Count);
                }
            }

            Workbook  book = new Workbook();
            Worksheet ws;
            int       rowIndex = 0;
            Workbook  template = new Workbook();

            if (_data.Count > 30 || _UserSelectCount > 14)
            {
                book.Open(new MemoryStream(Resource1.班級評量成績平均比較表60));
                ws = book.Worksheets[0];
                template.Open(new MemoryStream(Resource1.班級評量成績平均比較表60));
            }
            else
            {
                book.Open(new MemoryStream(Resource1.班級評量成績平均比較表));
                ws = book.Worksheets[0];
                template.Open(new MemoryStream(Resource1.班級評量成績平均比較表));
            }
            Range all = template.Worksheets.GetRangeByName("All");

            //Range printDate = template.Worksheets.GetRangeByName("PrintDate");
            //printDate[0, 0].PutValue(DateTime.Today.ToString("yyyy/MM/dd"));

            Range title = template.Worksheets.GetRangeByName("Title");
            //Range feedback = template.Worksheets.GetRangeByName("Feedback");
            Range rowHeaders    = template.Worksheets.GetRangeByName("RowHeaders");
            Range columnHeaders = template.Worksheets.GetRangeByName("ColumnHeaders");
            //Range rankColumnHeader = template.Worksheets.GetRangeByName("RankColumnHeader");

            int RowNumber     = all.RowCount;
            int DataRowNumber = rowHeaders.RowCount;

            //_data.Sort(delegate(ClassExamScoreData x, ClassExamScoreData y)
            //{
            //    return x.Class.Name.CompareTo(y.Class.Name);
            //});

            int dataRowIndex = rowHeaders.FirstRow;

            List <string>            headers    = new List <string>();
            Dictionary <string, int> colMapping = new Dictionary <string, int>();

            foreach (ClassExamScoreData ced in _data)
            {
                //ws.Cells.CreateRange(rowIndex, RowNumber, false).Copy(all);

                //int classColIndex = 0;

                foreach (string courseID in ced.ValidCourseIDs)
                {
                    JHCourseRecord course = _courseDict[courseID];
                    if (!headers.Contains(course.Subject))
                    {
                        headers.Add(course.Subject);
                    }

                    #region comment
                    //if (!colMapping.ContainsKey(GetTaggedDomain(course.Domain)) && _domains.Contains(course.Domain))
                    //{
                    //    colMapping.Add(GetTaggedDomain(course.Domain), classColIndex);
                    //    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue(course.Domain);
                    //    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].Style.Font.IsBold = true;

                    //    classColIndex++;
                    //    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue("排序");
                    //    classColIndex++;
                    //}
                    //if (!colMapping.ContainsKey(course.Subject))
                    //{
                    //    colMapping.Add(course.Subject, classColIndex);
                    //    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue(course.Subject);

                    //    classColIndex++;
                    //    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue("排序");
                    //    classColIndex++;
                    //}
                    #endregion
                }

                foreach (StudentRow row in ced.Rows.Values)
                {
                    foreach (var sce in row.RawScoreList)
                    {
                        if (sce.RefExamID != _exam.ID)
                        {
                            continue;
                        }
                        JHCourseRecord course = _courseDict[sce.RefCourseID];

                        if (!headers.Contains(GetTaggedDomain(course.Domain)))
                        {
                            headers.Add(GetTaggedDomain(course.Domain));
                        }
                    }
                }
            }

            #region 產生 Headers
            headers.Sort(Sort);
            int classColIndex = 0;
            foreach (string each in headers)
            {
                if (IsDomain(each))
                {
                    if (_domains.Contains(GetOriginalDomain(each)))
                    {
                        colMapping.Add(each, classColIndex);
                        ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue(GetOriginalDomain(each));
                        ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].Style.Font.IsBold = true;
                        classColIndex++;
                        ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue("排序");
                        classColIndex++;
                    }
                }
                else
                {
                    colMapping.Add(each, classColIndex);
                    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue(each);
                    classColIndex++;
                    ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue("排序");
                    classColIndex++;
                }
            }
            #endregion

            foreach (ClassExamScoreData ced in _data)
            {
                Dictionary <string, decimal?> subjectScores = new Dictionary <string, decimal?>();
                Dictionary <string, int>      subjectCount  = new Dictionary <string, int>();

                foreach (StudentRow row in ced.Rows.Values)
                {
                    foreach (var sce in row.RawScoreList)
                    {
                        if (sce.RefExamID != _exam.ID)
                        {
                            continue;
                        }
                        JHCourseRecord course = _courseDict[sce.RefCourseID];

                        //if (!headers.Contains(GetTaggedDomain(course.Domain)))
                        //{
                        //    headers.Add(GetTaggedDomain(course.Domain));
                        //}
                        //if (!colMapping.ContainsKey(GetTaggedDomain(course.Domain)) && _domains.Contains(course.Domain))
                        //{
                        //    colMapping.Add(GetTaggedDomain(course.Domain), classColIndex);
                        //    //ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue(course.Domain);
                        //    //ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].Style.Font.IsBold = true;

                        //    classColIndex += 2;
                        //    //ws.Cells[columnHeaders.FirstRow + rowIndex, columnHeaders.FirstColumn + classColIndex].PutValue("排序");
                        //    //classColIndex++;
                        //}

                        string ds = GetDomainSubjectKey(course.Domain, course.Subject);
                        if (!subjectScores.ContainsKey(ds))
                        {
                            subjectScores.Add(ds, 0);
                            subjectCount.Add(ds, 0);
                        }
                        if (sce.Score.HasValue)
                        {
                            subjectCount[ds]++;
                            decimal value = decimal.Zero;
                            if (row.StudentScore.CalculationRule != null)
                            {
                                value = row.StudentScore.CalculationRule.ParseSubjectScore(sce.Score.Value);
                            }
                            else
                            {
                                value = _calc.ParseSubjectScore(sce.Score.Value);
                            }
                            subjectScores[ds] += value;
                        }
                    }
                }

                foreach (string ds in new List <string>(subjectScores.Keys))
                {
                    if (subjectScores[ds].HasValue && subjectCount[ds] > 0)
                    {
                        subjectScores[ds] = subjectScores[ds].Value / (decimal)subjectCount[ds];
                    }
                }

                Dictionary <string, decimal?> domainScores = new Dictionary <string, decimal?>();
                Dictionary <string, int>      domainCount  = new Dictionary <string, int>();

                foreach (string ds in subjectScores.Keys)
                {
                    string domain = GetOnlyDomain(ds);
                    if (!domainScores.ContainsKey(domain))
                    {
                        domainScores.Add(domain, 0);
                        domainCount.Add(domain, 0);
                    }
                    domainCount[domain]++;
                    domainScores[domain] += subjectScores[ds];
                }

                foreach (string domain in new List <string>(domainScores.Keys))
                {
                    if (domainScores[domain].HasValue && domainCount[domain] > 0)
                    {
                        domainScores[domain] = domainScores[domain].Value / (decimal)domainCount[domain];
                    }
                }

                #region 填入班級平均
                //int rankIndex = rankColumnHeader.FirstColumn;

                // 班級平均
                ClassCourseAvg cca = new ClassCourseAvg();

                foreach (var stud in ced.Students)
                {
                    if (ced.Rows.ContainsKey(stud.ID))
                    {
                        //阿寶...這也許是地雷....

                        // 當學生不屬於任何班級跳過
                        if (stud.Class == null)
                        {
                            continue;
                        }

                        cca.ClassID   = stud.Class.ID;
                        cca.ClassName = stud.Class.Name;
                        StudentRow srow = ced.Rows[stud.ID];
                        foreach (CourseScore cs in srow.CourseScoreList)
                        {
                            if (cs.Score.HasValue)
                            {
                                cca.ClassID   = stud.Class.ID;
                                cca.ClassName = stud.Class.Name;
                                decimal value = decimal.Zero;
                                if (srow.StudentScore.CalculationRule != null)
                                {
                                    value = srow.StudentScore.CalculationRule.ParseSubjectScore(cs.Score.Value);
                                }
                                else
                                {
                                    value = _calc.ParseSubjectScore(cs.Score.Value);
                                }
                                cca.AddSubjectScore(_courseDict[cs.CourseID].Subject, value);
                            }
                            //decimal? s = GetRoundScore(cs.Score);
                            //if (s.HasValue)
                            //{
                            //    cca.ClassID = stud.Class.ID;
                            //    cca.ClassName = stud.Class.Name;
                            //    cca.AddCourseScore(cs.CourseID, s.Value);
                            //}
                        }
                    }
                }

                // 班級名稱
                ws.Cells[dataRowIndex, 0].PutValue(cca.ClassName);
                // 放班級人數
                int peoColIdx = 32;
                // 找到人數放位置
                for (int i = 32; i <= 60; i++)
                {
                    if (ws.Cells[2, i].StringValue.Trim() == "人數")
                    {
                        peoColIdx = i;
                        break;
                    }
                }
                if (cca.ClassID != null && cca.ClassName != "")
                {
                    if (ClassStudCount.ContainsKey(cca.ClassID))
                    {
                        ws.Cells[dataRowIndex, peoColIdx].PutValue(ClassStudCount[cca.ClassID].ToString());
                    }
                }


                foreach (KeyValuePair <string, decimal?> val in cca.GetSubjectStudScoreAvg())
                {
                    if (val.Value.HasValue)
                    {
                        decimal value = Math.Round((decimal)val.Value, 2, MidpointRounding.AwayFromZero);
                        ws.Cells[dataRowIndex, colMapping[val.Key] + 1].PutValue(value);
                    }
                }
                //填入領域
                bool domainHasData = false;
                foreach (string domain in _domains)
                {
                    if (!domainScores.ContainsKey(domain))
                    {
                        continue;
                    }
                    if (!domainScores[domain].HasValue)
                    {
                        continue;
                    }

                    string taggedDomain = GetTaggedDomain(domain);
                    if (colMapping.ContainsKey(taggedDomain))
                    {
                        decimal value = Math.Round((decimal)domainScores[domain].Value, 2, MidpointRounding.AwayFromZero);
                        ws.Cells[dataRowIndex, colMapping[taggedDomain] + 1].PutValue(value);
                        domainHasData = true;
                    }
                }
                if (cca.GetSubjectStudScoreAvg().Count > 0 || domainHasData)
                {
                    dataRowIndex++;
                }

                #endregion

                #region 填入標題及回條
                //Ex. 新竹市立光華國民中學 97 學年度第 1 學期    第1次平時評量成績單
                ws.Cells[title.FirstRow + rowIndex, title.FirstColumn].PutValue(string.Format("{0}  {1}  {2} 各班各科平均成績比較表", SchoolName, Semester, _exam.Name));
                //Ex. 101 第1次平時評量回條 (家長意見欄)
                //ws.Cells[feedback.FirstRow + rowIndex, feedback.FirstColumn].PutValue(string.Format("{0}  {1}回條  (家長意見欄)", ced.Class.Name, _exam.Name));
                #endregion

                //rowIndex += RowNumber;
                //ws.HPageBreaks.Add(rowIndex, 0);
            }

            e.Result = book;
        }
示例#9
0
 public void RemoveStudentRow(StudentRow row)
 {
     this.Rows.Remove(row);
 }
示例#10
0
 public void AddStudentRow(StudentRow row)
 {
     this.Rows.Add(row);
 }