admin/edit_product.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_product : 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 category order by c_id desc";//构造选出行业所有字段的SQL语句
            DataTable dt = db.ExecuteQuery(sql, CommandType.Text);
            this.ddl_category.DataSource = dt;
            this.ddl_category.DataTextField = "category";
            this.ddl_category.DataValueField = "c_id";
            this.ddl_category.DataBind();
            //
            int id = int.Parse(Request.QueryString["id"].ToString());
            string cx= "select * from product where pro_id=" + id;//构造选出行业所有字段的SQL语句
            DataTable d= db.ExecuteQuery(cx, CommandType.Text);
            this.ddl_category.Items.FindByValue(d.Rows[0]["c_id"].ToString()).Selected = true;
            this.txt_product.Text = d.Rows[0]["product"].ToString();
            this.txt_limit.Text = d.Rows[0]["limit_kc"].ToString();
            //
        }
        //
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            int c_id = int.Parse(this.ddl_category.SelectedValue.ToString());
            string product = this.txt_product.Text.ToString();
            int limit_kc = int.Parse(this.txt_limit.Text.ToString());
            string sql = "update product set c_id='" + c_id + "',product='" + product + "',limit_kc='"+limit_kc+"' where pro_id="+id;
            int s = db.ExecuteNonQuery(sql, CommandType.Text);
            Response.Write("<script>alert('成功!');location='productlist.aspx'</script>");
        }
    }
}

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

AI 解读 AI

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

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