<%@ Page Title="角色管理" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Users_Role.aspx.cs" Inherits="Dotnet.Admin.Users_Role" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">





<div class="result-wrap">
      
    

   <div class="result-title">
             <span class="span_help">说明</span>:系统使用如下角色。其中，administrator是管理员，manager是部门经理，supervisor是部门主管，staff是员工，所有未显式设置角色的用户默认都属于staff角色。
     </div>




           
    <div class="result-list">
                          <asp:LinkButton ID="lb_delete"  CssClass="btn  btn-danger" 
                         OnClientClick="if(!isselect()) return false; " 
                        runat="server" onclick="lb_delete_Click">批量删除</asp:LinkButton> 
                     
 </div>
                  



 

 
   <div class="result-title">


    <table  width="100%">
                        <tbody> 
                            <tr>
                                <th width="120px">自定义角色：</th>
                                <td width="250px">
                                   
                                    <asp:TextBox CssClass="form-control"  ValidationGroup="Add" ID="txt_catname" Text="" Width=220px runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ValidationGroup="Add" ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写自定义角色名称" ControlToValidate="txt_catname" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            
                                <td>
                                    <asp:Button ID="btn_add" runat="server" Text="新建新角色"  ValidationGroup="Add" 
                                         class="btn btn-primary" onclick="btn_add_Click" />
 
                                  
                                </td>
                            </tr>
                        </tbody></table>

  </div>












  <div class="result-content" id="thetable">
  
  
<asp:gridview  id="RoleList"   
        DataKeyNames="id" 
        CssClass="table  table-hover table-bordered" 
        GridLines="None"
        AutoGenerateColumns="False"   
        Runat="Server" 
        DataSourceID="SqlDataSource1" 
         >
 
<columns>


  <asp:TemplateField> 
        <HeaderTemplate> 
              <input id="cb_selectall" type="checkbox"    /> 
         </HeaderTemplate> 
                            
         <ItemTemplate  > 

            <input type="checkbox" 
            <%#Eval("IsSystem").ToString() == "1" ? " disabled=disabled " : ""%> 
             class="ck_item"    value='<%# Eval("id") %>'  /> 
         
            <asp:HiddenField runat="server" ID="hf_id" Value=<%# Eval("id") %> /> 
          </ItemTemplate>    
          <HeaderStyle  Width=50px  CssClass="tc"/>        
        
          </asp:TemplateField>



         <asp:BoundField DataField="rolename"  HeaderStyle-Width="260px"   HeaderText="角色名称" />
          <asp:BoundField DataField="roletype" HeaderStyle-Width="380px"   HeaderText="角色说明" />


          <asp:TemplateField>
          <HeaderTemplate>系统内置</HeaderTemplate>
          <ItemTemplate>
  
          <%#Eval("IsSystem").ToString() == "1" ? "<img src=images/onCorrect.gif >" : ""%>
          </ItemTemplate>
          </asp:TemplateField>
 

     <asp:TemplateField>
         <HeaderTemplate>人员查询</HeaderTemplate>
         <ItemTemplate>
         <a  href="###" onclick="Pop('Users_Query.aspx?t=role&name=<%#Server.UrlEncode(Eval("rolename").ToString()) %>',850,450,'部门员工查询');return false;"   >查询角色人员</a>
         </ItemTemplate>
         <HeaderStyle Width=140px />
         </asp:TemplateField>




         <asp:TemplateField>
 
         <HeaderTemplate>操作</HeaderTemplate>
         <ItemTemplate>
         <div <%#Eval("IsSystem").ToString() == "1" ? " style='display:none'" : ""%> > 
 
         <asp:LinkButton runat="server" ID="btnEdit" CommandName="Edit" Text="编辑" ></asp:LinkButton> 

        <asp:LinkButton runat="server" ID="btnDel" CommandName="Delete" Text="删除" OnClientClick="return confirm('确定要删除吗？');"></asp:LinkButton>
         </div>
         </ItemTemplate>
 
         <EditItemTemplate>
 
          <asp:LinkButton runat="server" CausesValidation="false" ID="lbUpdate" CommandName="Update" Text="更新" ></asp:LinkButton>
           <asp:LinkButton runat="server" CausesValidation="false" ID="lbCanel" CommandName="Cancel" Text="取消" ></asp:LinkButton>

         </EditItemTemplate>
 
         </asp:TemplateField>
  
</columns>
 </asp:gridview>












 
        <asp:SqlDataSource ID="SqlDataSource1"  
           ConnectionString='<%$ ConnectionStrings:ConnectionString %>'
           Runat="server" 
           DeleteCommand="DELETE FROM [users_roles] WHERE [id] = @id"  
           SelectCommand="SELECT * FROM [users_roles] order by issystem desc  " 
           UpdateCommand="UPDATE [users_roles] SET [rolename] = @rolename , roletype@roletype WHERE [id] = @id"  >
      
            
         <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>

        <UpdateParameters>
            <asp:Parameter Name="rolename" Type="String" /> 
            <asp:Parameter Name="roletype" Type="String" /> 
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
       
    </asp:SqlDataSource>





       






</div>









    

  <input type="hidden" name="hf_ids" id="hf_ids" />





 </div>






     



      
</asp:Content>
