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

📄 readerinfo.aspx.cs

📁 代码为图书馆管理系统软件
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using DBase;

namespace Library
{
	/// <summary>
	/// ReaderInfo 的摘要说明。
	/// </summary>
	public class ReaderInfo : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Panel Panel2;
		protected System.Web.UI.WebControls.LinkButton LinkBookBorrow;
		protected System.Web.UI.WebControls.LinkButton LinkBorrowHistory;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.HyperLink HyperLink1;
		protected System.Web.UI.WebControls.LinkButton LinkReaderInfo;
		protected System.Web.UI.WebControls.Label lblMessage;
		protected System.Web.UI.WebControls.Label lblTel;
		protected System.Web.UI.WebControls.Label Label21;
		protected System.Web.UI.WebControls.Label Label20;
		protected System.Web.UI.WebControls.Label lblReaderScale;
		protected System.Web.UI.WebControls.Label lblEmail;
		protected System.Web.UI.WebControls.Label Label16;
		protected System.Web.UI.WebControls.Label Label15;
		protected System.Web.UI.WebControls.Label lblArrearage;
		protected System.Web.UI.WebControls.Label Label13;
		protected System.Web.UI.WebControls.Label Label12;
		protected System.Web.UI.WebControls.Label lblSex;
		protected System.Web.UI.WebControls.Label lblDepartment;
		protected System.Web.UI.WebControls.Label lblOpenDate;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.Label lblReaderID;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label lblValidDate;
		protected System.Web.UI.WebControls.Label lblReaderName;
		protected System.Web.UI.WebControls.Label Label18;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Button btnPwdMod;
		protected System.Web.UI.WebControls.Button btnInfoMod;
		protected System.Web.UI.WebControls.Label lblReader;
		protected System.Web.UI.WebControls.LinkButton LinkSignOut;

		//显示用户是否有图书到期或将要到期以及用户的欠款情况
		void firstTip()
		{
//			string constr = System.Configuration.ConfigurationSettings.AppSettings["constr"];
//			SqlConnection cn = new SqlConnection(constr);

			int nWill=0,nAlready=0,nMoney=0;

			string strNumWill = "select count(*) from Borrow where ReaderID='" + Session["ReaderID"].ToString() + "' and DateDiff(day,getdate(),PromiseReturnDate)<=5 and DateDiff(day,getdate(),PromiseReturnDate) >= 0";
			string strNumAlready = "select count(*) from Borrow where ReaderID='" + Session["ReaderID"].ToString() + "' DateDiff(day,getdate(),PromiseReturnDate) < 0";
			string strMoney = "select Arrearage from Reader where ReaderID='" + Session["ReaderID"].ToString() +" '";

			SqlCommand comWill = new SqlCommand(strNumWill,DB.cn);
			SqlCommand comAlready = new SqlCommand(strNumWill,DB.cn); 
			SqlCommand comMoney = new SqlCommand(strNumWill,DB.cn);

			if(DB.cn.State == ConnectionState.Closed)
				DB.cn.Open();

			nWill = (int)comWill.ExecuteScalar();
			nAlready = (int)comAlready.ExecuteScalar();
			nMoney = (int)comMoney.ExecuteScalar();
            
			DB.cn.Close();

			lblMessage.Text = nAlready>0?"你有"+ nAlready +"本书已经超期,":"";
			lblMessage.Text += nWill>0?"你有"+ nWill +"本书将要到期,":"";
			lblMessage.Text += nMoney>0?"你目前欠款"+ nMoney +"元,":"";
			lblMessage.Text += "谢谢你对本馆的关注!";

		}

		void loadData()
		{
			if(DB.cn.State == ConnectionState.Closed)
				DB.cn.Open();

			string str = "select ReaderID,ReaderName,SexName,Department,ScaleName,OpenDate,"
				     + "ValidDate,Arrearage,Telephone,Email from Reader,ReaderScale,SexName "
				            + "where Reader.Scale=ReaderScale.Scale and Reader.Sex=SexName.SexID and "
				                   + "ReaderID ="+Session["ReaderID"].ToString();
			SqlCommand com= new SqlCommand(str,DB.cn);
			SqlDataReader myr = com.ExecuteReader();
			if(myr.Read())
			{
				lblReaderID.Text = myr.GetValue(0).ToString();
				lblReaderName.Text = myr.GetValue(1).ToString();
				lblSex.Text = myr.GetValue(2).ToString();
				lblDepartment.Text = myr.GetValue(3).ToString();
				lblReaderScale.Text = myr.GetValue(4).ToString();
				lblOpenDate.Text = myr.GetValue(5).ToString();
				lblValidDate.Text = myr.GetValue(6).ToString();
				lblArrearage.Text = myr.GetValue(7).ToString() + "元";
				lblEmail.Text = myr.GetValue(8).ToString();
				lblTel.Text = myr.GetValue(9).ToString();
			}
			myr.Close();
			DB.cn.Close();
		}

		private void Page_Load(object sender, System.EventArgs e)
		{
			lblReader.Text = "欢迎你!" + Session["ReaderName"].ToString();
			firstTip();
			loadData();
			Response.Buffer=true;
			Response.ExpiresAbsolute=DateTime.Now.AddSeconds(-1);
			Response.Expires=0;
			Response.CacheControl="no-cache";
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.LinkReaderInfo.Click += new System.EventHandler(this.LinkReaderInfo_Click);
			this.LinkBookBorrow.Click += new System.EventHandler(this.LinkBookBorrow_Click);
			this.LinkBorrowHistory.Click += new System.EventHandler(this.LinkBorrowHistory_Click);
			this.LinkSignOut.Click += new System.EventHandler(this.LinkSignOut_Click);
			this.btnPwdMod.Click += new System.EventHandler(this.btnPwdMod_Click);
			this.btnInfoMod.Click += new System.EventHandler(this.btnInfoMod_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void LinkReaderInfo_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("ReaderInfo.aspx");
		}

		private void LinkBookBorrow_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("BookBorrow.aspx?id=" + this.lblReaderID.Text.Trim());
		}

		private void LinkBorrowHistory_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("BorrowHistory.aspx?id=" + this.lblReaderID.Text.Trim());
		}

		private void btnPwdMod_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("PswMod.aspx?id="+ this.lblReaderID.Text.Trim());
		}

		private void btnInfoMod_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("InfoMod.aspx?id="+ this.lblReaderID.Text.Trim() + "&email=" + this.lblEmail.Text.Trim()+ "&tel=" + this.lblTel.Text.Trim());
		}

		private void LinkSignOut_Click(object sender, System.EventArgs e)
		{
			FormsAuthentication.SignOut();
			Response.Redirect("../Logout.aspx");
		}
	}
}

⌨️ 快捷键说明

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