📄 bookmanager.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;
public partial class BookManager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
string strSql = "SELECT [bookID],[bookName],[bookWriter],[bookFrom] FROM [bookInfo]";
BookManageGV.DataSource = DBhelper.sqlLoad(strSql);
BookManageGV.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["bookID"] = null;
Response.Redirect("BookInfo.aspx");
}
protected void BookManageGV_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "edit")
{
//将所选取的行号实体化
int index = int.Parse(e.CommandArgument.ToString());
//利用Session传递用户编号至编辑页
Session["bookID"] = BookManageGV.Rows[index].Cells[0].Text;
Response.Redirect("BookInfo.aspx");
}
}
protected void BookManageGV_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string bookID = BookManageGV.Rows[e.RowIndex].Cells[0].Text;
string strSql = "SELECT [borrowID] FROM [borrowInfo] WHERE [borrowStatus]=0 AND [bookID]='" + bookID + "'";
if (DBhelper.sqlLoad(strSql).Rows.Count == 0)
{
strSql = "DELETE FROM [bookInfo] WHERE [bookID]='" + bookID + "'";
int i = DBhelper.sqlinit(strSql);
if (i > 0)
{
txtMsg.Text = "删除成功!";
BindData();
}
}
else
{
txtMsg.Text = "此书仍处于借出状态,无法撤柜!";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("BorrowManager.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -