📄 borrowmanager.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 BorrowManager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//读取信息
if (!IsPostBack)
{
userStatus();
BindData();
}
}
private void BindData()
{
string strSql = "SELECT [bookID],[bookName],[bookWriter],[bookFrom] FROM [bookInfo] Where [bookNum]!=0";
BookGV.DataSource = DBhelper.sqlLoad(strSql);
BookGV.DataBind();
}
private void userStatus()
{
txtTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
if (Session["uid"] == null)
{
txtLogin.Text = "您尚未登录!请先登录本系统!";
borrowLB.Visible = false;
historyLB.Visible = false;
BookLB.Visible = false;
userLB.Visible = false;
passwordLB.Visible = false;
exitLB.Visible = false;
}
else
{
int UserID = Int32.Parse(Session["uid"].ToString());
string strSql = "SELECT [userID],[userLoginID],[userPwd],[userName],[userStatus] FROM [userInfo] WHERE [userID] ='" + UserID + "'";
UserInfo userinfo = new UserInfo();
userinfo = DBhelper.sqlUserInfo(strSql);
txtLogin.Text = "欢迎你使用本系统!" + userinfo.UserName;
if (userinfo.UserStatus == 0)
{
LoginLB.Visible = false;
borrowLB.Visible = false;
historyLB.Visible = false;
}
else
{
LoginLB.Visible = false;
BookLB.Visible = false;
userLB.Visible = false;
}
}
}
protected void LoginLB_Click(object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}
protected void borrowLB_Click(object sender, EventArgs e)
{
Response.Redirect("BorrowInfo.aspx");
}
protected void historyLB_Click(object sender, EventArgs e)
{
Response.Redirect("historyInfo.aspx");
}
protected void BookLB_Click(object sender, EventArgs e)
{
Response.Redirect("BookManager.aspx");
}
protected void userLB_Click(object sender, EventArgs e)
{
Response.Redirect("UserManager.aspx");
}
protected void passwordLB_Click(object sender, EventArgs e)
{
Response.Redirect("PwdManager.aspx");
}
protected void exitLB_Click(object sender, EventArgs e)
{
//清除Session储存内容
Session.Clear();
Response.Redirect("BorrowManager.aspx");
}
protected void searchBtn_Click(object sender, EventArgs e)
{
string strSql = "SELECT [bookID],[bookName],[bookWriter],[bookFrom] FROM [bookInfo] Where [bookNum]!=0 AND [bookName] Like '%" + textSearch.Text + "%'";
BookGV.DataSource = DBhelper.sqlLoad(strSql);
BookGV.DataBind();
}
protected void BookGV_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "seeBook")
{
if (Session["uid"] != null)
{
//将所选取的行号实体化
int index = int.Parse(e.CommandArgument.ToString());
//利用Session传递用户编号至编辑页
Session["BookID"] = BookGV.Rows[index].Cells[0].Text;
Response.Redirect("BookInfo.aspx");
}
else
{
txtMsg.Text = "您尚未登录!请登陆后再操作!";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -