温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:个人图书管理系统源码
当前文件路径:MyLibary/BookManage/BookAdd.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using MyLibrary.BusinessLogicLayer; 12
13
public partial class BookManage_BookAdd : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
if (!this.IsPostBack) 18
{ 19
for (int i = 2000; i < 2050; i++) 20
{ 21
ddlYear.Items.Add(i.ToString()); 22
} 23
for (int i = 1; i < 13; i++) 24
{ 25
ddlMonth.Items.Add(i.ToString()); 26
} 27
for (int i = 1; i < 32; i++) 28
{ 29
ddlDay.Items.Add(i.ToString()); 30
} 31
} 32
else 33
{ } 34
} 35
//添加按钮单击事件 36
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 37
{ 38
if (Page.IsValid) 39
{ 40
Book book = new Book();//创建Book类对象book 41
book.BookName=txtName.Text.Trim();//为book对象各属性赋值 42
book.BookISBN=txtISBN.Text.Trim(); 43
book.BookAuthor=txtAuthor.Text.Trim(); 44
book.BookPublish=txtPublish.Text.Trim(); 45
book.BookPublishDate=Convert.ToDateTime(ddlYear.SelectedItem.Text+"-"+ddlMonth.SelectedItem.Text+"-"+ddlDay.SelectedItem.Text); 46
book.BookClassify=rblClassify.SelectedItem.Text; 47
book.BookSubject=txtSubject.Text; 48
book.BookIndex=txtIndex.Text; 49
book.BookPrice=Convert.ToDouble(txtPrice.Text); 50
book.BookPageNum=int.Parse(txtPageNum.Text); 51
book.BookSeries=txtSeries.Text; 52
book.BookDescription=txtDescription.Text; 53
if (book.InsertByProc())//使用InsertByProc方法向数据库添加图书信息 54
{ 55
lblMessage.Text = "成功添加书刊!"; 56
} 57
else 58
{ 59
lblMessage.Text = "添加书刊失败!"; 60
} 61
} 62
} 63
} 64





}
}