📄 welcome.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace e_librarys
{
/// <summary>
/// Welcome 的摘要说明。
/// </summary>
public partial class Welcome : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label_Placement;
protected System.Web.UI.WebControls.Label Label1;
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//用户租赁信息显示
SqlConnection Conn = new SqlConnection("server=(local);database=e_library;uid=sa;pwd=");
Conn.Open();
string StrSql="select * from User_Info ,Tenancy,Book_Info where U_Name='"+Session["U_Name"]+"' and U_ID=T_U_ID and (T_Status=1 or T_Status=2) and T_Return=0 and B_ID=T_B_ID";
SqlCommand Comm = new SqlCommand(StrSql,Conn);
SqlDataReader Dr=Comm.ExecuteReader();
if(Dr.Read())
{
Session["B_ID"]=Dr["B_ID"];
Session["T_Status"]=Dr["T_Status"];
Label3.Text=Session["U_Name"].ToString();
if(Dr["T_Status"].ToString()=="2")
{
LinkButton1.Text=Dr["B_Name"].ToString();
LinkButton2.Text=Dr["B_Name"].ToString();
if(Dr["T_MsgUser"].ToString()=="1")
LinkButton3.Text=Dr["B_Name"].ToString();
else
LinkButton3.Text="没有要到期图书";
if(Dr["T_TimeOut"].ToString()=="1")
LinkButton4.Text=Dr["B_Name"].ToString();
else
LinkButton4.Text="没有要超期图书";
}
else
{
LinkButton1.Text=Dr["B_Name"].ToString();
LinkButton2.Text="您还没租赁图书";
LinkButton3.Text="您还没租赁图书";
LinkButton4.Text="您还没租赁图书";
}
}
else
{
Session["T_Status"]=0;
LinkButton1.Text="您还没预定图书";
LinkButton2.Text="您还没预定图书";
LinkButton3.Text="您还没预定图书";
LinkButton4.Text="您还没预定图书";
}
Conn.Close();
//绑定推荐版
Conn.Open();
StrSql = "select top 10 * from Book_Info order by B_RentCount desc";
SqlDataAdapter Da = new SqlDataAdapter(StrSql, Conn);
DataSet Ds = new DataSet();
Da.Fill(Ds);
DataList_Detail0.DataSource = Ds.Tables[0];
DataList_Detail0.DataBind();
Conn.Close();
//绑定排行版
Conn.Open();
StrSql = "select top 10 * from Book_Info order by B_Count desc";
Da = new SqlDataAdapter(StrSql, Conn);
Ds = new DataSet();
Da.Fill(Ds);
DataList_Detail.DataSource = Ds.Tables[0];
DataList_Detail.DataBind();
Conn.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void Button_All_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_HomePage_Click(object sender, System.EventArgs e)
{
Response.Redirect("Welcome.aspx");
}
protected void Button_ComputerBooks_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='电脑书籍' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_EnglishReading_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='英语读物' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_PoliticsEconomics_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='政治经济' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_PhilosophyReligion_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='哲学宗教' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_ForiegnLiterature_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='外国文学' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_Poetry_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='诗歌' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_Novel_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='小说' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void Button_MathPhysicsChemistry_Click(object sender, System.EventArgs e)
{
string StrSql="select * from Book_Info a,Book_Style b,Book_DetailStyle c where B_S_Name='数理化' and b.B_S_ID=c.B_S_ID and a.B_BDS_ID=c.B_DS_ID";
Session["StrSql"]=StrSql;
Response.Redirect("Massage.aspx");
}
protected void LinkButton1_Click(object sender, System.EventArgs e)
{
if (Session["T_Status"].ToString() == "1" || Session["T_Status"].ToString() == "2")
Response.Redirect("TanancyMassage.aspx");
else
Response.Write("<Script Language='JavaScript'>alert('你还没有预定图书')</Script>");
}
protected void LinkButton2_Click(object sender, System.EventArgs e)
{
if(Session["T_Status"].ToString()=="2")
Response.Redirect("TanancyMassage.aspx");
else
Response.Write("<Script Language='JavaScript'>alert('你还没有租赁图书')</Script>");
}
protected void LinkButton3_Click(object sender, System.EventArgs e)
{
if(Session["T_Status"].ToString()=="2")
Response.Redirect("TanancyMassage.aspx");
else
Response.Write("<Script Language='JavaScript'>alert('你还没有租赁图书')</Script>");
}
protected void LinkButton4_Click(object sender, System.EventArgs e)
{
if(Session["T_Status"].ToString()=="2")
Response.Redirect("TanancyMassage.aspx");
else
Response.Write("<Script Language='JavaScript'>alert('你还没有租赁图书')</Script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -