Example #1
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 #2
0
 public void Initialize()
 {
     _categories = new Categories();
     _target     = new PrivateObject(_categories);
     _categories.AddCategory("test category");
     _target.Invoke("LoadCategoryProducts", new object[] { "../../../Product/testProducts.txt", 6 });
 }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string     category    = changeCombo.GetItemText(this.changeCombo.SelectedItem);
            string     newCategory = ChangeToField.Text;
            Validation v           = new Validation();

            if (Validation.textEmpty(category))
            {
                MessageBox.Show("Välj en kategori att ändra!");
            }
            else
            {
                if (v.IsNewCat(newCategory))
                {
                    Categories.RemoveCategory(category);
                    Categories.AddCategory(newCategory);
                    MessageBox.Show("Kategorin: " + category + " har ändrats till: " + newCategory);
                    Close();
                }
                else
                {
                    MessageBox.Show("Ändringen du angett är inte giltig!");
                }
            }
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        bool         res;
        CategoryInfo cat = catID.Value == "0" ? new CategoryInfo() : Categories.GetCategory(Convert.ToInt32(catID.Value));

        cat.Name              = txtName.Text;
        cat.Order             = Convert.ToInt32(txtOrder.Text);
        cat.Status            = Convert.ToInt32(catStatus.SelectedValue);
        cat.ModerationLevel   = Convert.ToInt32(catMod.SelectedValue);
        cat.SubscriptionLevel = Convert.ToInt32(catSub.SelectedValue);
        try
        {
            if (catID.Value == "0")
            {
                Categories.AddCategory(cat);
            }
            else
            {
                Categories.UpdateCategory(cat);
            }
            errLbl.Visible = false;
            Panel2.Visible = false;
            GridView1.DataBind();
        }
        catch (Exception)
        {
            errLbl.Text    = catID.Value == "0" ? "Error Adding Category" : "Error Updating Category";
            errLbl.Visible = false;
            throw;
        }
    }
Example #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Server2Client sc  = new Server2Client();
            Categories    cat = new Categories();
            Category      c   = new Category();

            c.CategoryID   = CID;
            c.CategoryName = txtCNM.Text.ToUpper();

            if (!IsEdit)
            {
                sc = cat.AddCategory(c);

                if (sc.Message == null)
                {
                    XtraMessageBox.Show("New Category added successfully!");
                }
                else
                {
                    XtraMessageBox.Show(sc.Message);
                }
                txtCNM.Text = "";
                txtCNM.Focus();
            }
            else
            {
                sc = cat.UpdateCategory(c);

                if (sc.Message == null)
                {
                    XtraMessageBox.Show("Category updated successfully!");
                }
                else
                {
                    XtraMessageBox.Show(sc.Message);
                }

                dp.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
            }
            LoadData();
        }
Example #6
0
 private static void TestValues()
 {
     Categories.AddCategory("Alcohol");
     Categories.AddCategory("Home");
     Categories.AddCategory("Food");
     Categories.AddCategory("Car");
     Categories.AddCategory("Sports");
     Categories.AddCategory("Goods");
     Categories.AddCategory("Medicine");
     Categories.AddCategory("Clothes");
     Categories.AddCategory("Mobile phone");
     Categories.AddCategory("Transportation");
     Categories.AddCategory("Taxi");
     Accounts.AddAccount("Visa", 500);
     Accounts.AddAccount("MasterCard", 300);
     Accounts.AddAccount("BolCart", 200);
     TransactionServicecs.Transfer("Visa", "Car", 200);
     TransactionServicecs.Transfer("Visa", "Clothes", 50);
     TransactionServicecs.Transfer("BolCart", "Taxi", 50);
     TransactionServicecs.Transfer("MasterCard", "Taxi", 100);
 }
        private void AddCategory()
        {
            string pattern = "^[A-Za-z0-9]{3,20}$";

            while (true)
            {
                categories.Show();
                Console.WriteLine(Literals.getLiterals("Input the name of category or it's identity describer , or 123 to exit"));
                string idName = Console.ReadLine();
                if (idName.CompareTo("123") == 0)
                {
                    Console.Clear(); break;
                }


                if (Regex.IsMatch(idName, pattern, RegexOptions.IgnoreCase))
                {
                    if (!Categories.CategoryExists(idName))
                    {
                        Categories.AddCategory(idName);
                        Console.Clear();
                        break;
                    }
                    else
                    {
                        Console.WriteLine(Literals.getLiterals("Category exists"));
                        Console.ReadKey(true);
                    }
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine(Literals.getLiterals("Invalid category pattern"));
                    Console.ReadKey(true);
                }
            }
        }
Example #8
0
        private void OKbtn_Click(object sender, EventArgs e)
        {
            Validation v        = new Validation();
            string     category = textBox1.Text;

            if (Validation.textEmpty(category))
            {
                MessageBox.Show("Ange en kategori att lägga till!");
            }
            else
            {
                if (v.IsNewCat(category))
                {
                    v.IsNewCat(category);
                    Categories.AddCategory(category);
                    MessageBox.Show("Kategorin: " + category + " har lagts till!");
                    Close();
                }
                else
                {
                    MessageBox.Show("Denna kategori finns redan!");
                }
            }
        }
Example #9
0
 public void AddCategoryTest()
 {
     _categories.AddCategory("add category");
     Assert.AreEqual(_categories.Count, 8);
 }