예제 #1
0
        protected void dlSearchTeacher_ItemCommand(object source, DataListCommandEventArgs e)
        {
            string teacherNowSelected = this.dlSearchTeacher.DataKeys[e.Item.ItemIndex].ToString(); //取选中行教师的编号
            DalOperationAboutUserAuth dalua = new DalOperationAboutUserAuth();
            UserAuth userAuth = dalua.GetUserAuth(pageName);
            if (e.CommandName == "addAuth")
            {
                if (userAuth == null)
                {
                    userAuth = new UserAuth();
                    userAuth.pageName = pageName;
                    userAuth.userIds = teacherNowSelected;
                }
                else
                {
                    if (userAuth.userIds == null || userAuth.userIds.Equals(""))
                    {
                        userAuth.userIds = teacherNowSelected;
                    }
                    else
                    {
                        userAuth.userIds = userAuth.userIds + "," + teacherNowSelected;
                    }
                }
            }
            else if (e.CommandName == "removeAuth")
            {
                if (userAuth == null) return;
                string[] ids = userAuth.userIds.Split(',');

                List<string> list = new List<string>();

                for (int i = 0; i < ids.Length; i++)
                {
                    if (!ids[i].Equals(teacherNowSelected))
                    {
                        list.Add(ids[i]);
                    }
                }
                userAuth.userIds = string.Join(",", list.ToArray());
            }

            dalua.setUserAuth(userAuth);
            Javascript.JavaScriptLocationHref("ProjectManager.aspx?fragment=1&teacherName=" + this.txtKeyword.Text.Trim(), Page);
        }
예제 #2
0
        protected void dsltAuthTeacher_OnItemCommand(object source, DataListCommandEventArgs e)
        {
            string teacherNoSelect = this.dsltAuthTeacher.DataKeys[e.Item.ItemIndex].ToString();//取选中行教师编号
            if (e.CommandName.Equals("remove"))
            {
                DalOperationNorm dalOperationNorm = new DalOperationNorm();
                DalOperationAboutUserAuth dalua = new DalOperationAboutUserAuth();
                UserAuth userAuth = dalua.GetUserAuth(pageName);
                string[] ids = userAuth.userIds.Split(',');

                List<string> list = new List<string>();

                for (int i = 0; i < ids.Length; i++)
                {
                    if (!ids[i].Equals(teacherNoSelect))
                    {
                        list.Add(ids[i]);
                    }
                }
                userAuth.userIds = string.Join(",", list.ToArray());
                dalua.setUserAuth(userAuth);
                Javascript.JavaScriptLocationHref("/Administrator/ViewNormAuth.aspx", Page);
            }
        }