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

ASP.NET TimeTracker Starter Kits Porting from Windows to Linux (Race to Linux)

Rate me:
Please Sign up or sign in to vote.
2.84/5 (9 votes)
5 Oct 20055 min read 70.6K   388   21  
ASP.NET TimeTracker Starter Kits Porting from Windows to Linux using Mainsoft's Grasshopper
using System;
using System.Data;
using System.Web;
using System.Text;
using System.Web.UI.WebControls;
using ASPNET.StarterKit.TimeTracker.BusinessLogicLayer;

namespace ASPNET.StarterKit.TimeTracker.Web
{
	//*********************************************************************
	//
	// ProjectList.aspx
	//
	// Report launching page for the project and resource reports.
	//
	//*********************************************************************

	public class Reports : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ListBox ProjectList;
		protected System.Web.UI.WebControls.ListBox UserList;
		protected System.Web.UI.WebControls.Button GenProjectRpt;
		protected System.Web.UI.WebControls.Button GenResourceRpt;
		protected System.Web.UI.WebControls.TextBox StartDate;
		protected System.Web.UI.WebControls.TextBox EndDate;
		protected System.Web.UI.WebControls.RequiredFieldValidator ProjectListRequiredFieldValidator;
		protected System.Web.UI.WebControls.RequiredFieldValidator UserListRequiredFieldValidator;

		private string _pageIndex = string.Empty;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Ensure that the visiting user has access to view the current page
			if (TTSecurity.IsInRole(TTUser.UserRoleAdminPMgr) == false) 
			{
				Response.Redirect("AccessDenied.aspx?Index=-1", true);
			}

			DateTime startingDate = DateTime.Today;
			DateTime endingDate = DateTime.Today;

			_pageIndex = Request.QueryString["Index"];

			if (!this.IsPostBack)
			{   
				ProjectList.DataSource = Project.GetProjects(TTSecurity.GetUserID(), TTSecurity.GetUserRole());
				ProjectList.DataTextField = "Name";
				ProjectList.DataValueField = "ProjectID";
				ProjectList.DataBind();

				UserList.DataSource = TTUser.GetUsers(TTSecurity.GetUserID(), TTSecurity.GetUserRole());
				UserList.DataTextField = "Name";
				UserList.DataValueField = "UserID";
				UserList.DataBind();

				BusinessLogicLayer.TimeEntry.FillCorrectStartEndDates(DateTime.Today, ref startingDate, ref endingDate);
				StartDate.Text = startingDate.ToShortDateString();
				EndDate.Text = endingDate.ToShortDateString();
			}
		}

		//*********************************************************************
		//
		// Converts values contained in the provided ListItemsCollection to a 
		// comma-delimited string. 
		//
		//*********************************************************************

		private string BuildValueList(ListItemCollection items)
		{
			// Build up list of IDs of selected users
			StringBuilder idList = new StringBuilder();
			foreach (ListItem item in items)
			{
				if (item.Selected)
				{
					if (idList.ToString() != string.Empty)
						idList.Append(",");
					idList.Append(item.Value.ToString());
				}
			}

			return idList.ToString();
		}

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

		}
		#endregion

		//*********************************************************************
		//
		// Launches the project report using the selected projects as input.
		//
		//*********************************************************************

		private void GenProjectRpt_Click(object sender, System.EventArgs e)
		{
			ProjectListRequiredFieldValidator.Validate();

			// Go to the project report page using the selected project IDs
			if (ProjectListRequiredFieldValidator.IsValid)
				Server.Transfer("ProjectReport.aspx?IDs=" + BuildValueList(ProjectList.Items) + 
					"&index=" + _pageIndex);
		}

		//*********************************************************************
		//
		// Launches the resource report using the selected consultants and date range as input.
		//
		//*********************************************************************

		private void GenResourceRpt_Click(object sender, System.EventArgs e)
		{
			UserListRequiredFieldValidator.Validate();

			// Go to the resource report page using the selected user IDs
			if (UserListRequiredFieldValidator.IsValid)
				Response.Redirect("ResourceReport.aspx?IDs=" + BuildValueList(UserList.Items) + 
					"&Start=" + StartDate.Text + "&End=" + EndDate.Text + "&index=" + _pageIndex, false);		
		}
	}
}

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
Architect
Australia Australia
"Impossible" + "'" + " " = "I'm Possible"

Started programming when i was a kid with 286 computers and Spectrum using BASIC from 1986. There was series of languages like pascal, c, c++, ada, algol, prolog, assembly, java, C#, VB.NET and so on. Then shifted my intrest in Architecture during past 5 years with Rational Suite and UML. Wrote some articles, i was member of month on some sites, top poster(i only answer) of week (actually weeks), won some books as prizes, rated 2nd in ASP.NET and ADO.NET in Australia.

There is simplicity in complexity

Comments and Discussions