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

📄 recommandbook.ascx.cs

📁 网上书店
💻 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;

public partial class DefaultControl_AllBook : System.Web.UI.UserControl
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int howManyPage;
            GetRecommandBook(1, out howManyPage);
            Label6.Text = howManyPage.ToString();
            DropDownList1.Items.Clear();
            for (int i = 1; i <= howManyPage; i++)
            {
                DropDownList1.Items.Add(i.ToString());
            }
        }
        
    }

    protected void GetRecommandBook(int pageNumber, out int howManyPage)
    {

        DataList1.DataSource = CommonDataAccess.GetBooksRecommand(pageNumber, out howManyPage);
        DataList1.DataBind();
    }
    
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int pageNumber =Int32.Parse( DropDownList1.SelectedItem.Text);
        int howManyPage;
        GetRecommandBook(pageNumber, out howManyPage);
    }
    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 == "sc")
        {

            if (Session["Customer"] == null)
            {
                Response.Write("<script language='javascript' type='text/javascript'>alert('你还没有登陆,请先登陆');window.location.href='Default.aspx';</script>");
            }
            else
            {
                string bookID = e.CommandArgument.ToString();
                CommonDataAccess.HotClick(Int32.Parse(bookID));

                if (CommonDataAccess.AddShouCang(Session["Customer"].ToString(), Int32.Parse(bookID)))
                {
                    Message.ShowMsgBox(Page, "图书已被收藏");
                }
            }

        }

    }
}

⌨️ 快捷键说明

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