示例#1
0
 /// <summary>
 /// 插入T_SYS_ROLE_PERMISSIONS
 /// </summary>
 public virtual bool Insert(RolePermissionsOR rolePermissions)
 {
     string sql = "insert into T_SYS_ROLE_PERMISSIONS (ROLE_GUID, PERMISSION_CODE) values (:ROLE_GUID, :PERMISSION_CODE)";
     SqlParameter[] parameters = new SqlParameter[]
     {
         new SqlParameter(":ROLE_GUID", SqlDbType.VarChar, 36, ParameterDirection.Input, false, 0, 0, "ROLE_GUID", DataRowVersion.Default, rolePermissions.RoleGuid),
         new SqlParameter(":PERMISSION_CODE", SqlDbType.VarChar, 512, ParameterDirection.Input, false, 0, 0, "PERMISSION_CODE", DataRowVersion.Default, rolePermissions.PermissionCode)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }
示例#2
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            string guid = Request.QueryString["guid"];
            List<RolePermissionsOR> list = new List<RolePermissionsOR>();
            foreach (RepeaterItem item0 in rptMenu0.Items)
            {
                CheckBox cb0 = item0.FindControl("cb0") as CheckBox;
                if (cb0.Checked)
                {
                    Label lb0 = item0.FindControl("lb0") as Label;
                    RolePermissionsOR permissions0 = new RolePermissionsOR();
                    permissions0.RoleGuid = guid;
                    permissions0.PermissionCode = lb0.Text;
                    list.Add(permissions0);

                    Repeater rptMenu1 = item0.FindControl("rptMenu1") as Repeater;
                    foreach (RepeaterItem item1 in rptMenu1.Items)
                    {
                        CheckBox cb1 = item1.FindControl("cb1") as CheckBox;
                        if (cb1.Checked)
                        {
                            Label lb1 = item1.FindControl("lb1") as Label;
                            RolePermissionsOR permissions1 = new RolePermissionsOR();
                            permissions1.RoleGuid = guid;
                            permissions1.PermissionCode = lb1.Text;
                            list.Add(permissions1);

                            Repeater rptMenu2 = item1.FindControl("rptMenu2") as Repeater;
                            foreach (RepeaterItem item2 in rptMenu2.Items)
                            {
                                CheckBox cb2 = item2.FindControl("cb2") as CheckBox;
                                if (cb2.Checked)
                                {
                                    Label lb2 = item2.FindControl("lb2") as Label;
                                    RolePermissionsOR permissions2 = new RolePermissionsOR();
                                    permissions2.RoleGuid = guid;
                                    permissions2.PermissionCode = lb2.Text;
                                    list.Add(permissions2);
                                }
                            }
                        }
                    }
                }

            }

            foreach (RepeaterItem itemt0 in rptMenut.Items)
            {
                CheckBox cb0 = itemt0.FindControl("cbt0") as CheckBox;
                if (cb0.Checked)
                {
                    Label lb0 = itemt0.FindControl("lbt0") as Label;
                    RolePermissionsOR permissions0 = new RolePermissionsOR();
                    permissions0.RoleGuid = guid;
                    permissions0.PermissionCode = lb0.Text;
                    list.Add(permissions0);

                    Repeater rptMenu1 = itemt0.FindControl("rptMenut1") as Repeater;
                    foreach (RepeaterItem item1 in rptMenu1.Items)
                    {
                        CheckBox cb1 = item1.FindControl("cbt1") as CheckBox;
                        if (cb1.Checked)
                        {
                            Label lb1 = item1.FindControl("lbt1") as Label;
                            RolePermissionsOR permissions1 = new RolePermissionsOR();
                            permissions1.RoleGuid = guid;
                            permissions1.PermissionCode = lb1.Text;
                            list.Add(permissions1);

                            Repeater rptMenu2 = item1.FindControl("rptMenut2") as Repeater;
                            foreach (RepeaterItem item2 in rptMenu2.Items)
                            {
                                CheckBox cb2 = item2.FindControl("cbt2") as CheckBox;
                                if (cb2.Checked)
                                {
                                    Label lb2 = item2.FindControl("lbt2") as Label;
                                    RolePermissionsOR permissions2 = new RolePermissionsOR();
                                    permissions2.RoleGuid = guid;
                                    permissions2.PermissionCode = lb2.Text;
                                    list.Add(permissions2);
                                }
                            }
                        }
                    }
                }

            }

            try
            {
                new RolePermissionsDA().InsertRolePermission(list);

            }
            catch (Exception ex)
            {
                base.Alert("设置权限失败.\n\n异常信息:" + ex.Message);
                return;
            }
            Response.Redirect("roleList.aspx");
        }
示例#3
0
 public RolePermissionsOR selectARowDate(string m_id)
 {
     string sql = string.Format("select * from T_SYS_ROLE_PERMISSIONS where RoleGuid='{0}'", m_id);
     DataTable dt = null;
     try
     {
         dt = db.ExecuteQueryDataSet(sql).Tables[0];
     }
     catch (Exception ex)
     {
         throw ex;
     }
     if (dt == null)
         return null;
     if (dt.Rows.Count == 0)
         return null;
     DataRow dr = dt.Rows[0];
     RolePermissionsOR m_Role = new RolePermissionsOR(dr);
     return m_Role;
 }
示例#4
0
 /// <summary>
 /// 更新T_SYS_ROLE_PERMISSIONS
 /// </summary>
 public virtual bool Update(RolePermissionsOR rolePermissions)
 {
     string sql = "update T_SYS_ROLE_PERMISSIONS set  PERMISSION_CODE = :PERMISSION_CODE where  ROLE_GUID = :ROLE_GUID";
     SqlParameter[] parameters = new SqlParameter[]
     {
         new SqlParameter(":ROLE_GUID", SqlDbType.VarChar, 36, ParameterDirection.Input, false, 0, 0, "ROLE_GUID", DataRowVersion.Default, rolePermissions.RoleGuid),
         new SqlParameter(":PERMISSION_CODE", SqlDbType.VarChar, 512, ParameterDirection.Input, false, 0, 0, "PERMISSION_CODE", DataRowVersion.Default, rolePermissions.PermissionCode)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }