📄 booklistsortbyc0.aspx.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.Configuration ;
using System.Data .SqlClient ;
namespace BMS
{
/// <summary>
/// BookListSortByC0
/// </summary>
public partial class BookListSortByC0 : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
BindList();
}
public void BindList()
{ //afrom Web.configread the connection
string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
//connect the bms database
SqlConnection cn= new SqlConnection (strconn);
//Create a query -- by the other classifications, according to BID, in descending demonstrate that the new book
string sqlSortByC0="select * from book,bookprice where book.bid=bookprice.ppid and book.bgroup=0 order by bid desc";
//SqlDataAdapter object creation, called View
SqlDataAdapter da1=new SqlDataAdapter (sqlSortByC0,cn);
//Create and fill DataSet
DataSet ds1=new DataSet ();
da1.Fill (ds1);
dlt_class1.DataSource =ds1;
dlt_class1.DataBind ();
cn.Close ();
}
protected void btn_submit_Click(object sender, System.EventArgs e)
{ //from Web.configread the connection
string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
//connect the computer with bms database
SqlConnection cn= new SqlConnection (strconn);
cn.Open ();
//Construction SQL statements, the statements in the Users table check user name and password is correct
string mysql= "select * from Users where Uid='"+tbx_uid.Text +"'and UPassword='"+tbx_upassword.Text +"'";
//create Command object
SqlCommand cm=new SqlCommand (mysql,cn);
//Executive ExecuteReader () method
SqlDataReader dr=cm.ExecuteReader ();
if(dr.Read ())
{
lbl_message.Text= "";
//Preservation of the current user name and user rights
Session["uid"]=dr["uid"];
Session["upower"]=dr["upower"];
lbl_message.Text="WELCOME!"+Session["uid"];
if(Session["upower"].ToString ()=="1")
{ //Access management interface
Response.Redirect ("bookmanage.aspx");
}
else
{ //Ordinary users, the interface remains unchanged
}
}
else
{
lbl_message.Text ="Sorry,incorrect user name and password,plz re enter";
}
//Close Link
cn.Close();
}
protected void btn_search_Click(object sender, System.EventArgs e)
{ //Enter detailed information page bibliography
int varbid=Convert.ToInt16 (tbx_bid.Text .ToString ());
Response.Redirect ("bookdetail.aspx?bid="+varbid);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void dlt_class1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -