📄 viewbookcomment.aspx.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.Data.SqlClient;
using BookShop;
public partial class DesktopModules_Book_ViewBookComment : System.Web.UI.Page
{
protected int nBookID = -1;
protected string sName;
protected string sAuthor;
protected string sPublish;
protected string sPublishDate;
protected string sPrice;
protected string sISBN;
protected string sAttribute1;
protected string sAttribute2;
protected string sAttribute3;
protected string sAttribute4;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["BookID"] != null)
{
nBookID = Int32.Parse(Request.Params["BookID"].ToString());
}
if (!Page.IsPostBack)
{
if (nBookID > -1)
{
BindBookData(nBookID);
BindBookCommentData(nBookID);
}
}
}
private void BindBookData(int nBookID)
{
Book book = new Book();
SqlDataReader recb = book.GetSingleBook(nBookID);
if (recb.Read())
{
sName = recb["Name"].ToString();
sAuthor = recb["Author"].ToString();
sPublish = recb["Publish"].ToString();
sPublishDate = recb["PublishDate"].ToString();
sPrice = recb["Price"].ToString();
sISBN = recb["ISBN"].ToString();
sAttribute1 = recb["Attribute1"].ToString();
sAttribute2 = recb["Attribute2"].ToString();
sAttribute3 = recb["Attribute3"].ToString();
sAttribute4 = recb["Attribute4"].ToString();
BookPicture.ImageUrl = "../.." + recb["Url"].ToString();
}
recb.Close();
}
private void BindBookCommentData(int nBookID)
{
Comment comment = new Comment();
SqlDataReader recc = comment.GetCommentByBook(nBookID);
CommentList.DataSource = recc;
CommentList.DataBind();
recc.Close();
}
protected void SureBtn_Click(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
Response.Write("<script>window.alert('你还没有登录,现在不能对书籍评论!')</script>");
return;
}
Comment comment = new Comment();
try
{
///添加书籍的评论信息
comment.AddComment(Title.Text, Comment.Text, nBookID,Int32.Parse(Session["UserID"].ToString()));
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET2System.OPERATIONADDSUCCESSMESSAGE + "')</script>");
}
catch (Exception ex)
{
///显示添加操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ ASPNET2System.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n", " "));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -