admin/add_product.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 add_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();
        }
        //
        protected void Button1_Click(object sender, EventArgs e)
        {
            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 = "insert into product(c_id,product,limit_kc) values('"+c_id+"','"+product+"','"+limit_kc+"')";
            int s = db.ExecuteNonQuery(sql, CommandType.Text);
            Response.Write("<script>alert('成功!');location='add_product.aspx'</script>");
        }
    }
}

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

AI 解读 AI

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

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