Esempio n. 1
0
    /// <summary>
    /// Recursively adds nodes to the treeview menu starting at a given set of peers of a parent node.
    /// </summary>
    /// <param name="nodes">The root treenode collection to which to add child cnodes</param>
    /// <param name="parentCodexRecordId">The parent node record's ID, used to fetch the children</param>
    private void BuildCodexMenu( TreeNodeCollection nodes, int parentCodexRecordId )
    {
        CodexRecordList list = parentCodexRecordId > 0 ? CodexRecordList.GetCodexRecordList( parentCodexRecordId ) : CodexRecordList.GetCodexRecordList();

        //no child nodes (parent will always be included), exit function
        if ( list.Count < 2 ) return;

        foreach ( CodexRecord record in list )
        {
            if ( record.ID == parentCodexRecordId || ( parentCodexRecordId == 0 && record.ParentCodexRecordID != 0 ) ) continue;

            TreeNode node = new TreeNode( record.Title, record.ID.ToString() );

            // automatically select the first root node
            if ( record.ParentCodexRecordID == 0 && CodexMenu.SelectedNode == null ) node.Select();

            nodes.Add( node );
            node.ToggleExpandState();

            BuildCodexMenu( node.ChildNodes, record.ID );
        }
    }
            private void BuildChildNodes(TreeNodeCollection nodes, DataView DtView, string filter, bool ThreadViewPermission)
            {
                //string href = ATC.Tools.GetParam("RootURL") + "?page=" + ATC.Tools.URLParam("page") + "&Thread=" + ATC.Tools.URLParam("Thread");

                string rURL = RequestUrl.Url.OriginalString;
                //string href = "#";//rURL.Substring(0, RequestUrl.Url.AbsoluteUri.IndexOf("Thread") + 10) + ATC.Tools.URLParam("Thread");

                if (DtView.Count > 0)
                {
                    DtView.RowFilter = filter;
                    int RowCounter = 0;

                    string sFieldName = string.Empty;
                    string sId = string.Empty;
                    string sParentId = string.Empty;
                    string sMessage = string.Empty;
                    string sImageUrl = string.Empty;
                    string state = string.Empty;

                    for (RowCounter = 0; RowCounter <= DtView.Count - 1; RowCounter++)
                    {
                        TreeNode tn = new TreeNode();
                        sFieldName = DtView[RowCounter]["Subject"].ToString() + " " + state;
                        sId = DtView[RowCounter]["ID"].ToString();
                        sParentId = DtView[RowCounter]["ParentID"].ToString();
                        sMessage = DtView[RowCounter]["Message"].ToString();
                        sImageUrl = DtView[RowCounter]["PostType"].ToString();
                        sImageUrl = getImageIconUrl(sImageUrl);

                        tn.Text = sFieldName;
                        tn.Value = sId;
                        tn.ToolTip = sMessage;
                        tn.ImageUrl = sImageUrl;
                        tn.SelectAction = TreeNodeSelectAction.None;

                        nodes.Add(tn);
                        tn.ToggleExpandState();

                        DataView vuData2 = new DataView(Data.Tables[0]);
                        if (DtView.Count > RowCounter)
                        {
                            BuildChildNodes(tn.ChildNodes, vuData2, ChildColumn + " = " + DtView[RowCounter][ParentColumn], ThreadViewPermission);
                        }
                    }
                }
            }
