Beispiel #1
0
        private void MenuButton_Click(object sender, EventArgs e)
        {
            TeacherRecord teacher = (sender as MenuButton).Tag as TeacherRecord;

            //List<string> courseIDs = new List<string>(K12.Presentation.NLDPanels.Course.SelectedSource);

            //List<JHTCInstructRecord> insertList = new List<JHTCInstructRecord>();
            //List<JHTCInstructRecord> updateList = new List<JHTCInstructRecord>();

            //foreach (JHTCInstructRecord tc in JHTCInstruct.SelectByTeacherIDAndCourseID(new string[] { }, K12.Presentation.NLDPanels.Course.SelectedSource))
            //{
            //    if (tc.Sequence == 1) //評分教師
            //    {
            //        courseIDs.Remove(tc.RefCourseID);
            //        tc.RefTeacherID = teacher.ID;
            //        updateList.Add(tc);
            //    }
            //}
            //foreach (string courseID in courseIDs)
            //{
            //    JHTCInstructRecord newTCInstruct = new JHTCInstructRecord();
            //    newTCInstruct.RefCourseID = courseID;
            //    newTCInstruct.RefTeacherID = teacher.ID;
            //    newTCInstruct.Sequence = 1;
            //    insertList.Add(newTCInstruct);
            //}

            //if (insertList.Count > 0)
            //    JHTCInstruct.Insert(insertList);
            //if (updateList.Count > 0)
            //    JHTCInstruct.Update(updateList);
            //MsgBox.Show("指定評分教師完成");

            List <TCInstructRecordEditor> editors = new List <TCInstructRecordEditor>();

            foreach (var item in Course.Instance.SelectedList)
            {
                editors.Add(item.SetFirstTeacher(teacher));
            }

            if (editors.Count > 0)
            {
                MultiThreadBackgroundWorker <TCInstructRecordEditor> worker = new MultiThreadBackgroundWorker <TCInstructRecordEditor>();
                worker.PackageSize = 50;
                worker.Loading     = MultiThreadLoading.Light;
                worker.DoWork     += delegate(object worker_sender, PackageDoWorkEventArgs <TCInstructRecordEditor> worker_e)
                {
                    worker_e.Items.SaveAllEditors();
                };
                worker.RunWorkerCompleted += delegate
                {
                    MsgBox.Show("指定評分教師完成");
                };
                worker.RunWorkerAsync(editors);
            }
        }
Beispiel #2
0
        private void AddSCAttends(List <StudentRecord> students, List <CourseRecord> courses)
        {
            if (students.Count <= 0)
            {
                return;
            }
            if (courses.Count <= 0)
            {
                return;
            }

            FISCA.LogAgent.LogSaver logSaver = FISCA.LogAgent.ApplicationLog.CreateLogSaverInstance();

            Dictionary <string, List <string> > studentScattends = new Dictionary <string, List <string> >();
            List <string> courseIDs      = courses.AsKeyList();
            StringBuilder coursesBuilder = new StringBuilder("");
            string        coursesString  = string.Empty;

            foreach (CourseRecord courseRecord in courses)
            {
                coursesBuilder.Append(courseRecord.Name + "、");
            }
            coursesString = coursesBuilder.ToString();
            if (coursesString.EndsWith("、"))
            {
                coursesString = coursesString.Substring(0, coursesString.Length - 1);
            }

            foreach (var student in students)
            {
                if (!studentScattends.ContainsKey(student.ID))
                {
                    studentScattends.Add(student.ID, courseIDs);

                    string s = string.Empty;
                    if (student.Class != null)
                    {
                        s += student.Class.Name;
                        if (student.SeatNo != "")
                        {
                            s += "(" + student.SeatNo + "號)";
                        }
                        s += " ";
                    }
                    if (student.StudentNumber != "")
                    {
                        s += student.StudentNumber + " ";
                    }
                    if (s == "")
                    {
                        s += "學生:";
                    }
                    s += student.Name;

                    string desc = string.Format("學生「{0}」加入修課:{1}", s, coursesString);
                    logSaver.AddBatch("成績系統.修課", "學生指定修課", desc);
                }
            }

            foreach (Data.JHSCAttendRecord record in Data.JHSCAttend.SelectByStudentIDAndCourseID(students.AsKeyList(), courses.AsKeyList()))
            {
                if (studentScattends.ContainsKey(record.RefStudentID))
                {
                    if (studentScattends[record.RefStudentID].Contains(record.RefCourseID))
                    {
                        studentScattends[record.RefStudentID].Remove(record.RefCourseID);
                    }
                }
            }

            List <Data.JHSCAttendRecord> list = new List <JHSchool.Data.JHSCAttendRecord>();

            foreach (string studentID in studentScattends.Keys)
            {
                foreach (string courseID in studentScattends[studentID])
                {
                    Data.JHSCAttendRecord record = new JHSchool.Data.JHSCAttendRecord();
                    record.RefCourseID  = courseID;
                    record.RefStudentID = studentID;
                    list.Add(record);
                }
            }

            if (list.Count > 0)
            {
                MultiThreadBackgroundWorker <Data.JHSCAttendRecord> worker = new MultiThreadBackgroundWorker <JHSchool.Data.JHSCAttendRecord>();
                worker.PackageSize = 50;
                worker.Loading     = MultiThreadLoading.Light;
                worker.DoWork     += delegate(object sender, PackageDoWorkEventArgs <Data.JHSCAttendRecord> e)
                {
                    Data.JHSCAttend.Insert(e.Items);
                };
                worker.RunWorkerCompleted += delegate
                {
                    logSaver.LogBatch();
                    MsgBox.Show("指定修課完成");
                };
                worker.RunWorkerAsync(list);
            }
        }
Beispiel #3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            _result.Clear();

            //取得通知單樣板
            ReportName = "未達畢業標準通知單";
            _rc        = new ReportConfiguration(ReportName);

            if (_rc.Template == null)
            {
                _rc.Template = new ReportTemplate(Properties.Resources.未達畢業標準通知單樣板, TemplateType.Word);
            }

            _template = _rc.Template.ToDocument();

            // 檢查學業勾選
            Config.rpt_isCheckGraduateDomain = Config.rpt_isCheckSemesterDomain = false;

            /* 小郭, 2013/12/25
             * if (chCondition1.Checked == true || chCondition2.Checked == true)
             *  Config.rpt_isCheckSemesterDomain = true;
             *
             * if (chConditionGr1.Checked)
             *  Config.rpt_isCheckGraduateDomain = true;
             */
            // 取得使用者選擇學年度學期
            int.TryParse(cboSchoolYear.Text, out UIConfig._UserSetSHSchoolYear);
            int.TryParse(cboSemester.Text, out UIConfig._UserSetSHSemester);

            if (UIConfig._UserSetSHSchoolYear == 0 || UIConfig._UserSetSHSemester == 0)
            {
                FISCA.Presentation.Controls.MsgBox.Show("日前學年度或學期輸入錯誤.");
                return;
            }


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

            // 檢查畫面上畢業成績使用者勾選
            foreach (Control ctrl in gpScore.Controls)
            {
                if (ctrl is System.Windows.Forms.CheckBox)
                {
                    System.Windows.Forms.CheckBox chk = ctrl as System.Windows.Forms.CheckBox;
                    if (chk.Checked && !string.IsNullOrEmpty("" + chk.Tag))
                    {
                        if (!conditions.Contains("" + chk.Tag))
                        {
                            conditions.Add("" + chk.Tag);
                        }
                    }
                }
            }

            // 檢查畫面上日常生活表現使用者勾選
            foreach (Control ctrl in gpDaily.Controls)
            {
                if (ctrl is System.Windows.Forms.CheckBox)
                {
                    System.Windows.Forms.CheckBox chk = ctrl as System.Windows.Forms.CheckBox;
                    if (chk.Checked && !string.IsNullOrEmpty("" + chk.Tag))
                    {
                        if (!conditions.Contains("" + chk.Tag))
                        {
                            conditions.Add("" + chk.Tag);
                        }
                    }
                }
            }

            // 檢查使用者是否有勾選,至少有勾一項才執行。
            if (conditions.Count > 0)
            {
                Config.rpt_isCheckSemesterDomain = IsShowSemesterDomainSheet(); // 小郭, 2013/12/25
                Config.rpt_isCheckGraduateDomain = IsShowGraduateDomainSheet(); // 小郭, 2013/12/25

                IEvaluateFactory factory = new ConditionalEvaluateFactory(conditions);
                Graduation.Instance.SetFactory(factory);
                Graduation.Instance.Refresh();

                if (!_historyWorker.IsBusy)
                {
                    btnPrint.Enabled = false;
                    _historyWorker.RunWorkerAsync(_students, _errorList);
                }
            }
            else
            {
                FISCA.Presentation.Controls.MsgBox.Show("請勾選檢查條件。");
                return;
            }
        }
        public static void Calculate(List <StudentRecord> students)
        {
            const string LearnDomain = "學習領域";
            const string CourseLearn = "課程學習";

            ScoreCalcRule.Instance.SyncAllBackground();
            //SemesterScore.Instance.SyncAllBackground();
            Dictionary <string, List <JHSemesterScoreRecord> > studentSemesterScoreRecordCache = new Dictionary <string, List <JHSchool.Data.JHSemesterScoreRecord> >();

            foreach (JHSemesterScoreRecord record in JHSemesterScore.SelectByStudentIDs(students.AsKeyList()))
            {
                if (!studentSemesterScoreRecordCache.ContainsKey(record.RefStudentID))
                {
                    studentSemesterScoreRecordCache.Add(record.RefStudentID, new List <JHSchool.Data.JHSemesterScoreRecord>());
                }
                studentSemesterScoreRecordCache[record.RefStudentID].Add(record);
            }

            List <GradScoreRecordEditor> editors = new List <GradScoreRecordEditor>();

            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress = true;

            MultiThreadBackgroundWorker <GradScoreRecordEditor> multiWorker = new MultiThreadBackgroundWorker <GradScoreRecordEditor>();

            multiWorker.WorkerReportsProgress = true;
            multiWorker.AutoReportsProgress   = true;
            multiWorker.PackageSize           = 50;
            multiWorker.Loading = MultiThreadLoading.Light;

            worker.DoWork += delegate
            {
                Dictionary <string, ScoreCalculator> calc = new Dictionary <string, ScoreCalculator>();

                double studentTotal = students.Count;
                double studentCount = 0;

                foreach (StudentRecord student in students)
                {
                    studentCount++;

                    #region 取得成績計算規則
                    string calcID = string.Empty;
                    ScoreCalcRuleRecord calcRecord = student.GetScoreCalcRuleRecord();
                    if (calcRecord != null)
                    {
                        calcID = calcRecord.ID;
                        if (!calc.ContainsKey(calcID))
                        {
                            JHScoreCalcRuleRecord        record = null;
                            List <JHScoreCalcRuleRecord> list   = JHScoreCalcRule.SelectByIDs(new string[] { calcRecord.ID });
                            if (list.Count > 0)
                            {
                                record = list[0];
                            }
                            calc.Add(calcID, new ScoreCalculator(record));
                        }
                    }
                    else
                    {
                        if (!calc.ContainsKey(string.Empty))
                        {
                            calc.Add(string.Empty, new ScoreCalculator(null));
                        }
                    }
                    #endregion

                    #region 取得各學期成績
                    List <JHSemesterScoreRecord> semesterScoreRecordList;
                    if (studentSemesterScoreRecordCache.ContainsKey(student.ID))
                    {
                        semesterScoreRecordList = studentSemesterScoreRecordCache[student.ID];
                    }
                    else
                    {
                        semesterScoreRecordList = new List <JHSemesterScoreRecord>();
                    }
                    Dictionary <string, List <decimal> > domainScores = new Dictionary <string, List <decimal> >();

                    foreach (JHSemesterScoreRecord record in semesterScoreRecordList)
                    {
                        foreach (K12.Data.DomainScore domain in record.Domains.Values)
                        {
                            if (!domainScores.ContainsKey(domain.Domain))
                            {
                                domainScores.Add(domain.Domain, new List <decimal>());
                            }

                            if (domain.Score.HasValue)
                            {
                                domainScores[domain.Domain].Add(domain.Score.Value);
                            }
                        }

                        if (!domainScores.ContainsKey(LearnDomain))
                        {
                            domainScores.Add(LearnDomain, new List <decimal>());
                        }
                        if (record.LearnDomainScore.HasValue)
                        {
                            domainScores[LearnDomain].Add(record.LearnDomainScore.Value);
                        }

                        if (!domainScores.ContainsKey(CourseLearn))
                        {
                            domainScores.Add(CourseLearn, new List <decimal>());
                        }
                        if (record.CourseLearnScore.HasValue)
                        {
                            domainScores[CourseLearn].Add(record.CourseLearnScore.Value);
                        }
                    }
                    #endregion

                    #region 產生畢業成績資料
                    GradScoreRecordEditor editor;
                    GradScoreRecord       gradScoreRecord = GradScore.Instance.Items[student.ID];
                    if (gradScoreRecord != null)
                    {
                        editor = gradScoreRecord.GetEditor();
                    }
                    else
                    {
                        editor = new GradScoreRecordEditor(student);
                    }

                    editor.LearnDomainScore = null;
                    editor.CourseLearnScore = null;
                    editor.Domains.Clear();

                    foreach (string domain in domainScores.Keys)
                    {
                        decimal total = 0;
                        decimal count = domainScores[domain].Count;

                        if (count <= 0)
                        {
                            continue;
                        }

                        foreach (decimal score in domainScores[domain])
                        {
                            total += score;
                        }

                        total = total / count;
                        total = calc[calcID].ParseGraduateScore(total);


                        if (domain == LearnDomain)
                        {
                            editor.LearnDomainScore = total;
                        }
                        else if (domain == CourseLearn)
                        {
                            editor.CourseLearnScore = total;
                        }
                        else
                        {
                            if (!editor.Domains.ContainsKey(domain))
                            {
                                editor.Domains.Add(domain, new GradDomainScore(domain));
                            }
                            editor.Domains[domain].Score = total;
                        }
                    }

                    editors.Add(editor);
                    #endregion

                    worker.ReportProgress((int)(studentCount * 100 / studentTotal));
                }
            };
            worker.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
            {
                FISCA.Presentation.MotherForm.SetStatusBarMessage("計算畢業成績中", e.ProgressPercentage);
            };
            worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                if (e.Error != null)
                {
                    MsgBox.Show("計算畢業成績時發生錯誤。" + e.Error.Message);
                    editors.Clear();
                }
                else
                {
                    multiWorker.RunWorkerAsync(editors);
                }
            };

            multiWorker.DoWork += delegate(object sender, PackageDoWorkEventArgs <GradScoreRecordEditor> e)
            {
                IEnumerable <GradScoreRecordEditor> list = e.Items;
                list.SaveAllEditors();
            };
            multiWorker.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
            {
                FISCA.Presentation.MotherForm.SetStatusBarMessage("上傳畢業成績中", e.ProgressPercentage);
            };
            multiWorker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                if (e.Error != null)
                {
                    MsgBox.Show("上傳畢業成績時發生錯誤。" + e.Error.Message);
                }
                else
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("上傳畢業成績完成");
                }
            };

            worker.RunWorkerAsync();
        }
Beispiel #5
0
        public RetakeWithCourseList()
        {
            this.Path     = "重修資料";
            this.Text     = "隨堂重修課程表";
            this.OnClick += delegate
            {
                SelectSemesterForm form = new SelectSemesterForm();
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int                  schoolYear = form.SchoolYear, semester = form.Semester;
                    AccessHelper         helper      = new AccessHelper();
                    List <StudentRecord> studentList = helper.StudentHelper.GetSelectedStudent();
                    #region   資料
                    MultiThreadBackgroundWorker <StudentRecord> dataLoader = new MultiThreadBackgroundWorker <StudentRecord>();
                    //dataLoader.Loading = SmartSchool.Common.MultiThreadLoading.Heavy;
                    dataLoader.PackageSize = 125;
                    dataLoader.DoWork     += delegate(object sender, PackageDoWorkEventArgs <StudentRecord> e)
                    {
                        helper.StudentHelper.FillSemesterSubjectScore(true, e.Items);
                        helper.StudentHelper.FillAttendCourse(schoolYear, semester, e.Items);
                    };
                    dataLoader.ProgressChanged    += delegate(object sender, ProgressChangedEventArgs e) { SmartSchool.Customization.PlugIn.Global.SetStatusBarMessage("隨堂重修課程表產生中...", e.ProgressPercentage * 70 / 100); };
                    dataLoader.RunWorkerCompleted += delegate(object se, RunWorkerCompletedEventArgs ex)
                    {
                        if (ex.Error != null)
                        {
                            throw ex.Error;
                        }
                        #region 資料抓完就生張報表出來
                        Workbook template = new Workbook();
                        Workbook workBook = new Workbook();

                        template.Open(new MemoryStream(Properties.Resources.隨堂重修清單), FileFormatType.Excel2003);
                        workBook.Open(new MemoryStream(Properties.Resources.隨堂重修清單), FileFormatType.Excel2003);

                        BackgroundWorker worker = new BackgroundWorker();
                        worker.WorkerReportsProgress = true;
                        worker.RunWorkerCompleted   += delegate { SmartSchool.Customization.PlugIn.Global.SetStatusBarMessage("隨堂重修課程表產生完成"); Common.Excel.Save("隨堂重修課程表", workBook); };
                        worker.ProgressChanged      += delegate(object sender, ProgressChangedEventArgs e) { SmartSchool.Customization.PlugIn.Global.SetStatusBarMessage("隨堂重修課程表產生中...", e.ProgressPercentage); };
                        worker.DoWork += delegate
                        {
                            #region 產生報表
                            #region 填入報表
                            int rowIndex = 1;
                            int count = 0, sum = studentList.Count;
                            foreach (StudentRecord studentRec in studentList)
                            {
                                foreach (StudentAttendCourseRecord attendRecord in studentRec.AttendCourseList)
                                {
                                    foreach (SemesterSubjectScoreInfo subjectScore in studentRec.SemesterSubjectScoreList)
                                    {
                                        if ((subjectScore.SchoolYear * 10 + subjectScore.Semester) < (schoolYear * 10 + semester) && subjectScore.Subject == attendRecord.Subject && subjectScore.Level == attendRecord.SubjectLevel)
                                        {
                                            #region 如果需要換頁就填入下一頁的樣版
                                            if (rowIndex % 45 == 0)
                                            {
                                                for (int i = 0; i < 45; i++)
                                                {
                                                    workBook.Worksheets[0].Cells.CopyRow(template.Worksheets[0].Cells, i, rowIndex + i);
                                                    workBook.Worksheets[0].Cells.SetRowHeight(rowIndex + i, template.Worksheets[0].Cells.GetRowHeight(i));
                                                }
                                                workBook.Worksheets[0].HPageBreaks.Add(rowIndex, 7);
                                                rowIndex++;
                                            }
                                            #endregion
                                            workBook.Worksheets[0].Cells[rowIndex, 0].PutValue(studentRec.StudentNumber);
                                            workBook.Worksheets[0].Cells[rowIndex, 1].PutValue(studentRec.RefClass == null ? "" : studentRec.RefClass.ClassName);
                                            workBook.Worksheets[0].Cells[rowIndex, 2].PutValue(studentRec.SeatNo);
                                            workBook.Worksheets[0].Cells[rowIndex, 3].PutValue(studentRec.StudentName);
                                            workBook.Worksheets[0].Cells[rowIndex, 4].PutValue(attendRecord.CourseName);
                                            workBook.Worksheets[0].Cells[rowIndex, 5].PutValue(subjectScore.SchoolYear);
                                            workBook.Worksheets[0].Cells[rowIndex, 6].PutValue(subjectScore.Semester);
                                            rowIndex++;
                                        }
                                    }
                                }
                                worker.ReportProgress(70 + count * 30 / sum);
                            }
                            #endregion
                            #endregion
                        };
                        worker.RunWorkerAsync();
                        #endregion
                    };
                    dataLoader.RunWorkerAsync(studentList);
                    #endregion
                }
            };
        }