protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e) { ImageButton imageButton = sender as ImageButton; string id = imageButton.CommandArgument; AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(id); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter,null,false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } Response.Write("<script>alert('删除成功!');location.href='showCourseTable.aspx';</script>"); }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; #region 先删除旧数据 DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter,null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } #endregion #region 后添加新数据 string semester = DropDownList_semester_from.SelectedValue + "-" + DropDownList_semester_to.SelectedValue + "学年" + DropDownList_semester_end.SelectedValue; int week_from = Convert.ToInt32(DropDownList_week_from.SelectedValue); int week_to = Convert.ToInt32(DropDownList_week_to.SelectedValue); string weekDay = DropDownList_weekDay.SelectedValue; string place = TextBox_place.Text; string courseTime = DropDownList_courseTime.SelectedValue + "节"; string teachId = ct.TeachID; string classId = ct.ClassID; string courId = ct.CourId; CourseTable courTable = new CourseTable(); courTable.Semester = semester; courTable.WeekDay = weekDay; courTable.Place = place; courTable.CourseTime = courseTime; courTable.TeachID = teachId; courTable.ClassID = classId; courTable.CourId = courId; for (int i = week_from; i <= week_to; i++) { courTable.Week = i.ToString(); ctBLL.save(courTable); } #endregion Response.Write("<script>alert('修改成功!');location.href='showCourseTable.aspx';</script>"); } }