GoodsDetail.aspx.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class GoodsDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Convert.ToInt32(Request.QueryString["goodsid"]);
            string Sql = "select * from tb_Goods where GoodsID=" + id;
            DataSet result = DBHelper.GetDataSet(Sql);
            DataTable dt = result.Tables[0];
            this.Label2.Text = dt.Rows[0]["GoodsName"].ToString();
            this.Label3.Text = dt.Rows[0]["TypeID"].ToString();
            this.Label4.Text = dt.Rows[0]["Price"].ToString();
            this.Label5.Text = dt.Rows[0]["Introduce"].ToString();
            this.Image10.ImageUrl = dt.Rows[0]["GoodsPicture"].ToString();
         
        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["MemberName"] != null)
        {

            int goodsid = Convert.ToInt32(Request.QueryString["goodsid"]);
            float price = Convert.ToSingle(this.Label4.Text);
            //添加商品到表tb_BuyInfo
            BuyCar.AddShopCart(goodsid, price, Int32.Parse(Session["MemberID"].ToString()), 1);
            //提示添加成功
            Response.Write("<script>alert('恭喜您,添加成功!');document.location=document.location;</script>");   
            

        }
        else //没有登陆。提示:请先登录,谢谢合作!
        {
            Response.Write("<script>alert('请先登录,谢谢合作!');document.location=document.location;</script>");
        }
    }
}

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

AI 解读 AI

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

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