/// <summary> /// 点击单元格事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridViewCellContent_Click(object sender, DataGridViewCellEventArgs e) { if (skinDataGridView1.Columns[e.ColumnIndex].Name == "btnOpenCourse") {//判断列名,点击的列是DataGridViewButtonColumn列 int courseId = (int)skinDataGridView1.Rows[e.RowIndex].Cells[1].Value; int pickedCount = (int)skinDataGridView1.Rows[e.RowIndex].Cells[4].Value; if (pickedCount == 0) { MessageBox.Show("开班失败!没有学生选择该课程!"); return; } //查:表[CourseClass] CourseClassBean courseClass = new CourseClassBean(3, courseId, 50, teacher.Id); CourseClassDao DAO = new CourseClassDao(); if (DAO.FindByCourId_TeacherId(courseClass) != null) { MessageBox.Show("开班失败!您已开设过该课程!"); return; } //增:表[CourseClass] if (DAO.Add(courseClass)) { ShowMyOpenCourse(); MessageBox.Show("开班成功!"); } } }
/// <summary> /// 监听DataGridView列按钮的点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridViewCellContent_Click(object sender, DataGridViewCellEventArgs e) { if (skinDataGridView1.Columns[e.ColumnIndex].Name == "btnChooseCourse") { int courseClassId = (int)skinDataGridView1.Rows[e.RowIndex].Cells[1].Value; CourseClassBean courseClass = new CourseClassDao().FindById(new CourseClassBean(courseClassId)); if (courseClass != null) { new CountScoreForm(courseClass).Show(); } } }