コード例 #1
0
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        if (Page.IsValid)
        {
            Course course = new Course();               //创建试卷科目对象
            if (course.IsCourseNameExist(txtName.Text.Trim()))
            {
                AjaxCommond ac = new AjaxCommond();
                ac.OpenDialogForButton((ImageButton)sender, "该名称已被占用!!!");
                txtName.Text = "";
            }
            else
            {
                course.Name = txtName.Text;                 //设置试卷科目对象属性
                if (course.InsertByProc())                  //调用添加试卷科目方法添加试卷科目
                {
                    lblMessage.Text = "成功添加该试卷科目!";
                    txtName.Text = "";

                }
                else
                {
                    lblMessage.Text = "添加该试卷科目失败!";
                }
            }

        }
    }
コード例 #2
0
 protected void CheckPagerName_Click(object sender, EventArgs e)
 {
     AjaxCommond ac = new AjaxCommond();
     //���������Ķ���
     SqlDataReader read = ExceRead("select * from Papermr where PaperName='" + this.txtPaperName.Text + "'");
     read.Read();                                                            //�������Ķ���
     if (read.HasRows)                                                       //�ж��Ƿ�������
     {
         if (this.txtPaperName.Text == read["PaperName"].ToString())
         {
             //����AJAX�����еĶԻ���
             ac.OpenDialogForButton((Button)sender, "���ź������Ծ������Ѿ����ڣ�����");
         }
     }
     else
     {
         //����AJAX�����еĶԻ���
         ac.OpenDialogForButton((Button)sender, "��ϲ�������Ծ����ƿ�����ӣ�����");
     }
     read.Close();                                                           //�ر������Ķ���
 }
コード例 #3
0
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     AjaxCommond ac = new AjaxCommond();
     if(IsPaperNameNotExist())
         ac.OpenDialogForLinkButton((LinkButton)sender, "该试卷名可以用!!!");
     else
         ac.OpenDialogForLinkButton((LinkButton)sender, "很遗憾!该试卷名称已经存在!!!");
 }
コード例 #4
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");
 }
コード例 #5
0
    //将生成试卷保存到数据库
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        AjaxCommond ac = new AjaxCommond();
        if (IsPaperNameNotExist())
        {
            DataBase db = new DataBase();
            string insertpaper = "insert into Paper(CourseID,PaperName,PaperState,NeedTime) values(" + int.Parse(ddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "',0," + int.Parse(ddlNeedTime.SelectedValue) * 60 + ") SELECT @@IDENTITY as id";
            int afterID = GetIDInsert(insertpaper);//保存试卷,并返回自动生成的试卷编号
            if (afterID > 0)
            {
                for (int i = 0; i < this.GridView11.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView11.Rows[i].FindControl("chkSelect1")).Checked;
                    if (isChecked)
                    {
                        string str1 = ((Label)GridView11.Rows[i].FindControl("Label3")).Text;
                        string single = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'单选题'," + str1 + "," + int.Parse(txtSingleFen.Text) + ")";
                        db.Insert(single);
                    }

                }
                for (int i = 0; i < this.GridView2.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView2.Rows[i].FindControl("chkSelect2")).Checked;
                    if (isChecked)
                    {
                        string str2 = ((Label)GridView2.Rows[i].FindControl("Label6")).Text;
                        string multi = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'多选题'," + str2 + "," + int.Parse(txtMultiFen.Text) + ")";
                        db.Insert(multi);
                    }

                }
                for (int i = 0; i < this.GridView3.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView3.Rows[i].FindControl("chkSelect3")).Checked;
                    if (isChecked)
                    {
                        string str3 = ((Label)GridView3.Rows[i].FindControl("Label7")).Text;
                        string judge = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'判断题'," + str3 + "," + int.Parse(txtJudgeFen.Text) + ")";
                        db.Insert(judge);
                    }

                }
                for (int i = 0; i < this.GridView4.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView4.Rows[i].FindControl("chkSelect4")).Checked;
                    if (isChecked)
                    {
                        string str4 = ((Label)GridView4.Rows[i].FindControl("Label8")).Text;
                        string fill = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'填空题'," + str4 + "," + int.Parse(txtFillFen.Text) + ")";
                        db.Insert(fill);
                    }

                }
                for (int i = 0; i < this.GridView5.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView5.Rows[i].FindControl("chkSelect5")).Checked;
                    if (isChecked)
                    {
                        string str5 = ((Label)GridView5.Rows[i].FindControl("Label23")).Text;
                        string que = "insert into PaperDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'问答题'," + str5 + "," + int.Parse(txtQuestionFen.Text) + ")";
                        db.Insert(que);
                    }

                }

            }
            txtPaperName.Text = "";
            ac.OpenDialogForButtonWithLocation((ImageButton)sender, "保存成功!");
        }
        else
        {
            ac.OpenDialogForButton((ImageButton)sender, "很遗憾!该试卷名称已经存在!!!");
            return ;
        }
    }