📄 usermanager.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 UserManager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
string strSql = "SELECT [userID],[userLoginID],[userPwd],[userName] FROM [userInfo]WHERE [userStatus]!=0";
userGV.DataSource = DBhelper.sqlLoad(strSql);
userGV.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["userID"] = null;
Response.Redirect("UserInfos.aspx");
}
protected void userGV_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "edit")
{
//将所选取的行号实体化
int index = int.Parse(e.CommandArgument.ToString());
//利用Session传递用户编号至编辑页
Session["userID"] = userGV.Rows[index].Cells[0].Text;
Response.Redirect("UserInfos.aspx");
}
}
protected void userGV_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string userID = userGV.Rows[e.RowIndex].Cells[0].Text;
string strSql = "SELECT [borrowID] FROM [borrowInfo] WHERE [borrowStatus]=0 AND [userID]='" + userID + "'";
if (DBhelper.sqlLoad(strSql).Rows.Count == 0)
{
strSql = "DELETE FROM [userInfo] WHERE [userID]='" + userID + "'";
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 + -