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); } }