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

📄 commentmanage.aspx.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;
using System.Linq;
using System.Data.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;

public partial class CommentManage : System.Web.UI.Page
{
	int nBookID = -1;

	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);

				///显示图片列表信息
				BindCommentData(nBookID);
			}
		}

		///添加删除确认对话框
		DeleteBtn.Attributes.Add("onclick","return confirm('" + ASPNET35System.OPERATIONDELETEMESSAGE + "');");
	}

	private void BindBookData(int nBookID)
	{
		///从数据库获取数据
		BookM book = new BookM();
		Book recb = book.GetSingleBook(nBookID);

		if (recb!=null)
		{
			///显示书籍名称
			Name.Text = recb.Name;
		}
	}

	private void BindCommentData(int nBookID)
	{
		///从数据库获取图片信息
		CommentM comment = new CommentM();
		IList<Comment> recp = comment.GetCommentByBook(nBookID);

		///绑定图片列表的数据
		CommentList.DataSource = recp;
		CommentList.DataTextField = "Desn";
		CommentList.DataValueField = "CommentID";
		CommentList.DataBind();
	}

	protected void DeleteBtn_Click(object sender,EventArgs e)
	{
		if (CommentList.SelectedIndex <= -1)
		{
			///显示提示信息
			Response.Write("<script>window.alert('" + ASPNET35System.LISTBOX_NO_SELECT_ITEM + "')</script>");
			return;
		}

		try
		{
			///定义类
			CommentM comment = new CommentM();

			///删除操作
			comment.DeleteComment(Int32.Parse(CommentList.SelectedValue));

			///显示操作结果信息
			Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONDELETESUCCESSMESSAGE + "')</script>");

			///重新绑定数据
			BindCommentData(nBookID);
		}
		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 + -