Beispiel #1
1
    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
        switch (e.MenuItem.Value)
        {

            case "NewFolder":
                if ((RadTreeView1.SelectedNode != null) && (RadTreeView1.SelectedNode.Level == 0))
                {
                    string newNodeTitle = ("New Folder");
                    e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                    e.Node.Category = "Folder";
                    e.Node.ImageUrl = "/admin/images/folder.gif";
                    e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                    e.Node.ContextMenuID = "MainContextMenu";
                    e.Node.Value = getpath(Request["pg"].ToString()) + "\\" + newNodeTitle;
                    e.Node.Expanded = true;
                    Directory.CreateDirectory(getpath(Request["pg"].ToString()) + "\\" + newNodeTitle);
                    createtree("");
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                else
                {
                    string newNodeTitle = string.Format("New Folder", e.Node.ParentNode.Nodes.Count + 1);
                    e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                    e.Node.Category = "Folder";
                    e.Node.ImageUrl = "/admin/images/folder.gif";
                    e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                    e.Node.ContextMenuID = "MainContextMenu";
                    e.Node.Value = getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle;
                    e.Node.Expanded = true;
                    Directory.CreateDirectory(getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle);
                    createtree(getpath(Request["pg"].ToString()) + (RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1)).Replace("/", "\\"));
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                break;

            case "Delete":

                break;

            case "Rename":

                if (RadTreeView1.SelectedNode != null)
                {
                    GC.Collect();
                    RadTreeNode nodeEdited = e.Node;
                    string oldtext = e.Node.Text;
                    string oldpath = e.Node.Value.Substring(0, e.Node.Value.LastIndexOf("\\") + 1);
                    string newText = e.Node.Text;

                    nodeEdited.Text = newText;

                    string newpath = nodeEdited.Value;
                    if (e.Node.Category == "Files")
                    {

                        getitemonserver(e.Node.Category, e.Node.Value, oldpath + newText);
                    }
                    else
                    {

                        getitemonserver(e.Node.Category, oldpath + oldtext, oldpath + newText);
                    }
                    System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(oldpath);
                    mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
                    createtree(oldpath.Substring(0, oldpath.LastIndexOf("\\")));
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                break;

        }
    }
Beispiel #2
0
        // treeview event handlers
        protected void rtvGCA_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Node.Value))
            {
                return;
            }
            Guid ID = new Guid(e.Node.Value);

            if (string.IsNullOrEmpty(e.MenuItem.Value))
            {
                return;
            }

            string[] command = e.MenuItem.Value.Split(' ');
            if (command.Length != 2)
            {
                return;
            }

            if (command[0] == "Delete")
            {
                Bll.GroupCategoryAspect.Delete(ID);
                GenerateTreeView();
            }
        }
protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            RadTreeNode clickedNode = e.Node;

            switch (e.MenuItem.Value)
            {
                case "NewRelation":
                    //RadTreeNode newRelation = new RadTreeNode(string.Format("Nieuwe Relatie {0}", clickedNode.Nodes.Count + 1));
                    //newRelation.Selected = true;
                    //newRelation.ImageUrl = clickedNode.ImageUrl;
                    //clickedNode.Nodes.Add(newRelation);
                    //clickedNode.Expanded = true;
                    ////update the number in the brackets
                    ////if (Regex.IsMatch(clickedNode.Text, unreadPattern))
                    ////    clickedNode.Text = Regex.Replace(clickedNode.Text, unreadPattern, "(" + clickedNode.Nodes.Count.ToString() + ")");
                    ////else
                    ////    clickedNode.Text += string.Format(" ({0})", clickedNode.Nodes.Count);
                    ////clickedNode.Font.Bold = true;
                    ////set node's value so we can find it in startNodeInEditMode
                    //newRelation.Value = newRelation.GetFullPath("/");
                    //startNodeInEditMode(newRelation.Value);
                    break;
                case "Verwijder":

                    if (clickedNode.ParentNode != null)
                    {
                        new ShareHolders().RemoveSubsidiary(clickedNode.ParentNode.Text, clickedNode.Text);
                        clickedNode.Remove();
                        IsUpdated = true;
                    }
                    break;
            }
        }
        protected void OnContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            TreeSearchInfo info = this.CreateFromQueryString();
            if (null != info && this.IsSelectable(info, e.Node))
            {
                SetSelectedNode(info, e.Node);

                Javascript.WriteDynamicClosePage(this, "_Close");
            }
        }
        protected void tvCat_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            RadTreeNode clickedNode = e.Node;

            if (e.MenuItem.Value == ContextMenuKey.ShowId.ToString())
            {
                IsShowNodeId = true;
                LoadData();
            }
            else if (e.MenuItem.Value == ContextMenuKey.HideId.ToString())
            {
                IsShowNodeId = false;
                LoadData();
            }
        }
Beispiel #6
0
        // treeview event handlers
        protected void rtvMetricCategory_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Node.Value))
            {
                return;
            }
            Guid ID = new Guid(e.Node.Value);

            if (string.IsNullOrEmpty(e.MenuItem.Value))
            {
                return;
            }
            string[] command = e.MenuItem.Value.Split(' ');
            if (command[0] == "Delete")
            {
                MetricTrac.Bll.MetricCategory.Delete(ID);
                GenerateTreeView();
            }
        }
Beispiel #7
0
 protected void rtv1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
 {
     if (hidCurrNavID.Value == string.Empty)
     {
         hidCurrNavID.Value = Request.Form[hidCurrNavID.UniqueID];
     }
     if (e.MenuItem != null)
     {
         if (e.MenuItem.Value == "NewNode")
         {
             string      newNodeValue = Guid.NewGuid().ToString();
             RadTreeNode rtN          = new RadTreeNode("NewFolder", newNodeValue);
             e.Node.ParentNode.Nodes.Add(rtN);
             AddNavNode("NewFolder", newNodeValue, e.Node.ParentNode.Value);
             ShowNodeEdit(newNodeValue, true);
             rtN.Selected = true;
             rtN.ExpandParentNodes();
             hidCurrentNodeValue.Value = newNodeValue;
         }
         else if (e.MenuItem.Value == "NewSubNode")
         {
             string      newNodeValue = Guid.NewGuid().ToString();
             RadTreeNode rtN          = new RadTreeNode("NewFolder", newNodeValue);
             e.Node.Nodes.Add(rtN);
             rtN.Selected = true;
             rtN.ExpandParentNodes();
             AddNavNode("NewFolder", newNodeValue, e.Node.Value);
             ShowNodeEdit(newNodeValue, true);
             hidCurrentNodeValue.Value = newNodeValue;
         }
         else if (e.MenuItem.Value == "DeleteNode")
         {
             RemoveNavNode(e.Node.Value);
             hidCurrentNodeValue.Value  = e.Node.ParentNode.Value;
             e.Node.ParentNode.Selected = true;
             e.Node.Remove();
         }
         else if (e.MenuItem.Value == "NewName")
         {
             ShowNaviNameEdit();
         }
     }
 }
        protected void CtlPagesContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            SelectedNode = e.Node.Value;

            var tabController = new TabController();
            var portalId = rblMode.SelectedValue == "H" ? Null.NullInteger : PortalId;
            var objTab = tabController.GetTab(int.Parse(e.Node.Value), portalId, false);

            switch (e.MenuItem.Value.ToLower())
            {
                case "makehome":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        var portalController = new PortalController();
                        PortalInfo portalInfo = portalController.GetPortal(PortalId);
                        portalInfo.HomeTabId = objTab.TabID;
                        PortalSettings.HomeTabId = objTab.TabID;
                        portalController.UpdatePortalInfo(portalInfo);
                        DataCache.ClearPortalCache(PortalId, false);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabMadeHome", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "view":
                    Response.Redirect(objTab.FullUrl);
                    break;
                case "edit":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        var editUrl = Globals.NavigateURL(objTab.TabID, "Tab", "action=edit", "returntabid=" + TabId);
                        // Prevent PageSettings of the current page in a popup if SSL is enabled and enforced, which causes redirection/javascript broswer security issues.
                        if (PortalSettings.EnablePopUps && !(objTab.TabID == TabId && (PortalSettings.SSLEnabled && PortalSettings.SSLEnforced)))
                        {
                            editUrl = UrlUtils.PopUpUrl(editUrl, this, PortalSettings, true, false);
                            var script = string.Format("<script type=\"text/javascript\">{0}</script>", editUrl);
                            ClientAPI.RegisterStartUpScript(Page, "EditInPopup", script);
                        }
                        else
                        {
                            Response.Redirect(editUrl, true);
                        }
                    }
                    break;
                case "delete":
                    if (TabPermissionController.CanDeletePage(objTab))
                    {
                        tabController.SoftDeleteTab(objTab.TabID, PortalSettings);
                        BindTree();
                        //keep the parent tab selected
                        if (objTab.ParentId != Null.NullInteger)
                        {
                            SelectedNode = objTab.ParentId.ToString(CultureInfo.InvariantCulture);
                            ctlPages.FindNodeByValue(SelectedNode).Selected = true;
                            ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes();
                            BindTab(objTab.ParentId);
                        }
                        else
                        {
                            pnlDetails.Visible = false;
                        }
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDeleted", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "add":
                    if ((objTab!= null && TabPermissionController.CanAddPage(objTab)) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
                    {
                        pnlBulk.Visible = true;
                        btnBulkCreate.CommandArgument = e.Node.Value;
                        ctlPages.FindNodeByValue(e.Node.Value).Selected = true;
                        txtBulk.Focus();
                        pnlDetails.Visible = false;
                        //Response.Redirect(NavigateURL(objTab.TabID, "Tab", "action=add", "returntabid=" & TabId.ToString), True)
                    }
                    break;
                case "hide":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabHidden", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "show":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabShown", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "disable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDisabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "enable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabEnabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
            }
        }
Beispiel #9
0
 /// <summary>
 /// Handles the OnContextMenuItemClick event of the rtvTreeMenu control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Telerik.Web.UI.RadTreeViewContextMenuEventArgs"/> instance containing the event data.</param>
 protected void rtvTreeMenu_OnContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
 {
     MenuActions(e.Node, e.MenuItem.Value, "");
 }
        protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            RadTreeNode clickedNode = e.Node;

            switch (e.MenuItem.Value)
            {
                case "AddFromRoot":
                   hdfType.Value = "Add";
                    break;
                case "Add":
                    hdfType.Value = "Add";
                    ddlServiceParent.ClearSelection();
                    ddlServiceParent.Items.FindByValue(clickedNode.ParentNode.Value).Selected = true;
                    LoadBehind();
                    break;
                case "AddChild":
                    hdfType.Value = "Add";
                    ddlServiceParent.ClearSelection();
                    ddlServiceParent.Items.FindByValue(clickedNode.Value).Selected = true;
                    LoadBehind();
                    break;
                case "Edit":
                    try
                    {
                        hdfType.Value = "Edit";
                        ddlServiceParent .ClearSelection();
                        ddlStatus.ClearSelection();
                        tbl_CategorysController ctl = new tbl_CategorysController(myConn );
                        tbl_CategorysInfo obj = ctl.Gettbl_Categorys(int.Parse(clickedNode.Value.Split('_')[2]));
                        if (obj != null)
                        {
                            ddlServiceParent.Items.FindByValue(clickedNode.ParentNode.Value).Selected = true;
                            ddlStatus.Items.FindByValue(clickedNode.Value.Split('_')[1]).Selected = true;
                            txt_name.Text = obj.Name;
                            txt_content.Value = obj.Content;
                            txt_image.Text = obj.Image;
                            hdfIdEdit.Value = clickedNode.Value;
                            LoadBehind();
                            if (clickedNode.Index > 0)
                            {
                                ddlBehind.ClearSelection();
                                ddlBehind.SelectedIndex = clickedNode.Index;
                            }
                        }
                    }
                    catch (Exception ex) { }
                    break;
                case "Delete":
                    break;
            }
        }
Beispiel #11
0
        void TreeView_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            string test = e.MenuItem.Value;

            switch (e.MenuItem.Value)
            {
                case "CopyHyperlink":
                    CopyHyperlink("test");
                    break;
                case "Subscribe":
                    //lblAbout.Text = Subscribe("test");
                    break;
                case "Lock":
                    LockItem("test");
                    break;
                case "Download":
                    DownloadFile(e.Node.FullPath, e.Node.Text);
                    break;
                default:
                    break;
            }
        }
Beispiel #12
0
        protected void Tree_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            List.Visible = false;
            if (e.MenuItem.Value.StartsWith("CREATE", StringComparison.OrdinalIgnoreCase))
            {
                string[] menuItemValues = e.MenuItem.Value.Split('_');
                bool     maxRestricted  = false;
                if (new Guid(e.Node.Value) != Guid.Empty)
                {
                    EntityNodeType ent = Entity.NodeTypes[menuItemValues[1]];
                    if (ent != null && ent.MaxRestrict > 0)
                    {
                        maxRestricted = IsRestricted(e.Node, menuItemValues[1], ent.MaxRestrict, this.Entity.HierarchyMaxDepth);
                    }
                }

                if (!maxRestricted)
                {
                    Guid        entityId = Bll.Providers.EntityNodeProvider.InsertEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, "new", new Guid(menuItemValues[1]), this.EntityId, new Guid(e.Node.Value), this.Entity.HierarchyStartLevel);
                    RadTreeNode rtn      = new RadTreeNode();
                    rtn.Text          = "new";
                    rtn.Value         = entityId.ToString("N");
                    rtn.Category      = menuItemValues[1];
                    rtn.ContextMenuID = "Menu" + menuItemValues[1];
                    e.Node.Nodes.Add(rtn);
                    e.Node.Expanded = true;
                    Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(entityId, rtn.GetFullPath(" > "));
                    StartNodeInEditMode(rtn.Value);
                }
                else
                {
                    RestrictErrorLabel.Text    = Resources.EntityControl_RestrictErrorLabel_Text;
                    RestrictErrorLabel.Visible = true;
                }
            }
            else if (e.MenuItem.Value.ToUpperInvariant() == "DELETE")
            {
                EntityNodeProvider.DeleteEntityNode(new Guid(e.Node.Value));
                Tree.FindNodeByValue(e.Node.Value).Remove();
            }
            else if (e.MenuItem.Value.ToUpperInvariant() == "CLONE")
            {
                Guid sourceId = new Guid(e.Node.Value);
                ClientDataSet.EntityNodeRow source = EntityNodeProvider.GetEntityNode(sourceId);

                if (source.IsParentEntityNodeIdNull())
                {
                    source.ParentEntityNodeId = Guid.Empty;
                }

                RadTreeNode rtn = new RadTreeNode();
                rtn.Text          = e.Node.Text + "_Copy" + (e.Node.ParentNode.Nodes.Count + 1).ToString(CultureInfo.InvariantCulture);
                rtn.Value         = EntityNodeProvider.InsertEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, rtn.Text, source.EntityNodeTypeId, source.EntityId, source.ParentEntityNodeId, this.Entity.HierarchyStartLevel).ToString();
                rtn.Category      = e.Node.Category;
                rtn.ContextMenuID = e.Node.ContextMenuID;
                e.Node.ParentNode.Nodes.Add(rtn);
                Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(new Guid(rtn.Value), rtn.GetFullPath(" > "));
                CloneNode(e.Node, rtn);
            }

            else if (e.MenuItem.Value == Resources.EntityControl_AddNodeType || e.MenuItem.Value == Resources.EntityControl_EditNodeType)
            {
                List.DataBind();
                List.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(e.MenuItem.Value))
                {
                    Response.Redirect(string.Format(CultureInfo.InvariantCulture, e.MenuItem.Value, e.Node.Value));
                }
            }
        }
        protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            RadTreeNode clickedNode = e.Node;


            var nodoA           = treeEstructura.Nodes[0];
            var hijosPrimerNodo = listEstructura.Where(x => x.Nivel == 1).ToList();

            if (e.MenuItem.Value.StartsWith("[ACYS]"))
            {
                var strValue = e.MenuItem.Value;
                strValue = strValue.Replace("[ACYS]", "");

                int idACYS = Int32.Parse(strValue);


                CN_CatCNac_Estructura cm_EstrACYS = new CN_CatCNac_Estructura(model);
                CatCNac_Estructura    estACYS     = new CatCNac_Estructura();
                if (clickedNode.Level == nivelMax && nivelMax >= 1)
                {
                    RadMenuItem itemPadre = ((RadMenuItem)(e.MenuItem.Owner));
                    itemPadre.Value = itemPadre.Value.Replace("Asignar", "");

                    estACYS.Id         = Int32.Parse(clickedNode.Value);
                    estACYS.Nivel_ACYS = 1;
                    estACYS.id_Acys    = idACYS;
                    int id       = cm_EstrACYS.CambiarNivel(estACYS);
                    var itemEstr = listEstructura.Where(x => x.Id == estACYS.Id).FirstOrDefault();
                    itemEstr.Nivel_ACYS = estACYS.Nivel_ACYS;
                    itemEstr.id_Acys    = idACYS;
                }
                else
                {
                    AsignarACYS(ref clickedNode, clickedNode.Level, idACYS);
                }

                AgregarControles(ref nodoA, hijosPrimerNodo, null);
            }
            else
            {
                switch (e.MenuItem.Value)
                {
                case "Nuevo":
                    RadTreeNode nodoNuevo = new RadTreeNode();
                    nodoNuevo.Selected = true;
                    nodoNuevo.ImageUrl = clickedNode.ImageUrl;
                    clickedNode.Nodes.Add(nodoNuevo);
                    clickedNode.Expanded = true;

                    //set node's value so we can find it in startNodeInEditMode
                    nodoNuevo.Value = "Nuevo - " + Guid.NewGuid().ToString();
                    StartNodeInEditMode(nodoNuevo.Value);

                    AgregarControles(ref nodoA, hijosPrimerNodo, nodoNuevo);

                    break;

                case "Asignar":
                    AsignarACYS(ref clickedNode, clickedNode.Level, 1);
                    AgregarControles(ref nodoA, hijosPrimerNodo, null);
                    break;

                case "Asignar1":

                    CN_CatCNac_Estructura cm_Estr1 = new CN_CatCNac_Estructura(model);
                    CatCNac_Estructura    est1     = new CatCNac_Estructura();

                    if (clickedNode.Level == nivelMax && nivelMax >= 1)
                    {
                        est1.Id         = Int32.Parse(clickedNode.Value);
                        est1.Nivel_ACYS = 1;
                        int id       = cm_Estr1.CambiarNivel(est1);
                        var itemEstr = listEstructura.Where(x => x.Id == est1.Id).FirstOrDefault();
                        itemEstr.Nivel_ACYS = 1;
                    }


                    AgregarControles(ref nodoA, hijosPrimerNodo, null);
                    break;

                case "Asignar2":

                    CN_CatCNac_Estructura cm_Estr2 = new CN_CatCNac_Estructura(model);
                    CatCNac_Estructura    est2     = new CatCNac_Estructura();

                    if (clickedNode.Level == nivelMax && nivelMax >= 2)
                    {
                        est2.Id         = Int32.Parse(clickedNode.Value);
                        est2.Nivel_ACYS = 2;
                        int id       = cm_Estr2.CambiarNivel(est2);
                        var itemEstr = listEstructura.Where(x => x.Id == est2.Id).FirstOrDefault();
                        itemEstr.Nivel_ACYS = 2;
                    }

                    AgregarControles(ref nodoA, hijosPrimerNodo, null);

                    break;

                case "Asignar3":

                    CN_CatCNac_Estructura cm_Estr3 = new CN_CatCNac_Estructura(model);
                    CatCNac_Estructura    est3     = new CatCNac_Estructura();

                    if (clickedNode.Level == nivelMax && nivelMax >= 3)
                    {
                        est3.Id         = Int32.Parse(clickedNode.Value);
                        est3.Nivel_ACYS = 3;
                        int id       = cm_Estr3.CambiarNivel(est3);
                        var itemEstr = listEstructura.Where(x => x.Id == est3.Id).FirstOrDefault();
                        itemEstr.Nivel_ACYS = 3;
                    }

                    AgregarControles(ref nodoA, hijosPrimerNodo, null);

                    break;

                case "Asignar4":

                    CN_CatCNac_Estructura cm_Estr4 = new CN_CatCNac_Estructura(model);
                    CatCNac_Estructura    est4     = new CatCNac_Estructura();

                    if (clickedNode.Level == nivelMax && nivelMax >= 4)
                    {
                        est4.Id         = Int32.Parse(clickedNode.Value);
                        est4.Nivel_ACYS = 4;
                        int id       = cm_Estr4.CambiarNivel(est4);
                        var itemEstr = listEstructura.Where(x => x.Id == est4.Id).FirstOrDefault();
                        itemEstr.Nivel_ACYS = 4;
                    }

                    AgregarControles(ref nodoA, hijosPrimerNodo, null);

                    break;

                case "Borrar":
                    clickedNode.Remove();

                    CN_CatCNac_Estructura cm_EstrA = new CN_CatCNac_Estructura(model);
                    var estrA = new CatCNac_Estructura();

                    estrA.Id = Int32.Parse(clickedNode.Value);

                    cm_EstrA.Borrar(estrA);
                    listEstructura.Remove(estrA);
                    AgregarControles(ref nodoA, hijosPrimerNodo, null);



                    break;

                default:

                    CN_CatCNac_Estructura cm_EstrD = new CN_CatCNac_Estructura(model);
                    CatCNac_Estructura    estD     = new CatCNac_Estructura();

                    if (clickedNode.Level == nivelMax && e.MenuItem.Value != "")
                    {
                        estD.Id             = Int32.Parse(clickedNode.Value);
                        estD.Sucursal       = Int32.Parse(e.MenuItem.Value);
                        estD.NombreSucursal = e.MenuItem.Text;
                        int id = cm_EstrD.CambiarSucursal(estD);

                        var itemEstr = listEstructura.Where(x => x.Id == estD.Id).FirstOrDefault();
                        itemEstr.Sucursal       = Int32.Parse(e.MenuItem.Value);
                        itemEstr.NombreSucursal = e.MenuItem.Text;
                    }

                    AgregarControles(ref nodoA, hijosPrimerNodo, null);
                    break;
                }
            }
        }
Beispiel #14
0
        protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            string commondName = e.MenuItem.Value;
            RadTreeNode clickedNode = e.Node;
            string cgid = clickedNode.Value;
            if (commondName.Equals("edit"))
            {
                if (cg.Exists(long.Parse(cgid)))
                {
                    string targetUrl = "CategoryDetail.aspx?CategoryID=" + cgid;
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "openRadWindow('" + targetUrl + "','SubModalWindow')", true);
                }
                else
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c3", "OpenAlert('抱歉,该分类已不存在!(请刷新!)');", true);
                }
            }
            else if (commondName.Equals("new"))
            {
                if (cg.Exists(long.Parse(cgid)))
                {
                    string targetUrl = "AddCategory.aspx?CategoryParentID=" + cgid;
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c2", "openRadWindow('" + targetUrl + "','SubModalWindow')", true);
                }
                else
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c3", "OpenAlert('抱歉,该分类已不存在!(请刷新!)');", true);
                }
            }
            else if (commondName.Equals("delete"))
            {
                if (!cg.Exists(long.Parse(cgid)))
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c3", "OpenAlert('抱歉,该分类已不存在!(请刷新!)');", true);
                }
                else
                {
                    if (cg.GetList(2, cgid).Tables[0].Rows.Count != 0)
                    {
                        RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c3", "OpenAlert('删除失败,仍含有子类的分类不能删除!');", true);
                    }
                    else
                    {
                        bool isDelete = true;
                        Model.Log logModel = new Model.Log();
                        logModel.OperationItem = "删除分类";
                        logModel.Operator = user.UserInfo.UserID;
                        logModel.OperationTime = DateTime.Now;
                        try
                        {
                            Model.Category cgModel = cg.GetModel(long.Parse(cgid));
                            logModel.OperationDetail = "分类编号:" + cgModel.AutoID + " - 分类名称:" + cgModel.CategoryName + " - 父类编号:" + cgModel.ParentCategoryID + " - 备注:" + cgModel.Memo;

                            isDelete = cg.Delete(long.Parse(cgid));
                            if (isDelete)
                            {
                                logModel.Memo = "成功";
                            }
                            else
                            {
                                logModel.Memo = "失败!";
                            }
                        }
                        catch (Exception ex)
                        {
                            logModel.Memo = "异常:" + ex.Message;
                        }
                        finally
                        {
                            log.Add(logModel);
                            if (isDelete)
                            {
                                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c4", "OpenAlert('删除成功!');", true);
                                e.Node.Remove();
                            }
                            else
                            {
                                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c5", "OpenAlert('删除失败!');", true);
                            }
                        }
                    }
                }
            }
        }
Beispiel #15
0
    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
        switch (e.MenuItem.Value)
        {
        case "NewFolder":
            if ((RadTreeView1.SelectedNode != null) && (RadTreeView1.SelectedNode.Level == 0))
            {
                string newNodeTitle = ("New Folder");
                e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                e.Node.Category         = "Folder";
                e.Node.ImageUrl         = "/admin/images/folder.gif";
                e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                e.Node.ContextMenuID    = "MainContextMenu";
                e.Node.Value            = getpath(Request["pg"].ToString()) + "\\" + newNodeTitle;
                e.Node.Expanded         = true;
                Directory.CreateDirectory(getpath(Request["pg"].ToString()) + "\\" + newNodeTitle);
                createtree("");
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            else
            {
                string newNodeTitle = string.Format("New Folder", e.Node.ParentNode.Nodes.Count + 1);
                e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                e.Node.Category         = "Folder";
                e.Node.ImageUrl         = "/admin/images/folder.gif";
                e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                e.Node.ContextMenuID    = "MainContextMenu";
                e.Node.Value            = getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle;
                e.Node.Expanded         = true;
                Directory.CreateDirectory(getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle);
                createtree(getpath(Request["pg"].ToString()) + (RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1)).Replace("/", "\\"));
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            break;

        case "Delete":

            break;

        case "Rename":

            if (RadTreeView1.SelectedNode != null)
            {
                GC.Collect();
                RadTreeNode nodeEdited = e.Node;
                string      oldtext    = e.Node.Text;
                string      oldpath    = e.Node.Value.Substring(0, e.Node.Value.LastIndexOf("\\") + 1);
                string      newText    = e.Node.Text;

                nodeEdited.Text = newText;

                string newpath = nodeEdited.Value;
                if (e.Node.Category == "Files")
                {
                    getitemonserver(e.Node.Category, e.Node.Value, oldpath + newText);
                }
                else
                {
                    getitemonserver(e.Node.Category, oldpath + oldtext, oldpath + newText);
                }
                System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(oldpath);
                mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
                createtree(oldpath.Substring(0, oldpath.LastIndexOf("\\")));
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            break;
        }
    }