Пример #1
0
        protected void AddStudentLinkButton_Click(object sender, EventArgs e)
        {
            StudentListPanel.Visible = false;
            AddStudentPanel.Visible  = true;

            DuckIDTextBox.Text           = "";
            FirstNameTextBox.Text        = "";
            LastNameTextBox.Text         = "";
            AddStudentLinkButton.Visible = false;
            SendWelcomeToAllStudentsLinkButton.Visible = false;
            DeleteAllStudentsLinkButton.Visible        = false;

            ProgrammingLanguagesDropDownList.DataSource = GrouperMethods.GetLanguages();
            ProgrammingLanguagesDropDownList.DataBind();

            RolesDropDownList.DataSource = GrouperMethods.GetRoles();
            RolesDropDownList.DataBind();

            SkillsDropDownList.DataSource = GrouperMethods.GetSkills();
            SkillsDropDownList.DataBind();

            RolesGridView.DataSource = null;
            RolesGridView.DataBind();

            ProgrammingLanguagesGridView.DataSource = null;
            ProgrammingLanguagesGridView.DataBind();

            SkillsGridView.DataSource = null;
            SkillsGridView.DataBind();

            ProgrammingLanguagesDropDownList.DataSource = GrouperMethods.GetLanguages();
            ProgrammingLanguagesDropDownList.DataBind();
        }
Пример #2
0
    private void renderRolesGridView(string memberId)
    {
        HideMessage();
        try
        {
            if (!String.IsNullOrEmpty(memberId))
            {
                LoadAndMergeRefAndMemberRoles(int.Parse(memberId.Trim()));

                if (GlobalLists.MemberRoles.Count == 0)
                {
                    //hide grids
                    ValidateGridDisplayParameters(-1);
                    ShowMessage(GlobalMessages.sMSG_NO_USERROLES_WARNING);
                }
                else
                {
                    RolesGridView.DataSource = GlobalLists.MemberRoles;
                    RolesGridView.DataBind();
                }
            }
            else
            {
                ShowMessage(String.Format(GlobalMessages.sMSG_EMPTYPARAM, "Member id"));
            }
        }
        catch (Exception ex)
        {
            logger.Error("Exception in uc_MemberDetail.renderOrganizationsGridView:" + ex.Message);
            ShowMessage(String.Format(GlobalMessages.sMSG_WARNING, ex.Message));
        }
    }
Пример #3
0
        protected void AddRoleLinkButton_Click(object sender, EventArgs e)
        {
            int roleID = int.Parse(RolesDropDownList.SelectedValue);

            if (ViewState["Roles"] != null)
            {
                List <Role> roles = (List <Role>)ViewState["Roles"];

                Role role = new Role();
                role.Name          = RolesDropDownList.SelectedItem.Text;
                role.RoleID        = int.Parse(RolesDropDownList.SelectedValue);
                role.InterestLevel = int.Parse(RoleInterestDropDownList.SelectedValue);

                ((List <Role>)ViewState["Roles"]).Add(role);

                RolesGridView.DataSource = (List <Role>)ViewState["Roles"];
                RolesGridView.DataBind();

                RolesDropDownList.Items.FindByValue(role.RoleID.ToString()).Enabled = false;
            }
            else
            {
                ViewState["Roles"] = new List <Role>();
                Role role = new Role();
                role.Name          = RolesDropDownList.SelectedItem.Text;
                role.RoleID        = int.Parse(RolesDropDownList.SelectedValue);
                role.InterestLevel = int.Parse(RoleInterestDropDownList.SelectedValue);

                ((List <Role>)ViewState["Roles"]).Add(role);

                RolesGridView.DataSource = (List <Role>)ViewState["Roles"];
                RolesGridView.DataBind();
                RolesDropDownList.Items.FindByValue(role.RoleID.ToString()).Enabled = false;
            }
        }
Пример #4
0
 protected void RolesGridView_Sorting(object sender, GridViewSortEventArgs e)
 {
     SetSortDirection(SortDireaction);
     if (GlobalLists.MemberRoles.Count > 1)
     {
         //Sort the data.
         var prop = typeof(vMemberRoleModel).GetProperty(e.SortExpression);
         List <vMemberRoleModel> sortedRefAndMemberRoles;
         if (_sortDirection == "ASC")
         {
             sortedRefAndMemberRoles = GlobalLists.MemberRoles.OrderBy(ll => prop.GetValue(ll, null)).ToList();
         }
         else
         {
             sortedRefAndMemberRoles = GlobalLists.MemberRoles.OrderByDescending(ll => prop.GetValue(ll, null)).ToList();
         }
         RolesGridView.DataSource = sortedRefAndMemberRoles;
         RolesGridView.DataBind();
         SortDireaction = _sortDirection;
         int columnIndex = 0;
         foreach (DataControlFieldHeaderCell headerCell in RolesGridView.HeaderRow.Cells)
         {
             if (headerCell.ContainingField.SortExpression == e.SortExpression)
             {
                 columnIndex = RolesGridView.HeaderRow.Cells.GetCellIndex(headerCell);
             }
         }
         RolesGridView.HeaderRow.Cells[columnIndex].Controls.Add(sortImage);
     }
 }
Пример #5
0
 protected void RolesGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     RolesGridView.DataSource = GlobalLists.MemberRoles;
     RolesGridView.PageIndex  = e.NewPageIndex;
     RolesGridView.DataBind();
     GlobalUtils.SetAccessToControls(this.Page, SaltShakerSession.CurrentRole);
 }
Пример #6
0
        void LoadRoles()
        {
            string siteID = SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty;

            RolesGridView.DataSource = AccountHelper.GetRoles(siteID, OwnerRank.All, string.Empty);
            RolesGridView.DataBind();
        }
Пример #7
0
        public void BindGridView()
        {
            ForumService service = new ForumService();

            RolesGridView.DataSource = service.FetchForumDspModel();
            RolesGridView.DataBind();
        }
Пример #8
0
        /// <summary>
        /// 加载角色
        /// </summary>
        void LoadRoles()
        {
            if (AdvicePager.Count < 0)
            {
                AdvicePager.PageIndex = 0;
            }
            AdvicePager.FreshMyself();
            List <Role> roleList = new List <Role>();
            string      siteID   = SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty;

            AdvicePager.RecorderCount = AccountHelper.GetRoleCount(siteID, OwnerRank.All);
            roleList = AccountHelper.GetRoles(siteID, AdvicePager.Begin, AdvicePager.PageSize);
            RolesGridView.DataSource = roleList;
            RolesGridView.DataBind();
        }
Пример #9
0
        protected void RolesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "delete_role")
            {
                int roleID = int.Parse(e.CommandArgument.ToString());

                if (ViewState["Roles"] != null)
                {
                    ((List <Role>)ViewState["Roles"]).RemoveAll(x => x.RoleID == roleID).ToString();
                    RolesGridView.DataSource = (List <Role>)ViewState["Roles"];
                    RolesGridView.DataBind();

                    RolesDropDownList.Items.FindByValue(roleID.ToString()).Enabled = true;
                }
            }
        }
Пример #10
0
        protected void RolesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridView gridView = (GridView)sender;

            if (e.CommandName == "DeleteItem")
            {
                //System.Web.Security.Roles.DeleteRole(e.CommandArgument.ToString());
                RolesGridView.DataBind();
            }
            if (e.CommandName == "SelectItem")
            {
                // If event was attached then...
                if (RoleSelected != null)
                {
                    RoleSelected(sender, e);
                }
            }
        }
Пример #11
0
        protected void CancelAddStudentLinkButton_Click(object sender, EventArgs e)
        {
            AddStudentPanel.Visible      = false;
            DuckIDTextBox.Text           = "";
            FirstNameTextBox.Text        = "";
            LastNameTextBox.Text         = "";
            AddStudentLinkButton.Visible = true;
            SendWelcomeToAllStudentsLinkButton.Visible = true;
            DeleteAllStudentsLinkButton.Visible        = true;

            RolesGridView.DataSource = null;
            RolesGridView.DataBind();
            ProgrammingLanguagesGridView.DataSource = null;
            ProgrammingLanguagesGridView.DataBind();
            SkillsGridView.DataSource = null;
            SkillsGridView.DataBind();

            StudentListPanel.Visible = true;
        }
Пример #12
0
        /// <summary>
        /// Add selected roles to user.
        /// </summary>
        public void AddSelected()
        {
            System.Collections.Generic.List <string> list;
            list = GetItemKeys(true);
            var user   = Data.User.GetUser(new Guid(SearchUserId.Text));
            int length = list.Count;

            for (int i = 0; i < length; i++)
            {
                string roleName = list[i];
                if (user.UserName.Length > 0 && roleName.Length > 0)
                {
                    if (!System.Web.Security.Roles.IsUserInRole(user.UserName, roleName))
                    {
                        System.Web.Security.Roles.AddUserToRole(user.UserName, roleName);
                    }
                }
            }
            // Clean list.
            ItemsTextBox.Text = "";
            RolesGridView.DataBind();
        }
