Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version
Go to top

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.zip
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
{
	//*********************************************************************
	//
	// SimpleReport.aspx
	//
	// This report lists all customer contacts information from the database
	// in a DataGrid control
	//
	//*********************************************************************

	public class Simple : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid CustomerGrid;
		protected System.Web.UI.WebControls.HyperLink PrintButton;
		protected System.Web.UI.WebControls.LinkButton PagingButton;
		protected string _styleSheet;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!IsPostBack)
			{
				BindGrid();
			}

			// switches the style sheet based on printer friendly view or not
			if (Request.QueryString["Print"]=="true")
			{
				_styleSheet = "stylesPrint.css";
				PrintButton.Visible = true;
				PagingButton.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.CustomerGrid.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.CustomerGrid_PageIndexChanged);
			this.CustomerGrid.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.CustomerGrid_Sort);
			this.PagingButton.Click += new System.EventHandler(this.pagingButton_Click);
			this.ID = "Simple";
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		//*********************************************************************
		//
		// The BindGrid method retrieves a collection of simple report items
		// and databinds it to the CustomerGrid
		//
		//*********************************************************************

		private void BindGrid()
		{
			SimpleReportCollection customerList = SimpleReport.GetCustomerContacts();
			SortGridData(customerList, SortField, SortAscending);
			CustomerGrid.DataSource = customerList;
			CustomerGrid.DataBind();
		}

		//*********************************************************************
		//
		// The SortGrid event handler changes the sortfield for the Customer grid 
		// and re-binds it.
		//
		//*********************************************************************

		private void CustomerGrid_Sort(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
		{
			// change sort field
			SortField = (string)e.SortExpression;

			// re-bind to display new sorting
			BindGrid();
		}

		//*******************************************************
		//
		// SortGridData methods sorts the datagrid based on which
		// sort field is being selected.  Also does reverse sorting based on the boolean.
		//
		//*******************************************************

		private void SortGridData(SimpleReportCollection list, string sortField, bool asc)
		{
			SimpleReportCollection.SimpleReportFields sortCol = SimpleReportCollection.SimpleReportFields.InitValue;

			switch(sortField)
			{
				case "City":
					sortCol = SimpleReportCollection.SimpleReportFields.City;
					break;
				case "CompanyName":
					sortCol = SimpleReportCollection.SimpleReportFields.CompanyName;
					break;
				case "ContactName":
					sortCol = SimpleReportCollection.SimpleReportFields.ContactName;
					break;
				case "ContactTitle":
					sortCol = SimpleReportCollection.SimpleReportFields.ContactTitle;
					break;
				case "Phone":
					sortCol = SimpleReportCollection.SimpleReportFields.Phone;
					break;
			}

			list.Sort(sortCol, asc);
		}

		//*******************************************************
		//
		// CustomerGrid_PageIndexChanged server event handler on this page is used
		// for changing page index
		//
		//*******************************************************

		private void CustomerGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			CustomerGrid.CurrentPageIndex = e.NewPageIndex;
			BindGrid();
		}

		//*******************************************************
		//
		// pagingButton_Click server event handler on this page is used
		// for changing paging property on CustomerGrid
		//
		//*******************************************************
		private void pagingButton_Click(object sender, System.EventArgs e)
		{
			CustomerGrid.AllowPaging = !CustomerGrid.AllowPaging;	
			BindGrid();

			PagingButton.Text = CustomerGrid.AllowPaging ? "Disable Paging" : "Enable Paging";
		}

		string SortField 
		{
			get 
			{
				object o = ViewState["SortField"];
				if (o == null) 
				{
					return String.Empty;
				}
				return (string)o;
			}
			set 
			{
				if (value == SortField) 
				{
					// same as current sort file, toggle sort direction
					SortAscending = !SortAscending;
				}
				ViewState["SortField"] = value;
			}
		}
 
		//*********************************************************************
		//
		// SortAscending property is tracked in ViewState
		//
		//*********************************************************************

		bool SortAscending 
		{
			get 
			{
				object o = ViewState["SortAscending"];

				if (o == null) 
				{
					return true;
				}
				return (bool)o;
			}
			set 
			{
				ViewState["SortAscending"] = value;
			}
		}
		
	}
}

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 1 Oct 2005
Article Copyright 2005 by idepaula
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid