viewbookattribute.aspx.cs

来自「《精通ASP.NET2.0网络应用系统开发》书中的源码」· CS 代码 · 共 82 行

CS
82
字号
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 BookShop;
using System.Data.SqlClient;

public partial class DesktopModules_Book_ViewBookAttribute : System.Web.UI.Page
{
    private int nAttributeFlag = -1;
    private int nBookID = -1;
    private int nCategoryID = -1;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["CategoryID"] != null)
        {
            nCategoryID = Int32.Parse(Request.Params["CategoryID"].ToString());
        }
        if (Request.Params["AttributeFlag"] != null)
        {
            nAttributeFlag = Int32.Parse(Request.Params["AttributeFlag"].ToString());
        }
        if (Request.Params["BookID"] != null)
        {
            nBookID = Int32.Parse(Request.Params["BookID"].ToString());
        }
        if (!Page.IsPostBack)
        {
            if (nAttributeFlag > -1 && nBookID > -1)
            {
                BindBookAttributeData(nBookID, nAttributeFlag);
            }
        }
    }

    private void BindBookAttributeData(int nBookID, int nAttributeFlag)
    {
        Book book = new Book();
        SqlDataReader recb = book.GetSingleBook(nBookID);
        if (recb.Read())
        {
            switch (nAttributeFlag)
            {
                case 0:   ///前言
                    {
                        AttributeName.Text = "书籍的前言信息:";
                        AttributeValue.Text = recb["Foreword"].ToString();
                        break;
                    }
                case 1:   ///目录
                    {
                        AttributeName.Text = "书籍的目录信息:";
                        AttributeValue.Text = recb["List"].ToString();
                        break;
                    }
                case 2:  ///内容提要
                    {
                        AttributeName.Text = "书籍的内容提要信息:";
                        AttributeValue.Text = recb["OutLine"].ToString();
                        break;
                    }               
                default: break;
            }

        }
        recb.Close();
    }

    protected void ReturnBtn_Click(object sender, EventArgs e)
    {
        ///关闭窗口
        Response.Write("<script>window.close();</script>");    
    }
}

⌨️ 快捷键说明

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