Beispiel #1
0
    private void RefreshUserList()
    {
        UserList.Items.Clear();
        SnitzRoleProvider srp = new SnitzRoleProvider();
        srp.GetUsersInRole(txtName.Text);
        UserList.DataSource = srp.GetUsersInRole(txtName.Text);
        UserList.DataBind();

        UsersInRole.Text = String.Format("{0} User(s) in {1} Role", UserList.Items.Count, txtName.Text);
        NewUserForRole.Text = "";
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int avIndex = Convert.ToInt32(DropDownList1.SelectedValue);

        MultiView1.ActiveViewIndex = avIndex;

        SnitzRoleProvider srp = new SnitzRoleProvider();

        if (avIndex == 0) //Moderator View
        {
            if (ModeratorList.Items.Count == 0) // if the list has never been filled
            {

                ModeratorList.DataSource = srp.GetUsersInRole("Moderator");
                ModeratorList.DataTextField = "u.UserName";
                ModeratorList.DataValueField = "u.UserId";
                ModeratorList.DataBind();

                if (ModeratorList.SelectedItem == null)
                    ModeratorList.SelectedIndex = 0;
            }

            int memberId = Convert.ToInt32(ModeratorList.SelectedItem.Value);

            Dictionary<int, string> unForumList = Moderators.GetUnModeratedForumsIdNameList(memberId);
            AvForumsList.DataSource = unForumList;
            AvForumsList.DataTextField = "Value";
            AvForumsList.DataValueField = "Key";

            Dictionary<int, string> forumList = Moderators.GetModeratedForumsIdNameList(memberId);
            MdForumsList.DataSource = forumList;
            MdForumsList.DataTextField = "Value";
            MdForumsList.DataValueField = "Key";

        }
        else  // Forums View
        {
            if (ForumsList.Items.Count == 0)
            {

                ForumsList.DataSource = Forums.GetAllForums();
                ForumsList.DataTextField = "Subject";
                ForumsList.DataValueField = "Id";

                ForumsList.DataBind();

                if (ForumsList.SelectedItem == null)
                    ForumsList.SelectedIndex = 0;
            }

            int forumId = Convert.ToInt32(ForumsList.SelectedItem.Value);

            Dictionary<int, string> avList = Moderators.GetAvailableModeratorsIdName(forumId);
            AvModsList.DataSource = avList;
            AvModsList.DataTextField = "Value";
            AvModsList.DataValueField = "Key";

            Dictionary<int, string> mList = Moderators.GetCurrentModeratorsIdName(forumId);
            CurModsList.DataSource = mList;
            CurModsList.DataTextField = "Value";
            CurModsList.DataValueField = "Key";

        }

        Page.DataBind();
    }
Beispiel #3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteClick")
        {
            try
            {
                if (Roles.DeleteRole(e.CommandArgument.ToString(), !delPopRoles.Checked))
                {
                    errLbl2.Text = "Role deleted successfully.";
                    errLbl2.Visible = true;
                }
            }
            catch (ProviderException p)
            {
                errLbl2.Text = p.Message;
                errLbl2.Visible = true;
            }

            RoleTable.DataBind();
        }

        if (e.CommandName == "EditClick")
        {
            SnitzRoleProvider srp = new SnitzRoleProvider();

            int roleid = Convert.ToInt32(e.CommandArgument);
            RoleInfo role  = SnitzRoleProvider.GetRoleFull(roleid);

            txtRoleID.Text = roleid.ToString();
            txtName.Text = role.RoleName;
            txtDescription.Text = role.Description.ToString();
            UsersInRole.Text = String.Format("{0} User(s) in {1} Role", srp.GetUsersInRole(txtName.Text).Length, role.RoleName);
            RoleView.SetActiveView(viewEditRole);
            errLbl2.Visible = false;

            UserListPanel.Visible = (roleid > 1);
            RefreshUserList();
        }
    }