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

📄 bookadd.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>
	/// BookAdd 
	/// </summary>
	public partial class BookAdd : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			
		}

		#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_submit_Click(object sender, System.EventArgs e)
		{
			if(Page.IsValid )
            {//from the file Web.config Read connecting string
				string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
				//CONNECT WITH BMSDATABASE,CREATE THREE CONNECTION
				SqlConnection cn= new SqlConnection (strconn);
				cn.Open (); 
				SqlConnection cn1= new SqlConnection (strconn);
				cn1.Open (); 
				SqlConnection cn2= new SqlConnection (strconn);
				cn2.Open (); 
				//CALLED THE PARMETER
				SqlCommand cmbookadd=new SqlCommand  ("bookadd",cn);
                //use Order types to store types 
				cmbookadd.CommandType =CommandType.StoredProcedure ;
				//add the valu to the paramter 
				cmbookadd.Parameters .Add ("@BID",SqlDbType.Int);
				cmbookadd.Parameters .Add ("@BISBN",SqlDbType.VarChar);
				cmbookadd.Parameters .Add ("@BName",SqlDbType.VarChar);
				cmbookadd.Parameters .Add ("@BAuthor",SqlDbType.VarChar);
				cmbookadd.Parameters .Add ("@BPress",SqlDbType.VarChar );
				cmbookadd.Parameters .Add ("@BGroup",SqlDbType.Int );
				cmbookadd.Parameters .Add ("@BDescribe",SqlDbType.VarChar);

                //Use Command object to call stored procedures, table creation adding bookprice order types
				SqlCommand cmbookpriceadd=new SqlCommand  ("bookpriceadd",cn1);
                //use Order types to store types 
				cmbookpriceadd.CommandType =CommandType.StoredProcedure ;
                //add the valu to the paramter 
				cmbookpriceadd.Parameters .Add ("@PPID",SqlDbType.Int);
				cmbookpriceadd.Parameters .Add ("@PPrice",SqlDbType.Money );
				cmbookpriceadd.Parameters .Add ("@PDiscount",SqlDbType.Float  );

                //Use Command object to call stored procedures, table creation adding BookMaxBIDGet order types 
                //The type we want to return to the book, bookprice table value added BID 
				SqlCommand cmbookmaxbidget=new SqlCommand  ("BookMaxBIDGet ",cn2);
                //use Order types to store types 
				cmbookmaxbidget.CommandType =CommandType.StoredProcedure ;
                //add the valu to the paramter
				cmbookmaxbidget.Parameters .Add ("@maxbid",SqlDbType.Int);

                //BookMaxBIDGet parameters of the process output 
				cmbookmaxbidget.Parameters ["@maxbid"].Direction =ParameterDirection.Output ;

				cmbookmaxbidget.ExecuteReader ();
				string maxbidstring=cmbookmaxbidget.Parameters ["@maxbid"].Value.ToString();
                //Consider the database space, will air maxbidstring 
				int maxbid ;
				if(maxbidstring=="")//if database is null
				{maxbid=1 ;
				}
				else//if there is data
				{maxbid=Convert.ToInt32(maxbidstring)+1 ; //取出表中BID的最大值作为下一纪录的BID
				}
		
				//add to the book table the data
				cmbookadd.Parameters ["@BID"].Value =maxbid;
				cmbookadd.Parameters ["@BName"].Value =tbx_bname.Text .ToString ();
				cmbookadd.Parameters ["@BISBN"].Value =tbx_bisbn.Text .ToString ();
				cmbookadd.Parameters ["@BAuthor"].Value =tbx_bauthor.Text .ToString ();
				cmbookadd.Parameters ["@BPress"].Value =tbx_bpress.Text .ToString ();
				cmbookadd.Parameters ["@BDescribe"].Value =tbx_bdescribe.Text .ToString ();
				cmbookadd.Parameters ["@BGroup"].Value =ddl_bgroup.SelectedItem .Value.ToString () ;
                //Bookprice table to pay the value of parameters 
				cmbookpriceadd.Parameters ["@PPID"].Value =maxbid;
				cmbookpriceadd.Parameters ["@PPrice"].Value =Convert.ToDouble (tbx_bprice.Text .ToString ());
				cmbookpriceadd.Parameters ["@PDiscount"].Value =Convert.ToInt16 (ddl_bdiscount.SelectedItem .Value .ToString());

				cmbookadd.ExecuteNonQuery ();
				cmbookpriceadd.ExecuteNonQuery ();
				//close the connection
				cn.Close();
				cn1.Close ();
				cn2.Close ();
				Response.Redirect("bookmanage.aspx");
			}
		}
	}
}

⌨️ 快捷键说明

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