//将生成试卷保存到数据库
 protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
 {
     DataBase db = new DataBase();
     string insertpaper = "insert into Paper(ChapterID,PaperName,PaperState) values(" + int.Parse(ddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "',1) "+
                          "select MAX(ID) from Paper";
     try
     {
         int afterID = db.GetIDInsert(insertpaper);//保存试卷,并返回自动生成的试卷编号
         if (afterID > 0)
         {
             foreach (GridViewRow dr in GridView1.Rows)//保存试卷单选题信息
             {
                 string single = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'单选题'," + int.Parse(((Label)dr.FindControl("Label3")).Text) + "," + int.Parse(txtSingleFen.Text) + ")";
                 db.Insert(single);
             }
             foreach (GridViewRow dr in GridView2.Rows)//保存试卷多选题信息
             {
                 string multi = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'多选题'," + int.Parse(((Label)dr.FindControl("Label6")).Text) + "," + int.Parse(txtMultiFen.Text) + ")";
                 db.Insert(multi);
             }
             foreach (GridViewRow dr in GridView3.Rows)//保存试卷判断题信息
             {
                 string judge = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'判断题'," + int.Parse(((Label)dr.FindControl("Label7")).Text) + "," + int.Parse(txtJudgeFen.Text) + ")";
                 db.Insert(judge);
             }
             foreach (GridViewRow dr in GridView4.Rows)//保存试卷填空题信息
             {
                 string fill = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'填空题'," + int.Parse(((Label)dr.FindControl("Label8")).Text) + "," + int.Parse(txtFillFen.Text) + ")";
                 db.Insert(fill);
             }
             Response.Write("<script>alert('试卷添加成功');</script>");
         }
     }
     //胡媛媛添加,试卷成功添加后的页面处理,2010-4-13
     catch (Exception ex)
     {
         Response.Write("<script>alert('试卷添加失败');</script>");
     }
     finally
     {
         Panel1.Visible = false;
         InitData();
         Label4.Visible = false;
         Label5.Visible = false;
         Label11.Visible = false;
         Label12.Visible = false;
         this.txtPaperName.Text = null;
         this.txtSingleNum.Text = null;
         this.txtSingleFen.Text = null;
         this.txtMultiNum.Text = null;
         this.txtMultiFen.Text = null;
         this.txtFillNum.Text = null;
         this.txtFillFen.Text = null;
         this.txtJudgeNum.Text = null;
         this.txtJudgeFen.Text = null;
         this.Warning.Text = null;
     }
 }