示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsAsyncRequest)
            {
                SearchCriterion.SetOrder("CreateDate");
                SearchCriterion.SetOrder("SortIndex");
                ents = SysRoleRule.FindAll(SearchCriterion);

                this.PageState.Add("RoleList", ents);
            }

            SysRole ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <SysRole>();
                ent.SaveAndFlush();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Create:
                ent = this.GetPostedData <SysRole>();
                ent.CreateAndFlush();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SysRole>();
                ent.DeleteAndFlush();
                this.SetMessage("删除成功!");
                break;

            case RequestActionEnum.Custom:
                if (RequestActionString == "refreshsys")
                {
                    PortalService.RefreshSysModules();
                    SetMessage("操作成功!");
                }
                break;
            }

            SysRoleType[] roleTypes = SysRoleTypeRule.FindAll();
            this.PageState.Add("RoleTypeList", roleTypes);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsAsyncRequest)
            {
                SearchCriterion.SetOrder("CreateDate");
                SearchCriterion.SetOrder("SortIndex");
                ents = SysRoleRule.FindAll(SearchCriterion);

                this.PageState.Add("RoleList", ents);
            }

            SysRole ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <SysRole>();
                ent.SaveAndFlush();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Create:
                ent = this.GetPostedData <SysRole>();
                ent.CreateAndFlush();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SysRole>();
                ent.DeleteAndFlush();
                this.SetMessage("删除成功!");
                break;

            case RequestActionEnum.Custom:
                if (RequestActionString == "refreshsys")
                {
                    PortalService.RefreshSysModules();
                    SetMessage("操作成功!");
                }
                else if (RequestActionString == "getusers")
                {
                    string uids  = "";
                    string names = "";
                    using (new SessionScope())
                    {
                        ent = SysRole.Find(this.RequestData.Get <string>("id"));
                        if (ent.User.Count > 0)
                        {
                            SysUser[] usrs = ent.User.ToArray();
                            foreach (SysUser usr in usrs)
                            {
                                uids  += usr.UserID + ",";
                                names += usr.Name + ",";
                            }
                        }
                    }
                    uids  = uids.TrimEnd(',');
                    names = names.TrimEnd(',');
                    this.PageState.Add("UserId", uids);
                    this.PageState.Add("UserName", names);
                }
                else if (RequestActionString == "setusers")
                {
                    string roleId  = this.RequestData.Get <string>("id");
                    string userIds = this.RequestData.Get <string>("userids");
                    DataHelper.ExecSql("delete from SysUserRole where RoleId='" + roleId + "'");
                    string   insertTpl = "insert into SysUserRole values ('{0}','" + roleId + "')";
                    string   sql       = "";
                    string[] users     = userIds.Split(',');
                    foreach (string user in users)
                    {
                        if (user != "")
                        {
                            sql += string.Format(insertTpl, user);
                        }
                    }
                    if (sql.Trim() != "")
                    {
                        DataHelper.ExecSql(sql);
                    }
                }
                break;
            }

            SysRoleType[] roleTypes = SysRoleTypeRule.FindAll();
            this.PageState.Add("RoleTypeList", roleTypes);
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsAsyncRequest)
            {
                string where = "";
                foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches)
                {
                    if (!String.IsNullOrEmpty(item.Value.ToString()))
                    {
                        switch (item.PropertyName)
                        {
                        default:
                            where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                            break;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(RequestData.Get <string>("Rolid") + ""))
                {
                    string sql = "select * from SYSUSER where USERID in(select USERID from SYSUSERROLE where  ROLEID ='" + RequestData.Get <string>("Rolid") + "') and 1=1";
                    sql = sql.Replace("and 1=1", where);
                    this.PageState.Add("UserList", GetPageData(sql, SearchCriterion));
                }
            }

            SysRole ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <SysRole>();
                ent.SaveAndFlush();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Create:
                ent = this.GetPostedData <SysRole>();
                ent.CreateAndFlush();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SysRole>();
                ent.DeleteAndFlush();
                this.SetMessage("删除成功!");
                break;

            default:

                if (RequestActionString == "setusers")    //添加人员
                {
                    bool bol = false;
                    //string get_task = "select * from HD_Task where ENDTIME is null ";
                    //DataTable dt = DataHelper.QueryDataTable(get_task);

                    string roleId  = this.RequestData.Get <string>("id");
                    string userIds = this.RequestData.Get <string>("userids");
                    DataHelper.ExecSql("delete from SysUserRole where RoleId='" + roleId + "'");
                    string   insertTpl = "insert into SysUserRole values ('{0}','" + roleId + "') ";
                    string[] users     = userIds.Split(',');

                    foreach (string user in users)
                    {
                        if (user != "")
                        {
                            DataHelper.ExecSql(string.Format(insertTpl, user));
                        }
                    }
                    if (roleId == "fe0464db-1b6e-483d-b983-4352f14cc367")
                    {
                        bol = true;
                    }
                }
                else if (RequestActionString == "getusers")
                {
                    string uids  = "";
                    string names = "";
                    using (new SessionScope())
                    {
                        ent = SysRole.Find(this.RequestData.Get <string>("id"));
                        if (ent.User.Count > 0)
                        {
                            SysUser[] usrs = ent.User.ToArray();
                            foreach (SysUser usr in usrs)
                            {
                                uids  += usr.UserID + ",";
                                names += usr.Name + ",";
                            }
                        }
                    }
                    uids  = uids.TrimEnd(',');
                    names = names.TrimEnd(',');
                    this.PageState.Add("UserId", uids);
                    this.PageState.Add("UserName", names);
                }
                else if (RequestActionString == "deleteusers")
                {
                    string roleId  = this.RequestData.Get <string>("id");
                    string userIds = this.RequestData.Get <string>("userids").TrimEnd(',');
                    string delsql  = "delete from SysUserRole where RoleId='" + roleId + "' and UserID in ('" + userIds.Replace(",", "','") + "') ";
                    DataHelper.ExecSql(delsql);
                }
                else
                {
                    DoSelect();
                }

                break;
            }
        }