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;
            }
        }
    }
    private void LoadCategory()
    {
        DAProductCat daProductCat = new DAProductCat();

        RadTreeView1.DataSource = daProductCat.USP_ProductCat_GetBelongDiscountID(this.KeyID);
        RadTreeView1.DataBind();
    }
示例#3
0
    protected void DeleteRegionClick(object sender, EventArgs e)
    {
        string       regionID       = popDeleteRegion.ReferrerId;
        Region       region         = SiteManager.GetRegionById(regionID);
        Region       parentRegion   = region.ParentRegion;
        string       regionName     = region.Name;
        string       regionTypeName = region.GetType().Name;
        IList <Site> sites          = SiteManager.GetAllSitesByRegion(region, true);

        if (sites.Count == 0)
        {
            SiteManager.DeleteRegion(region);
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                regionTypeName,
                Feedback.Actions.Deleted,
                regionName
                );

            PopulateTreeView <Region>(SiteManager.GetAllRegions(), true, false, string.Empty);
            RadTreeView1.DataBind();

            RadTreeView1.FindNodeByText(parentRegion.Name).Selected = true;
        }
        else
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                region.GetType().Name,
                Feedback.Actions.Error,
                ErrorRegionNotEmpty
                );
        }
    }
    override protected Boolean LoadData()
    {
        try
        {
            if (ddlRGroup.Items.Count > 0)
            {
                Int32 iRGroup;
                iRGroup = Convert.ToInt32(ddlRGroup.SelectedValue);

                int UserID = int.Parse(MyConfig.GetValueByKey("UserID"));

                DataSet ds = new DataSet();
                ds = tData.USP_WebFunction_GetListByGroupIDAndUserID(iRGroup, UserID);
                RadTreeView1.DataSource = ds;
                RadTreeView1.DataBind();


                //
            }
        }
        catch (Exception ex)
        {
            ShowErrorMes("Lỗi hệ thống: " + ex.Message);
        }

        return(true);
    }
示例#5
0
    protected void AddRegionClick(object sender, EventArgs e)
    {
        Region newRegion = new Region();

        newRegion.Name = popAddRegion.Value;

        newRegion.ParentRegion = SiteManager.GetRegionById(popAddRegion.ReferrerId);
        IList <RegionType> regionTypes = SiteManager.GetAllRegionTypes();
        RegionType         regionType  = regionTypes.Last();

        newRegion.RegionType = regionType;
        if (!SiteManager.IsRegionUnique(newRegion))
        {
            ((IFeedback)this.Page.Master).SetError(GetType(), "The region is not unique within its parent region");
            return;
        }
        SiteManager.CreateRegion(newRegion);

        PopulateTreeView <Region>(SiteManager.GetAllRegions(), true, false, string.Empty);
        RadTreeView1.DataBind();

        RadTreeView1.FindNodeByText(newRegion.Name).ExpandParentNodes();
        RadTreeView1.FindNodeByText(newRegion.ParentRegion.Name).Selected = true;

        ((IFeedback)this.Page.Master).ShowFeedback(
            BusiBlocksConstants.Blocks.Administration.LongName,
            newRegion.GetType().Name,
            Feedback.Actions.Created,
            newRegion.Name
            );
    }
示例#6
0
    protected void AddSiteClick(object sender, EventArgs e)
    {
        string regionId = popAddSite.ReferrerId;
        string siteName = popAddSite.Value;

        // If this site name already exists, then error
        if (SiteManager.GetSiteByName(siteName) != null)
        {
            ((IFeedback)Page.Master).ShowFeedback(Feedback.Actions.Error, "Site " + siteName + " already exists");
        }
        else
        {
            Region region = SiteManager.GetRegionById(regionId);
            Site   site   = new Site();
            site.Name     = siteName;
            site.Region   = region;
            site.SiteType = SiteManager.GetAllSiteTypes().First();
            SiteManager.CreateSite(site);

            this.PopulateTreeView <Region>(SiteManager.GetAllRegions(), true, false, string.Empty);

            RadTreeView1.DataBind();
            RadTreeView1.FindNodeByText(region.Name).ExpandParentNodes();
            RadTreeView1.FindNodeByText(region.Name).Selected = true;

            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                site.GetType().Name,
                Feedback.Actions.Created,
                site.Name
                );
        }
    }
