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

📄 default.aspx.cs

📁 根据起降城市,查询到起降时间,以及航次的具体信息.
💻 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 BusinessFacade;
using BusinessEntity;

namespace FlightSite
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList ddlFromCity;
		protected System.Web.UI.WebControls.DataGrid grdCabin;
		protected System.Web.UI.WebControls.DropDownList ddlToCity;
		protected System.Web.UI.WebControls.TextBox txtStartTime;
		protected System.Web.UI.WebControls.TextBox txtEndTime;
		protected System.Web.UI.WebControls.Button btnQuery;
		protected System.Web.UI.WebControls.Repeater rpt;
		FlightCollection flights = null;

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
				CityCollection c = Application["Cities"] as CityCollection;
				for(int i = 0; i < c.Count; i++)
				{
					this.ddlFromCity.Items.Add(new ListItem(c[i].CityName, c[i].Id.ToString()));
					this.ddlToCity.Items.Add(new ListItem(c[i].CityName, c[i].Id.ToString()));
				}
			}
		}

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

		}
		#endregion

		private void btnQuery_Click(object sender, System.EventArgs e)
		{
			City fromCity = (Application["Cities"] as CityCollection)[this.ddlFromCity.SelectedIndex];
			City toCity = (Application["Cities"] as CityCollection)[this.ddlToCity.SelectedIndex];
			flights = BusinessFacade.FlightBF.GetFlights(fromCity, toCity, new DateTime(1990, 1, 1), new DateTime(2009, 12, 31));
			this.rpt.DataSource = flights;
			this.rpt.DataBind();
		}

		private void rpt_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
		{
			if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
			{
				System.Web.UI.HtmlControls.HtmlTableRow trCabin = (e.Item.FindControl("trCabin") as HtmlTableRow);
				System.Web.UI.WebControls.Image img = (e.Item.FindControl("imgShow") as System.Web.UI.WebControls.Image);
				img.Attributes["onClick"] = "showCabin(this, document.all." + trCabin.ClientID + ")";
				DataGrid grd = (e.Item.FindControl("grdCabin") as DataGrid);
				if(null != grd)
				{
					grd.DataSource = flights[e.Item.ItemIndex].Items;
					grd.DataBind();
				}
			}
		}
	}
}

⌨️ 快捷键说明

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