Esempio n. 1
0
        public IEnumerable <FaqCategoryInfo> GetCategories(string lang)
        {
            string strSql = "SELECT FC_ID,FC_DESCRIPTION,FC_ORDER,FC_ROLES FROM " + Config.ForumTablePrefix + "FAQ_CAT WHERE FC_LANG_ID = @Lang ORDER BY FC_ORDER,FC_DESCRIPTION";
            List <FaqCategoryInfo> faqcategories = new List <FaqCategoryInfo>();

            OleDbParameter parm = new OleDbParameter("@Lang", OleDbType.VarChar)
            {
                Value = lang
            };

            //Execute a query to read the products
            using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, parm))
            {
                while (rdr.Read())
                {
                    FaqCategoryInfo faqcat = new FaqCategoryInfo
                    {
                        Id          = rdr.GetInt32(0),
                        Description = rdr.GetString(1),
                        Language    = lang,
                        Order       = rdr.GetInt32(2),
                        Roles       = rdr.SafeGetString(3)
                    };
                    faqcategories.Add(faqcat);
                }
            }
            return(faqcategories);
        }
Esempio n. 2
0
        public FaqCategoryInfo GetById(int catid)
        {
            string          strSql = "SELECT FC_ID,FC_DESCRIPTION,FC_ORDER,FC_LANG_ID,FC_ROLES FROM " + Config.ForumTablePrefix + "FAQ_CAT WHERE FC_ID = @CatId";
            FaqCategoryInfo faqcat = null;

            //Execute a query to read the products
            using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@CatId", OleDbType.Integer)
            {
                Value = catid
            }))
            {
                while (rdr.Read())
                {
                    faqcat = new FaqCategoryInfo
                    {
                        Id          = rdr.GetInt32(0),
                        Description = rdr.SafeGetString(1),
                        Language    = rdr.SafeGetString(3),
                        Order       = rdr.GetInt32(2),
                        Roles       = rdr.SafeGetString(4)
                    };
                }
            }
            return(faqcat);
        }
Esempio n. 3
0
 protected void BindQuestions(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         FaqCategoryInfo cat = (FaqCategoryInfo)e.Item.DataItem;
         if (!String.IsNullOrEmpty(cat.Roles) && !Roles.IsUserInRole(cat.Roles) && !IsAdministrator)
         {
             e.Item.Visible = false;
             return;
         }
         int id = 0;
         if (e.Item.FindControl("hdnCatId") != null)
         {
             id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hdnCatId")).Value);
         }
         if (e.Item.FindControl("FaqQuestions") != null)
         {
             Repeater fqr = ((Repeater)e.Item.FindControl("FaqQuestions"));
             if (fqr != null)
             {
                 if (!String.IsNullOrEmpty(Filter))
                 {
                     fqr.DataSource = SnitzFaq.FindFaqQuestion(Filter, CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                 }
                 else
                 {
                     fqr.DataSource = SnitzFaq.GetFaqQuestionsByCategory(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                 }
                 fqr.DataBind();
             }
         }
     }
 }
Esempio n. 4
0
        public void Update(FaqCategoryInfo faqcat)
        {
            string strSql = "UPDATE " + Config.ForumTablePrefix + "FAQ_CAT SET FC_DESCRIPTION=@Description,FC_ORDER=@Order,FC_LANG_ID=@Lang,FC_ROLES=@Roles WHERE FC_ID=@CatId";
            List <OleDbParameter> parms = new List <OleDbParameter>
            {
                new OleDbParameter("@Description", OleDbType.VarChar)
                {
                    Value = faqcat.Description
                },
                new OleDbParameter("@Order", OleDbType.Integer)
                {
                    Value = faqcat.Order
                },
                new OleDbParameter("@Lang", OleDbType.VarChar)
                {
                    Value = faqcat.Language
                },
                new OleDbParameter("@CatId", OleDbType.Integer)
                {
                    Value = faqcat.Id
                },
                new OleDbParameter("@Roles", OleDbType.Integer)
                {
                    Value = faqcat.Roles
                }
            };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
        }
Esempio n. 5
0
        public int Add(FaqCategoryInfo cat)
        {
            string strSql = "INSERT INTO " + Config.ForumTablePrefix + "FAQ_CAT (FC_DESCRIPTION,FC_ORDER,FC_LANG_ID,FC_ROLES) VALUES (@Description,@Order,@Lang,@Roles)";
            List <OleDbParameter> parms = new List <OleDbParameter>
            {
                new OleDbParameter("@Description", OleDbType.VarChar)
                {
                    Value = cat.Description
                },
                new OleDbParameter("@Order", OleDbType.Integer)
                {
                    Value = cat.Order
                },
                new OleDbParameter("@Lang", OleDbType.VarChar)
                {
                    Value = cat.Language
                },
                new OleDbParameter("@Roles", OleDbType.VarChar)
                {
                    Value = cat.Roles
                }
            };

            return(Convert.ToInt32(SqlHelper.ExecuteInsertQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray())));
        }
Esempio n. 6
0
        protected void SelectCategory(object sender, EventArgs e)
        {
            FaqCategoryInfo cat = SnitzFaq.GetCategory(ddlCategoryEdit.SelectedItem.Text);


            if (cat != null)
            {
                if (currentfaq == cat.Id)
                {
                    return;
                }
                currentfaq          = cat.Id;
                catDescription.Text = cat.Description;
                catLang.Text        = cat.Language;
                catOrder.Text       = cat.Order.ToString();
                catRole.Text        = cat.Roles;
            }
            else
            {
                currentfaq          = -1;
                catDescription.Text = "";
                catLang.Text        = "en";
                catOrder.Text       = "99";
                catRole.Text        = "";
            }
        }
Esempio n. 7
0
        public void Delete(FaqCategoryInfo faqcat)
        {
            string strSql = "DELETE FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_CAT=@CatId; DELETE FROM " + Config.ForumTablePrefix + "FAQ_CAT WHERE FC_ID=@CatId";

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@CatId", OleDbType.Integer)
            {
                Value = faqcat.Id
            });
        }
Esempio n. 8
0
        protected void DeleteCat(object sender, ImageClickEventArgs e)
        {
            FaqCategoryInfo cat = SnitzFaq.GetCategory(fcCategory.SelectedItem.Text);

            if (cat != null)
            {
                var questions = SnitzFaq.GetFaqQuestionsByCategory(cat.Id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                if (!questions.Any())
                {
                    SnitzFaq.DeleteFaqCategory(cat);
                    //refresh the category cache
                    Cache.Remove("faqcatlist");
                    Response.Redirect(this.Request.RawUrl);
                }
            }
        }
Esempio n. 9
0
        protected void SelectCategory(object sender, EventArgs e)
        {
            FaqCategoryInfo cat = SnitzFaq.GetCategory(fcCategory.SelectedItem.Text);

            if (cat != null)
            {
                fcTitle.Text = cat.Description;
                fcRoles.Text = cat.Roles;
                fcLang.Text  = cat.Language;
                fcOrder.Text = cat.Order.ToString();
            }
            else
            {
                fcTitle.Text = "";
                fcLang.Text  = "en";
                fcOrder.Text = "99";
                fcRoles.Text = "";
            }
        }
Esempio n. 10
0
        protected void SaveCat(object sender, ImageClickEventArgs e)
        {
            FaqCategoryInfo cat = SnitzFaq.GetCategory(fcTitle.Text) ?? new FaqCategoryInfo();

            cat.Description = fcTitle.Text;
            cat.Order       = Convert.ToInt32(fcOrder.Text);
            cat.Roles       = fcRoles.Text;
            cat.Language    = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
            if (cat.Id > 0)
            {
                SnitzFaq.UpdateFaqCategory(cat);
            }
            else
            {
                SnitzFaq.AddFaqCategory(cat);
            }

            //refresh the category cache
            Cache.Remove("faqcatlist");
            Response.Redirect(this.Request.RawUrl);
        }
Esempio n. 11
0
        protected void AddNewCategory(object sender, EventArgs e)
        {
            FaqCategoryInfo cat = SnitzFaq.GetCategory(catDescription.Text) ?? new FaqCategoryInfo();

            cat.Description = catDescription.Text;
            cat.Order       = Convert.ToInt32(catOrder.Text);
            cat.Roles       = catRole.Text;
            cat.Language    = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
            if (cat.Id > 0)
            {
                SnitzFaq.UpdateFaqCategory(cat);
            }
            else
            {
                SnitzFaq.AddFaqCategory(cat);
            }
            SetDefaultView();
            //refresh the category cache
            Cache.Remove("faqcatlist");
            Response.Redirect(this.Request.RawUrl);
        }
Esempio n. 12
0
        public static void DeleteFaqCategory(FaqCategoryInfo category)
        {
            IFaqCategory dal = Factory <IFaqCategory> .Create("Faq");

            dal.Delete(category);
        }
Esempio n. 13
0
        public static int AddFaqCategory(FaqCategoryInfo category)
        {
            IFaqCategory dal = Factory <IFaqCategory> .Create("Faq");

            return(dal.Add(category));
        }