Esempio n. 3
0
		void HandleExpandCollapseEvent (TreeNode node)
		{
			node.ToggleExpandState ();
		}
        private void GetNodeForCompanyLevels(TreeNodeCollection nodes, int parentId, int companyLevelId)
        {
            Int32 thisId;
            string thisName;

            DataRow[] children = companyLevelsTDS.Tables["LFS_FM_COMPANYLEVEL"].Select("ParentID='" + parentId + "'");

            //no child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // step 2
                thisName = Convert.ToString(child.ItemArray[1]);

                // step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                //step 4
                if (companyLevelId == thisId)
                {
                    newNode.Checked = true;
                }

                // step 5
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // step 6
                GetNodeForCompanyLevels(newNode.ChildNodes, thisId, companyLevelId);
            }
        }
        private void GetNodeForCategory(TreeNodeCollection nodes, int parentId)
        {
            Int32 thisId;
            String thisName;
            UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);

            DataRow[] children = categoriesTDS.Tables["LFS_FM_CATEGORY"].Select("ParentID='" + parentId + "'");

            //no child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // step 2
                thisName = Convert.ToString(child.ItemArray[2]);

                // step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                //step 4
                if (unitsCategoryGateway.IsUsedInUnitCategory(Int32.Parse(hdfUnitId.Value), thisId))
                {
                    newNode.Checked = true;
                }

                // step 5
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // step 6
                GetNodeForCategory(newNode.ChildNodes, thisId);
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // FINAL METHODS
        //
        private void GetNodeForCategory(TreeNodeCollection nodes, int parentId)
        {
            Int32 thisId;
            String thisName;

            DataRow[] children = categoriesTDS.Tables["LFS_FM_CATEGORY"].Select("ParentID='" + parentId + "'");

            // No child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // Step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // Step 2
                thisName = Convert.ToString(child.ItemArray[2]);

                // Step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                // Step 4
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // Step 5
                GetNodeForCategory(newNode.ChildNodes, thisId);
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP1 - GENERAL INFORMATION - METHODS
        //
        private void StepGeneralInformationIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Please provide general information";

            if (rbtnBeginTemplate.Checked)
            {
                int costingSheetTemplateId = Int32.Parse(hdfSelectedIdTemplate.Value);

                if (costingSheetTemplateId != 0)
                {
                    // Prepare initial data
                    // ... for template
                    foreach (ProjectCostingSheetAddTDS.TemplateInformationRow row in (ProjectCostingSheetAddTDS.TemplateInformationDataTable)Session["templateInformation"])
                    {
                        if (row.CostingSheetTemplateID == costingSheetTemplateId)
                        {
                            tbxName.Text = row.Name;

                            cbxRehabAssessmentData.Checked = row.RAData;
                            cbxFullLengthLiningData.Checked = row.FLLData;
                            cbxPointRepairData.Checked = row.PRData; ;
                            cbxJunctionLiningData.Checked = row.JLData;
                            cbxManholeRehabData.Checked = row.MRData;
                            cbxMobilizationData.Checked = row.MOBData;
                            cbxOtherData.Checked = row.OtherData;

                            cbxLabourHour.Checked = row.LabourHourData;
                            cbxTrucksEquipment.Checked = row.UnitData;
                            cbxMaterial.Checked = row.MaterialData;
                            cbxSubcontractor.Checked = row.SubcontractorData;
                            cbxOtherCost.Checked = row.MiscData;

                            cbxRevenueInformation.Checked = row.RevenueIncluded;

                            luEndSaveTemplate.SelectedValue = row.CostingSheetTemplateID.ToString();

                            try
                            {
                                DateTime startDate = new DateTime(row.Year, row.Month, row.Day);
                                tkrdpFrom.SelectedDate = startDate;
                            }
                            catch { }

                            try
                            {
                                DateTime endDate = new DateTime(row.Year2, row.Month2, row.Day2);
                                tkrdpTo.SelectedDate = endDate;
                            }
                            catch { }
                        }
                    }
                }

                //foreach (ProjectTDS.LFS_PROJECTRow row in (ProjectTDS.LFS_PROJECTDataTable)project.Table)
                //{
                //    // step 1
                //    thisId = Convert.ToInt32(row[0].ToString());

                //    // step 2
                //    thisName = Convert.ToString(row[8].ToString());

                //    // step 3
                //    TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                //    newNode.ShowCheckBox = true;
                //    newNode.SelectAction = TreeNodeSelectAction.None;

                //    // step 4
                //    nodes.Add(newNode);
                //    newNode.ToggleExpandState();
                //}
            }

            Int32 thisId;
            String thisName;
            TreeNodeCollection nodes;

            CompaniesGateway companies = new CompaniesGateway();
            companies.LoadByCompaniesId(int.Parse(hdfClientId.Value), int.Parse(hdfCompanyId.Value));
            string nameCompany = companies.GetName(int.Parse(hdfClientId.Value));

            ProjectGateway project = new ProjectGateway();
            project.LoadByClientId(int.Parse(hdfClientId.Value));

            TreeNode tnParent = new TreeNode();
            tnParent.Text = nameCompany;
            tnParent.Value = "0";
            tnParent.ShowCheckBox = true;
            tnParent.SelectAction = TreeNodeSelectAction.None;

            tvProjectsRoot.Nodes.Add(tnParent);
            tnParent.ToggleExpandState();

            PopulateNodes(project.Table, tnParent.ChildNodes);
        }
            private void BuildChildNodes(TreeNodeCollection nodes, DataView DtView, string filter, bool ThreadViewPermission, Panel StartingPanel, HtmlTable ForumsTable)
            {
                //string href = ATC.Tools.GetParam("RootURL") + "?page=" + ATC.Tools.URLParam("page") + "&Thread=" + ATC.Tools.URLParam("Thread");

                string rURL = RequestUrl.Url.OriginalString;
                string href = rURL.Substring(0, RequestUrl.Url.AbsoluteUri.IndexOf("Thread") + 10) + ATC.Tools.URLParam("Thread");

                if (DtView.Count > 0)
                {
                    DtView.RowFilter = filter;
                    int RowCounter = 0;

                    string sFieldName = string.Empty;
                    string sId = string.Empty;
                    string sParentId = string.Empty;
                    string sMessage = string.Empty;
                    string sImageUrl = string.Empty;
                    string state = string.Empty;

                    int iCount = 0;

                    for (RowCounter = 0; RowCounter <= DtView.Count - 1; RowCounter++)
                    {
                        TreeNode tn = new TreeNode();

                        if (ThreadViewPermission)
                        {
                            /* if post is published admins can unpublish or delete */
                            if (DtView[RowCounter]["IsPublished"].ToString() == "1")
                            {
                                state = "<span class='forum_link'><a href='"
                                      + href + "&PostAction=Reject&Post=" + DtView[RowCounter]["ID"].ToString()
                                      + "' class='admin_link'>Unpublish</a></span>&nbsp;-&nbsp;<span class='forum_link'><a href='"
                                      + href + "&PostAction=Delete&Post="
                                      + DtView[RowCounter]["ID"].ToString() + "' class='admin_link'>Delete</a></span>&nbsp;";
                            }
                            else // Post unpublished
                            {
                                state = "<span class='forum_link'><a href='"
                                      + href + "&PostAction=Accept&Post=" + DtView[RowCounter]["ID"].ToString()
                                      +  "' class='admin_link'>Re-publish</a></span>&nbsp;|&nbsp;<span class='forum_link'><a href='"
                                      + href + "&PostAction=Delete&Post="
                                      + DtView[RowCounter]["ID"].ToString() + "' class='admin_link'>Delete</a></span>&nbsp;";
                            }
                        }
                        sFieldName = DtView[RowCounter]["Subject"].ToString() + " " + state;
                        sId = DtView[RowCounter]["ID"].ToString();
                        sParentId = DtView[RowCounter]["ParentID"].ToString();
                        sMessage = DtView[RowCounter]["Message"].ToString();
                        sImageUrl = DtView[RowCounter]["PostType"].ToString();
                        sImageUrl = getImageIconUrl(sImageUrl);

                        tn.Text = sFieldName;
                        tn.Value = sId;

                        //tn.ToolTip = sMessage;
                        tn.ImageUrl = sImageUrl;

                        nodes.Add(tn);
                        tn.ToggleExpandState();

                        DataView vuData2 = new DataView(Data.Tables[0]);
                        if (DtView.Count > RowCounter)
                        {
                            BuildChildNodes(tn.ChildNodes, vuData2, ChildColumn + " = " +
                                DtView[RowCounter][ParentColumn], ThreadViewPermission, StartingPanel, ForumsTable);
                        }
                    }
                }
            }
        private void GetNodeForCompanyLevels(TreeNodeCollection nodes, int parentId)
        {
            Int32 thisId;
            string thisName;
            RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null);

            DataRow[] children = companyLevelsTDS.Tables["LFS_FM_COMPANYLEVEL"].Select("ParentID='" + parentId + "'");

            // No child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // Step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // Step 2
                thisName = Convert.ToString(child.ItemArray[1]);

                // Step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                // Step 4
                if (ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(Int32.Parse(hdfRuleId.Value), thisId))
                {
                    newNode.Checked = true;
                    arrayCompanyLevelsSelected.Add(int.Parse(newNode.Value));
                }

                // Step 5
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // Step 6
                GetNodeForCompanyLevels(newNode.ChildNodes, thisId);
            }
        }
		public void TreeNode_ToggleExpandState ()
		{
			TreeNode node = new TreeNode ("node");
			Assert.AreEqual (null, node.Expanded, "TreeNode_ToggleExpandState#1");
			node.ToggleExpandState ();
			Assert.AreEqual (true, node.Expanded, "TreeNode_ToggleExpandState#2");
			node.ToggleExpandState ();
			Assert.AreEqual (false, node.Expanded, "TreeNode_ToggleExpandState#3");
		}