private void changeBaseAttribute(StuList stuList, mainGridCellIndex index, string value) { Student stu = stuList[editingStudentId]; switch (index) { case mainGridCellIndex.Name: stu.name = value; break; case mainGridCellIndex.id: setStuId(stuList, stu, value); break; case mainGridCellIndex.sex: stu.sex = Student.stringToSex(value); break; case mainGridCellIndex.major: stu.major.name = value; break; case mainGridCellIndex.grade: stu.major.grade = value; break; case mainGridCellIndex._class: stu.major._class = value; break; case mainGridCellIndex.courseAttribute: stu.courseAttribute = Student.stringToCourseAttribute(value); break; case mainGridCellIndex.examMethod: stu.examMethod = Student.stringToExamMethod(value); break; case mainGridCellIndex.examAttribute: stu.examAttribute = Student.stringToExamAttribute(value); break; case mainGridCellIndex.isExamDelay: stu.isExamDelay = Student.stringToIsExamDelay(value); break; case mainGridCellIndex.score: stu.score = value; break; case mainGridCellIndex.subAttStartIndex: break; default: break; } }
private void MainGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e) { Model.Course course = courseRef; StuList stuList = course.getStuList(SelectedStuListUUID); if (e.ColumnIndex < (int)mainGridCellIndex.subAttStartIndex) { mainGridCellIndex index = (mainGridCellIndex)e.ColumnIndex; string value = getRowValue(e.RowIndex, index); changeBaseAttribute(stuList, index, value); } else { changeSpecalAttribute(course, stuList, e); } saveChange(); }
public DataGridViewCell cell(DataGridViewRow row, mainGridCellIndex index) { return(row.Cells[(int)index]); }
public string getRowValue(int rowIndex, mainGridCellIndex index) { return((string)mainGrid.Rows[rowIndex].Cells[(int)index].Value); }