Example #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;
        }
Example #2
0
        private void EditCategory(int faqCategoryId)
        {
            FAQsController faqsController = new FAQsController();

            panelAddEdit.Visible = true;
            PopulateCategoriesDropDown(faqCategoryId);
            CategoryInfo categoryItem     = faqsController.GetCategory(faqCategoryId);
            int?         parentCategoryId = categoryItem.FaqCategoryParentId;

            drpParentCategory.SelectedValue = (parentCategoryId == null ? "-1" : parentCategoryId.ToString());
            txtCategoryName.Text            = categoryItem.FaqCategoryName;
            txtCategoryDescription.Text     = categoryItem.FaqCategoryDescription;
        }
Example #3
0
        public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            PropertyNotFound = false;
            FAQsController faqController;

            switch (strPropertyName.ToLower())
            {
            case "question":
                return(PropertyAccess.FormatString(Question, strFormat));

            case "answer":
                return(PropertyAccess.FormatString(Answer, strFormat));

            case "user":
                UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser));
                return(PropertyAccess.FormatString(user.DisplayName, strFormat));

            case "viewcount":
                return(ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "vieworder":
                return(ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "categoryname":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat));

            case "categorydesc":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat));

            case "datecreated":
                return(CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "datemodified":
                return(DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "index":
                return(Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            default:
                PropertyNotFound = true;
                return(String.Empty);
            }
        }
Example #4
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);
            }
        }
		/// <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);
			}
		}
		private void EditCategory(int faqCategoryId)
		{
			FAQsController faqsController = new FAQsController();
			panelAddEdit.Visible = true;
			PopulateCategoriesDropDown(faqCategoryId);
			CategoryInfo categoryItem = faqsController.GetCategory(faqCategoryId);
			int? parentCategoryId = categoryItem.FaqCategoryParentId;
			drpParentCategory.SelectedValue = (parentCategoryId == null ? "-1" : parentCategoryId.ToString());
			txtCategoryName.Text = categoryItem.FaqCategoryName;
			txtCategoryDescription.Text = categoryItem.FaqCategoryDescription;
		}
		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;
		}
Example #8
0
		public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
		{

			PropertyNotFound = false;
		    FAQsController faqController;
			switch (strPropertyName.ToLower())
			{
				case "question":
					return PropertyAccess.FormatString(Question, strFormat);
				case "answer":
					return PropertyAccess.FormatString(Answer, strFormat);
				case "user":
			        UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser));
					return PropertyAccess.FormatString(user.DisplayName, strFormat);
				case "viewcount":
					return ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				case "vieworder":
					return ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				case "categoryname":
                    faqController = new FAQsController();
                    return PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat);
				case "categorydesc":
                    faqController = new FAQsController();
                    return PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat);
				case "datecreated":
					return CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider);
				case "datemodified":
					return DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider);
				case "index":
					return Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				default:
					PropertyNotFound = true;
					return String.Empty;
			}
		}