admin/product/insertpro.aspx.cs

(完整代码) 2KB

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_product_insertpro : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strName = Server.HtmlEncode(txtName.Text);
        strName = strName.Replace("\r\n", "<br>");
        strName = strName.Replace("'", "''");
        strName = strName.Replace(" ", "&nbsp;");

        string strIntro = Server.HtmlEncode(txtIntro.Text);
        strIntro = strIntro.Replace("\r\n", "<br>");
        strIntro = strIntro.Replace("'", "''");
        strIntro = strIntro.Replace(" ", "&nbsp;");

        string fPrice = Server.HtmlEncode(txtPrice.Text);
        fPrice=fPrice.Replace("\r\n", "<br>");
        fPrice=fPrice.Replace("'", "''");
        fPrice = fPrice.Replace(" ", "&nbsp;");

        if (FileUpload1.HasFile)
        {
            string strExtention = System.IO.Path.GetExtension(FileUpload1.FileName);
            string strFileName = DropDownList1.SelectedItem.Text + DateTime.Now.ToString("yyMMddHHmmss");
            FileUpload1.SaveAs(Server.MapPath("../../product/image/" + strFileName + strExtention));
            string strSQL = "insert into Product (ProductImg,ProductName,ProductPrice,TypeId,ProductContent) values('image/" + strFileName + strExtention + "','" + strName + "'," + fPrice + ",'" + DropDownList1.SelectedValue.ToString() + "','" + strIntro + "')";
            if (MyClass.ExecuteSql(strSQL) > 0)
            {
                Response.Write("<script>alert('添加商品成功!')</script>");
                Response.Write("<script>location.assign('manageproduct.aspx')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加商品失败!')</script>");
            }
        }
        else
        {
             Response.Write("<script>alert('请选择商品图片!')</script>");
        }
    }
}

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

AI 解读 AI

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

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