private void ChangeClassesProgramPlanID(string id) { _logSaver.ClearBatch(); List <JHClassRecord> classList = new List <JHClassRecord>(); foreach (var cla in JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource)) { cla.RefProgramPlanID = id; classList.Add(cla); string desc = string.Empty; if (string.IsNullOrEmpty(id)) { desc = string.Format("班級「{0}」不指定課程規劃", cla.Name); } else { desc = string.Format("班級「{0}」指定課程規劃為:{1}", cla.Name, ProgramPlan.Instance.Items[id].Name); } _logSaver.AddBatch("成績系統.課程規劃", "班級指定課程規劃", desc); } if (classList.Count > 0) { JHClass.Update(classList); _logSaver.LogBatch(); } }
private void ChangeClassesScoreCalcRuleID(string id) { _logSaver.ClearBatch(); List <ClassRecordEditor> classRecordEditors = new List <ClassRecordEditor>(); foreach (var cla in Class.Instance.SelectedList) { ClassRecordEditor editor = cla.GetEditor(); editor.RefScoreCalcRuleID = id; classRecordEditors.Add(editor); string desc = string.Empty; if (string.IsNullOrEmpty(id)) { desc = string.Format("班級「{0}」不指定計算規則", cla.Name); } else { desc = string.Format("班級「{0}」指定計算規則為:{1}", cla.Name, ScoreCalcRule.Instance.Items[id].Name); } _logSaver.AddBatch("成績系統.計算規則", "班級指定計算規則", desc); } if (classRecordEditors.Count > 0) { classRecordEditors.SaveAllEditors(); _logSaver.LogBatch(); // 同步班級JHDAL List <string> classIDs = (from data in Class.Instance.SelectedList select data.ID).ToList(); JHClass.RemoveByIDs(classIDs); JHClass.SelectByIDs(classIDs); } }
private void btnDelete_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count <= 0) { return; } ListViewItem item = listView.SelectedItems[0]; JHCourseRecord course = item.Tag as JHCourseRecord; if (MsgBox.Show(string.Format("您確定要刪除課程「{0}」的修課記錄及相關評量成績嗎?", course.Name), MessageBoxButtons.YesNo) == DialogResult.Yes) { JHStudentRecord student = JHStudent.SelectByID(PrimaryKey); List <JHSCETakeRecord> sces = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID); if (sces.Count > 0) { JHSCETake.Delete(sces); FISCA.LogAgent.LogSaver logSaver = FISCA.LogAgent.ApplicationLog.CreateLogSaverInstance(); string studentInfo = StudentInfoConvertor.GetInfoWithClass(student); foreach (var sce in sces) { string desc = studentInfo + " 刪除評量成績:" + sce.Course.Name + " " + sce.Exam.Name; logSaver.AddBatch("成績系統.修課及評量成績", "刪除評量成績", "student", PrimaryKey, desc); } logSaver.LogBatch(); } List <JHSCAttendRecord> scattends = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID }); if (scattends.Count > 0) { JHSCAttend.Delete(scattends); StringBuilder builder = new StringBuilder(""); builder.Append(StudentInfoConvertor.GetInfoWithClass(student)); builder.Append(" 刪除修課:" + course.Name); FISCA.LogAgent.ApplicationLog.Log("成績系統.修課及評量成績", "刪除修課", "student", PrimaryKey, builder.ToString()); } listView.Items.Remove(item); } }
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); } }