namespace ASPNET.StarterKit.TimeTracker.Web
{
	using System;
	using System.Collections;
	using ASPNET.StarterKit.TimeTracker.BusinessLogicLayer;

	// Usercontrol for the Project and User subtabs on the Administration tab.
	public abstract class AdminTabs : System.Web.UI.UserControl
	{
		protected System.Web.UI.WebControls.DataList tabs;

		private void Page_Load(object sender, System.EventArgs e)
		{
			ArrayList tabItems = new ArrayList();
			int mainIndex = (Request["index"]==null) ? 0 : Convert.ToInt32(Request["index"]);

			// Always add the project list tab.  If the user was able to see the Administration tab, they'll
			// always be able to view this tab.
			tabItems.Add(new TabItem("ÏîÄ¿", "ProjectList.aspx?index=" + mainIndex + "&adminIndex=" + tabItems.Count));
			
			if (TTSecurity.IsInRole(TTUser.UserRoleAdministrator))
			{
				tabItems.Add(new TabItem("ÓÃ»§", "UserList.aspx?index=" + mainIndex + "&adminIndex=" + tabItems.Count));
			}
			
			tabs.DataSource = tabItems;
			tabs.SelectedIndex = (Request["adminIndex"]==null) ? 0 : Convert.ToInt32(Request["adminIndex"]);
			tabs.DataBind();
		}

		#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);
		}
		
		///		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
	}
}
