protected void save_Click(object sender, EventArgs e) { if (Page.IsValid) { JudgeProblem judgeproblem = new JudgeProblem(); //创建判断题对象 judgeproblem.CourseID = int.Parse(ddlCourse.SelectedValue); //为判断题对象各属性赋值 judgeproblem.Title = txtTitle.Text; judgeproblem.Answer = bool.Parse(rblAnswer.SelectedValue); if (Request["ID"] != null) //如果是修改题目信息 { judgeproblem.ID = int.Parse(Request["ID"].ToString()); //取出试题主键 if (judgeproblem.UpdateByProc(int.Parse(Request["ID"].ToString()))) //调用修改试题方法修改试题 { lblMessage.Text = "成功修改该判断题!"; } else { lblMessage.Text = "修改该判断题失败!"; } } else //如果是添加试题 { if (judgeproblem.InsertByProc()) //调用添加试题方法添加试题 { lblMessage.Text = "成功添加该判断题!"; } else { lblMessage.Text = "添加该判断题失败!"; } } } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (Page.IsValid) { JudgeProblem judgeproblem = new JudgeProblem(); //创建判断题对象 judgeproblem.c_id = int.Parse(ddlCourse.SelectedValue); //为判断题对象各属性赋值 judgeproblem.Title = txtTitle.Text; judgeproblem.Answer = bool.Parse(rblAnswer.SelectedValue); if (Request["ID"] != null) //如果是修改题目信息 { judgeproblem.ID = int.Parse(Request["ID"].ToString()); //取出试题主键 if (judgeproblem.UpdateByProc(int.Parse(Request["ID"].ToString()))) //调用修改试题方法修改试题 { Response.Write("<script>alert('修改成功!');</script>"); } else { Response.Write("<script>alert('修改失败!');</script>"); } } } }