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