protected override void OnSaveButtonClick(EventArgs e) { if (cboProgramPlan.SelectedItem != null) { string id = string.Empty; if (cboProgramPlan.SelectedItem is JHProgramPlanRecord) { JHProgramPlanRecord record = cboProgramPlan.SelectedItem as JHProgramPlanRecord; id = record.ID; } if (id != _programPlanID) { JHClassRecord cla = JHClass.SelectByID(PrimaryKey); cla.RefProgramPlanID = id; JHClass.Update(cla); //ClassRecord classRecord = Class.Instance.Items[PrimaryKey]; //ClassRecordEditor editor = classRecord.GetEditor(); //editor.RefProgramPlanID = id; //editor.Save(); } } base.OnSaveButtonClick(e); }
private void FillPeriodCredit() { _filled = true; #region 取得領域總節數權數 JHProgramPlanRecord record = _student.ProgramPlan; if (record != null) { Dictionary <string, PeriodCredit> pcs = new Dictionary <string, PeriodCredit>(); foreach (K12.Data.ProgramSubject subject in record.Subjects) { if ("" + subject.GradeYear == "" + _util.GetGradeYear(cboSchoolYear.Text, cboSemester.Text) && "" + subject.Semester == cboSemester.Text) { #region 其它領域 if (!pcs.ContainsKey(subject.Domain)) { pcs.Add(subject.Domain, new PeriodCredit(0, 0)); } if (subject.Period.HasValue) { pcs[subject.Domain].Period += subject.Period.Value; } if (subject.Credit.HasValue) { pcs[subject.Domain].Credit += subject.Credit.Value; } #endregion } } txtPC1.Text = pcs.ContainsKey("國語文") ? pcs["國語文"].ToString() : ""; txtPC2.Text = pcs.ContainsKey("英語") ? pcs["英語"].ToString() : ""; txtPC3.Text = pcs.ContainsKey("數學") ? pcs["數學"].ToString() : ""; txtPC4.Text = pcs.ContainsKey("社會") ? pcs["社會"].ToString() : ""; //txtPC5.Text = pcs.ContainsKey("藝術與人文") ? pcs["藝術與人文"].ToString() : ""; //txtPC6.Text = pcs.ContainsKey("自然與生活科技") ? pcs["自然與生活科技"].ToString() : ""; txtPC5.Text = pcs.ContainsKey("自然科學") ? pcs["自然科學"].ToString() : ""; txtPC6.Text = pcs.ContainsKey("藝術") ? pcs["藝術"].ToString() : ""; txtPC7.Text = pcs.ContainsKey("健康與體育") ? pcs["健康與體育"].ToString() : ""; txtPC8.Text = pcs.ContainsKey("綜合活動") ? pcs["綜合活動"].ToString() : ""; txtPC10.Text = pcs.ContainsKey("科技") ? pcs["科技"].ToString() : ""; // 2019/1/10 穎驊修正 佳樺反映 快速登錄沒有 自動帶出 語文領域節數/權數 // 討論過後, 確認 語文領域的權數 為 國語文、 英文 加總 int chinesesPeriodCredit = 0; int englishPeriodCredit = 0; chinesesPeriodCredit = pcs.ContainsKey("國語文") ? int.Parse(pcs["國語文"].ToString()) : 0; englishPeriodCredit = pcs.ContainsKey("英語") ? int.Parse(pcs["英語"].ToString()) : 0; txtPC9.Text = "" + (chinesesPeriodCredit + englishPeriodCredit); } #endregion }
protected override void OnCancelButtonClick(EventArgs e) { JHProgramPlanRecord programPlanRecord = JHProgramPlan.SelectByID(_programPlanID); if (programPlanRecord != null) { SetComboBoxSelection(programPlanRecord); } else { SetComboBoxSelection(null); } base.OnCancelButtonClick(e); }
private void FillPeriodCredit() { _filled = true; #region 取得領域總節數權數 JHProgramPlanRecord record = _student.ProgramPlan; if (record != null) { Dictionary <string, PeriodCredit> pcs = new Dictionary <string, PeriodCredit>(); foreach (K12.Data.ProgramSubject subject in record.Subjects) { if ("" + subject.GradeYear == "" + _util.GetGradeYear(cboSchoolYear.Text, cboSemester.Text) && "" + subject.Semester == cboSemester.Text) { // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,將語文領域的子領域兩個項目欄位拿掉,僅保留輸入語文領域成績的單一功能。 #region 各領域 if (!pcs.ContainsKey(subject.Domain)) { pcs.Add(subject.Domain, new PeriodCredit(0, 0)); } if (subject.Period.HasValue) { pcs[subject.Domain].Period += subject.Period.Value; } if (subject.Credit.HasValue) { pcs[subject.Domain].Credit += subject.Credit.Value; } #endregion } } textBoxPC1.Text = pcs.ContainsKey("語文") ? pcs["語文"].ToString() : ""; // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,將語文領域的子領域兩個項目欄位拿掉,僅保留輸入語文領域成績的單一功能。 textBoxPC2.Text = pcs.ContainsKey("數學") ? pcs["數學"].ToString() : ""; textBoxPC3.Text = pcs.ContainsKey("社會") ? pcs["社會"].ToString() : ""; //textBoxPC4.Text = pcs.ContainsKey("藝術與人文") ? pcs["藝術與人文"].ToString() : ""; //textBoxPC5.Text = pcs.ContainsKey("自然與生活科技") ? pcs["自然與生活科技"].ToString() : ""; textBoxPC4.Text = pcs.ContainsKey("藝術") ? pcs["藝術"].ToString() : ""; textBoxPC5.Text = pcs.ContainsKey("自然科學") ? pcs["自然科學"].ToString() : ""; textBoxPC6.Text = pcs.ContainsKey("健康與體育") ? pcs["健康與體育"].ToString() : ""; textBoxPC7.Text = pcs.ContainsKey("綜合活動") ? pcs["綜合活動"].ToString() : ""; textBoxPC8.Text = pcs.ContainsKey("科技") ? pcs["科技"].ToString() : ""; } #endregion }
private void SetComboBoxSelection(JHProgramPlanRecord programPlanRecord) { if (programPlanRecord == null) { cboProgramPlan.SelectedIndex = 0; } else { foreach (object item in cboProgramPlan.Items) { if (item is JHProgramPlanRecord && (item as JHProgramPlanRecord).ID == programPlanRecord.ID) { cboProgramPlan.SelectedItem = item; break; } } } }
private void FillPeriodCredit() { _filled = true; #region 取得領域總節數權數 JHProgramPlanRecord record = _student.ProgramPlan; if (record != null) { Dictionary <string, PeriodCredit> pcs = new Dictionary <string, PeriodCredit>(); foreach (K12.Data.ProgramSubject subject in record.Subjects) { if ("" + subject.GradeYear == "" + _util.GetGradeYear(cboSchoolYear.Text, cboSemester.Text) && "" + subject.Semester == cboSemester.Text) { #region 其它領域 if (!pcs.ContainsKey(subject.Domain)) { pcs.Add(subject.Domain, new PeriodCredit(0, 0)); } if (subject.Period.HasValue) { pcs[subject.Domain].Period += subject.Period.Value; } if (subject.Credit.HasValue) { pcs[subject.Domain].Credit += subject.Credit.Value; } #endregion } } txtPC1.Text = pcs.ContainsKey("國語文") ? pcs["國語文"].ToString() : ""; txtPC2.Text = pcs.ContainsKey("英語") ? pcs["英語"].ToString() : ""; txtPC3.Text = pcs.ContainsKey("數學") ? pcs["數學"].ToString() : ""; txtPC4.Text = pcs.ContainsKey("社會") ? pcs["社會"].ToString() : ""; txtPC5.Text = pcs.ContainsKey("藝術與人文") ? pcs["藝術與人文"].ToString() : ""; txtPC6.Text = pcs.ContainsKey("自然與生活科技") ? pcs["自然與生活科技"].ToString() : ""; txtPC7.Text = pcs.ContainsKey("健康與體育") ? pcs["健康與體育"].ToString() : ""; txtPC8.Text = pcs.ContainsKey("綜合活動") ? pcs["綜合活動"].ToString() : ""; } #endregion }
protected override void OnPrimaryKeyChanged(EventArgs e) { SaveButtonVisible = CancelButtonVisible = false; JHClassRecord classRecord = JHClass.SelectByID(PrimaryKey); if (classRecord != null) { JHProgramPlanRecord programPlanRecord = GetProgramPlan(classRecord); if (programPlanRecord != null) { _programPlanID = programPlanRecord.ID; SetComboBoxSelection(programPlanRecord); } else { _programPlanID = string.Empty; SetComboBoxSelection(null); } } base.OnPrimaryKeyChanged(e); }
private void cboProgramPlan_SelectedIndexChanged(object sender, EventArgs e) { if (cboProgramPlan.SelectedItem == null) { return; } string id = string.Empty; if (cboProgramPlan.SelectedItem is JHProgramPlanRecord) { JHProgramPlanRecord record = cboProgramPlan.SelectedItem as JHProgramPlanRecord; id = record.ID; } if (id != _programPlanID) { SaveButtonVisible = CancelButtonVisible = true; } else { SaveButtonVisible = CancelButtonVisible = false; } }
/// <summary> /// 設定使用者介面 /// </summary> public void SetupPresentation() { if (_initialize) { return; } programPlanCache = new Dictionary <string, JHProgramPlanRecord>(); _classProgramPlanField.PreloadVariableBackground += delegate { foreach (JHProgramPlanRecord record in JHProgramPlan.SelectAll()) { if (!programPlanCache.ContainsKey(record.ID)) { programPlanCache.Add(record.ID, record); } } }; _classProgramPlanField.GetVariable += delegate(object sender, GetVariableEventArgs e) { JHProgramPlanRecord record = GetProgramPlan(JHClass.SelectByID(e.Key)); if (record != null) { e.Value = record.Name; } else { e.Value = ""; } }; K12.Presentation.NLDPanels.Class.AddListPaneField(_classProgramPlanField); _studentProgramPlanField.PreloadVariableBackground += delegate { foreach (JHProgramPlanRecord record in JHProgramPlan.SelectAll()) { if (!programPlanCache.ContainsKey(record.ID)) { programPlanCache.Add(record.ID, record); } } }; _studentProgramPlanField.GetVariable += delegate(object sender, GetVariableEventArgs e) { JHStudentRecord stu = JHStudent.SelectByID(e.Key); JHProgramPlanRecord record = GetProgramPlan(stu); if (record != null) { e.Value = string.IsNullOrEmpty(stu.OverrideProgramPlanID) ? record.Name : "(指定)" + record.Name; } else { e.Value = ""; } }; K12.Presentation.NLDPanels.Student.AddListPaneField(_studentProgramPlanField); JHClass.AfterUpdate += delegate { _classProgramPlanField.Reload(); }; JHStudent.AfterUpdate += delegate { _studentProgramPlanField.Reload(); }; AddAssignProgramPlanButtons(); _initialize = true; }
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 }
private void FillPeriodCredit() { _filled = true; #region 取得領域總節數權數 JHProgramPlanRecord record = _student.ProgramPlan; if (record != null) { List <string> chList = new List <string>(new string[] { "國文", "國語文", "國語" }); List <string> enList = new List <string>(new string[] { "英文", "英語文", "英語" }); string chinese = "", english = "", chPC = "", enPC = ""; Dictionary <string, PeriodCredit> pcs = new Dictionary <string, PeriodCredit>(); foreach (K12.Data.ProgramSubject subject in record.Subjects) { if ("" + subject.GradeYear == "" + _util.GetGradeYear(cboSchoolYear.Text, cboSemester.Text) && "" + subject.Semester == cboSemester.Text) { if (subject.Domain == "語文") { #region 語文領域特別處理 foreach (string word in chList) { if (subject.SubjectName.Contains(word)) { chinese = subject.SubjectName; if (subject.Period != subject.Credit) { chPC = "" + subject.Period + "/" + subject.Credit; } else { chPC = "" + subject.Period; } } } foreach (string word in enList) { if (subject.SubjectName.Contains(word)) { english = subject.SubjectName; if (subject.Period != subject.Credit) { enPC = "" + subject.Period + "/" + subject.Credit; } else { enPC = "" + subject.Period; } } } #endregion } else { #region 其它領域 if (!pcs.ContainsKey(subject.Domain)) { pcs.Add(subject.Domain, new PeriodCredit(0, 0)); } if (subject.Period.HasValue) { pcs[subject.Domain].Period += subject.Period.Value; } if (subject.Credit.HasValue) { pcs[subject.Domain].Credit += subject.Credit.Value; } #endregion } } } textBoxX36.Text = chinese; textBoxX37.Text = english; textBoxX25.Text = chPC; textBoxX26.Text = enPC; textBoxX27.Text = pcs.ContainsKey("數學") ? pcs["數學"].ToString() : ""; textBoxX28.Text = pcs.ContainsKey("社會") ? pcs["社會"].ToString() : ""; textBoxX29.Text = pcs.ContainsKey("藝術與人文") ? pcs["藝術與人文"].ToString() : ""; textBoxX30.Text = pcs.ContainsKey("自然與生活科技") ? pcs["自然與生活科技"].ToString() : ""; textBoxX31.Text = pcs.ContainsKey("健康與體育") ? pcs["健康與體育"].ToString() : ""; textBoxX32.Text = pcs.ContainsKey("綜合活動") ? pcs["綜合活動"].ToString() : ""; } #endregion }