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

📄 shoucang.ascx.cs

📁 网上书店
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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;

public partial class DefaultControl_ShouCang : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int howManyProducts = 0;
        if (!IsPostBack)
        {
            if (Session["Customer"] == null)
            {
                Response.Write("<script language='javascript' type='text/javascript'>alert('你还没有登陆,请先登陆');window.location.href='Default.aspx';</script>");
            }
            else
            {
                GetShouCang(Session["Customer"].ToString(), 1, out howManyProducts);
            }
            DropDownList1.Items.Clear();
            Label6.Text = howManyProducts.ToString();
            for (int i = 1; i <= howManyProducts; i++)
            {
                DropDownList1.Items.Add(i.ToString());
            }

        }

        
    }
    private void GetShouCang(string customerName, int pageNumber,out int howManyProducts)
    {
         
        DataList1.DataSource = CommonDataAccess.GetShouCang(customerName, pageNumber ,out howManyProducts);
        DataList1.DataBind();
    }

    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Buy")
        {

            string bookID = e.CommandArgument.ToString();
            CommonDataAccess.HotClick(Int32.Parse(bookID));
            if (ShoppingCartAccess.ShoppingCartAddItem(bookID))
            {
                Message.ShowMsgBox(Page, "该图书已放入购物车");
            }
        }
        if (e.CommandName == "xx")
        {

            string bookID = e.CommandArgument.ToString();
            CommonDataAccess.HotClick(Int32.Parse(bookID));
            Response.Redirect(Request.ApplicationPath + @"\Product.aspx?xx=" + bookID);

        }
        if (e.CommandName == "del")
        {
            string  bookID = e.CommandArgument.ToString();
            CommonDataAccess.DelShouCang(Session["Customer"].ToString(), bookID);
            Response.Redirect("ShouCang.aspx");
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int pageNumber = Int32.Parse(DropDownList1.SelectedItem.Text);
        int howManyProducts = 0;
        GetShouCang(Session["Customer"].ToString(), pageNumber, out howManyProducts);
    }
}

⌨️ 快捷键说明

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