Пример #13
0
        public void BindGridView()
        {
            string      fpath  = HttpContext.Current.Server.MapPath("~/App_Data/Permissions.xml");
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(fpath);
            XmlNodeList mylist = xmlDoc.GetElementsByTagName("Roles")[0].ChildNodes;
            DataSet     ds     = new DataSet("ds_mission");
            DataTable   dt     = new DataTable("dt_mission");

            dt.Columns.Add(new DataColumn("Name", typeof(string)));//为dt_dry表内建立Column
            dt.Columns.Add(new DataColumn("Test", typeof(string)));
            for (int i = 0; i < mylist.Count; i++)
            {
                XmlNode node = mylist[i];
                DataRow dr   = dt.NewRow();
                dr["Name"] = node.Attributes["Name"].Value;
                dr["Test"] = node.Attributes["Name"].Value;
                dt.Rows.Add(dr);
            }
            ds.Tables.Add(dt);
            RolesGridView.DataSource = ds.Tables[0].DefaultView;
            RolesGridView.DataBind();
        }
 private void BindRolesGridView()
 {
     RolesGridView.DataSource = Roles.GetAllRoles();
     RolesGridView.DataBind();
 }
Пример #15
0
        protected void SaveAddStudentLinkButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(SelectedStudentIDHiddenField.Value))
            {
                Student student = new Student();
                student.InstructorCourseID = InstructorCourseID;
                student.FirstName          = FirstNameTextBox.Text.Trim();
                student.LastName           = LastNameTextBox.Text.Trim();
                student.DuckID             = DuckIDTextBox.Text.Trim();

                int studentID = GrouperMethods.InsertStudent(student);

                if (studentID > 0)
                {
                    if (ViewState["Languages"] != null)
                    {
                        if (((List <ProgrammingLanguage>)ViewState["Languages"]).Count() > 0)
                        {
                            foreach (ProgrammingLanguage language in ((List <ProgrammingLanguage>)ViewState["Languages"]))
                            {
                                GrouperMethods.InsertStudentLanguage(studentID, language.LanguageID, (int)language.ProficiencyLevel);
                            }
                        }
                    }
                    if (ViewState["Roles"] != null)
                    {
                        if (((List <Role>)ViewState["Roles"]).Count() > 0)
                        {
                            foreach (Role role in ((List <Role>)ViewState["Roles"]))
                            {
                                GrouperMethods.InsertStudentRoleInterest(studentID, role.RoleID, (int)role.InterestLevel);
                            }
                        }
                    }
                    if (ViewState["Skills"] != null)
                    {
                        if (((List <Skill>)ViewState["Skills"]).Count() > 0)
                        {
                            foreach (Skill skill in ((List <Skill>)ViewState["Skills"]))
                            {
                                GrouperMethods.InsertStudentSkill(studentID, skill.SkillID, (int)skill.ProficiencyLevel);
                            }
                        }
                    }
                }
            }
            else
            {
                int studentID = int.Parse(SelectedStudentIDHiddenField.Value);

                Student student = GrouperMethods.GetStudent(studentID);

                student.FirstName = FirstNameTextBox.Text.Trim();
                student.LastName  = LastNameTextBox.Text.Trim();
                student.DuckID    = DuckIDTextBox.Text.Trim();

                if (ViewState["Languages"] != null)
                {
                    student.Languages = (List <ProgrammingLanguage>)ViewState["Languages"];
                }

                if (ViewState["Roles"] != null)
                {
                    student.InterestedRoles = (List <Role>)ViewState["Roles"];
                }

                if (ViewState["Skills"] != null)
                {
                    student.Skills = (List <Skill>)ViewState["Skills"];
                }

                GrouperMethods.UpdateStudent(student);
            }

            StudentsGridView_BindGridView();

            SelectedStudentIDHiddenField.Value = null;

            RolesGridView.DataSource = null;
            RolesGridView.DataBind();
            ProgrammingLanguagesGridView.DataSource = null;
            ProgrammingLanguagesGridView.DataBind();
            SkillsGridView.DataSource = null;
            SkillsGridView.DataBind();

            AddStudentPanel.Visible      = false;
            DuckIDTextBox.Text           = "";
            FirstNameTextBox.Text        = "";
            LastNameTextBox.Text         = "";
            AddStudentLinkButton.Visible = true;
            SendWelcomeToAllStudentsLinkButton.Visible = true;
            DeleteAllStudentsLinkButton.Visible        = true;

            StudentListPanel.Visible = true;
        }
