train2.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace 在线考试
{
    public partial class train2 : System.Web.UI.Page
    {
        SQLHelper db = new SQLHelper();
        int cj = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
        //
        public void bind()
        {
            int kc_id = int.Parse(Request.QueryString["kc_id"].ToString());
            string sql = "select top 5 * from ti where xz='判断题' and kc_id=" + kc_id + " order by newid()";
            DataTable dt = db.ExecuteQuery(sql, CommandType.Text);
            this.gv.DataSource = dt;
            this.gv.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //
            foreach (GridViewRow dr in gv.Rows)//对单选题每题进行判断用户选择答案
            {
                string str = "";
                RadioButtonList r = (RadioButtonList)dr.FindControl("rbt_choice");
                str = r.SelectedValue.ToString();
                //
                if (((Label)dr.FindControl("lb_ans")).Text.Trim() == str)//将用户选择结果和答案进行比较
                {
                    dr.FindControl("lb_str").Visible = true;
                    ((Label)dr.FindControl("lb_str")).Text = "您的答案是正确的";

                }
                else
                {
                    dr.FindControl("lb_str").Visible = true;
                    //将错题转入错题表中
                    ((Label)dr.FindControl("lb_str")).Text = "<font color=red>正确答案是:</font>" + ((Label)dr.FindControl("lb_ans")).Text;
                }
            }
            //
            this.Button1.Enabled = false;
            //
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
后面还有 5 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。