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

📄 updatebook.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 UpdateBook : System.Web.UI.Page
{
	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["BookID"] != null)
		{
			nBookID = Int32.Parse(Request.Params["BookID"].ToString());
		}
		if (!Page.IsPostBack)
		{
			if (nBookID > -1)
			{
				///显示被修改书籍的数据
				BindBookData(nBookID);
			}
		}

		///设置更新按钮的可用性
		UpdateBtn.Enabled = (nBookID <= -1) ? false : true;
	}

	private void BindBookData(int nBookID)
	{
		///从数据库获取数据
		BookM book = new BookM();
		Book recb = book.GetSingleBook(nBookID);
		
		///显示数据
		if (recb!=null)
		{
			Name.Text = recb.Name;
			Desn.Text = recb.Desn;
			Author.Text = recb.Author;
			Publish.Text = recb.Publish;
			PublishDate.Text = recb.PublishDate.ToString();
			Foreword.Text = recb.Foreword;
			List.Text = recb.List;
			OutLine.Text = recb.OutLine;
			BuyInDate.Text = recb.BuyInDate.ToString();
			Price.Text = recb.Price.ToString();
			TotalNum.Text = recb.TotalNum.ToString();
			StoreNum.Text = recb.StoreNum.ToString();
			SellOrder.Text = recb.SellOrder.ToString();
			Attribute1.Text = recb.Attribute1;
            Attribute2.Text = recb.Attribute2;
            Attribute3.Text = recb.Attribute3;
            Attribute4.Text = recb.Attribute4;
            Attribute5.Text = recb.Attribute5;
			Remark.Text = recb.Remark;
		}
	}

	protected void UpdateBtn_Click(object sender,EventArgs e)
	{
		///如果页面输入内容合法
		if (Page.IsValid == true)
		{
			///定义类
			BookM book = new BookM();

			try
			{
				///修改书籍信息
				book.UpdateBook(nBookID,Name.Text.Trim(),Desn.Text.Trim(),
					Author.Text.Trim(),Publish.Text.Trim(),DateTime.Parse(PublishDate.Text.Trim()),
					ISBN.Text.Trim(),Foreword.Text.Trim(),List.Text.Trim(),
					OutLine.Text.Trim(),DateTime.Parse(BuyInDate.Text.Trim()),
					Decimal.Parse(Price.Text.Trim()),
					Int32.Parse(TotalNum.Text.Trim()),Attribute1.Text,
					Attribute2.Text,Attribute3.Text,Attribute4.Text,Attribute5.Text,
					Remark.Text);

				///显示操作结果信息
				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"," "));
			}
		}
	}

	protected void ReturnBtn_Click(object sender,EventArgs e)
	{
		///返回管理页面
		Response.Redirect("~/DesktopModules/Book/MainManage.aspx?CategoryID="
			+ nCategoryID.ToString());
	}
}

⌨️ 快捷键说明

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