Click here to Skip to main content
15,881,248 members
Articles / Web Development / ASP.NET

Race to Linux - Race 3: Reports Starter Kit using Mono SqlServer/Firebird

Rate me:
Please Sign up or sign in to vote.
2.33/5 (2 votes)
30 Sep 20052 min read 52.6K   328   15  
Reports Starter Kit port to Linux using Mono
using System;
using System.Web.UI.WebControls;
using ASPNET.StarterKit.Reports.Components;

namespace ASPNET.StarterKit.Reports
{
	//*********************************************************************
	//
	// DrillDown.aspx
	//
	// The drilldown report displays customer order info. Users are presented with 
	// a list of customers. From there, they can focus in on a customer and see the
	// orders shipped to that customer. Then, they can focus in on an order ID to 
	// view the details for a particular order.
	//
	//*********************************************************************

	public class DrillDown : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataList CustomerList;
		protected System.Web.UI.WebControls.HyperLink PrintButton;
		protected string _styleSheet;

		private const string _customerID = "CustomerID";
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!IsPostBack)
			{
				BindList();
			}

			// switches the style sheet based on printer friendly view or not
			if (Request.QueryString["Print"]=="true")
			{
				_styleSheet = "stylesPrint.css";
				PrintButton.Visible = true;
			}
			else 
			{
				_styleSheet = "styles.css";
			}
		}

		#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.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		//*********************************************************************
		//
		// The BindList method retrieves the list of customers
		// and then databinds them to the Customers Datalist
		//
		//*********************************************************************

		private void BindList()
		{
			CustomerList.DataSource = DrillDownReport.GetCustomers();
			CustomerList.DataBind();
		}

		//*******************************************************
		//
		// DataList_ItemCommand event handler is tied to the OnItemDataBound of the Customers DataList.
		// It sets the selected index of the Customers List and then re-binds.
		//
		//*******************************************************

		protected void CustomersList_ItemCommand(object Sender, DataListCommandEventArgs e) 
		{
			// change the Datalist to selected index
			string cmd = ((LinkButton)e.CommandSource).CommandName;
			if (cmd == "select")
				((DataList)Sender).SelectedIndex = e.Item.ItemIndex;

			// re-bind to display data with the new selected index
			BindList();

			// store the customer id to re-bind in the orders list
			ViewState[_customerID] = ((Label)e.Item.FindControl("CustomerID")).Text;
		}

		//*******************************************************
		//
		// OrdersList_ItemCommand event handler is tied to the OnItemDataBound of the Orders DataList.
		// It sets the selected index of the Orders List and then re-binds.
		//
		//*******************************************************

		protected void OrdersList_ItemCommand(object Sender, DataListCommandEventArgs e) 
		{
			// change the selected index of Orders Datalist
			string cmd = ((LinkButton)e.CommandSource).CommandName;
			DataList sender = (DataList)Sender;
			if (cmd == "select")
				sender.SelectedIndex = e.Item.ItemIndex;

			// re-bind to display orders info with new selected index.
			sender.DataSource = GetOrders((string)ViewState[_customerID]);
			sender.DataBind();
		}

		//*********************************************************************
		//
		// The GetOrders method calls the BLL to retrieve the list of orders shipped
		// for customer with customerID.
		//
		//*********************************************************************

		protected DrillDownReportCollection GetOrders(string customerID)
		{
			// only use the customerID in session if it doesn't exist.
			if (customerID == null)
				customerID = (string)ViewState[_customerID];

			return DrillDownReport.GetOrders(customerID);
		}

		//*********************************************************************
		//
		// The GetOrderDetails method calls the BLL to retrieve order info given an order id.
		//
		//*********************************************************************

		protected DrillDownReportCollection GetOrderDetails(int orderID)
		{
			return DrillDownReport.GetOrderDetails(orderID);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Uruguay Uruguay
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions