// save private void SemesterHistoryDetail_SaveButtonClick(object sender, EventArgs e) { // 資料檢查 foreach (DataGridViewRow row in dataGridViewX1.Rows) { if (row.IsNewRow) { continue; } foreach (DataGridViewCell cell in row.Cells) { if (cell.ErrorText != "") { MsgBox.Show("資料有疑問無法儲存,請檢查標紅色儲存格.", "儲存失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } JHSchool.Data.JHSemesterHistoryRecord updateSemeHsitoryRec = new JHSchool.Data.JHSemesterHistoryRecord(); updateSemeHsitoryRec.RefStudentID = PrimaryKey; foreach (DataGridViewRow row in dataGridViewX1.Rows) { int SchoolYear = 0, Semester = 0, GradeYear = 0, SchoolDayCount = 0, SeatNo = 0; if (row.IsNewRow) { continue; } K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); if (row.Cells[colSchoolYear.Index] != null) { int.TryParse("" + row.Cells[colSchoolYear.Index].Value, out SchoolYear); } if (row.Cells[colSemester.Index] != null) { int.TryParse("" + row.Cells[colSemester.Index].Value, out Semester); } if (row.Cells[colGradeYear.Index] != null) { int.TryParse("" + row.Cells[colGradeYear.Index].Value, out GradeYear); } if (row.Cells[colSchoolDayCount.Index] != null) { int.TryParse("" + row.Cells[colSchoolDayCount.Index].Value, out SchoolDayCount); } if (row.Cells[colSeatNo.Index] != null) { int.TryParse("" + row.Cells[colSeatNo.Index].Value, out SeatNo); } shi.SchoolYear = SchoolYear; shi.Semester = Semester; shi.GradeYear = GradeYear; if (row.Cells[colClassName.Index] != null) { shi.ClassName = row.Cells[colClassName.Index].Value + ""; } if (SeatNo == 0) { shi.SeatNo = null; } else { shi.SeatNo = SeatNo; } if (row.Cells[colTeacherName.Index] != null) { shi.Teacher = row.Cells[colTeacherName.Index].Value + ""; } if (SchoolDayCount == 0) { shi.SchoolDayCount = null; } else { shi.SchoolDayCount = SchoolDayCount; } updateSemeHsitoryRec.SemesterHistoryItems.Add(shi); string logIdxStr = shi.SchoolYear + "" + shi.Semester + "_"; prlp.SetAfterSaveText(logIdxStr + "學年度", shi.SchoolYear + ""); prlp.SetAfterSaveText(logIdxStr + "學期", shi.Semester + ""); prlp.SetAfterSaveText(logIdxStr + "年級", shi.GradeYear + ""); prlp.SetAfterSaveText(logIdxStr + "班級", shi.ClassName); prlp.SetAfterSaveText(logIdxStr + "座號", SeatNo + ""); prlp.SetAfterSaveText(logIdxStr + "班導師", shi.Teacher); prlp.SetAfterSaveText(logIdxStr + "上課天數", SchoolDayCount + ""); } JHSchool.Data.JHSemesterHistory.Update(updateSemeHsitoryRec); prlp.SetActionBy("學籍", "學生學期對照表"); prlp.SetAction("修改學生學期對照表"); JHStudentRecord studRec = JHStudent.SelectByID(PrimaryKey); prlp.SetDescTitle("學生姓名:" + studRec.Name + ",學號:" + studRec.StudentNumber + ","); prlp.SaveLog("", "", "student", PrimaryKey); this.CancelButtonVisible = false; this.SaveButtonVisible = false; }
void BGWorker_DoWork(object sender, DoWorkEventArgs e) { _SemesterHistoryRec = JHSchool.Data.JHSemesterHistory.SelectByStudentID(PrimaryKey); }