Beispiel #1
0
    protected void CreateRegionNodeItems(Region region, string personId)
    {
        IList <Site> sites            = SiteManager.GetAllSitesByRegion(region, false);
        string       parentRegionName = region.Name;
        string       parentRegionId   = region.Id;

        foreach (Site site in sites)
        {
            RadTreeNode node = new RadTreeNode(site.Name, site.Id);
            node.ImageUrl = "../App_Themes/Default/icons/site.png";

            Panel p = new Panel();
            p.ID       = "pnlNode";
            p.CssClass = "tvNode";

            Label lblName = new Label();
            lblName.ID   = "lblDivNodeName";
            lblName.Text = site.Name + "&nbsp;";

            Label lblContextMenu = new Label();
            lblContextMenu.CssClass = site.Id + "_tvContext hideElement";
            lblContextMenu.Text     = "<a href=# onclick=\"addSites('" + personId + "','" + site.Id.ToString() + "','" + site.Name.ToString() + "','Site');\">" +
                                      "<img src='../App_Themes/Default/icons/add.png' />Add Site Access</a>";

            p.Controls.Add(lblName);
            p.Controls.Add(lblContextMenu);
            node.Controls.Add(p);

            if (region != null)
            {
                RadTreeView1.FindNodeByValue(parentRegionId).Nodes.Add(node);
            }
        }
    }
    private double CalculateTotalReceived(IAccount account)
    {
        double received = 0;

        foreach (var inv in account.ErpReceivables)
        {
            if (inv.GrandTotal.HasValue)
            {
                received += inv.GrandTotal.Value;
            }
        }
        if (chkCascade.Checked)
        {
            var node = RadTreeView1.FindNodeByValue(account.Id.ToString());
            if (node != null && node.Nodes != null)
            {
                foreach (RadTreeNode kid in node.Nodes)
                {
                    var childAccount = EntityFactory.GetById <IAccount>(kid.Value);
                    if (childAccount != null)
                    {
                        received += CalculateTotalReceived(childAccount);
                    }
                }
            }
        }
        return(received);
    }
    protected void LoadTree(string activeNode, bool expand)
    {
        if (CurrentEntity == null)
        {
            return;
        }

        var groupHierarchy = Sage.SalesLogix.Account.Helpers.GetAccountHierarchy(CurrentEntity);

        RadTreeView1.DataTextField     = "Display";
        RadTreeView1.DataValueField    = "Id";
        RadTreeView1.DataFieldID       = "Id";
        RadTreeView1.DataFieldParentID = "ParentId";
        RadTreeView1.DataSource        = groupHierarchy;
        RadTreeView1.DataBind();

        if (expand)
        {
            RadTreeView1.ExpandAllNodes();
        }

        if (!string.IsNullOrEmpty(activeNode))
        {
            var radTreeNode = RadTreeView1.FindNodeByValue(activeNode);
            if (radTreeNode != null)
            {
                radTreeNode.Selected = true;
            }
        }
    }
Beispiel #4
0
 protected void RadTreeView1_DataBound(object sender, EventArgs e)
 {
     if (_hId > 0)
     {
         RadTreeNode node = RadTreeView1.FindNodeByValue("" + _hId);
         node.Selected = true;
         node.Expanded = true;
         node.ExpandParentNodes();
     }
 }
Beispiel #5
0
    private void AddChildNodes(BbTreeViewNode rootNode, RadTreeNode rootNodeRad)
    {
        foreach (BbTreeViewNode childNode in rootNode.ChildNodes)
        {
            RadTreeNode radChildNode = new RadTreeNode(childNode.Value + childNode.Menu, childNode.Id)
            {
                ImageUrl = childNode.Icon
            };

            RadTreeView1.FindNodeByValue(rootNodeRad.Value).Nodes.Add(radChildNode);

            if (childNode.IsBranch)
            {
                AddChildNodes(childNode, radChildNode);
            }
        }
    }
    private object[] GetAccountChildIds(IAccount account)
    {
        var accIds = new List <object> {
            account.Id.ToString()
        };
        var node = RadTreeView1.FindNodeByValue(account.Id.ToString());

        if (node != null && node.Nodes != null)
        {
            foreach (RadTreeNode kid in node.Nodes)
            {
                if (!accIds.Contains(kid.Value))
                {
                    var childAccount = EntityFactory.GetById <IAccount>(kid.Value);
                    accIds.AddRange(GetAccountChildIds(childAccount));
                }
            }
        }
        return(accIds.ToArray());
    }
Beispiel #7
0
    public void RebindNode(string id, bool showContextMenu)
    {
        RadTreeNode node = RadTreeView1.FindNodeByValue(id);
        Panel       pnl  = (Panel)node.FindControl("pnlNode");

        node.Selected = true;
        Label plbl = (Label)pnl.FindControl("lblContextMenu");

        if (showContextMenu)
        {
            plbl.CssClass = id + "_tvContext";
        }
        else
        {
            plbl.CssClass = id + "_tvContext hideElement";
        }

        RadTreeView1.DataBind();
        node.ExpandParentNodes();
    }
    private int CalculateQuotesCount(IAccount account)
    {
        var qCount = account.Quotes.Count;

        if (chkCascade.Checked)
        {
            var node = RadTreeView1.FindNodeByValue(account.Id.ToString());
            if (node != null && node.Nodes != null)
            {
                foreach (RadTreeNode kid in node.Nodes)
                {
                    var childAccount = EntityFactory.GetById <IAccount>(kid.Value);
                    if (childAccount != null)
                    {
                        qCount += CalculateQuotesCount(childAccount);
                    }
                }
            }
        }
        return(qCount);
    }
