QueryBorrowInfo.aspx.cs
上传用户:gooyliu
上传日期:2018-09-29
资源大小:5816k
文件大小:3k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Xml.Linq;
  13. using System.Data.SqlClient;
  14. using BusinessLogicLayer;
  15. namespace Web.SysOperator
  16. {
  17.     public partial class BorrowInfo : System.Web.UI.Page
  18.     {
  19.         protected void Page_Load(object sender, EventArgs e)
  20.         {
  21.         }
  22.         protected void btnQuery_Click(object sender, EventArgs e)
  23.         {
  24.             BindData();
  25.             borrowInfoTable.Visible =true;
  26.         }
  27.         void BindData()
  28.         {
  29.             string userID =txtReaderID.Text.Trim().ToString();
  30.             DataSet dsBorrowBook = new DataSet();
  31.             Users user = new Users();
  32.             dsBorrowBook = user.GetBorrowBook(userID);
  33.             if (dsBorrowBook.Tables[0].Rows.Count > 0)
  34.             {
  35.                 gvBorrowBookList.DataSource = dsBorrowBook;
  36.                 gvBorrowBookList.DataBind();
  37.                 this.TrMsg.Visible = false;       //有借阅记录则显示列表,并不显示提示
  38.             }
  39.             else                                  //没有借阅记录则不显示gridview,并给出提示信息
  40.             {
  41.                 this.TrGrid.Visible = false;
  42.                 lblMsgNoBorrow.Text = "该用户还没有借阅记录";
  43.             }
  44.         }
  45.         protected void gvBorrowBookList_RowDataBound(object sender, GridViewRowEventArgs e)
  46.         {
  47.             if (e.Row.RowType == DataControlRowType.DataRow)
  48.             {
  49.                 DateTime shouldEndDate = Convert.ToDateTime(e.Row.Cells[1].Text).AddDays(30);
  50.                 DateTime today = DateTime.Today;
  51.                 if (today.CompareTo(shouldEndDate) > 0)           //今天比应归还日期晚
  52.                 {
  53.                     e.Row.BackColor = System.Drawing.Color.Yellow;
  54.                     ClientScriptManager CSM = Page.ClientScript;  //加载页面时给出图书过期提示框
  55.                     string ScriptName = "showMsg";
  56.                     if (!CSM.IsClientScriptBlockRegistered(ScriptName))
  57.                     {
  58.                         string StrScript = "<script>";
  59.                         StrScript += "alert('该读者有过期的图书,请催还');";
  60.                         StrScript += "</script>";
  61.                         CSM.RegisterStartupScript(this.GetType(), ScriptName, StrScript);
  62.                     }
  63.                     //Page.RegisterStartupScript("", "<script>alert('您有过期的图书,请尽快归还');</script>");
  64.                 }
  65.                 else
  66.                 { }
  67.                 ((Label)e.Row.Cells[2].FindControl("lblEndDate")).Text = (Convert.ToDateTime(e.Row.Cells[1].Text).AddDays(30)).ToString();
  68.             }
  69.         }
  70.         protected void btnReset_Click(object sender, EventArgs e)
  71.         {
  72.             this.btnReset.Text = string.Empty;
  73.         }
  74.     }
  75. }