Ejemplo n.º 1
0
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();
            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            _aeIncludeRecordList   = JHAEInclude.SelectByAssessmentSetupID(_assessmentSetupRecord.ID).AsKHJHAEIncludeRecords();

            FillToComboBox();

            // 當沒有試別關閉
            if (cboExamList.Items.Count < 1)
            {
                this.Close();
            }

            // 載入分數顏色
            LoadDvScoreColor();

            _ExamName = cboExamList.Text;
            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();

            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            if (!AEInclude.Instance.Loaded)
            {
                AEInclude.Instance.SyncAllBackground();
            }
            _aeIncludeRecordList = _assessmentSetupRecord.GetAEIncludes();

            FillToComboBox();

            #endregion
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 將學生填入DataGridView。
        /// </summary>
        private void FillStudentsToDataGridView()
        {
            dgv.SuspendLayout();
            dgv.Rows.Clear();

            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            _ScAttendDic.Clear();
            foreach (JHSCAttendRecord record in _scAttendRecordList)
            {
                if (!_ScAttendDic.ContainsKey(record.RefStudentID))
                {
                    _ScAttendDic.Add(record.RefStudentID, record);
                }
            }
            _scAttendRecordList.Sort(SCAttendComparer);

            foreach (var record in _scAttendRecordList)
            {
                JHStudentRecord student = record.Student;
                if (student.StatusStr != "一般")
                {
                    continue;
                }

                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv,
                                (student.Class != null) ? student.Class.Name : "",
                                student.SeatNo,
                                student.Name,
                                student.StudentNumber
                                );
                row.Tag = student.ID;
                dgv.Rows.Add(row);

                if (!_studentRow.ContainsKey(student.ID))
                {
                    _studentRow.Add(student.ID, row);
                }
            }

            dgv.ResumeLayout();
        }
Ejemplo n.º 4
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region DoWork

            SelectSemesterForm opt = e.Argument as SelectSemesterForm;

            Worker.ReportProgress(0, "正在進行開課...");

            double totalClass = K12.Presentation.NLDPanels.Class.SelectedSource.Count;
            if (totalClass <= 0)
            {
                totalClass = 0;
            }
            double classCount = 0;

            Dictionary <string, JHCourseRecord> subjectCourseDict = new Dictionary <string, JHCourseRecord>();

            foreach (JHClassRecord cla in JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource))
            {
                #region 班級開課

                classCount++;

                int gradeYear = 0; //取得班級年級
                if (!cla.GradeYear.HasValue)
                {
                    continue;
                }
                gradeYear = cla.GradeYear.Value;

                // TODO: 先寫著,之後再討論…
                if (gradeYear >= 7)
                {
                    gradeYear -= 6;
                }

                #region 取得班級內每個學生的課程規劃表
                List <JHProgramPlanRecord> programPlanList = new List <JHProgramPlanRecord>();

                List <JHStudentRecord> studentsInSchool = GetInSchoolStudents(cla.Students);
                if (studentsInSchool.Count > 0) //班級有學生,抓學生課程規劃表
                {
                    foreach (JHStudentRecord stu in studentsInSchool)
                    {
                        //取得學生的課程規劃表
                        JHProgramPlanRecord record = PPCollection.GetProgramPlanRecord(stu);
                        if (record != null)
                        {
                            if (!programPlanList.Contains(record))
                            {
                                programPlanList.Add(record);
                            }
                        }
                    }
                }
                else //班級沒有學生,也是要開課的!
                {
                    JHProgramPlanRecord record = PPCollection.GetProgramPlanRecord(cla);
                    if (record != null)
                    {
                        if (!programPlanList.Contains(record))
                        {
                            programPlanList.Add(record);
                        }
                    }
                }
                #endregion

                #region 所有課程規劃表中要開的課程
                Dictionary <string, K12.Data.ProgramSubject> courseDict = new Dictionary <string, K12.Data.ProgramSubject>();

                foreach (JHProgramPlanRecord record in programPlanList)
                {
                    foreach (K12.Data.ProgramSubject subject in record.Subjects)
                    {
                        if (subject.GradeYear == gradeYear &&
                            subject.Semester == opt.Semester &&
                            subject.Period.HasValue &&
                            subject.Credit.HasValue)
                        {
                            string key = subject.SubjectName.Trim();
                            if (!courseDict.ContainsKey(key))
                            {
                                courseDict.Add(key, subject);
                            }
                        }
                    }
                }
                #endregion

                //快取來源學期課程先放這
                Dictionary <string, JHCourseRecord> copySourceCourses = new Dictionary <string, JHCourseRecord>();

                #region 取得本學期已開的課程
                Dictionary <string, JHCourseRecord> existSubjects = new Dictionary <string, JHCourseRecord>();

                foreach (JHCourseRecord course in JHCourse.SelectAll())
                {
                    #region 取得複製來源學期的課程,智慧型開課需要
                    if (opt.CopyOptionEnabled && (opt.CopyTeacher || opt.CopyAssessmentSetup))
                    {
                        if (course.SchoolYear == opt.CopySchoolYear && course.Semester == opt.CopySemester && course.RefClassID == cla.ID)
                        {
                            if (!copySourceCourses.ContainsKey(course.Subject))
                            {
                                copySourceCourses.Add(course.Subject, course);
                            }
                        }
                    }
                    #endregion

                    //取得本學期的課程
                    if (course.SchoolYear == opt.SchoolYear && course.Semester == opt.Semester && course.RefClassID == cla.ID)
                    {
                        if (!existSubjects.ContainsKey(course.Subject))
                        {
                            existSubjects.Add(course.Subject, course);
                        }
                    }
                }
                #endregion

                #region 開課(加入新課程)
                List <JHCourseRecord> insertCourseList = new List <JHCourseRecord>();
                foreach (string key in courseDict.Keys)
                {
                    //是原來沒有的課程
                    if (!existSubjects.ContainsKey(key))
                    {
                        K12.Data.ProgramSubject subject   = courseDict[key];
                        JHCourseRecord          newCourse = new JHCourseRecord();

                        newCourse.Credit          = subject.Credit;
                        newCourse.Period          = subject.Period;
                        newCourse.Domain          = subject.Domain;
                        newCourse.Name            = cla.Name + " " + subject.SubjectName;
                        newCourse.SchoolYear      = opt.SchoolYear;
                        newCourse.Semester        = opt.Semester;
                        newCourse.Subject         = subject.SubjectName.Trim();
                        newCourse.RefClassID      = cla.ID;
                        newCourse.CalculationFlag = subject.CalcFlag ? "1" : "2";

                        insertCourseList.Add(newCourse);
                    }
                }
                if (insertCourseList.Count > 0)
                {
                    JHCourse.Insert(insertCourseList);
                }
                #endregion

                #region 重新取得本學期已開的課程(包含這次新開的課程)
                JHCourse.RemoveAll();
                Dictionary <string, JHCourseRecord> reloadedExistSubjects = new Dictionary <string, JHCourseRecord>();
                List <string> courseIDs = new List <string>();
                foreach (JHCourseRecord course in JHCourse.SelectAll())
                {
                    if (course.SchoolYear == opt.SchoolYear &&
                        course.Semester == opt.Semester &&
                        course.RefClassID == cla.ID)
                    {
                        string key = course.Subject;
                        if (!reloadedExistSubjects.ContainsKey(key))
                        {
                            reloadedExistSubjects.Add(key, course);
                        }

                        courseIDs.Add(course.ID);
                    }
                }
                #endregion

                #region 加入學生修課
                CourseAttendCollection caCollection = new CourseAttendCollection();
                foreach (JHSCAttendRecord sca in JHSCAttend.SelectByCourseIDs(courseIDs))
                {
                    if (!caCollection.ContainsKey(sca.RefCourseID))
                    {
                        caCollection.Add(sca.RefCourseID, new List <JHSCAttendRecord>());
                    }
                    caCollection[sca.RefCourseID].Add(sca);
                }

                List <JHSCAttendRecord> insertSCAttendList = new List <JHSCAttendRecord>();

                foreach (JHStudentRecord student in GetInSchoolStudents(cla.Students))
                {
                    if (PPCollection.GetProgramPlanRecord(student) == null)
                    {
                        continue;
                    }

                    foreach (K12.Data.ProgramSubject subject in PPCollection.GetProgramPlanRecord(student).Subjects)
                    {
                        string key = subject.SubjectName.Trim();

                        if (subject.GradeYear == gradeYear &&
                            subject.Semester == opt.Semester &&
                            reloadedExistSubjects.ContainsKey(key))
                        {
                            bool found = false;
                            foreach (JHStudentRecord attendStudent in caCollection.GetAttendStudents(reloadedExistSubjects[key]))
                            {
                                if (attendStudent.ID == student.ID)
                                {
                                    found = true;
                                    break;
                                }
                            }
                            if (found == false)
                            {
                                JHSCAttendRecord newSCAttend = new JHSCAttendRecord();
                                newSCAttend.RefStudentID = student.ID;
                                newSCAttend.RefCourseID  = reloadedExistSubjects[key].ID;
                                insertSCAttendList.Add(newSCAttend);
                            }
                        }
                    }
                }
                if (insertSCAttendList.Count > 0)
                {
                    int t1 = Environment.TickCount;

                    JHSCAttend.Insert(insertSCAttendList);

                    Trace.WriteLine("寫入修課記錄時間:" + (Environment.TickCount - t1).ToString());
                }
                #endregion

                #region 判斷是否進行智慧型開課
                if (opt.CopyOptionEnabled)
                {
                    CourseInstructCollection ciCollection        = new CourseInstructCollection();
                    CourseInstructCollection currentCICollection = new CourseInstructCollection();
                    List <string>            copyCourseIDs       = new List <string>();
                    foreach (JHCourseRecord course in copySourceCourses.Values)
                    {
                        copyCourseIDs.Add(course.ID);
                    }
                    foreach (JHTCInstructRecord tc in JHTCInstruct.SelectByTeacherIDAndCourseID(new string[] { }, copyCourseIDs))
                    {
                        if (!ciCollection.ContainsKey(tc.RefCourseID))
                        {
                            ciCollection.Add(tc.RefCourseID, new List <JHTCInstructRecord>());
                        }
                        ciCollection[tc.RefCourseID].Add(tc);
                    }
                    foreach (JHTCInstructRecord tc in JHTCInstruct.SelectByTeacherIDAndCourseID(new string[] { }, courseIDs))
                    {
                        if (!currentCICollection.ContainsKey(tc.RefCourseID))
                        {
                            currentCICollection.Add(tc.RefCourseID, new List <JHTCInstructRecord>());
                        }
                        currentCICollection[tc.RefCourseID].Add(tc);
                    }

                    List <JHTCInstructRecord> insertTCList = new List <JHTCInstructRecord>();
                    List <JHTCInstructRecord> updateTCList = new List <JHTCInstructRecord>();

                    List <JHCourseRecord> updateCourseList = new List <JHCourseRecord>();

                    //針對目前這個班級在開課學年度學期的所有課程
                    foreach (JHCourseRecord course in reloadedExistSubjects.Values)
                    {
                        //如果課程不存在課程規劃表中,則不處理
                        if (!courseDict.ContainsKey(course.Subject))
                        {
                            continue;
                        }

                        //複製來源課程中,如果有相同科目名稱,則進行複製
                        if (copySourceCourses.ContainsKey(course.Subject))
                        {
                            JHCourseRecord copyCourseRecord = copySourceCourses[course.Subject];

                            #region 自動加入授課教師
                            if (opt.CopyTeacher == true)
                            {
                                for (int i = 1; i <= 3; i++)
                                {
                                    //取得來源課程的授課教師
                                    JHTeacherRecord teacherRecord = ciCollection.GetTeacher(copyCourseRecord, i);
                                    if (teacherRecord != null)
                                    {
                                        //取得開課課程的授課記錄
                                        JHTCInstructRecord tc = currentCICollection.GetInstruct(course, i);
                                        if (tc == null)
                                        {
                                            tc              = new JHTCInstructRecord();
                                            tc.RefCourseID  = course.ID;
                                            tc.RefTeacherID = teacherRecord.ID;
                                            tc.Sequence     = i;
                                            insertTCList.Add(tc);
                                        }
                                        else
                                        {
                                            tc.RefTeacherID = teacherRecord.ID;
                                            updateTCList.Add(tc);
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region 自動加入評量設定
                            if (opt.CopyAssessmentSetup == true)
                            {
                                course.RefAssessmentSetupID = copyCourseRecord.RefAssessmentSetupID;
                                updateCourseList.Add(course);
                            }
                            #endregion
                        }
                    }

                    if (insertTCList.Count > 0)
                    {
                        JHTCInstruct.Insert(insertTCList);
                    }
                    if (updateTCList.Count > 0)
                    {
                        JHTCInstruct.Update(updateTCList);
                    }
                    if (updateCourseList.Count > 0)
                    {
                        JHCourse.Update(updateCourseList);
                    }
                }
                #endregion

                #endregion

                //回報進度
                Worker.ReportProgress((int)(classCount * 100d / totalClass), "正在進行開課...");
            }
            #endregion
        }
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得評量成績缺考暨免試設定

            PluginMain.ScoreTextMap.Clear();
            PluginMain.ScoreValueMap.Clear();

            Framework.ConfigData cd = JHSchool.School.Configuration["評量成績缺考暨免試設定"];
            if (!string.IsNullOrEmpty(cd["評量成績缺考暨免試設定"]))
            {
                XmlElement element = Framework.XmlHelper.LoadXml(cd["評量成績缺考暨免試設定"]);

                foreach (XmlElement each in element.SelectNodes("Setting"))
                {
                    var     UseText          = each.SelectSingleNode("UseText").InnerText;
                    var     AllowCalculation = bool.Parse(each.SelectSingleNode("AllowCalculation").InnerText);
                    decimal Score;
                    decimal.TryParse(each.SelectSingleNode("Score").InnerText, out Score);
                    var Active   = bool.Parse(each.SelectSingleNode("Active").InnerText);
                    var UseValue = decimal.Parse(each.SelectSingleNode("UseValue").InnerText);

                    if (Active)
                    {
                        if (!PluginMain.ScoreTextMap.ContainsKey(UseText))
                        {
                            PluginMain.ScoreTextMap.Add(UseText, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                        if (!PluginMain.ScoreValueMap.ContainsKey(UseValue))
                        {
                            PluginMain.ScoreValueMap.Add(UseValue, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                    }
                }
            }

            #endregion

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();

            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            _aeIncludeRecordList   = JHAEInclude.SelectByAssessmentSetupID(_assessmentSetupRecord.ID).AsHCJHAEIncludeRecords();

            FillToComboBox();

            // 當沒有試別關閉
            if (cboExamList.Items.Count < 1)
            {
                this.Close();
            }

            // 載入分數顏色
            LoadDvScoreColor();
            _ExamName = cboExamList.Text;
            #endregion
        }
Ejemplo n.º 6
0
        // 載入修課學生與成績到畫面
        private void LoadSCAttendScoreToDGV()
        {
            // 取得修課成績
            foreach (JHSCAttendRecord rec in JHSCAttend.SelectByCourseIDs(CIDs))
            {
                if (!_SCAttendListDic.ContainsKey(rec.RefStudentID))
                {
                    _SCAttendListDic.Add(rec.RefStudentID, rec);
                }
            }

            // 組成學生課程成績
            foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(_SCAttendListDic.Keys))
            {
                // 過濾非一般生
                if (studRec.Status != K12.Data.StudentRecord.StudentStatus.一般)
                {
                    continue;
                }

                StudentSCAtendScore sscas = new StudentSCAtendScore();
                sscas.StudentID = studRec.ID;
                if (studRec.Class != null)
                {
                    sscas.ClassName = studRec.Class.Name;
                    // 小郭, 2012/12/27
                    sscas.ClassId = studRec.Class.ID;
                }
                if (studRec.SeatNo.HasValue)
                {
                    sscas.SeatNo = studRec.SeatNo.Value;
                }
                sscas.Name          = studRec.Name;
                sscas.StudentNumber = studRec.StudentNumber;
                if (_SCAttendListDic.ContainsKey(studRec.ID))
                {
                    sscas.SCAtendRec = _SCAttendListDic[studRec.ID];
                }
                _StudentSCAtendScoreList.Add(sscas);
            }

            // 排序
            _StudentSCAtendScoreList.Sort(new Comparison <StudentSCAtendScore>(SortStudSeatNo));

            // 載入值
            dgv.SuspendLayout();
            dgv.Rows.Clear();

            int dgRowIdx = 0;

            foreach (StudentSCAtendScore sscas in _StudentSCAtendScoreList)
            {
                dgv.Rows.Add();
                dgv.Rows[dgRowIdx].Cells[colClassName.Index].Value     = sscas.ClassName;
                dgv.Rows[dgRowIdx].Cells[colSeatNo.Index].Value        = sscas.SeatNo;
                dgv.Rows[dgRowIdx].Cells[colName.Index].Value          = sscas.Name;
                dgv.Rows[dgRowIdx].Cells[colStudentNumber.Index].Value = sscas.StudentNumber;
                dgv.Rows[dgRowIdx].Cells[colInputScore.Index].Value    = sscas.GetOrdinarilyScore();
                dgv.Rows[dgRowIdx].Cells[colInputEffort.Index].Value   = sscas.GetOrdinarilyEffort();
                dgv.Rows[dgRowIdx].Tag = sscas.StudentID;
                dgRowIdx++;
            }
            dgv.ResumeLayout();
        }