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

📄 bookmodify.aspx.cs

📁 book shop system how to sell and buy online
💻 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>
	/// BookModify 
	/// </summary>
	public partial class BookModify : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{	//from Web.configread connection
				string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
				//connect the computer with 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 connection
				cn.Open ();
                //Executive 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 ();
					ddl_pdiscount.SelectedIndex =Convert.ToInt16 (dr["pdiscount"].ToString ());
					ddl_bgroup.SelectedIndex =Convert.ToInt16 (dr["bgroup"].ToString ());
					tbx_bdescribe.Text =dr["bdescribe"].ToString ();
					cn.Close ();
				}
			
				else
				{
					Response.Write ("该书目不存在,请返回");
					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_modify_Click(object sender, System.EventArgs e)
        {	//from Web.configread connection
			string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
            //connect the computer with database
			SqlConnection cn= new SqlConnection (strconn);
			cn.Open ();
			//create cm1,for book tabel data opration
			string bookmodify="UPDATE Book SET BISBN = @BISBN,BName = @BName,BAuthor = @BAuthor,BPress = @BPress,BGroup = @BGroup,BDescribe = @BDescribe WHERE  BID = @BID";
			SqlCommand cm1=new SqlCommand (bookmodify,cn);
			cm1.Parameters .Add ("@BID",SqlDbType.Int  );
			cm1.Parameters .Add ("@BISBN",SqlDbType.VarChar );
			cm1.Parameters .Add ("@BName",SqlDbType.VarChar );
			cm1.Parameters .Add ("@BAuthor",SqlDbType.VarChar );
			cm1.Parameters .Add ("@BPress",SqlDbType.VarChar );
			cm1.Parameters .Add ("@BGroup",SqlDbType.Int );
			cm1.Parameters .Add ("@BDescribe",SqlDbType.VarChar );
			//cm1.CommandType =CommandType.StoredProcedure ;
            //create cm2,for book tabel data opration
			SqlCommand cm2=new SqlCommand ("bookpricemodify",cn);
			cm2.Parameters .Add ("@PPID",SqlDbType.Int  );
			cm2.Parameters .Add ("@PPrice",SqlDbType.Money );
			cm2.Parameters .Add ("@PDiscount",SqlDbType.Float );
			cm2.CommandType =CommandType.StoredProcedure ;
            //From Label made to update the content of the book, 
			string bidvalue=lbl_bid.Text .ToString ();
			cm1.Parameters ["@BID"].Value =Convert.ToInt16 (bidvalue);
			cm2.Parameters ["@PPID"].Value =Convert.ToInt16 (bidvalue);
            //From the TextBox made to update the value 
            //Table to the book value parameter pay 
			cm1.Parameters ["@BName"].Value =tbx_bname.Text .ToString ();
			cm1.Parameters ["@BISBN"].Value =tbx_bisbn.Text .ToString ();
			cm1.Parameters ["@BAuthor"].Value =tbx_bauthor.Text .ToString ();
			cm1.Parameters ["@BPress"].Value =tbx_bpress.Text .ToString ();
			cm1.Parameters ["@BDescribe"].Value =tbx_bdescribe.Text .ToString ();
			cm1.Parameters ["@BGroup"].Value =ddl_bgroup.SelectedItem .Value.ToString () ;
            //Bookprice table to pay the value of parameters 
			cm2.Parameters ["@PPrice"].Value =Convert.ToDouble (tbx_pprice.Text .ToString ());
			cm2.Parameters ["@PDiscount"].Value =Convert.ToInt16 (ddl_pdiscount.SelectedItem .Value .ToString());
			cm1.ExecuteNonQuery ();
			cm2.ExecuteNonQuery ();
			cn.Close ();
		}

		protected void btn_delete_Click(object sender, System.EventArgs e)
		{
            //from Web.configread connection
			string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
            //connect the computer with database
			SqlConnection cn= new SqlConnection (strconn);
			cn.Open ();
            //create cm1,for book tabel data opration
			SqlCommand cm1=new SqlCommand ("bookdelete",cn);
			cm1.Parameters .Add ("@BID",SqlDbType.Int  );
			cm1.CommandType =CommandType.StoredProcedure ;
            //create cm2,for book tabel data opration
			SqlCommand cm2=new SqlCommand ("bookpricedelete",cn);
			cm2.Parameters .Add ("@PPID",SqlDbType.Int  );
			cm2.CommandType =CommandType.StoredProcedure ;
			 //From Label made to update the content of the book, 
			string bidvalue=lbl_bid.Text .ToString ();
			cm1.Parameters ["@BID"].Value =Convert.ToInt16 (bidvalue);
			cm2.Parameters ["@PPID"].Value =Convert.ToInt16 (bidvalue);
			cm1.ExecuteNonQuery ();
			cm2.ExecuteNonQuery ();
			cn.Close ();
			Response.Redirect ("bookmanage.aspx");
		}
	}
}

⌨️ 快捷键说明

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