admin/edit_judge.aspx.cs

(完整代码) 1KB

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 在线考试.admin
{
    public partial class edit_judge : System.Web.UI.Page
    {
        SQLHelper db = new SQLHelper();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
        //
        public void bind()
        {
            //
            string sql = "select * from kc";
            DataTable d = db.ExecuteQuery(sql, CommandType.Text);
            this.ddl__kc.DataSource = d;
            this.ddl__kc.DataTextField = "kc";
            this.ddl__kc.DataValueField = "kc_id";
            this.ddl__kc.DataBind();
            //
            int id = Convert.ToInt32(Request.QueryString["id"].ToString());
            string cx = "select * from ti where ti_id=" + id;
            DataTable dt = db.ExecuteQuery(cx, CommandType.Text);
            this.txt_question.Text = dt.Rows[0]["question"].ToString();
            this.ddl__kc.Items.FindByValue(dt.Rows[0]["kc_id"].ToString()).Selected = true;
            this.ddl_ans.Items.FindByValue(dt.Rows[0]["ans"].ToString()).Selected = true;
            //
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"].ToString());
            string question = this.txt_question.Text.ToString();
            int kc_id = int.Parse(this.ddl__kc.SelectedValue.ToString());
            string ans = this.ddl_ans.SelectedValue.ToString();
            string sql = "update ti set question='" + question + "',kc_id='" + kc_id + "',ans='" + ans + "' where ti_id=" + id;
            db.ExecuteNonQuery(sql, CommandType.Text);
            Response.Write("<script>alert('修改成功!');location='judgelist.aspx'</script>");
        }
    }
}

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

AI 解读 AI

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

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