예제 #1
0
 //�������Ծ���浽���ݿ�
 protected void imgBtnSave_Click(object sender, EventArgs e)
 {
     DataBase database = new DataBase();//ʵ����������DataBase
     AjaxCommond ac = new AjaxCommond();//ʵ����������AjaxCommond
     string insertExamPage = "insert into Papermr(CourseID,PaperName,PaperState) values(" + int.Parse(MyddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "',1) SELECT @@IDENTITY as id";
     int autopageID = GetIDInsert(insertExamPage);//�����Ծ���������Զ����ɵ��Ծ���
     if (autopageID > 0)
     {
         //���ɵ�ѡ����Ϣ�������������ݿ���
         for (int i = 0; i < this.GridView1.Rows.Count; i++)
         {
             bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("chkSelect1")).Checked;
             if (isChecked)
             {
                 string sqlstr1 = ((Label)GridView1.Rows[i].FindControl("Label3")).Text;
                 string singlepaper = "insert into PaperDetailmr(PaperID,Type,TitleID,Mark) values(" + autopageID + ",'��ѡ��'," + sqlstr1 + "," + int.Parse(txtSingleFen.Text) + ")";
                 database.Insert(singlepaper);
             }
         }
         //���ɶ�ѡ����Ϣ�������������ݿ���
         for (int i = 0; i < this.GridView2.Rows.Count; i++)
         {
             bool isChecked = ((CheckBox)GridView2.Rows[i].FindControl("chkSelect2")).Checked;
             if (isChecked)
             {
                 string sqlstr2 = ((Label)GridView2.Rows[i].FindControl("Label6")).Text;
                 string multipaper = "insert into PaperDetailmr(PaperID,Type,TitleID,Mark) values(" + autopageID + ",'��ѡ��'," + sqlstr2 + "," + int.Parse(txtMultiFen.Text) + ")";
                 database.Insert(multipaper);
             }
         }
         //�����ж�����Ϣ�������������ݿ���
         for (int i = 0; i < this.GridView3.Rows.Count; i++)
         {
             bool isChecked = ((CheckBox)GridView3.Rows[i].FindControl("chkSelect3")).Checked;
             if (isChecked)
             {
                 string sqlstr3 = ((Label)GridView3.Rows[i].FindControl("Label7")).Text;
                 string judgepaper = "insert into PaperDetailmr(PaperID,Type,TitleID,Mark) values(" + autopageID + ",'���'," + sqlstr3 + "," + int.Parse(txtJudgeFen.Text) + ")";
                 database.Insert(judgepaper);
             }
         }
         //�����������Ϣ�������������ݿ���
         for (int i = 0; i < this.GridView4.Rows.Count; i++)
         {
             bool isChecked = ((CheckBox)GridView4.Rows[i].FindControl("chkSelect4")).Checked;
             if (isChecked)
             {
                 string sqlstr4 = ((Label)GridView4.Rows[i].FindControl("Label8")).Text;
                 string fillpaper = "insert into PaperDetailmr(PaperID,Type,TitleID,Mark) values(" + autopageID + ",'�����'," + sqlstr4 + "," + int.Parse(txtFillFen.Text) + ")";
                 database.Insert(fillpaper);
             }
         }
         //�����ʴ�����Ϣ�������������ݿ���
         for (int i = 0; i < this.GridView5.Rows.Count; i++)
         {
             bool isChecked = ((CheckBox)GridView5.Rows[i].FindControl("chkSelect5")).Checked;
             if (isChecked)
             {
                 string sqlstr5 = ((Label)GridView5.Rows[i].FindControl("Label23")).Text;
                 string quepaper = "insert into PaperDetailmr(PaperID,Type,TitleID,Mark) values(" + autopageID + ",'�ʴ���'," + sqlstr5 + "," + int.Parse(txtQuestionFen.Text) + ")";
                 database.Insert(quepaper);
             }
         }
     }
     //����ajax�����е���ʾ�Ի���
     ac.OpenDialogForButton((Button)sender, "���ݱ���ɹ���");
     //��ת���Ծ�ά��ҳ
     Response.Redirect("PaperLists.aspx");
 }
예제 #2
0
    public void PageSubmit()
    {
        int paperid = Convert.ToInt32(Session["PaperID"].ToString());
        DataBase db = new DataBase();

        //取出单选题的每题分值
        if (GridView1.Rows.Count > 0)
        {
            int singlemark = int.Parse(((Label)GridView1.Rows[0].FindControl("Label4")).Text);
            foreach (GridViewRow dr in GridView1.Rows)
            {
                string str = "";
                if (((RadioButton)dr.FindControl("RadioButton1")).Checked)
                {
                    str = "A";
                }
                else if (((RadioButton)dr.FindControl("RadioButton2")).Checked)
                {
                    str = "B";
                }
                else if (((RadioButton)dr.FindControl("RadioButton3")).Checked)
                {
                    str = "C";
                }
                else if (((RadioButton)dr.FindControl("RadioButton4")).Checked)
                {
                    str = "D";
                }

                int titleid = int.Parse(((Label)dr.FindControl("Label40")).Text);
                string single = "insert into UserAnswermr(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + labUser.Text + "','" + paperid + "','单选题','" + titleid + "','" + singlemark + "','" + str + "','" + DateTime.Now.ToString() + "')";
                db.Insert(single);
            }
        }

        //取出多选题每题分值
        if (GridView2.Rows.Count > 0)
        {
            int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);
            foreach (GridViewRow dr in GridView2.Rows)//对多选题每题进行判断用户选择答案
            {
                string str = "";
                if (((CheckBox)dr.FindControl("CheckBox1")).Checked)
                {
                    str += "A";
                }
                if (((CheckBox)dr.FindControl("CheckBox2")).Checked)
                {
                    str += "B";
                }
                if (((CheckBox)dr.FindControl("CheckBox3")).Checked)
                {
                    str += "C";
                }
                if (((CheckBox)dr.FindControl("CheckBox4")).Checked)
                {
                    str += "D";
                }
                int titleid = int.Parse(((Label)dr.FindControl("Label41")).Text);
                string Multi = "insert into UserAnswermr(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + labUser.Text + "','" + paperid + "','多选题','" + titleid + "','" + multimark + "','" + str + "','" + DateTime.Now.ToString() + "')";
                db.Insert(Multi);
            }
        }

        //取出判断题每题分值
        if (GridView3.Rows.Count > 0)
        {
            int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);
            foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案
            {
                string str = "";
                CheckBox cbox5 = (CheckBox)dr.FindControl("CheckBox5");
                CheckBox cbox6 = (CheckBox)dr.FindControl("CheckBox6");
                    if (cbox5.Checked)
                    {
                        str = Convert.ToString(true);
                    }
                    if (cbox6.Checked)
                    {
                        str = Convert.ToString(false);
                    }
                int titleid = int.Parse(((Label)dr.FindControl("Label42")).Text);
                string Judge = "insert into UserAnswermr(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + labUser.Text + "','" + paperid + "','判断题','" + titleid + "','" + judgemark + "','" + str + "','" + DateTime.Now.ToString() + "')";
                db.Insert(Judge);
            }
        }
        //取出填空题每题分值
        if (GridView4.Rows.Count > 0)
        {
            int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text);
            foreach (GridViewRow dr in GridView4.Rows)
            {
                string str = "";
                str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim();
                int titleid = int.Parse(((Label)dr.FindControl("Label43")).Text);
                string Fill = "insert into UserAnswermr(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + labUser.Text + "','" + paperid + "','填空题','" + titleid + "','" + fillmark + "','" + str + "','" + DateTime.Now.ToString() + "')";
                db.Insert(Fill);
            }
        }

        //取出问答题每题分值
        if (GridView5.Rows.Count > 0)
        {
            int quemark = int.Parse(((Label)GridView5.Rows[0].FindControl("Label37")).Text);
            foreach (GridViewRow dr in GridView5.Rows)
            {
                string str = "";
                str = ((TextBox)dr.FindControl("TextBox2")).Text.Trim();
                int titleid = int.Parse(((Label)dr.FindControl("Label44")).Text);
                string Que = "insert into UserAnswermr(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + labUser.Text + "','" + paperid + "','问答题','" + titleid + "','" + quemark + "','" + str + "','" + DateTime.Now.ToString() + "')";
                db.Insert(Que);
            }
        }
    }