示例#7
0
    private IList <SortStruct> Add0Levels(IList <SortStruct> sortList, bool isAdmin, bool showNodeItems)
    {
        IList <SortStruct> oLevels = new List <SortStruct>();

        // An 0 level item is one whose parent is null, or who's parent is not in the sort list.
        foreach (SortStruct item in sortList)
        {
            if (string.IsNullOrEmpty(item.ParentId) || sortList.FirstOrDefault(x => x.Id.Equals(item.ParentId)) == null)
            {
                oLevels.Add(item);
            }
        }

        // Add 0levels to the tree view.
        foreach (SortStruct sortItem in oLevels)
        {
            Type originalType = sortItem.OriginalType;

            if (sortItem.OriginalType.FullName.Contains("News"))
            {
                BusiBlocks.CommsBlock.News.Category category = sortItem.Original as BusiBlocks.CommsBlock.News.Category;
                CreateCategoryNode(category, isAdmin);
            }
            else if (sortItem.OriginalType.FullName.Contains("Doco"))
            {
                BusiBlocks.DocoBlock.Category category = sortItem.Original as BusiBlocks.DocoBlock.Category;
                CreateCategoryNode(category, isAdmin);
            }
        }

        // Databind so that the children can find their parents in the tree view.
        RadTreeView1.DataBind();
        return(oLevels);
    }
示例#8
0
    protected void CreateRegionTreeView <T>(IList <T> regionDatasource, bool isAdmin, bool showNodeItems, string personId)
    {
        IList <Region> regions     = (IList <Region>)regionDatasource;
        Person         person      = PersonManager.GetPersonByUserName(Page.User.Identity.Name);
        IList <Region> userRegions = PersonManager.GetAdminRegionsByPerson(person, true);

        bool isSuperAdmin           = false;
        IList <PersonType> myGroups = PersonManager.GetPersonTypesByUser(Page.User.Identity.Name);

        if (myGroups.FirstOrDefault(x => x.Name.Equals(BusiBlocksConstants.AdministratorsGroup)) != null)
        {
            isSuperAdmin = true;
            userRegions  = SiteManager.GetAllRegions();
        }
        //add root node
        var rootNode = from x in regions
                       where x.ParentRegion == null
                       select x;

        IEnumerable <Region> rootNodes = rootNode;

        foreach (Region r in rootNodes)
        {
            if (isSuperAdmin == false)
            {
                if (userRegions.FirstOrDefault <Region>(x => x.Id.Equals(r.Id)) != null)
                {
                    AddSubNode(r, isAdmin, showNodeItems, userRegions, personId);
                }
            }
            else
            {
                AddSubNode(r, isAdmin, showNodeItems, userRegions, personId);
            }
        }
        RadTreeView1.DataBind();

        //add sub nodes
        var subNode = from x in regions
                      where x.ParentRegion != null
                      select x;

        IEnumerable <Region> subNodes = subNode;

        foreach (Region r in subNodes)
        {
            if (isSuperAdmin == false)
            {
                if (userRegions.FirstOrDefault <Region>(x => x.Id.Equals(r.Id)) != null)
                {
                    AddNodes(r, isAdmin, showNodeItems, userRegions, personId);
                }
            }
            else
            {
                AddNodes(r, isAdmin, showNodeItems, userRegions, personId);
            }
        }
    }
示例#9
0
    public void BindTree()
    {
        ProductManager manager = new ProductManager(this);
        DataTable      table   = manager.GetProductPartsByCompany((int)Company.MatrixId).Sort("ParentId").ToDataTable();

        RadTreeView1.DataSource = table;
        RadTreeView1.DataBind();

        lblDelete.Visible = RadTreeView1.Nodes.Count > 0;
        btnDelete.Visible = RadTreeView1.Nodes.Count > 0;
    }
示例#10
0
    protected void AddCategoryClick(object sender, EventArgs e)
    {
        string categoryName     = popAddCategory.Value;
        string categoryId       = popAddCategory.ReferrerId;
        string categoryTypeName = string.Empty;

        // Need to figure out if this is a comms block category or a doco block category.
        if (!string.IsNullOrEmpty(categoryId))
        {
            BusiBlocks.CommsBlock.News.Category news = null;
            try
            {
                news             = NewsManager.GetCategory(categoryId);
                categoryTypeName = news.GetType().Name;
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                BusiBlocks.CommsBlock.News.Category childCategory = NewsManager.CreateCategory(categoryName);
                childCategory.ParentCategory = news;
                NewsManager.UpdateCategory(childCategory);
                this.PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetAllCategories(), true, false, string.Empty);
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco             = DocoManager.GetCategory(categoryId);
                    categoryTypeName = doco.GetType().Name;
                }
                catch (DocoCategoryNotFoundException) { }
                if (doco != null)
                {
                    BusiBlocks.DocoBlock.Category childDocoCategory = DocoManager.CreateCategory(categoryName);
                    childDocoCategory.ParentCategory = doco;
                    DocoManager.UpdateCategory(childDocoCategory);
                    this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                }
            }
            RadTreeView1.DataBind();
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;

            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Created,
                categoryName
                );
        }
    }
示例#11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Session["idNV"] = null;
     if (!IsPostBack)
     {
         var TreeData = _entities.CoCauToChucs;
         RadTreeView1.DataTextField     = "TenDonVi";
         RadTreeView1.DataFieldID       = "IDCoCauToChuc";
         RadTreeView1.DataFieldParentID = "IDParent";
         RadTreeView1.DataSource        = TreeData;
         RadTreeView1.DataBind();
         RadTreeView1.Nodes[0].Selected = true;
         RadTreeNodeEventArgs tne = new RadTreeNodeEventArgs(RadTreeView1.Nodes[0]);
         RadTreeView1_Nodeclick(sender, tne);
     }
 }
示例#12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var dt = _entities.GetAllCVUngVien();
         RadGrid1.DataSource = dt;
         RadGrid1.DataBind();
         RadGrid1.Items[0].Selected = true;
         GridDataItem item       = RadGrid1.Items[0];
         Int32        IDNhanVien = Int32.Parse(item["IDNhanVien"].Text);
         FillCurrentEmployeeDetail(IDNhanVien);
         var TreeData = _entities.GetDotTuyenDung();
         RadTreeView1.DataTextField     = "TenDotTuyenDung";
         RadTreeView1.DataFieldID       = "IDDotTuyenDung";
         RadTreeView1.DataFieldParentID = "IDParent";
         RadTreeView1.DataSource        = TreeData;
         RadTreeView1.DataBind();
     }
 }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /*if (Session["UserID"] != null )*/ CheckPermis();

            if (!IsPostBack)
            {
                // fill data treeview
                var TreeData = from k in _entities.CoCauToChucs
                               select k;
                RadTreeView1.DataTextField     = "TenDonVi";
                RadTreeView1.DataFieldID       = "IDCoCauToChuc";
                RadTreeView1.DataFieldParentID = "IDParent";
                RadTreeView1.DataSource        = TreeData;
                RadTreeView1.DataBind();
                RadTreeView1.Nodes[0].Selected = true;
                RadTreeNodeEventArgs tne = new RadTreeNodeEventArgs(RadTreeView1.Nodes[0]);
                RadTreeView1_Nodeclick(sender, tne);
            }
        }
示例#14
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();
    }
示例#15
0
    protected void DeleteCategoryClick(object sender, EventArgs e)
    {
        string categoryName       = string.Empty;
        string categoryId         = popDeleteCategory.ReferrerId;
        string categoryTypeName   = string.Empty;
        string parentCategoryName = string.Empty;
        bool   deleteFailure      = false;

        // Need to figure out if this is a comms block category or a doco block category.
        if (!string.IsNullOrEmpty(categoryId))
        {
            BusiBlocks.CommsBlock.News.Category news = null;
            try
            {
                news = NewsManager.GetCategory(categoryId);
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                categoryTypeName = news.GetType().Name;
                categoryName     = news.Name;

                // Don't allow the root category to be deleted.
                if (news.ParentCategory == null)
                {
                    ((IFeedback)this.Page.Master).ShowFeedback(
                        BusiBlocksConstants.Blocks.Administration.LongName,
                        news.Name,
                        Feedback.Actions.Error,
                        "Cannot delete the highest level category"
                        );
                    return;
                }

                parentCategoryName = news.ParentCategory.Name;
                IList <BusiBlocks.CommsBlock.News.Item>     newsItems         = NewsManager.GetItems(news, true);
                IList <BusiBlocks.CommsBlock.News.Category> newsSubCategories = NewsManager.GetCategories(news.Id, true);
                // NewsManager.GetCategories returns the root category, so it will always have at least one item
                if (newsSubCategories.Count <= 1 && newsItems.Count == 0)
                {
                    NewsManager.DeleteCategory(news);
                    PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetViewableCategories(Page.User.Identity.Name), true, false, string.Empty);
                }
                else
                {
                    deleteFailure = true;
                }
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco = DocoManager.GetCategory(categoryId);
                }
                catch (DocoCategoryNotFoundException) { }

                if (doco != null)
                {
                    categoryTypeName   = doco.GetType().Name;
                    categoryName       = doco.DisplayName;
                    parentCategoryName = doco.ParentCategory.DisplayName;

                    IList <Article> docoItems = DocoManager.GetArticles(doco, ArticleStatus.All, true);
                    IList <BusiBlocks.DocoBlock.Category> docoSubCategories = DocoManager.GetAllCategoriesBelow(doco.Id);
                    if (docoSubCategories.Count == 0 && docoItems.Count == 0)
                    {
                        DocoManager.DeleteCategory(doco);
                        this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                    }
                    else
                    {
                        deleteFailure = true;
                    }
                }
            }
            RadTreeView1.DataBind();
        }
        //Displaying feedback.
        if (deleteFailure)
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Error,
                ErrorCategoryNotEmpty
                );
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;
        }
        else
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Deleted,
                categoryName
                );
            RadTreeView1.FindNodeByText(parentCategoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(parentCategoryName).Selected = true;
        }
    }