AllBook.aspx.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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;
using System.Xml.Linq;

public partial class AllBook : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //判断用户单击的是哪个按钮
        if (e.CommandName == "info")
        {
            //获取用户单击按钮的行
            int index = Convert.ToInt32(e.CommandArgument);
            //把单击按钮行的图书ID传给Session["bookname"]
            Session["BookName"] = GridView1.Rows[index].Cells[1].Text.ToString();
            //跳转到BookInfo页面中
            Response.Redirect("~/BookInfo.aspx");
        }
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        //定义一个用来接收控件CheckBox事件的行对象
        GridViewRow g = (GridViewRow)(((CheckBox)sender).NamingContainer);
        //单击CheckBox按纽,选择要购买的图书
        if ((((CheckBox)(Control)sender)).Checked)
        {
            //如果图书名示显列表等于0,则用户还未购买任何图书
            if (BookName.Items.Count == 0)
            {
                //图书数量为1
                BookNum.Text = "1";
                //图书价格等于单击CheckBox行的图书价格
                BookPrice.Text = g.Cells[2].Text.Replace("¥", "");
                //图书名显示列表添加刚才选择的图书名
                BookName.Items.Add(g.Cells[0].Text);
                //图书ID显示列表添加刚才选择的图书ID
                BookID.Items.Add(g.Cells[1].Text);
            }
            //如果用户已经购买图书
            else if (BookName.Items[0].Text.IndexOf(g.Cells[0].Text) == -1)
            {
                //图书总价格加上刚选择图书的价格
                //BookPrice.Text = Convert.ToString(Convert.ToDouble(BookPrice.Text) + Convert.ToDouble(g.Cells[2].Text.Replace("¥", "")));
                BookPrice.Text = Convert.ToString(Convert.ToDouble(BookPrice.Text) + Convert.ToDouble(g.Cells[2].Text));
                //图书数目加1
                BookNum.Text = Convert.ToString(Convert.ToInt32(BookNum.Text) + 1);
                //图书名显示列表添加刚才选择的图书名
后面还有 56 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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