<%@ Page Language="c#" Inherits="TopWinCMS.WebUI.Admin.Admin_Admin_Role" CodeBehind="Admin_Role.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>管理员角色管理</title>
    <meta http-equiv="Pragma" content="No-cach" />
    <link href="../Style.css" type="text/css" rel="stylesheet" />

    <script language="javascript" type="text/javascript" src="../TopWin.js"></script>

    <script language="javascript" type="text/javascript" src="../../Images/skysoft.js"></script>

</head>
<body>
    <form id="Form1" method="post" runat="server">
    <asp:GridView ID="GV_List" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" onrowdeleting="GV_List_RowDeleting" 
        onrowdatabound="GV_List_RowDataBound">
        <Columns>
            <asp:BoundField HeaderText="角色名称" DataField="RoleName">
                <ItemStyle Width="150px" HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField HeaderText="备注" DataField="Remark" />
       
            <asp:TemplateField HeaderText="查看权限">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink2" runat="server" 
                        NavigateUrl='<%# Eval("ID", "Admin_Role.aspx?Action=ReadOnly&amp;ID={0}") %>'><img src="../Images/Power.gif" alt="" /></asp:HyperLink>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="60px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="修改权限">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink3" runat="server" 
                        NavigateUrl='<%# Eval("ID", "Admin_Role.aspx?Action=Edit&ID={0}") %>'><img src="../Images/Edit.gif" alt="" /></asp:HyperLink>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="60px" />
            </asp:TemplateField>
            <asp:CommandField HeaderText="删除角色" ShowDeleteButton="True" ButtonType="Image" 
                DeleteImageUrl="~/Admin/Images/Del.gif">
                <ItemStyle HorizontalAlign="Center" Width="60px" />
            </asp:CommandField>
        </Columns>
        <HeaderStyle CssClass="HeaderStyle" />
    </asp:GridView>
    
    <asp:Panel ID="Panel1" runat="server" Width="100%">
        <table id="Table1" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr class="HeaderStyle">
                <td>
                    角 色 添 加
                </td>
            </tr>
            <tr>
                <td class="border">
                    <br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 角色名称：
                    <asp:TextBox ID="TB_RoleName" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;
                    <asp:Button ID="BT_Add" runat="server" Text="添加" OnClick="BT_Add_Click" CssClass="btn" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:CheckBox
                        ID="CB_ALL" onclick="javascript:SelectAll(this);" runat="server" Text="所有权限" /><table
                            id="Table2" cellspacing="0" cellpadding="0" width="100%" border="0">
                        </table>
                    <br />
              
                    <asp:DataList ID="DataList1" runat="server" Width="98%" CellPadding="8" BorderWidth="0"
                        RepeatColumns="2" RepeatDirection="Horizontal" HorizontalAlign="Center">
                        <ItemStyle BorderColor="ActiveBorder" Width="50%" />
                        <ItemTemplate>
                            <fieldset>
                                <legend>
                                    <%# Container.ItemIndex + 1%>、<%# Eval("Name")%></legend>
                                <asp:DataList ID="Datalist2" runat="server" Width="100%" RepeatColumns="4" RepeatDirection="Horizontal"
                                    DataSource='<%# BindPower(Eval("RootID"))%>'>
                                    <ItemStyle VerticalAlign="Top" />
                                    <ItemTemplate>
                                        <input name="chkOperation" type="checkbox" value='<%# Eval("Code")%>'><%# Eval("Name")%>
                                        </input>
                                    </ItemTemplate>
                                </asp:DataList>
                            </fieldset>
                        </ItemTemplate>
                    </asp:DataList>

                    <script language="javascript" type="text/javascript">                        //复选框选择值
                        function CheckValues(objSelectList, strValue) {
                            if (strValue == "") return;

                            if (objSelectList == null) return;

                            //如果只有一项
                            if (objSelectList.type == "checkbox") {
                                if (strValue.indexOf("," + objSelectList.value + ",") >= 0) {
                                    objSelectList.checked = true;
                                }
                            }

                            for (i = 0; i < objSelectList.length; i++) {

                                if (strValue.indexOf("," + objSelectList[i].value + ",") >= 0) {
                                    objSelectList[i].checked = true;
                                }
                            }
                        }
                        //初始化权限
                        CheckValues(Form1.chkOperation, ",<%=strOperation%>,");
                    </script>

                </td>
            </tr>
        </table>
    </asp:Panel>
    </form>
</body>
</html>
