温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:个人图书管理系统源码
当前文件路径:MyLibary/Borrow/BorrowBook.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
///Asp.net源码下载专业站 13
public partial class Borrow_BorrowBook : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
18
} 19
//借阅按钮单击事件 20
protected void imgBtnBorrow_Click(object sender, ImageClickEventArgs e) 21
{ 22
if (Page.IsValid) 23
{ 24
Borrow borrow = new Borrow();//创建Borrow类对象 25
Users user = new Users();//创建Users类对象 26
user.UserID = txtUserID.Text.Trim();//为user对象属性UserID赋值 27
int BorrowNum = 0; 28
if (user.LoadData(user.UserID))//查询用户并取出用户权限 29
{ 30
int userPower = user.UserPower; 31
if (userPower == 3)//学生 32
{ 33
BorrowNum = 10;//最大借书量10本 34
borrow.BorrowEndDate = Convert.ToDateTime(System.DateTime.Now.AddMonths(1).ToString());//借阅时间为1个月 35
} 36
else if (userPower == 4)//教师 37
{ 38
BorrowNum = 20;//最大借书量20本 39
borrow.BorrowEndDate = Convert.ToDateTime(System.DateTime.Now.AddMonths(3).ToString());//借阅时间为1个月 40
} 41
borrow.UserID = txtUserID.Text.Trim(); 42
int count = borrow.QueryCurrentBorrowCount(txtUserID.Text.Trim());//查询用户已经借阅图书量 43
if (count < BorrowNum)//如果还没有超出最大借书量,借书 44
{ 45
borrow.BookID = int.Parse(txtBookID.Text.Trim()); 46
borrow.BorrowBeginDate = Convert.ToDateTime(System.DateTime.Now.ToString()); 47
borrow.BorrowState = 0; 48
if (borrow.InsertByProc())//使用Borrow类InsertByProc方法插入一条借阅记录 49
{ 50
lblMessage.Text = "成功借阅该书!"; 51
} 52
else 53
{ 54
lblMessage.Text = "借书失败!"; 55
} 56
} 57
else//超出借书量,不能继续借书,给出提示 58
{ 59
lblMessage.Text = "该用户已借满!"; 60
} 61
} 62
else//不存在该用户提示 63
{ 64
lblMessage.Text = "不存在该用户!"; 65
} 66
} 67
} 68
} 69





}
}