public void ResetValue() { foreach (DataGridViewRow row in _dgv.Rows) { foreach (DataGridViewCell cell in row.Cells) { cell.Style.BackColor = Color.White; cell.Style.ForeColor = Color.Black; cell.ToolTipText = ""; IExamCell ic = cell.Tag as IExamCell; if (ic != null) { ic.Reset(); cell.Value = ic.GetValue(); ic.Standard.Judge(cell); } } } }
public override void Save() { // 產生新增成績 Request int insertStudentCount = 0; int updateStudentCount = 0; int deleteStudentCount = 0; int usCount = 0; DSXmlHelper insertHelper = new DSXmlHelper("Request"); DSXmlHelper updateHelper = new DSXmlHelper("Request"); DSXmlHelper deleteHelper = new DSXmlHelper("Request"); DSXmlHelper usHelper = new DSXmlHelper("Request"); insertHelper.AddElement("ScoreSheetList"); updateHelper.AddElement("ScoreSheetList"); deleteHelper.AddElement("ScoreSheet"); foreach (DataGridViewRow row in dataGridView1.Rows) { string attendid = row.Tag.ToString(); foreach (DataGridViewCell cell in row.Cells) { IExamCell ic = cell.Tag as IExamCell; if (ic == null) { continue; } ColumnSetting setting = dataGridView1.Columns[cell.ColumnIndex].Tag as ColumnSetting; string examid = setting.Key; if (ic is ScoreExamCell && ic.IsDirty) { usCount++; usHelper.AddElement("Attend"); usHelper.AddElement("Attend", "Score", ic.GetValue()); usHelper.AddElement("Attend", "ID", attendid); } else if (string.IsNullOrEmpty(ic.Key) && ic.IsDirty) { insertStudentCount++; insertHelper.AddElement("ScoreSheetList", "ScoreSheet"); insertHelper.AddElement("ScoreSheetList/ScoreSheet", "ExamID", examid); insertHelper.AddElement("ScoreSheetList/ScoreSheet", "AttendID", attendid); insertHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue()); } else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && !string.IsNullOrEmpty(ic.GetValue())) { updateStudentCount++; updateHelper.AddElement("ScoreSheetList", "ScoreSheet"); updateHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue()); updateHelper.AddElement("ScoreSheetList/ScoreSheet", "ID", ic.Key); } else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && string.IsNullOrEmpty(ic.GetValue())) { deleteStudentCount++; deleteHelper.AddElement("ScoreSheet", "ID", ic.Key); } } } if (insertStudentCount > 0) { EditCourse.InsertSCEScore(new DSRequest(insertHelper)); } if (updateStudentCount > 0) { EditCourse.UpdateSCEScore(new DSRequest(updateHelper)); } if (deleteStudentCount > 0) { EditCourse.DeleteSCEScore(new DSRequest(deleteHelper)); } if (usCount > 0) { EditCourse.UpdateAttend(usHelper); } SaveButtonVisible = false; LoadContent(RunningID); }