using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Drawing; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string logonUserName = Utilities.GetLoggedInUserID(User.Identity.Name); //switch (logonUserName) //{ // case "rgulamhussein": // case "rizwang": // case "sherinj": // case "noreenk": // case "mohamedj": // case "nazimp": // case "malikt": // break; // default: // Server.Transfer("sitemaintenance.html"); // break; //} try { // Code to check if user exists in the ASPNET database MembershipUser user = Membership.GetUser(logonUserName); if (user == null) { // User's account does not exist, or user is not permitted access // Redirect to accout creation page Response.Redirect("CreateAccount.aspx", true); } else { // Update aspnet_Users.LastActivityDate // contemplating because code is executed every time node is expanded // If user is in role "WaitingRoleAssignment", redirect to "Permision not granted yet" page if (Roles.IsUserInRole(logonUserName, "WaitingRoleAssignment")) { Response.Redirect("RoleNotAssigned.aspx", true); } } } catch { //Server.Transfer("error.html"); } } protected void Node_Populate(object sender, TreeNodeEventArgs e) { if (e.Node.ChildNodes.Count == 0) { switch (e.Node.Depth) { case 0: FillPortfolios(e.Node); break; case 1: FillEventsForPortfolios(e.Node); break; } } } protected void FillPortfolios(TreeNode node) { // Determine the year of the node we are filling string valPath = node.ValuePath; int ppYear = Convert.ToInt32(valPath.Split('/')[0]); bool showProjectList = false; bool showCreatePPNode = false; string sqlSelectPortfolios = "select "; sqlSelectPortfolios += "bp.BoardPortfolioID, "; sqlSelectPortfolios += "bp.BoardPortfolioName +' (' + cast(count(pd.ProjectID) as nvarchar(4)) + ')' as BoardPortfolioName "; sqlSelectPortfolios += "from "; sqlSelectPortfolios += "tluBoardPortfolio bp "; sqlSelectPortfolios += "inner join tblProject_Committee pc "; sqlSelectPortfolios += "on pc.BoardPortfolioID = bp.BoardPortfolioID "; sqlSelectPortfolios += "left join tblProjectDate pd "; sqlSelectPortfolios += "on pd.ProjectID = pc.ProjectID "; sqlSelectPortfolios += "where "; sqlSelectPortfolios += "pc.IsPrimaryOrganizerYN = 1 "; sqlSelectPortfolios += "and pd.ProposedProjectDate/10000 = " + ppYear + " "; try { // Filter the tree if user is member of a Board/Portfolio string boardPortfolioName = ReadWriteManager.GetUserBoardPortfolio(); switch (boardPortfolioName) { case "AdminPlanning": showCreatePPNode = true; showProjectList = true; break; case "AdminFinance": showProjectList = true; break; case "ReadOnlyFull": break; default: showCreatePPNode = true; sqlSelectPortfolios += " and BoardPortfolioName in ('" + boardPortfolioName + "')"; break; } sqlSelectPortfolios += "group by "; sqlSelectPortfolios += "bp.BoardPortfolioID, "; sqlSelectPortfolios += "bp.BoardPortfolioName"; string connString = ConfigurationManager.ConnectionStrings["cnPPDB"].ToString(); SqlConnection connection = new SqlConnection(connString); SqlCommand command = new SqlCommand(sqlSelectPortfolios, connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataSet portfolios = new DataSet(); adapter.Fill(portfolios); if (portfolios.Tables.Count > 0) { // Show Project List node if permitted if (showProjectList == true) { TreeNode projectListNode = new TreeNode(ppYear + " Project List", "", "", "ProjectList.aspx?projectyear=" + ppYear, "fraBody"); projectListNode.ToolTip = "View list of all projects for " + ppYear; node.ChildNodes.Add(projectListNode); } // Show Create PP node if permitted if (showCreatePPNode == true) { TreeNode createPPNode = new TreeNode("Create New Project", "", "","createnewproject.aspx", "fraBody"); createPPNode.ToolTip = "Create New Project"; node.ChildNodes.Add(createPPNode); } if (portfolios.Tables[0].Rows.Count > 0) { foreach (DataRow row in portfolios.Tables[0].Rows) { TreeNode newNode = new TreeNode(row["BoardPortfolioName"].ToString(), row["BoardPortfolioID"].ToString()); newNode.PopulateOnDemand = true; newNode.SelectAction = TreeNodeSelectAction.Expand; newNode.ToolTip = row["BoardPortfolioName"].ToString(); node.ChildNodes.Add(newNode); } } else { string noDetailsFound = "No details for " + boardPortfolioName; TreeNode newNode = new TreeNode(noDetailsFound); newNode.ToolTip = noDetailsFound; node.ChildNodes.Add(newNode); } // Show Project List node if permitted // Moved to top //if (showProjectList == true) //{ // TreeNode projectListNode = new TreeNode(ppYear + " Project List", "", "", "ProjectList.aspx?projectyear=" + ppYear, "fraBody"); // projectListNode.ToolTip = "View list of all projects for " + ppYear; // node.ChildNodes.Add(projectListNode); //} } } catch { Server.Transfer("error.html"); } } protected void FillEventsForPortfolios(TreeNode node) { try { string portfolioID = node.Value; // Determine the year of the node we are filling string valPath = node.ValuePath; int ppYear = Convert.ToInt32(valPath.Split('/')[0]); string connString = ConfigurationManager.ConnectionStrings["cnPPDB"].ToString(); SqlConnection connection = new SqlConnection(connString); SqlCommand command = new SqlCommand("select p.ProjectTitle, p.ProjectID, p.COENumber, s.PPStatus From tblProject p" + " inner join tblProject_Committee pc" + " on pc.ProjectID = p.ProjectID" + " inner join tluPPStatus s" + " on s.PPStatusID = p.PPStatusID" + " left join tblProjectDate pd" + " on pd.ProjectID = p.ProjectID" + " where pc.BoardPortfolioID = '" + portfolioID + "'" + " and pc.IsPrimaryOrganizerYN = 1" + " and pd.ProposedProjectDate/10000 = " + ppYear + " " + " order by p.COENumber", connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataSet eventsForPortfolios = new DataSet(); adapter.Fill(eventsForPortfolios); if (eventsForPortfolios.Tables.Count > 0) { foreach (DataRow row in eventsForPortfolios.Tables[0].Rows) { TreeNode newNode = new TreeNode(row["COENumber"].ToString() + " - " + row["ProjectTitle"].ToString() + " (" + row["PPStatus"].ToString() + ")", row["ProjectID"].ToString()); newNode.Text = " " + newNode.Text; newNode.PopulateOnDemand = false; //newNode.SelectAction = TreeNodeSelectAction.None; //newNode.SelectAction = TreeNodeSelectAction.Select; newNode.SelectAction = TreeNodeSelectAction.Expand; newNode.ToolTip = row["COENumber"].ToString() + " - " + row["ProjectTitle"].ToString() + " (" + row["PPStatus"].ToString() + ")"; newNode.ImageUrl = PPSUtilities.GetPPStatusImage(row["PPStatus"].ToString()); node.ChildNodes.Add(newNode); //add 3 child nodes //Project Details TreeNode detailsNode = new TreeNode(); detailsNode.Text = " Details"; detailsNode.ImageUrl = "images/form.png"; detailsNode.NavigateUrl = "projectdetails.aspx?ProjectID=" + row["ProjectID"].ToString(); detailsNode.Target = "fraBody"; newNode.ChildNodes.Add(detailsNode); //Budget Details //Display to be controlled by project state TreeNode budgetNode = new TreeNode(); budgetNode.Text = " Budget"; budgetNode.ImageUrl = "images/dollar2.jpg"; budgetNode.NavigateUrl = "tabs.aspx?ProjectID=" + row["ProjectID"].ToString(); budgetNode.Target = "fraBody"; newNode.ChildNodes.Add(budgetNode); //Eval Details //Display to be controlled by project state TreeNode evalNode = new TreeNode(); evalNode.Text = " Evaluation"; evalNode.ImageUrl = "images/check_red.gif"; evalNode.NavigateUrl = "eval.aspx?ProjectID=" + row["ProjectID"].ToString(); evalNode.Target = "fraBody"; newNode.ChildNodes.Add(evalNode); } } } catch { Server.Transfer("error.html"); } } }