private void SetupForm(CategoryInfo cat)
        {
            hdnCatId.Value = cat.Id.ToString();

            tbxSubject.Text = cat.Name;
            tbxOrder.Text = cat.Order.ToString();
            if (cat.ModerationLevel.HasValue) ddlMod.SelectedValue = cat.ModerationLevel.Value.ToString();
            #region Subscriptions
            if (Config.SubscriptionLevel > 0)
            {
                ddlSub.Items.Clear();
                ddlSub.Items.Add(new ListItem("No Subscriptions Allowed", "0"));
                if (Config.SubscriptionLevel < Enumerators.SubscriptionLevel.Forum)
                {
                    ddlSub.Items.Add(new ListItem("Category Subscriptions Allowed", "1"));
                }
                if (cat.SubscriptionLevel < (int)Enumerators.SubscriptionLevel.Topic)
                {
                    ddlSub.Items.Add(new ListItem("Forum Subscriptions Allowed", "2"));
                }
                ddlSub.Items.Add(new ListItem("Topic Subscriptions Allowed", "3"));
                ddlSub.SelectedValue = cat.SubscriptionLevel.ToString();

            }
            else
            {
                lblSub.Enabled = false;
                ddlSub.Enabled = false;
                ddlSub.Items.Clear();
                ddlSub.Items.Add(new ListItem("No Subscriptions Allowed", "0"));
                ddlSub.SelectedValue = "0";
            }
            #endregion
        }
Example #2
0
        public void Delete(CategoryInfo cat)
        {
            string strSql =
                "DELETE FROM " + Config.ForumTablePrefix + "A_REPLY WHERE CAT_ID = @CatId; " +
                "DELETE FROM " + Config.ForumTablePrefix + "A_TOPICS WHERE CAT_ID = @CatId; " +
                "DELETE FROM " + Config.ForumTablePrefix + "REPLY WHERE CAT_ID = @CatId; " +
                "DELETE FROM " + Config.ForumTablePrefix + "TOPICS WHERE CAT_ID=@CatId; " +
                "DELETE FROM " + Config.ForumTablePrefix + "FORUM WHERE CAT_ID=@CatId; " +
                "DELETE FROM " + Config.ForumTablePrefix + "CATEGORY WHERE CAT_ID=@CatId";

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, new SqlParameter("@CatId",SqlDbType.Int){Value = cat.Id});
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if(Data != null)
     {
         CategoryInfo cat = Categories.GetCategory(Convert.ToInt32(Data));
         SetupForm(cat);
     }
     else
     {
         var cat = new CategoryInfo();
         SetupForm(cat);
     }
 }
Example #4
0
 public static CategoryInfo CopyCategoryToBO(SqlDataReader rdr)
 {
     //CAT_ID, CAT_NAME, CAT_STATUS, CAT_MODERATION, CAT_SUBSCRIPTION, CAT_ORDER
     CategoryInfo category = new CategoryInfo
     {
         Id = rdr.GetInt32(0),
         Name = rdr.SafeGetString(1),
         Status = rdr.GetInt16(2),
         ModerationLevel = rdr.SafeGetInt32(3),
         SubscriptionLevel = rdr.SafeGetInt32(4),
         Order = rdr.GetInt32(5)
     };
     return category;
 }
Example #5
0
        public int Add(CategoryInfo cat)
        {
            string strSql = "INSERT INTO " + Config.ForumTablePrefix + "CATEGORY (CAT_NAME, CAT_STATUS, CAT_MODERATION, CAT_SUBSCRIPTION, CAT_ORDER) VALUES (@Name,@Status,@ModLevel,@SubsLevel,@Order); SELECT SCOPE_IDENTITY();";
            List<SqlParameter> parms = new List<SqlParameter>
                {
                    new SqlParameter("@Name", SqlDbType.NVarChar) {Value = cat.Name},
                    new SqlParameter("@Status", SqlDbType.Int) {Value = cat.Status},
                    new SqlParameter("@ModLevel", SqlDbType.Int) {Value = cat.ModerationLevel},
                    new SqlParameter("@SubsLevel", SqlDbType.Int) {Value = cat.SubscriptionLevel},
                    new SqlParameter("@Order", SqlDbType.Int) {Value = cat.Order}
                };

            return Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray()));
        }
Example #6
0
        public int Add(CategoryInfo cat)
        {
            string strSql = "INSERT INTO " + Config.ForumTablePrefix + "CATEGORY (CAT_NAME, CAT_STATUS, CAT_MODERATION, CAT_SUBSCRIPTION, CAT_ORDER) VALUES (@Name,@Status,@ModLevel,@SubsLevel,@Order)";
            List<OleDbParameter> parms = new List<OleDbParameter>
                {
                    new OleDbParameter("@Name", OleDbType.LongVarChar) {Value = cat.Name},
                    new OleDbParameter("@Status", OleDbType.Integer) {Value = cat.Status},
                    new OleDbParameter("@ModLevel", OleDbType.Integer) {Value = cat.ModerationLevel},
                    new OleDbParameter("@SubsLevel", OleDbType.Integer) {Value = cat.SubscriptionLevel},
                    new OleDbParameter("@Order", OleDbType.Integer) {Value = cat.Order}
                };

            return SqlHelper.ExecuteInsertQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
        }
Example #7
0
        public void Update(CategoryInfo cat)
        {
            string strSql = "UPDATE " + Config.ForumTablePrefix + "CATEGORY SET " +
                                  "CAT_NAME=@Name, CAT_STATUS=@Status, CAT_MODERATION=@ModLevel, CAT_SUBSCRIPTION=@SubsLevel, CAT_ORDER=@Order " +
                                  "WHERE CAT_ID=@CatId";
            List<SqlParameter> parms = new List<SqlParameter>
                {
                    new SqlParameter("@CatId", SqlDbType.Int) {Value = cat.Id},
                    new SqlParameter("@Name", SqlDbType.NVarChar) {Value = cat.Name},
                    new SqlParameter("@Status", SqlDbType.Int) {Value = cat.Status},
                    new SqlParameter("@ModLevel", SqlDbType.Int) {Value = cat.ModerationLevel},
                    new SqlParameter("@SubsLevel", SqlDbType.Int) {Value = cat.SubscriptionLevel},
                    new SqlParameter("@Order", SqlDbType.Int) {Value = cat.Order}
                };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
        }
Example #8
0
        private void AddDefaultData()
        {
            UpdateProgress(0,"Adding default data<br/>");
            //Add Admin Account
            string aUsername = adminUsername.Value ?? "Admin";
            string adminpassword = adminPassword.Value ?? "P@ssword01!!";
            string adminemail = adminEmail.Value ?? "*****@*****.**";

            MembershipCreateStatus status;
            MembershipUser admin = Membership.GetUser(aUsername);
            if (admin == null || admin.UserName != aUsername)
                admin = Membership.CreateUser(aUsername, adminpassword, adminemail, ".", ".", true, out status);
            Membership.UpdateUser(admin);
            Roles.AddUserToRoles(admin.UserName, new string[] { "Administrator", "Member" });

            var newadmin = "UPDATE FORUM_MEMBERS SET M_TITLE='Forum Administrator', M_SUBSCRIPTION=1,M_LEVEL=3,M_STATUS=1,M_HIDE_EMAIL = 1,M_RECEIVE_EMAIL = 1,M_VOTED = 0 WHERE M_NAME='" + aUsername + "'";
            Snitz.BLL.Admin.ExecuteScript(newadmin);
            Snitz.BLL.Admin.ExecuteScript("INSERT INTO FORUM_TOTALS (P_COUNT,P_A_COUNT,T_COUNT,T_A_COUNT,U_COUNT) VALUES (0,0,0,0,1)");
            CategoryInfo cat = new CategoryInfo();
            ForumInfo forum = new ForumInfo();
            TopicInfo topic = new TopicInfo();
            cat.Id = -1;
            cat.Name = "Snitz .Net Forums";
            cat.Order = 0;
            cat.Status = (int)Enumerators.PostStatus.Open;
            cat.SubscriptionLevel = 0;
            cat.ModerationLevel = 0;

            int catid = Categories.AddCategory(cat);

            forum.CatId = catid;
            forum.Id = -1;
            forum.Status = (int)Enumerators.PostStatus.Open;
            forum.AllowPolls = false;
            forum.Description = "This forum gives you a chance to become more familiar with how this product responds to different features and keeps testing in one place instead of posting tests all over. Happy Posting! [:)]";
            forum.Subject = "Testing Forum";
            forum.SubscriptionLevel = 0;
            forum.ModerationLevel = 0;
            forum.Order = 0;
            forum.PostCount = 0;
            forum.UpdatePostCount = true;

            int forumid = Forums.SaveForum(forum);

            topic.CatId = catid;
            topic.ForumId = forumid;
            topic.Status = 1;
            topic.Message = "Thank you for downloading Snitz Forums 2000. We hope you enjoy this great tool to support your organization!" + 0x13 + 0x10 + 0x13 + 0x10 + "Many thanks go out to John Penfold &lt;[email protected]&gt; and Tim Teal &lt;[email protected]&gt; for the original source code and to all the people of Snitz Forums 2000 at http://forum.snitz.com for continued support of this product.";
            topic.Subject = "Welcome to Snitz .Net Forums";
            topic.AuthorId = (int)admin.ProviderUserKey;
            topic.Date = DateTime.UtcNow;
            topic.PosterIp = "0.0.0.0";

            Topics.Add(topic);
        }
Example #9
0
 public static void DeleteCategory(CategoryInfo category)
 {
     ICategory dal = Factory<ICategory>.Create("Category");
     dal.Delete(category);
 }
Example #10
0
 public static int AddCategory(CategoryInfo category)
 {
     ICategory dal = Factory<ICategory>.Create("Category");
     return dal.Add(category);
 }