Beispiel #9
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        RadTreeNode n = RadTreeView1.FindNodeByValue(txtFile.Text);

        if (n.Category != "Folder")
        {
            string filed = "";
            int    size  = 0;

            string direc = txtFile.Text;
            string path  = direc.Substring(0, direc.LastIndexOf("\\"));
            string fild  = direc.Substring(path.Length);

            System.IO.FileInfo fi = new System.IO.FileInfo(direc);
            if (fi.Exists)
            {
                GC.Collect();
                fi.Attributes = FileAttributes.Normal;
                fi.Delete();
                createtree(path);
            }
        }
        else
        {
            string dir = txtFile.Text;
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dir);
            di.Attributes = FileAttributes.Normal;
            if (di.Exists)
            {
                GC.Collect();
                deletefilesfrfolder(dir);
                createtree(dir.Substring(0, dir.LastIndexOf("\\")));
            }
        }
        Session["delete"] = null;
    }
Beispiel #10
0
    protected void CreateRegionNode(Region region, bool isAdminBlock, IList <Region> userAdminRegions, string personId)
    {
        RadTreeNode node = new RadTreeNode(region.Name, region.Id);

        node.ImageUrl = "../App_Themes/Default/images/region.png";

        string id        = userAdminRegions.First <Region>(x => x.Id.Equals(region.Id)).Id;
        bool   hasAccess = false;

        if (!string.IsNullOrEmpty(id))
        {
            hasAccess = true;
        }

        Panel p = new Panel();

        p.ID       = "pnlNode";
        p.CssClass = "tvNode";

        Label lblName = new Label();

        lblName.ID   = "lblDivNodeName";
        lblName.Text = region.Name + "&nbsp;(" + SiteManager.GetAllSitesByRegion(region, true).Count.ToString() + ")&nbsp;";

        Label lblContextMenu = new Label();

        lblContextMenu.ID       = "lblContextMenu";
        lblContextMenu.CssClass = region.Id + "_tvContext hideElement";
        string regName = "\'" + Utilities.EscapeSpecialCharacters(region.Name.ToString()) + "\'";

        //create menu for the admin block
        if (isAdminBlock && hasAccess)
        {
            lblContextMenu.Text = "<a href=# class='edit' onclick=\"showEditRegionPopup('Region','" + region.Id.ToString() + "'," + regName + ",";

            string ParentCatId = string.Empty;
            string regParName  = string.Empty;
            if (region.ParentRegion != null)
            {
                regParName           = "\'" + Utilities.EscapeSpecialCharacters(region.ParentRegion.Name.ToString()) + "\'";
                lblContextMenu.Text += regParName + ",'Edit');\">Edit</a>&nbsp;";
                ParentCatId          = region.ParentRegion.Id;
            }  //edit link
            else
            {
                lblContextMenu.Text += "''" + "','Edit');\">Edit</a>&nbsp;";                                                                                                                 //edit link
            }
            lblContextMenu.Text += "<a href=# class='deleteitem' onclick=\"showDeleteRegionPopup('Region','" + region.Id.ToString() + "'," + regName + ",'','Delete');\">Delete</a>&nbsp;" + //delete link
                                   "<a href=# class='addRegion' onclick=\"showAddRegionPopup('Region','" + region.Id.ToString() + "',''," + regName + ",'Add');\">Create Region</a>&nbsp;" +
                                   "<a href=# class='addSite' onclick=\"showAddSitePopup('Site','" + region.Id.ToString() + "'," + regName + ",'','Site');\">" +
                                   "Create Site</a>";
        }
        //create menu for the non-admin block
        else
        {
            if (hasAccess)
            {
                lblContextMenu.Text = "<a href=# onclick=\"addSites('" + personId + "','" +
                                      region.Id.ToString() + "'," + regName + ",'Region');\">" +
                                      "<img src='../App_Themes/Default/icons/add.png' />Add Region Access</a>";
            }

            //don't allow drag and drop
            RadTreeView1.EnableDragAndDrop             = false;
            RadTreeView1.EnableDragAndDropBetweenNodes = false;
        }

        p.Controls.Add(lblName);
        p.Controls.Add(lblContextMenu);

        node.Controls.Add(p);

        if (region.ParentRegion != null)
        {
            if (userAdminRegions.FirstOrDefault <Region>(x => x.Id.Equals(region.ParentRegion.Id)) != null)
            {
                RadTreeView1.FindNodeByValue(region.ParentRegion.Id).Nodes.Add(node);
            }
            else
            {
                RadTreeView1.Nodes.Add(node);
            }
        }
        else
        {
            RadTreeView1.Nodes.Add(node);
        }
    }