<%@ Page Title="用户列表" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Users_Lists.aspx.cs" Inherits="Vote.Admin.Users_Lists" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<style>
    .must{ color:#ff0000}
    .txt0{ width:100px}
    .txt1{width:90px}
    .txt2{width:100px}
    .txt3{width:100px}
    .txt4{width:150px}
    .txt5{width:100px}
    .txt6{width:80px}
    </style>

 
 
 <div class="search-wrap">
            <div class="search-content">
              
                    <table class="search-tab">
                        <tr>
                            <th width="120">部门:</th>
                            <td> 
                                 <asp:DropDownList runat="server" ID="ddl_dept" Width="200"  AppendDataBoundItems="true"    AutoPostBack="True"  >
                                 <asp:ListItem Text="所有部门" Value="" ></asp:ListItem>
                                 </asp:DropDownList> 
                            </td>
                            <th width="90">姓名关键字:</th>
                            <td> 
                               <asp:TextBox ID="txtsearchname" runat="server"></asp:TextBox>
                             </td>
                            <td> 
                               <asp:Button ID="btn_search" class="btn btn-primary btn2" runat="server" Text="搜索"   />    
                            </td>
                        </tr>
                    </table>
               </div>
        </div>



<div class="result-wrap">
      
     <div class="result-title">
                    <div class="result-list">

<a   href="Users_EditUser.aspx"><i class=icon-font> &#xe026;</i>添加用户</a> 
  


   <asp:LinkButton ID="btn_del" runat="server"  OnClientClick="if(isselect()) return true; return false;"   onclick="btn_del_Click" ><i class=icon-font> &#xe019;</i>批量删除</asp:LinkButton>
   
   
       <a href="#" onclick="if(isselect()) openRole(); return false; " title="批量修改用户的角色" ><i class=icon-font> &#xe034;</i>批量角色...</a>
       <a  href="#"  onclick="if(isselect()) openUser(); return false; "  title="批量修改用户的共同属性" ><i class=icon-font> &#xe050;</i>批量更新...</a>
   
      <asp:LinkButton ID="btn_export" runat="server"    onclick="btn_export_Click"><i class=icon-font> &#xe011;</i>导出用户</asp:LinkButton>
  
  &nbsp;|&nbsp;
   <a href="#" id="a_addnew"><i class=icon-font> &#xe048;</i>批量添加</a>
<a href="Imports_Excel_Users.aspx" target="_blank"><i class=icon-font> &#xe048;</i>从Excel导入用户</a>
 
<a href="javascript:void(0);"
    onclick="Pop('Imports_AD_Users.aspx',500,380,'从AD域服务器里导入用户');return false;"
       
       >
       <i class=icon-font> &#xe050;</i>从AD导入用户</a> 
 

<a href="javascript:void(0);"
    onclick="Pop('Imports_AD_Users2.aspx',600,380,'从AD域服务器里导入用户');return false;"
       
       >
       <i class=icon-font> &#xe049;</i>从AD导入(自定义)</a> 


 </div>
 </div>

 
     
      


  <div id="thenew"   style="display:none"  class="result-content">  

   
   <table id="Table1"  class="result-tab"   runat="server" >
   
    <tr>
     <th> 登录名<span class="must">*</span> </th>
     <th style=" width:100px"> 密码<span class="must">*</span>  </th>
     <th> 显示名   </th>
     <th> 部门   </th>
     <th> 邮件   </th>
     <th> 电话   </th>
     <th> 员工号   </th>
   </tr>
   </table>


   <div class="bunc">
   
    <asp:Button ID="btn_addbatch" runat="server" Text="批量添加"    class="btn btn-primary btn6 mr10" onclick="btn_addbatch_Click" />
    <input class="btn btn6"  id="btn_back" value="返回" type="button">
                              
   </div>

  </div>

 
  
 <div class="thelist"    id="thetable">

       
 

  
  
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False"   PageSize=20
        DataKeyNames="uid"  Width="100%"
        DataSourceID="SqlDataSource1"   
       CssClass="result-tab"
      >
        
    
     <Columns>
           
 


 <asp:TemplateField> 
        <HeaderTemplate> 
              <asp:CheckBox ID="chk_SelectedHeader" runat="server" AutoPostBack="False" onclick="selectall(this)"  /> 
         </HeaderTemplate> 
                            
         <ItemTemplate  > 
            <input type="checkbox"  class="ck_item"   title=<%# Eval("uid") %> value='<%# Eval("uid") %>'  /> 
            <asp:HiddenField runat="server" ID="hf_id" Value=<%# Eval("uid") %> /> 
          </ItemTemplate>    
              <HeaderStyle  Width=50px  CssClass="tc"/>        
              <ItemStyle  Width=50px  CssClass="tc"/>
          </asp:TemplateField>
                        
     
      
           
           <asp:TemplateField>
           <HeaderTemplate>登录名</HeaderTemplate> 
           <ItemTemplate>
                <a href='Users_EditUser.aspx?id=<%#Eval("uid") %>' ><%#Eval("username") %></a>
           </ItemTemplate>
        
           </asp:TemplateField>
         
         
           
            <asp:BoundField DataField="displayname" HeaderText="显示名" 
                SortExpression="displayname"  />
            
     
            <asp:BoundField DataField="Department" HeaderText="部门" 
                SortExpression="Department" />

 


            <asp:BoundField DataField="StaffCode" HeaderText="员工号" 
                SortExpression="StaffCode"  />

                 
            <asp:BoundField DataField="tel" HeaderText="电话" 
                SortExpression="tel" />
            


       
        <asp:TemplateField>
                <HeaderTemplate>操作</HeaderTemplate>
                <ItemTemplate>
                
                   <a href="#" onclick="Pop('Users_SetRight.aspx?id=<%#Eval("uid") %>',500,380,'角色设置');return false;" >角色</a>   
                  
 
                </ItemTemplate>

               </asp:TemplateField>




      </Columns>
<HeaderStyle Font-Bold="True" BackColor="#DCDDDE"></HeaderStyle>
<AlternatingRowStyle BackColor="#F1F1F1" Height="32px"/>
<RowStyle BorderColor="#E1E1E1" Height="32px" />


<PagerSettings   PreviousPageText="上一页"  PageButtonCount="5"  Mode="NumericFirstLast"/>
<PagerStyle   Width="300px"    CssClass="pg" />
    </asp:GridView>

  </div>
  
  
  
  
  
  
  
  
  
  
    <asp:SqlDataSource ID="SqlDataSource1" 
    
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    runat="server" 
    DeleteCommand="DELETE FROM [users_users] WHERE [uid] = @uid" 
        InsertCommand="INSERT INTO [users_users] ([username], [displayname], [Tel], [email], [StaffCode], [Office], [Department]) VALUES (@username, @displayname, @Tel, @email, @StaffCode, @Office, @Department)" 
        ProviderName="System.Data.SqlClient" 
        SelectCommand="SELECT [uid], [username], [displayname], [Tel], [email], [StaffCode], [Office], [Department] FROM [users_users] where (@name='' or username+displayname like '%'+@name+'%') and (@dept='' or department=@dept) ORDER BY [uid] DESC" 
        UpdateCommand="UPDATE [users_users] SET [username] = @username, [displayname] = @displayname, [Tel] = @Tel, [email] = @email, [StaffCode] = @StaffCode, [Office] = @Office, [Department] = @Department WHERE [uid] = @uid">
        <DeleteParameters>
            <asp:Parameter Name="uid" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="username" Type="String" />
            <asp:Parameter Name="displayname" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="StaffCode" Type="String" />
            <asp:Parameter Name="Office" Type="String" />
            <asp:Parameter Name="Department" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="username" Type="String" />
            <asp:Parameter Name="displayname" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="StaffCode" Type="String" />
            <asp:Parameter Name="Office" Type="String" />
            <asp:Parameter Name="Department" Type="String" />
            <asp:Parameter Name="uid" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
        <asp:ControlParameter ControlID="txtsearchname" ConvertEmptyStringToNull=false Name="name" />
        <asp:ControlParameter ControlID="ddl_dept" ConvertEmptyStringToNull=false Name="dept" /> 
        </SelectParameters>

    </asp:SqlDataSource>
   


   <script>





       $(document).ready(

         function () {
             $("#a_addnew").click(
             function () {
                 $("#thenew").show();
                 $("#thetable").hide();
             }
             );

             $("#btn_back").click(
             function () {
                 $("#thenew").hide();
                 $("#thetable").show();
             }
             );

         }
         );

 


       function openRole() {
           var _uid = $("#hf_ids").val();
           Pop("Users_SetRight.aspx?uids=" + _uid, "500", "380", "设置角色");

       }

       function openUser() {
           var _uid = $("#hf_ids").val(); 
           Pop("EditUser_batch.aspx?uids=" + _uid, "800", "380", "批量修改用户信息");

       }


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


    </div>

</asp:Content>
