admin/edit_sub.aspx.cs

(完整代码) 2KB

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_sub : 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 depart";
            DataTable dt = db.ExecuteQuery(sql, CommandType.Text);
            this.ddl_depart.DataSource = dt;
            this.ddl_depart.DataTextField = "depart";
            this.ddl_depart.DataValueField = "depart_id";
            this.ddl_depart.DataBind();
            //
            int id = Convert.ToInt32(Request.QueryString["id"].ToString());
            string cx = "select * from sub_admin where sub_id=" + id;
            DataTable d = db.ExecuteQuery(cx, CommandType.Text);
            this.txt_zh.Text = d.Rows[0]["zh"].ToString();
            this.txt_mima.Text = d.Rows[0]["mima"].ToString();
            this.txt_name.Text = d.Rows[0]["name"].ToString();
            this.txt_tel.Text = d.Rows[0]["tel"].ToString();
            this.txt_zc.Text = d.Rows[0]["zc"].ToString();
            this.txt_bm.Text = d.Rows[0]["bm"].ToString();
            this.ddl_depart.Items.FindByValue(d.Rows[0]["depart_id"].ToString()).Selected = true;
            //
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"].ToString());
            int depart_id = int.Parse(this.ddl_depart.SelectedValue.ToString());
            string zh = this.txt_zh.Text.ToString();
            string mima = this.txt_mima.Text.ToString();
            string name = this.txt_name.Text.ToString();
            string tel = this.txt_tel.Text.ToString();
            string zc = this.txt_zc.Text.ToString();
            string bm = this.txt_bm.Text.ToString();
            string sql = "update sub_admin set depart_id='" + depart_id + "',zh='" + zh + "',mima='" + mima + "',name='" + name + "',tel='" + tel + "',zc='"+zc+"',bm='"+bm+"' where sub_id="+id;
            int t = db.ExecuteNonQuery(sql, CommandType.Text);
            Response.Write("<script>alert('修改成功!');location='sublist.aspx'</script>");
        }
    }
}

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

AI 解读 AI

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

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