📄 default.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>
/// _Default
/// </summary>
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
BindList();
}
#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
public void BindList()
{ //from the file Web.config Read connecting string
string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
//connect the local computer's MMS database
SqlConnection cn= new SqlConnection (strconn);
//create the inquiry using the computer's type to get the last three books
string sqlSortByC1="select top 3 * from book,bookprice where book.bid=bookprice.ppid and book.bgroup=1 order by bid desc";
//create SqlDataAdapter,by calling the view
SqlDataAdapter da1=new SqlDataAdapter (sqlSortByC1,cn);
//create and fill the DataSet
DataSet ds1=new DataSet ();
da1.Fill (ds1);
dlt_class1.DataSource =ds1;
dlt_class1.DataBind ();
//create the inquiry using the scince's type to get the last three books,by using the book id
string sqlSortByC2="select top 3 * from book,bookprice where book.bid=bookprice.ppid and book.bgroup=2 order by bid desc";
//create SqlDataAdapter,by calling the view
SqlDataAdapter da2=new SqlDataAdapter (sqlSortByC2,cn);
//create and fill the DataSet
DataSet ds2=new DataSet ();
da2.Fill (ds2);
dlt_class2.DataSource =ds2;
dlt_class2.DataBind ();
//create the inquiry using the scince's type to get the last three books,by using the book id
string sqlSortByC0="select top 3 * from book,bookprice where book.bid=bookprice.ppid and book.bgroup=0 order by bid desc";
//create SqlDataAdapter,by calling the view
SqlDataAdapter da0=new SqlDataAdapter (sqlSortByC0,cn);
//create and fill the DataSet
DataSet ds0=new DataSet ();
da0.Fill (ds0);
dlt_class0.DataSource =ds0;
dlt_class0.DataBind ();
cn.Close ();
}
protected void btn_submit_Click(object sender, System.EventArgs e)
{ //from the file Web.config Read connecting string
string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
//connect the local computer's MMS database
SqlConnection cn= new SqlConnection (strconn);
cn.Open ();
//Construction SQL statements, the statements in the Users table check user name and password is correct or no
string mysql= "select * from Users where Uid='"+tbx_uid.Text +"'and UPassword='"+tbx_upassword.Text +"'";
//creat Command
SqlCommand cm=new SqlCommand (mysql,cn);
//execution ExecuteReader ()
SqlDataReader dr=cm.ExecuteReader ();
if(dr.Read ())
{
lbl_message.Text= "";
//save last user
Session["uid"]=dr["uid"];
Session["upower"]=dr["upower"];
lbl_message.Text="Welcome: "+Session["uid"];
if(Session["upower"].ToString ()=="1")
{ //administrator
Response.Redirect ("bookmanage.aspx");
}
else
{ //users
}
}
else
{
lbl_message.Text ="Sorry,incorrect user name and password,plz re enter";
}
//close the connection
cn.Close();
}
protected void btn_search_Click(object sender, System.EventArgs e)
{ //inter book information
int varbid=Convert.ToInt16 (tbx_bid.Text .ToString ());
Response.Redirect ("bookdetail.aspx?bid="+varbid);
}
protected void dlt_class1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -