📄 addbook.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 BookShop;
public partial class AddBook : System.Web.UI.Page
{
private int nCategoryID = -1;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["CategoryID"] != null)
{
nCategoryID = Int32.Parse(Request.Params["CategoryID"].ToString());
}
///设置更新按钮的可用性
AddBtn.Enabled = nCategoryID <= -1 ? false : true;
}
protected void AddBtn_Click(object sender,EventArgs e)
{
///如果页面输入内容合法
if (Page.IsValid == true)
{
///定义类
Book book = new Book();
try
{
///添加新的书籍信息
book.AddBook(Name.Text.Trim(),nCategoryID,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('" + ASPNET2System.OPERATIONADDSUCCESSMESSAGE + "')</script>");
}
catch (Exception ex)
{
///显示添加操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ ASPNET2System.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n"," "));
}
}
}
protected void ReturnBtn_Click(object sender,EventArgs e)
{
///返回管理页面
Response.Redirect("~/DesktopModules/Book/BookManage.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -