//修改课程 public void Update(string studentName, string subjectName, double scoreCount) { int studentNo = DataAccess.Student.GetStudentNo(_className, studentName); DataAccess.Course objCourse = new DataAccess.Course(_className, subjectName); int courseID = objCourse.GetCourseID(); DataAccess.Score objScore = new DataAccess.Score(studentNo, courseID); objScore.ScoreCount = scoreCount; if (objScore.Update() > 0) { UpdateDataGrid(); MessageBox.Show("修改成绩成功!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新成绩失败!", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//删除课程 public void Delete() { int studentNo = Int32.Parse(this._dgvScore.CurrentRow.Cells["StudentNo"].Value.ToString()); string subjectName = this._dgvScore.CurrentRow.Cells["SubjectName"].Value.ToString(); DataAccess.Course objCourse = new DataAccess.Course(_className, subjectName); int courseID = objCourse.GetCourseID(); DialogResult result = MessageBox.Show("真的要删除吗?", "删除确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { DataAccess.Score objScore = new DataAccess.Score(studentNo, courseID); if (objScore.Delete() > 0) { UpdateDataGrid(); MessageBox.Show("成功删除成绩!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("删除操作失败!", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }