Click here to Skip to main content
12,450,981 members (24,329 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads

Stats

44.3K views
309 downloads
15 bookmarked
Posted

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

, 30 Sep 2005
Reports Starter Kit port to Linux using Mono
RaceToLinuxRace3_src
bin
ASPNET.StarterKit.Reports.dll
FirebirdSql.Data.Firebird.dll
Components
BLL
DAL
docs
images
1x1.gif
crosstabnestedcontrols.png
crosstabtotals.png
customers.gif
drilldownnestedcontrols.png
employees.gif
getorderdetails.gif
getorders.gif
hierarchicalpaging.gif
hierarchicalreport.gif
hierarchicalschema.gif
hierarchicalsorting.gif
masterdetaildetails.png
masterdetailsummary.png
masterdetailtables.png
querysample.gif
querysample2.gif
simpleoverview.png
simplesp.png
tabdetail.png
tabheader.gif
tabheader.png
tabnestedcontrols.png
tabularcolorcode.png
tabularextendedprice.png
tabularsorting.png
textshot.gif
viscategorysales.gif
viscategorysales.png
vischartstructure.png
xtabsql.png
global.asax
images
asp.net-reports.gif
background.gif
crosstab.gif
drilldown.gif
grid_background.gif
hierarchical.gif
logo-neg.gif
logo.gif
masterdetail.gif
masterdetails.gif
report-table-bg.gif
simple.gif
spacer.gif
tabular.gif
textalternate.gif
textreport.gif
visual.gif
ReportsCSVS.csproj.webinfo
SourceViewer
1x1.gif
crosstab.src
drilldown.src
grid_background.gif
hierarchical.src
masterdetail.src
simple.src
tabular.src
textreport.src
visual.src
REPORTS.BKP
using System;
using System.Web.UI.WebControls;
using ASPNET.StarterKit.Reports.Components;

namespace ASPNET.StarterKit.Reports
{
	//*********************************************************************
	//
	// CrossTab.aspx
	//
	// The CrossTab.aspx page shows quarterly breakdown of sales based on the region.
	// It also displays the totals for each region, the totals for each month within the quarter,
	// and the total for the whole quarter.
	//
	//*********************************************************************

	public class CrossTab : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataList QuartersList;
		protected System.Web.UI.WebControls.DropDownList YearDropDownList;
		protected System.Web.UI.WebControls.HyperLink PrintButton;

		private double _eastern = 0;
		private double _western = 0;
		private double _southern = 0;
		private double _northern = 0;
		private double _totals = 0;
		protected string _styleSheet;
	
		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.YearDropDownList.SelectedIndexChanged += new System.EventHandler(this.YearDropDownList_SelectedIndexChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		//*********************************************************************
		//
		// The BindList method simply binds the Datalist with the four quarters
		//
		//*********************************************************************

		private void BindList()
		{
			QuartersList.DataSource = new int[4] { 1, 2, 3, 4 };
			QuartersList.DataBind();
		}

		//*********************************************************************
		//
		// The GetQuarterDetails method is set as the DataSource of the inner datagrid.
		// As the QuartsList is being data-bound, this populates the inner datagrids for the quarters.
		//
		//*********************************************************************

		protected CrossTabReportCollection GetQuarterDetails(int quarter)
		{
			return CrossTabReport.GetRegionSales(quarter, Convert.ToInt32(YearDropDownList.SelectedItem.Value));
		}

		//*********************************************************************
		//
		// The SumItems event handler is for the OnItemDataBound event of the datagrids for each quarter.
		// It adds running totals for each region for a particular quarter.
		// It also adds the sum totals fo the regions of the quarter as well.
		//
		//*********************************************************************

		protected void SumItems(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			// sum up the data in the columns as the datagrid is databinding
			if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
			{
				// get the sales value for eastern region
				double eastern = Convert.ToDouble(e.Item.Cells[1].Text);
				// add sales value to the running total
				_eastern += eastern;
				// format to display sales value as currency
				e.Item.Cells[1].Text = string.Format("{0:c}", eastern);

				double western = Convert.ToDouble(e.Item.Cells[2].Text);
				_western += western;
				e.Item.Cells[2].Text = string.Format("{0:c}", western);

				double southern = Convert.ToDouble(e.Item.Cells[3].Text);
				_southern += southern;
				e.Item.Cells[3].Text = string.Format("{0:c}", southern);
				
				double northern = Convert.ToDouble(e.Item.Cells[4].Text);
				_northern += northern;
				e.Item.Cells[4].Text = string.Format("{0:c}", northern);
				
				double totals = Convert.ToDouble(e.Item.Cells[5].Text);
				_totals += totals;
				e.Item.Cells[5].Text = string.Format("{0:c}", totals);
			}
			else if(e.Item.ItemType == ListItemType.Footer )
			{
				// display our summations in footer
				e.Item.Cells[0].Text = "Totals";
				e.Item.Cells[0].HorizontalAlign = HorizontalAlign.Left;
				e.Item.Cells[1].Text = string.Format("{0:c}", _eastern);
				e.Item.Cells[2].Text = string.Format("{0:c}", _western);
				e.Item.Cells[3].Text = string.Format("{0:c}", _southern);
				e.Item.Cells[4].Text = string.Format("{0:c}", _northern);
				e.Item.Cells[5].Text = string.Format("{0:c}", _totals);

				// reset the running totals for next datagrid
				_eastern = 0;
				_western = 0;
				_southern = 0;
				_northern = 0;
				_totals = 0;
			}
		}

		private void YearDropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			BindList();
		}
	}
}

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

Share

About the Author

idepaula
Web Developer
Uruguay Uruguay
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 1 Oct 2005
Article Copyright 2005 by idepaula
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid