Пример #1
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            string roleName = this.txtRoleName.Text.Trim();
            string description = this.txtDescription.Text.Trim();

            if (roleName == "")
            {
                ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色名称不能为空!");
                return;
            }

            if (dalRoels.Exist("RoleName", roleName))
            {
                ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色已存在!");
                return;
            }

            ADeeWu.HuoBi3J.Model.Admin_Roles ent = new ADeeWu.HuoBi3J.Model.Admin_Roles();
            ent.RoleName = roleName;
            ent.Description = this.txtDescription.Text;

            if (dalRoels.Add(ent) <= 0)
            {
                ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("添加失败!");
                return;
            }

            long[] alowPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("alowPageID", 0);
            foreach (long pageID in alowPageIDGroup)//设置角色所拥有的权限
            {
                if (pageID > 0)
                {
                    ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions();
                    entRolePermission.CheckState = 0;
                    entRolePermission.PageID = pageID;
                    entRolePermission.RoleID = ent.ID;
                    dalRolePermissions.Add(entRolePermission);
                }
            }

            long[] denyPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("denyPageID", 0);
            foreach (long pageID in denyPageIDGroup)//设置角色所拒绝的权限
            {
                if (pageID > 0)
                {
                    ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions();
                    entRolePermission.CheckState = 1;
                    entRolePermission.PageID = pageID;
                    entRolePermission.RoleID = ent.ID;
                    dalRolePermissions.Add(entRolePermission);
                }
            }

            ADeeWu.HuoBi3J.Libary.WebUtility.ShowPageSelector(this, "添加成功!选择\"是\"继续操作,选择否修改该记录!", "add.aspx", "edit.aspx?id" + ent.ID);
        }
Пример #2
0
        public ADeeWu.HuoBi3J.Model.Admin_Roles[] GetEntityList(string orderBy,string[] columns,params object[] values)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select * from [Admin_Roles] where 1=1");
            db.Parameters.Clear();
            for(int i=0;i<columns.Length;i++)
            {
                builder.AppendFormat(" and [{0}][email protected]{0}", columns[i]);
                db.Parameters.Append("@"+columns[i],values[i]);
            }

            if (!string.IsNullOrEmpty(orderBy))
            {
                builder.AppendFormat(" order by {0}", orderBy);
            }

            DataTable dt = db.Select(builder.ToString());

            ADeeWu.HuoBi3J.Model.Admin_Roles[] EntityList = new ADeeWu.HuoBi3J.Model.Admin_Roles[dt.Rows.Count];
             if (dt.Rows.Count == 0) return EntityList;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                ADeeWu.HuoBi3J.Model.Admin_Roles Entity = new ADeeWu.HuoBi3J.Model.Admin_Roles();
                Entity.ID = long.Parse(dr["ID"].ToString());
                Entity.RoleName = (string)(dr["RoleName"]);
                Entity.Description = (string)(dr["Description"]);
                EntityList[i] = Entity;
            }
             return EntityList;
        }
Пример #3
0
 public ADeeWu.HuoBi3J.Model.Admin_Roles GetEntity(string where)
 {
     DataTable dt = this.Select(where,"");
     if(dt.Rows.Count==0) return null;
     DataRow dr = dt.Rows[0];
     ADeeWu.HuoBi3J.Model.Admin_Roles Entity = new ADeeWu.HuoBi3J.Model.Admin_Roles();
     Entity.ID = long.Parse(dr["ID"].ToString());
     Entity.RoleName = (string)(dr["RoleName"]);
     Entity.Description = (string)(dr["Description"]);
     return Entity;
 }
Пример #4
0
 public ADeeWu.HuoBi3J.Model.Admin_Roles GetEntity(long  ID)
 {
     db.Parameters.Clear();
     db.Parameters.Append("@ID",ID);
     DataTable dt = db.Select("select * from [Admin_Roles] where 1=1  and [ID][email protected]");
     if(dt.Rows.Count==0) return null;
     DataRow dr = dt.Rows[0];
     ADeeWu.HuoBi3J.Model.Admin_Roles Entity = new ADeeWu.HuoBi3J.Model.Admin_Roles();
     Entity.ID = long.Parse(dr["ID"].ToString());
     Entity.RoleName = (string)(dr["RoleName"]);
     Entity.Description = (string)(dr["Description"]);
     return Entity;
 }