houtai/add_product.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 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.SqlClient;
using System.Data;
using System.IO;
namespace 电子商务.houtai
{
    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";
            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 Button2_Click(object sender, EventArgs e)
        {
           //
            //
            if (FileUpload1.HasFile)
            {
                if (FileUpload1.PostedFile.ContentType.Substring(0, 5) == "image")
                {
                    string upPath = "../img/";  //上传文件路径

                    string name = FileUpload1.PostedFile.FileName;
                    FileInfo file = new FileInfo(name);
                    string fileName = DateTime.Now.ToString("yyyyMMddhhmmssfff") + file.Extension; // 文件名称,当前时间(yyyyMMddhhmmssfff)
                    string webFilePath = Server.MapPath(upPath) + fileName;
                    string FilePath = "img/" + fileName;
                    string imgName = FileUpload1.FileName;//获取上传文件的名称
                    string newPath = Server.MapPath(upPath) + "\\" + imgName;//设置图片在服务器端的新路径
                    FileUpload1.SaveAs(webFilePath);
                    ClientScript.RegisterStartupScript(this.GetType(), "", "alert('上传成功!');", true);
                    //txtinfo.Text = "";
                    //img.ImageUrl = "upLoad/" + imgName;//显示上传的图片
                    txt_pic.Text = FilePath;
                }
            }
            //
          //

        }
后面还有 16 行代码,购买后查看完整代码

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

AI 解读 AI

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

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