⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 borrowinfo.aspx.cs

📁 图书管理的相关流程,借书还书流程,比较详细
💻 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 BorrowInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //读取信息
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        int UserID = Int32.Parse(Session["uid"].ToString());
        string strSql = "SELECT [borrowID],[bookName],[bookWriter],[bookFrom],[borrowDate] FROM [bookInfo],[borrowInfo] Where [bookInfo].[bookID]=[borrowInfo].[bookID] AND [borrowInfo].[borrowStatus]=0 AND [borrowInfo].[userID]='" + UserID + "'";
        if (DBhelper.sqlinit(strSql) == 0)
        {
            txtUser.Text = "你当前没有借书!";
        }
        else
        {
            txtUser.Text = "以下是您尚未归还的书籍!";
            BorrowGV.DataSource = DBhelper.sqlLoad(strSql);
            BorrowGV.DataBind();
        }
    }

    protected void BorrowGV_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "backBtn")
        {
            int index = int.Parse(e.CommandArgument.ToString());
            int borrowID = Int32.Parse(BorrowGV.Rows[index].Cells[0].Text);
            string bookName = BorrowGV.Rows[index].Cells[1].Text;
            string strSql = "UPDATE [bookInfo] SET [bookNum]=[bookNum]+1 WHERE [bookName]='" + bookName + "'";
            int i = DBhelper.sqlinit(strSql);
            string backDate = DateTime.Now.ToString("yyyy-MM-dd");
            strSql = "UPDATE [borrowInfo] SET [backDate]='" + backDate + "',[borrowStatus]=1 WHERE [borrowID]='" + borrowID + "'";
            i = DBhelper.sqlinit(strSql);
            if (i > 0)
            {
                txtMsg.Text = "[" + bookName + "]已归还!";
            }
            BindData();
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("BorrowManager.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -