⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complexprofile.aspx.cs

📁 asp。net 2.0宝典一书源码 全书源码给大家共享
💻 CS
字号:
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 System.Globalization;

public partial class ComplexProfile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindShoppingCart();
    }

    void BindShoppingCart()
    {
        if (Profile.ShoppingCart != null)
        {
            CartGrid.DataSource = Profile.ShoppingCart.CartItems;
            CartGrid.DataBind();
            lblTotal.Text = Profile.ShoppingCart.Total.ToString("c");
        }
    }

    protected void AddCartItem(Object s, EventArgs e)
    {
        GridViewRow row = ProductGrid.SelectedRow;

        int ID = (int)ProductGrid.SelectedDataKey.Value;
        String Name = row.Cells[1].Text;
        decimal Price = Decimal.Parse(row.Cells[2].Text,NumberStyles.Currency);

        if (Profile.ShoppingCart == null)
            Profile.ShoppingCart = new ShoppingCart();

        Profile.ShoppingCart.AddItem(ID, Name, Price);
        BindShoppingCart();
    }

    protected void RemoveCartItem(Object s, EventArgs e)
    {
        int ID = (int)CartGrid.SelectedDataKey.Value;
        Profile.ShoppingCart.RemoveItem(ID);
        BindShoppingCart();
    }
}

⌨️ 快捷键说明

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