returnbook.aspx.cs

来自「网上那个书店开发系统论文,需要的朋友可以下载参考哦」· CS 代码 · 共 108 行

CS
108
字号
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;
using BookManage.BLL;
using BookManage.Model;

public partial class Admin_BookBusiness : System.Web.UI.Page
{

    protected void lentList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
       BookBusiness business = new BookBusiness();
       int bookReturn= business.ReturnBook(Convert.ToInt32(lentList.DataKeys[e.RowIndex].Value));
       if (bookReturn > 0)
           Message.Alert("成功!",this.Page);
       else
           Message.Alert("出现错误!",true);

       lentList.DataSource = business.GetBookLendListByUserName(Request["txtReturn"].Trim());
       lentList.DataBind();
    }
    protected void btnReturn_ServerClick(object sender, EventArgs e)
    {
        lentList.Visible = true;
        BookBusiness business = new BookBusiness();
        string returner = Request["txtReturn"].Trim();
        lentList.DataSource = business.GetBookLendListByUserName(returner);
        lentList.DataBind();
        ViewState.Add("returner", returner);
        ViewState.Remove("bookName");
        bookList.Visible = false;
    }
    protected void bookList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            BookInfo bookInfo = (BookInfo)e.Row.DataItem;
            if (bookInfo.BookStatus == false)
            {
                e.Row.Cells[4].Text = "未借出";
            }
            else
            {
                e.Row.Cells[4].Text = "已借出";
                LinkButton btnLent = (LinkButton)e.Row.Cells[5].FindControl("btnLend");
                btnLent.Enabled = false;
            }
        }
    }
 
    protected void btnSearchBook_ServerClick(object sender, EventArgs e)
    {
        bookList.Visible = true;
        lentList.Visible = false;
        bookList.DataSource = Book.GetBookListByName(Request["txtBookName"].Trim());
        bookList.DataBind();
        ViewState.Add("bookName", Request["txtBookName"].Trim());
    }

    protected void bookList_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        int bookId = (int)bookList.DataKeys[e.NewSelectedIndex].Value;
         int result= BookBusiness.LendBook(bookId, Request["lendUser"].Trim());
           if (result ==(int)BookLentInfo.BookLendResult.HasExpiredBook)
           {
               lblMsg.Text = "该用户有超期书籍,禁止借书";bookList.Visible = false;
           }
           else if (result == (int)BookLentInfo.BookLendResult.FullBorrow)
           {
               lblMsg.Text = "该用户的借书数量已满,禁止借书";
           }
           else if (result == (int)BookLentInfo.BookLendResult.WrongUserName)
           {
               lblMsg.Text = "不存在该用户!";
           }
           else
           {
               lblMsg.Text = "借书成功";
               bookList.DataSource = Book.GetBookListByName(ViewState["bookName"].ToString());
               bookList.DataBind();
           }

    }




    protected void lentList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            BookLentInfo lentInfo = (BookLentInfo)e.Row.DataItem;
            if (lentInfo.EndTime <= DateTime.Today)
            {
                e.Row.Cells[4].Text = "<span class=\"red\">" + lentInfo.EndTime.ToString("yyyy-M-dd HH:mm:ss") + "</span>";
            }

        }
    }
}

⌨️ 快捷键说明

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