📄 bookdetail.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>
/// BookDetail
/// </summary>
public partial class BookDetail : System.Web.UI.Page
{
protected void Page_Load(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);
//Create corresponding inquiries bibliographic information sql statement
string mysql="select * from book,bookprice where book.bid=bookprice.ppid and book.bid=@bid";
//create SqlCommand
SqlCommand cm=new SqlCommand (mysql,cn);
//Set up parameters and add value
cm.Parameters .Add ("@BID", SqlDbType.Int );
cm.Parameters ["@BID"].Value =Request.QueryString [0];
//open the connection
cn.Open ();
// run ExecuteReader
SqlDataReader dr=cm.ExecuteReader ();
if (dr.Read())//Data is read out, that is matching users
{
//for Label binding
lbl_bid.Text =dr["bid"].ToString ();
tbx_bname.Text =dr["bname"].ToString ();
tbx_bisbn.Text =dr["bisbn"].ToString ();
tbx_bauthor.Text =dr["bauthor"].ToString ();
tbx_bpress.Text =dr["bpress"].ToString ();
tbx_pprice.Text =dr["pprice"].ToString ();
tbx_pdiscount.Text =dr["pdiscount"].ToString ();
if(dr["bgroup"].ToString ()=="0") tbx_bgroup.Text ="Other";
if(dr["bgroup"].ToString ()=="1") tbx_bgroup.Text ="Computer";
if(dr["bgroup"].ToString ()=="2") tbx_bgroup.Text ="General Science";
tbx_bdescribe.Text =dr["bdescribe"].ToString ();
double pdiscount=Convert.ToInt32 (dr["pdiscount"].ToString ());
double pprice=Convert.ToDouble (dr["pprice"].ToString ());
tbx_nowprice.Text =Convert.ToString (pdiscount*pprice*0.1);
cn.Close ();
}
else
{
Response.Write ("This book is not exist,plz return.");
Response.End ();
}
}
#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 btn_addorder_Click(object sender, System.EventArgs e)
{
//Using a judgment statement judge whether the user has logged in, If you did not sign Session[ "UID" ].ToString () would be abnormal operation
try//see if aliggal user
{ Session["UID"].ToString ();
//from Web.configread the connection
string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
//string strconn= ConfigurationSettings.AppSettings["dsn"];
//connect the bms database
SqlConnection cn= new SqlConnection (strconn);
cn.Open ();
//create cm,for order table data opration
SqlCommand cm=new SqlCommand ("orderadd",cn);
//Installed memory type
cm.CommandType =CommandType.StoredProcedure ;
//Add parameters
cm.Parameters .Add ("@OBID",SqlDbType.Int );
cm.Parameters .Add ("@OUID",SqlDbType.VarChar );
cm.Parameters .Add ("@OQuantity",SqlDbType.Int );
cm.Parameters .Add ("@ODate",SqlDbType.DateTime );
//Parameter values for pay
string obidvalue=lbl_bid.Text .ToString ();
cm.Parameters ["@OBID"].Value =Convert.ToInt16 (obidvalue);
cm.Parameters ["@OUID"].Value =Session["UID"];
string oquantityvalue=ddl_oquantity.SelectedItem .Value .ToString ();
cm.Parameters ["@OQuantity"].Value =Convert.ToInt16 (oquantityvalue);
cm.Parameters ["@ODate"].Value =System.DateTime .Now;
cm.ExecuteNonQuery ();
cn.Close ();
Response.Redirect ("orderstate.aspx");
}
//if not sing in
catch
{ lbl_message.Text ="you have not sing in ,plz return and sing in to use this opration";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -