Пример #1
0
        protected void treeCategories_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
        {
            FAQsController          FAQsController = new FAQsController();
            RadTreeNode             sourceNode     = e.SourceDragNode;
            RadTreeNode             destNode       = e.DestDragNode;
            RadTreeViewDropPosition dropPosition   = e.DropPosition;

            if (destNode == null || sourceNode == destNode || sourceNode.IsAncestorOf(destNode))
            {
                return;
            }

            int          sourceFaqCategoryId = Convert.ToInt32(sourceNode.Value);
            CategoryInfo sourceCategory      = FAQsController.GetCategory(sourceFaqCategoryId);

            int          destFaqCategoryId = Convert.ToInt32(destNode.Value);
            CategoryInfo destCategory      = FAQsController.GetCategory(destFaqCategoryId);

            switch (dropPosition)
            {
            case RadTreeViewDropPosition.Over:                     // child
                // Change Treeview
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.Nodes.Add(sourceNode);

                // Change the ParentId of Source in database
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryId;
                sourceCategory.ViewOrder           = 999;
                FAQsController.UpdateCategory(sourceCategory);
                break;

            case RadTreeViewDropPosition.Above:                     // sibling - above
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.InsertBefore(sourceNode);
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
                sourceCategory.ViewOrder           = destCategory.ViewOrder - 1;
                FAQsController.UpdateCategory(sourceCategory);

                break;

            case RadTreeViewDropPosition.Below:                     // sibling - below
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.InsertAfter(sourceNode);
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
                sourceCategory.ViewOrder           = destCategory.ViewOrder + 1;
                FAQsController.UpdateCategory(sourceCategory);
                break;
            }
            FAQsController.ReorderCategory(sourceCategory.FaqCategoryParentId, ModuleId);
            panelAddEdit.Visible = false;
        }
Пример #2
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void cmdUpdate_Click(Object sender, EventArgs e)
        {
            FAQsController faqsController = new FAQsController();
            CategoryInfo   categoryItem   = new CategoryInfo();
            PortalSecurity objSecurity    = new PortalSecurity();

            int parentCategoryId = Convert.ToInt32(drpParentCategory.SelectedValue);

            if (parentCategoryId < 0)
            {
                parentCategoryId = 0;
            }

            // We do not allow for script or markup
            categoryItem.FaqCategoryParentId    = parentCategoryId;
            categoryItem.FaqCategoryName        = objSecurity.InputFilter(txtCategoryName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
            categoryItem.FaqCategoryDescription = objSecurity.InputFilter(txtCategoryDescription.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
            categoryItem.ModuleId = ModuleId;

            try
            {
                RadTreeNode node = treeCategories.SelectedNode;
                if (node != null)
                {
                    categoryItem.FaqCategoryId = Convert.ToInt32(node.Value);
                    CategoryInfo originalCategoryItem = faqsController.GetCategory(categoryItem.FaqCategoryId);
                    categoryItem.ViewOrder = originalCategoryItem.ViewOrder;
                    faqsController.UpdateCategory(categoryItem);
                }
                else
                {
                    categoryItem.ViewOrder = 999;
                    faqsController.AddCategory(categoryItem);
                }
                faqsController.ReorderCategory(categoryItem.FaqCategoryParentId, ModuleId);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception exc)             //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #3
0
		/// <summary>
		/// Handles the Click event of the cmdUpdate control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
		protected void cmdUpdate_Click(Object sender, EventArgs e)
		{

			FAQsController faqsController = new FAQsController();
			CategoryInfo categoryItem = new CategoryInfo();
			PortalSecurity objSecurity = new PortalSecurity();

			int parentCategoryId = Convert.ToInt32(drpParentCategory.SelectedValue);
			if (parentCategoryId < 0) 
				parentCategoryId = 0;

			// We do not allow for script or markup
			categoryItem.FaqCategoryParentId = parentCategoryId;
			categoryItem.FaqCategoryName = objSecurity.InputFilter(txtCategoryName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
			categoryItem.FaqCategoryDescription = objSecurity.InputFilter(txtCategoryDescription.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
			categoryItem.ModuleId = ModuleId;

			try
			{
				RadTreeNode node = treeCategories.SelectedNode;
				if (node != null)
				{
					categoryItem.FaqCategoryId = Convert.ToInt32(node.Value);
					CategoryInfo originalCategoryItem = faqsController.GetCategory(categoryItem.FaqCategoryId);
					categoryItem.ViewOrder = originalCategoryItem.ViewOrder;
					faqsController.UpdateCategory(categoryItem);
				}
				else
				{
					categoryItem.ViewOrder = 999;
					faqsController.AddCategory(categoryItem);
				}
				faqsController.ReorderCategory(categoryItem.FaqCategoryParentId, ModuleId);
				Response.Redirect(Request.RawUrl);
			}
			catch (Exception exc) //Module failed to load
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}
Пример #4
0
		protected void treeCategories_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
		{
			FAQsController FAQsController = new FAQsController();
			RadTreeNode sourceNode = e.SourceDragNode;
			RadTreeNode destNode = e.DestDragNode;
			RadTreeViewDropPosition dropPosition = e.DropPosition;

			if (destNode == null || sourceNode == destNode || sourceNode.IsAncestorOf(destNode))
				return;
			
			int sourceFaqCategoryId = Convert.ToInt32(sourceNode.Value);
			CategoryInfo sourceCategory = FAQsController.GetCategory(sourceFaqCategoryId);

			int destFaqCategoryId = Convert.ToInt32(destNode.Value);
			CategoryInfo destCategory = FAQsController.GetCategory(destFaqCategoryId);

			switch (dropPosition)
			{
				case RadTreeViewDropPosition.Over: // child
					// Change Treeview
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.Nodes.Add(sourceNode);
						
					// Change the ParentId of Source in database
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryId;
					sourceCategory.ViewOrder = 999;
					FAQsController.UpdateCategory(sourceCategory);
					break;
				
				case RadTreeViewDropPosition.Above: // sibling - above
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.InsertBefore(sourceNode);
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
					sourceCategory.ViewOrder = destCategory.ViewOrder - 1;
					FAQsController.UpdateCategory(sourceCategory);
					
					break;
				
				case RadTreeViewDropPosition.Below: // sibling - below
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.InsertAfter(sourceNode);
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
					sourceCategory.ViewOrder = destCategory.ViewOrder + 1;
					FAQsController.UpdateCategory(sourceCategory);
					break;
			}
			FAQsController.ReorderCategory(sourceCategory.FaqCategoryParentId, ModuleId);
			panelAddEdit.Visible = false;
		}