示例#1
0
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblem pro = new MultiProblem();

        pro.ID       = int.Parse(Request["ID"].ToString());
        pro.CourseID = Convert.ToInt32(ddlCourse.SelectedValue);
        pro.Title    = txtTitle.Text;
        pro.AnswerA  = txtAnswerA.Text;
        pro.AnswerB  = txtAnswerB.Text;
        pro.AnswerC  = txtAnswerC.Text;
        pro.AnswerD  = txtAnswerD.Text;
        pro.AnswerE  = txtAnswerE.Text;
        pro.AnswerF  = txtAnswerF.Text;
        for (int i = 0; i < cblAnswer.Items.Count; i++)
        {
            if (cblAnswer.Items[i].Selected)
            {
                pro.Answer += cblAnswer.Items[i].Text;
            }
        }
        if (MultiProblemManager.multiProblemUpdate(pro))
        {
            lblMessage.Text = "修改成功!";
        }
        else
        {
            lblMessage.Text = "修改失败!";
        }
    }
示例#2
0
        //初始化数据
        protected void InitData()
        {
            int          multiProblemID = int.Parse(Request["ID"].ToString()); //取出传递过来的试题编号
            MultiProblem multiproblem   = new MultiProblem();                  //创建单选题对象

            if (multiproblem.LoadData(multiProblemID))                         //如果取出题目信息,分别放在相应控件显示
            {
                ddlCourse.SelectedValue = multiproblem.CourseID.ToString();
                txtTitle.Text           = multiproblem.Title;
                txtAnswerA.Text         = multiproblem.AnswerA;
                txtAnswerB.Text         = multiproblem.AnswerB;
                txtAnswerC.Text         = multiproblem.AnswerC;
                txtAnswerD.Text         = multiproblem.AnswerD;
                string answer = multiproblem.Answer;
                for (int i = 0; i < answer.Length; i++)
                {
                    string item = answer[i].ToString();
                    for (int j = 0; j < cblAnswer.Items.Count; j++)
                    {
                        if (item == cblAnswer.Items[i].Text)
                        {
                            cblAnswer.Items[i].Selected = true;
                        }
                    }
                }
            }
            else                //查询出错,给出提示
            {
                lblMessage.Text = "加载数据出错!";
            }
        }
示例#3
0
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
 {
     if (Page.IsValid)
     {
         MultiProblem multiproblem = new MultiProblem();            //创建单选题对象
         multiproblem.c_id    = int.Parse(ddlCourse.SelectedValue); //为单选题对象各属性赋值
         multiproblem.Title   = txtTitle.Text;
         multiproblem.AnswerA = txtAnswerA.Text;
         multiproblem.AnswerB = txtAnswerB.Text;
         multiproblem.AnswerC = txtAnswerC.Text;
         multiproblem.AnswerD = txtAnswerD.Text;
         string answer = "";
         for (int i = 0; i < cblAnswer.Items.Count; i++)
         {
             if (cblAnswer.Items[i].Selected)
             {
                 answer += cblAnswer.Items[i].Text;
             }
         }
         multiproblem.Answer = answer;
         if (Request["ID"] != null)                                              //如果是修改题目信息
         {
             multiproblem.ID = int.Parse(Request["ID"].ToString());              //取出试题主键
             if (multiproblem.UpdateByProc(int.Parse(Request["ID"].ToString()))) //调用修改试题方法修改试题
             {
                 Response.Write("<script>alert('修改成功!');</script>");
             }
             else
             {
                 Response.Write("<script>alert('修改失败!');</script>");
             }
         }
     }
 }
示例#4
0
    protected void InitData()
    {
        int          multiProblemID = int.Parse(Request["ID"].ToString()); //取出传递过来的试题编号
        MultiProblem multiproblem   = new MultiProblem();                  //创建单选题对象

        if (multiproblem.LoadData(multiProblemID))                         //如果取出题目信息,分别放在相应控件显示
        {
            db.ecDropDownList(ddlCourse, "select *from Course where c_id=(select c_id from MultiProblem where ID='" + multiProblemID + " ')", "c_name", "c_id");
            txtTitle.Text   = multiproblem.Title;
            txtAnswerA.Text = multiproblem.AnswerA;
            txtAnswerB.Text = multiproblem.AnswerB;
            txtAnswerC.Text = multiproblem.AnswerC;
            txtAnswerD.Text = multiproblem.AnswerD;
            string        answer = multiproblem.Answer.ToString();
            SqlConnection cn     = db.getcon();
            cn.Open();
            string     sqlstr1 = "select Answer from MultiProblem where ID='" + Request["ID"].ToString() + "'";
            SqlCommand cmd1    = new SqlCommand(sqlstr1, cn);
            Label1.Text = cmd1.ExecuteScalar().ToString();
        }
        else                //查询出错,给出提示
        {
            Response.Write("<script>alert('加载数据错误!');</script>");
            Response.Write("<script>window.location.href='ChangeDuoXuan'</script>");
        }
    }
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblem pro = new MultiProblem();
        pro.ID = int.Parse(Request["ID"].ToString());
        pro.CourseID = Convert.ToInt32(ddlCourse.SelectedValue);
        pro.Title = txtTitle.Text;
        pro.AnswerA = txtAnswerA.Text;
        pro.AnswerB = txtAnswerB.Text;
        pro.AnswerC = txtAnswerC.Text;
        pro.AnswerD = txtAnswerD.Text;

        for (int i = 0; i < cblAnswer.Items.Count; i++)
        {
            if (cblAnswer.Items[i].Selected)
            {
                pro.Answer += cblAnswer.Items[i].Text;
            }
        }
        if (multiProblemService.multiProblemUpdate(pro))
        {
            lblMessage.Text = "修改成功!";
        }
        else
        {
            lblMessage.Text = "修改失败!";
        }
    }
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblem pro = new MultiProblem();
        pro.CourseID = Convert.ToInt32(ddlCourse.SelectedValue);
        pro.Title = txtTitle.Text;
        pro.AnswerA = txtAnswerA.Text;
        pro.AnswerB = txtAnswerB.Text;
        pro.AnswerC = txtAnswerC.Text;
        pro.AnswerD = txtAnswerD.Text;

        for (int i = 0; i < cblAnswer.Items.Count; i++)
        {
            if (cblAnswer.Items[i].Selected)
            {
                pro.Answer += cblAnswer.Items[i].Text;

            }
        }

        if (multiProblemService.multiProblemInsert(pro))
        {
            lblMessage.Text = "添加成功!";
            txtTitle.Text = string.Empty;
            txtAnswerA.Text = string.Empty;
            txtAnswerB.Text = string.Empty;
            txtAnswerC.Text = string.Empty;
            txtAnswerD.Text = string.Empty;
            cblAnswer.ClearSelection();
        }
        else
        {
            lblMessage.Text = "添加失败!";
        }
    }
    protected void GridViewBind()
    {
        MultiProblem multiproblem = new MultiProblem();                                                 //创建多选题对象
        DataSet      ds           = multiproblem.QueryMultiProblem(int.Parse(ddlCourse.SelectedValue)); //根据试卷科目查询多选题信息

        GridView1.DataSource = ds.Tables[0].DefaultView;                                                //为GridView控件指名数据源
        GridView1.DataBind();                                                                           //绑定数据
    }
示例#8
0
    protected void txtTitle_TextChanged(object sender, EventArgs e)
    {
        MultiProblem mp = new MultiProblem();

        if (mp.isReduplicated(txtTitle.Text.Trim()) == true)
        {
            Page.RegisterStartupScript("", "<script>alert('改题已经存在!');</script>");
            txtTitle.Text = "";
        }
    }
    //删除多条记录
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblem multi = new MultiProblem();              //创建MultiProblem对象

        foreach (GridViewRow dr in GridView1.Rows)            //对GridView中的每一行进行判断
        {
            if (((CheckBox)dr.FindControl("xuanze")).Checked) //如果选择了进行删除
            {
                int ID = int.Parse(((Label)dr.FindControl("Label1")).Text);
                multi.ID = ID;
                multi.DeleteByProc(ID);
            }
        }
    }
    //删除试题事件
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        MultiProblem multiproblem = new MultiProblem();                                             //创建单选题对象
        int          ID           = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); //取出要删除记录的主键值

        if (multiproblem.DeleteByProc(ID))
        {
            Page.RegisterStartupScript("", "<script language=javascript>alert('成功删除试题!')</script>");
        }
        else
        {
            Page.RegisterStartupScript("", "<script language=javascript>alert('删除试题失败!')</script>");
        }
        GridViewBind();//重新绑定数据
    }
示例#11
0
 protected void save_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         MultiProblem multiproblem = new MultiProblem();             //创建单选题对象
         multiproblem.CourseID = int.Parse(ddlCourse.SelectedValue); //为单选题对象各属性赋值
         multiproblem.Title    = txtTitle.Text;
         multiproblem.AnswerA  = txtAnswerA.Text;
         multiproblem.AnswerB  = txtAnswerB.Text;
         multiproblem.AnswerC  = txtAnswerC.Text;
         multiproblem.AnswerD  = txtAnswerD.Text;
         string answer = "";
         for (int i = 0; i < cblAnswer.Items.Count; i++)
         {
             if (cblAnswer.Items[i].Selected)
             {
                 answer += cblAnswer.Items[i].Text;
             }
         }
         multiproblem.Answer = answer;
         if (Request["ID"] != null)                                              //如果是修改题目信息
         {
             multiproblem.ID = int.Parse(Request["ID"].ToString());              //取出试题主键
             if (multiproblem.UpdateByProc(int.Parse(Request["ID"].ToString()))) //调用修改试题方法修改试题
             {
                 lblMessage.Text = "成功修改该多选题!";
             }
             else
             {
                 lblMessage.Text = "修改该多选题失败!";
             }
         }
         else                                                       //如果是添加试题
         {
             if (multiproblem.InsertByProc())                       //调用添加试题方法添加试题
             {
                 lblMessage.Text = "成功添加该多选题!";
             }
             else
             {
                 lblMessage.Text = "添加该多选题失败!";
             }
         }
     }
 }
示例#12
0
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblem pro = new MultiProblem();

        pro.CourseID = Convert.ToInt32(ddlCourse.SelectedValue);
        pro.Title    = txtTitle.Text;
        pro.AnswerA  = txtAnswerA.Text;
        pro.AnswerB  = txtAnswerB.Text;
        pro.AnswerC  = txtAnswerC.Text;
        pro.AnswerD  = txtAnswerD.Text;
        pro.AnswerE  = txtAnswerE.Text;
        pro.AnswerF  = txtAnswerF.Text;

        for (int i = 0; i < cblAnswer.Items.Count; i++)
        {
            if (cblAnswer.Items[i].Selected)
            {
                pro.Answer += cblAnswer.Items[i].Text;
            }
        }

        if (MultiProblemManager.multiProblemInsert(pro))
        {
            lblMessage.Text = "添加成功!";
            txtTitle.Text   = string.Empty;
            txtAnswerA.Text = string.Empty;
            txtAnswerB.Text = string.Empty;
            txtAnswerC.Text = string.Empty;
            txtAnswerD.Text = string.Empty;
            txtAnswerE.Text = string.Empty;
            txtAnswerF.Text = string.Empty;
            cblAnswer.ClearSelection();
        }
        else
        {
            lblMessage.Text = "添加失败!";
        }
    }
 public bool multiProblemUpdate(MultiProblem mu)
 {
     return service.MultiProblemUpdate(mu);
 }
 public bool multiProblemInsert(MultiProblem mi)
 {
     return service.MultiProblemInsert(mi);
 }