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

📄 index.aspx.cs

📁 在线pizza 预定系统,可以供现在正编写预定程序的朋友学习或借鉴
💻 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.Data.SqlClient;
using System.Configuration;

namespace PizzaOnline
{
	//该源码下载自www.51aspx.com(51aspx.com)

	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid dg;
		protected System.Web.UI.WebControls.Button postOrder;
		protected System.Web.UI.WebControls.TextBox email;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!IsPostBack) 
			{
				Bind();
			}// 在此处放置用户代码以初始化页面
		}
		private void Bind()
		{
			SqlConnection con=ConnDB.Conn();
			SqlDataAdapter da=new SqlDataAdapter("sel_Pizza_tbl",con);
			da.SelectCommand.CommandType=CommandType.StoredProcedure;
			DataSet ds=new DataSet();
			da.Fill(ds,"Pizza");
			dg.DataSource=ds.Tables["Pizza"];
			dg.DataKeyField="pid";
			dg.DataBind();
			con.Close();
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.postOrder.Click += new System.EventHandler(this.postOrder_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void postOrder_Click(object sender,EventArgs e)
		{
			if (ConnDB.isEmailExist(email.Text)==1)
			{
				int orderid=-1;
				foreach (DataGridItem item in dg.Items)
				{
					CheckBox select=(CheckBox)item.FindControl("SelectCheck");
					Label pid=(Label)item.FindControl("pid");
					DropDownList size=(DropDownList)item.FindControl("size");
					TextBox quan=(TextBox)item.FindControl("quan");
					string size1=size.SelectedItem.Text.ToString();
					int quan1=Convert.ToInt32(quan.Text);
					int pid1=(int)dg.DataKeys[item.DataSetIndex];
					if (select.Checked)
					{
						if (orderid==-1)
						{
							orderid=ConnDB.insOrder(email.Text);
						}	
						ConnDB.insOrderDetail(orderid,pid1,size1,quan1);
					}

				}
				Response.Redirect("OrderCompleted.aspx?orderid="+orderid);
			}
			else
			{
				Response.Redirect("Registration.aspx");
			}
		}
	}
}

⌨️ 快捷键说明

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