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

📄 addtitle_typedds.aspx.cs

📁 Microsoft?ASP.NET Programming with Microsoft Visual C#?.NET Version 2003 Step By Step
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Chapter_09
{
	/// <summary>
	/// Summary description for AddTitle_TypedDS.
	/// </summary>
	public class AddTitle_TypedDS : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox title_id;
		protected System.Web.UI.WebControls.TextBox title;
		protected System.Web.UI.WebControls.TextBox type;
		protected System.Web.UI.WebControls.TextBox pub_id;
		protected System.Web.UI.WebControls.TextBox price;
		protected System.Web.UI.WebControls.TextBox advance;
		protected System.Web.UI.WebControls.TextBox royalty;
		protected System.Web.UI.WebControls.TextBox ytd_sales;
		protected System.Web.UI.WebControls.TextBox notes;
		protected System.Web.UI.WebControls.TextBox pubdate;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.DataGrid titlegrid;
		protected System.Data.SqlClient.SqlDataAdapter daTitles;
		protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
		protected System.Data.SqlClient.SqlConnection cnPubs;
		protected Chapter_09.TitleDataSet titleDataSet1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if ( this.IsPostBack )
			{
				cnPubs.Open();
				try
				{
					TitleDataSet.titlesRow MyTitleRow;
					MyTitleRow = titleDataSet1.titles.NewtitlesRow();
					MyTitleRow.title_id = title_id.Text;
					MyTitleRow.title = title.Text;
					MyTitleRow.type = type.Text;
					MyTitleRow.pub_id = pub_id.Text;
					MyTitleRow.price = decimal.Parse(price.Text);
					MyTitleRow.advance = decimal.Parse(advance.Text);
					MyTitleRow.royalty = int.Parse(royalty.Text);
					MyTitleRow.ytd_sales = int.Parse(ytd_sales.Text);
					MyTitleRow.notes = notes.Text;
					MyTitleRow.pubdate = DateTime.Parse(pubdate.Text);
					titleDataSet1.titles.AddtitlesRow(MyTitleRow);
					this.daTitles.Update(titleDataSet1);

					titlegrid.DataSource = titleDataSet1.Tables[0];
					titlegrid.DataBind();
				}
				finally
				{
					cnPubs.Close();
				}
			}
			else
			{
				//To prevent conflicts on multiple inserts, we can
				//generate a random value for title_id
				Random RandomNum = new Random();
				title_id.Text = "XX" + String.Format("{0:000#}", RandomNum.Next(9999));
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.daTitles = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
			this.cnPubs = new System.Data.SqlClient.SqlConnection();

⌨️ 快捷键说明

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