Пример #16
0
        protected void StudentsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "delete_student")
            {
                int     studentID = int.Parse(e.CommandArgument.ToString());
                Student student   = GrouperMethods.GetStudent(studentID);

                ConfirmDeleteMessageBox(student);
            }
            if (e.CommandName == "edit_student")
            {
                int studentID = int.Parse(e.CommandArgument.ToString());

                SelectedStudentIDHiddenField.Value = studentID.ToString();

                Student student = GrouperMethods.GetStudent(studentID);



                FirstNameTextBox.Text = student.FirstName;
                LastNameTextBox.Text  = student.LastName;
                DuckIDTextBox.Text    = student.DuckID;

                ProgrammingLanguagesDropDownList.DataSource = GrouperMethods.GetLanguages();
                ProgrammingLanguagesDropDownList.DataBind();

                ViewState["Languages"] = new List <ProgrammingLanguage>();

                foreach (ProgrammingLanguage language in student.Languages)
                {
                    ((List <ProgrammingLanguage>)ViewState["Languages"]).Add(language);
                    ProgrammingLanguagesDropDownList.Items.FindByValue(language.LanguageID.ToString()).Enabled = false;
                }

                ProgrammingLanguagesGridView.DataSource = (List <ProgrammingLanguage>)ViewState["Languages"];
                ProgrammingLanguagesGridView.DataBind();

                RolesDropDownList.DataSource = GrouperMethods.GetRoles();
                RolesDropDownList.DataBind();

                ViewState["Roles"] = new List <Role>();

                foreach (Role role in student.InterestedRoles)
                {
                    ((List <Role>)ViewState["Roles"]).Add(role);
                    RolesDropDownList.Items.FindByValue(role.RoleID.ToString()).Enabled = false;
                }

                RolesGridView.DataSource = (List <Role>)ViewState["Roles"];
                RolesGridView.DataBind();

                SkillsDropDownList.DataSource = GrouperMethods.GetSkills();
                SkillsDropDownList.DataBind();

                ViewState["Skills"] = new List <Skill>();

                foreach (Skill skill in student.Skills)
                {
                    ((List <Skill>)ViewState["Skills"]).Add(skill);
                    SkillsDropDownList.Items.FindByValue(skill.SkillID.ToString()).Enabled = false;
                }

                SkillsGridView.DataSource = (List <Skill>)ViewState["Skills"];
                SkillsGridView.DataBind();

                GUIDLabel.Text = "Student GUID: " + student.GUID;

                StudentListPanel.Visible = false;
                AddStudentPanel.Visible  = true;
            }
            if (e.CommandName == "send_welcome")
            {
                int studentID = int.Parse(e.CommandArgument.ToString());

                Student student = GrouperMethods.GetStudent(studentID);

                SendSurveyLinkMessage(student);

                student.InitialNotificationSentDate = DateTime.Now;
                GrouperMethods.UpdateStudent(student);

                StudentsGridView_BindGridView();
            }
        }
Пример #17
0
 public void SetUserAndFilter(Guid userId, string filter)
 {
     SearchUserId.Text      = userId.ToString();
     SearchFilterLabel.Text = filter;
     RolesGridView.DataBind();
 }
Пример #18
0
        private void LoadUsersData()
        {
            if (UsersTable == null)
            {
                UsersTable = new DataTable("Users");

                UsersTable.Columns.Add("Id", typeof(string));
                UsersTable.Columns.Add("UserName", typeof(string));
                UsersTable.Columns.Add("Email", typeof(string));
                UsersTable.Columns.Add("PhoneNumber", typeof(string));
                DataColumn[] keys = new DataColumn[] { UsersTable.Columns[0] };
                UsersTable.PrimaryKey = keys;
            }
            else
            {
                UsersTable.Rows.Clear();
            }

            var context     = new ApplicationDbContext();
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var users       = userManager.Users;

            foreach (var user in users)
            {
                var row = UsersTable.NewRow();
                row["Id"]          = user.Id;
                row["UserName"]    = user.UserName;
                row["Email"]       = user.Email;
                row["PhoneNumber"] = user.PhoneNumber;
                UsersTable.Rows.Add(row);
                UsersTable.AcceptChanges();
            }
            UsersGridView.DataSource = UsersTable;
            UsersGridView.DataBind();

            MUsersGridView.DataSource = UsersTable;
            MUsersGridView.DataBind();

            if (RolesTable == null)
            {
                RolesTable = new DataTable("Roles");
                RolesTable.Columns.Add("Id", typeof(string));
                RolesTable.Columns.Add("Name", typeof(string));
                RolesTable.PrimaryKey = new DataColumn[] { RolesTable.Columns["Id"] };
            }
            else
            {
                RolesTable.Rows.Clear();
            }

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var roles       = roleManager.Roles;

            foreach (var role in roles)
            {
                var row = RolesTable.NewRow();
                row["Id"]   = role.Id;
                row["Name"] = role.Name;
                RolesTable.Rows.Add(row);
                RolesTable.AcceptChanges();
            }
            RolesGridView.DataSource = RolesTable;
            RolesGridView.DataBind();

            MRolesGridView.DataSource = RolesTable;
            MRolesGridView.DataBind();

            if (UserInRoles == null)
            {
                UserInRoles = new DataTable("UserInRoles");
                UserInRoles.Columns.Add("Id", typeof(string));
                UserInRoles.Columns.Add("Name", typeof(string));
                UserInRoles.PrimaryKey = new DataColumn[] { UserInRoles.Columns["Id"] };
            }
            MUserInRolesGridView.DataSource = UserInRoles;
        }