productslist.aspx.cs

来自「天织在线购物网站完整源码及文档 本网站是一套基于Web2.0思想设计、采用」· CS 代码 · 共 72 行

CS
72
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ShopCart;
public partial class ProductsList : PageBase
{
    UserInfoClass ucObj = new UserInfoClass();
    String login;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Login"] != null)
        {
            login = Session["Login"].ToString();
        }
        else {
            Response.Redirect("Default.aspx");
        }
         
    }
    //绑定市场价格
    public string GetMKPStr(string P_Str_MarketPrice)
    {
        return ucObj.VarStr(P_Str_MarketPrice, 2);
    }
    //绑定会员价格
    public string GetMBPStr(string P_Str_MemberPrice)
    {
        return ucObj.VarStr(P_Str_MemberPrice, 2);
    }

    //当购买商品时,获取商品信息
    public SaveSubGoodsClass GetSubGoodsInformation(DataListCommandEventArgs e, DataList DLName)
    {
        //获取购物车中的信息
        SaveSubGoodsClass Goods = new SaveSubGoodsClass();
        Goods.GoodsID = int.Parse(DLName.DataKeys[e.Item.ItemIndex].ToString());
        string GoodsStyle = e.CommandArgument.ToString();
        int index = GoodsStyle.IndexOf("|");
        if (index < -1 || index + 1 >= GoodsStyle.Length)
            return Goods;
        Goods.GoodsWeight = float.Parse(GoodsStyle.Substring(0, index));
        Goods.MemberPrice = float.Parse(GoodsStyle.Substring(index + 1));
        return (Goods);

    }
    public void AddShopCart(DataListCommandEventArgs e, DataList DLName)
    {
        if (login == null)
        {
            Response.Write("<script>alert('对不起,你没有登陆,不能购买物品');</script>");
        }
        else
        {
            SaveSubGoodsClass Goods = null;
            Goods = GetSubGoodsInformation(e, DLName);
            ucObj.AddShopCart(Goods.GoodsID, Goods.MemberPrice, System.Convert.ToInt32(login), Goods.GoodsWeight);
            Response.Redirect("Cart.aspx");
        }
    }
    protected void DLrefinement_ItemCommand1(object source, DataListCommandEventArgs e)
    {
        AddShopCart(e, DLrefinement);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?