<%@ Page Title="" Language="C#" ClientIDMode="Static" EnableEventValidation="false"  MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="UserLists.aspx.cs" Inherits="ServiceDesk.Admin.UserLists" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


    <style>
        img.avtor { width:30px; height:30px; border-radius:5px;
        }
    </style>


     
          
            <!-- search start -->

              <asp:UpdatePanel runat="server" ID="pn1"  UpdateMode="Conditional">
                <ContentTemplate>

             <table class="layui-table table2">
                 <tr>
                     <th>
ID
                     </th>
                     <td>
  <asp:TextBox runat="server" ID="txt_id"  autocomplete="off" class="layui-input"></asp:TextBox>

                     </td>

                     <th>
                         名称
                     </th>
                     <td>
 <asp:TextBox runat="server" ID="txt_username"    autocomplete="off" class="layui-input"></asp:TextBox>
                     </td>

                     <th>
                         邮箱
                     </th>
                     <td>
                          <asp:TextBox runat="server" ID="txt_email" autocomplete="off" class="layui-input"></asp:TextBox>
                     </td>

                     <th>
                         电话
                     </th>
                     <td>
                          <asp:TextBox runat="server" ID="txt_tel"   autocomplete="off" class="layui-input"></asp:TextBox>
                     </td>
                 </tr>

                 <tr>
                     <th>
                         部门
                     </th>
                     <td>
                        <asp:DropDownList runat="server" AutoPostBack="true"
                    lay-ignore  CssClass="form-control"   
                     ID="ddl_dept"> 
                </asp:DropDownList>

                     </td>

                     <td>
                          <asp:Button runat="server" ID="lb_search"  Text="查询"
                              class="layui-btn layuiadmin-btn-useradmin"> 
                  </asp:Button>

                     </td>

                     <td colspan="5">
                         共有人员：<asp:Label runat="server" ID="lbl_total"></asp:Label> 名
                     </td>
                 </tr>
             </table>
                     
      
               </ContentTemplate>
            </asp:UpdatePanel>

             <!-- search end -->
         








        
          <!-- use list -->

                   

      <div class="alert">

             <a class="layui-btn layuiadmin-btn-useradmin"
             onclick="Pop('UserEditUser.aspx',990,550,'添加新用户'); return false;"
              >添加用户</a>

           

             <asp:Button runat="server" ID="btn_del" 
               OnClientClick=" if(!issel()) { return false;} "
               Text="批量删除" 
              class="layui-btn layui-btn-danger"
               OnClick="btn_del_Click" />

                   
           <a class="layui-btn   layui-btn-normal" title="在集成AD域的情况下，从AD域里导入用户"
             onclick="Pop('UserImportsFromAD.aspx',500,380,'导入用户'); return false;"
               >从AD域导入</a>


            &nbsp; &nbsp;| &nbsp; &nbsp;
              <a href="#" onclick="if(issel()) openRole(); return false; " class="layui-btn layui-btn-warm"  >批量修改角色</a>
       <a  href="#"  onclick="if(issel()) moveDept(); return false; "     class="layui-btn layui-btn-normal" >批量转移部门</a>
             

              <a href="###"  onclick='Pop("UserExportData.aspx?types=users");return false;'  class="layui-btn layui-btn-default  "> Excel导出</a> 

              <a href="###"  onclick='Pop("UserImportData.aspx?types=users");return false;'  class="layui-btn layui-btn-primary "> Excel导入</a> 

            
                  &nbsp; &nbsp;| &nbsp; &nbsp;
             <a href="###" class=" layui-btn layui-btn-warm"  
    onclick="Pop('usertb.aspx',500,380,'同步人员');return false;" 
       > 一键同步</a> 



        </div>
        


    

            <asp:UpdatePanel runat="server" ID="UpdatePanel1"   >

                <ContentTemplate>
          
    <asp:ListView EnableViewState="false"  ID="lv_lists" runat="server" 
        DataKeyNames="uid" DataSourceID="SqlDataSource1">
            

           <LayoutTemplate>
              
                       <table    class="layui-table" >
                           <thead>

                        <tr>
                         <th width=90px >   
                             <input type="checkbox"   id="chk_all" lay-skin="primary"  lay-filter="chk_all" > ID
                            <input type="hidden" name="hf_ids" id="hf_ids" />

                         </th>

                        <th width="60px">头像</th>
                        <th width="90px">用户名</th>
                        <th  width="100px">显示名</th>
                        <th  width="150px">部门</th> 
                        <th width="130px">电话</th>
                        <th width="180px">邮件</th> 
                          
                        <th width="250px">操作</th>
                  </tr>


                           </thead>

                           <tbody>

                         

                        <tr id="itemPlaceholder" runat="server">
                        </tr>
              </tbody>
                           
             </table>
                     
            
         </LayoutTemplate>


         <ItemTemplate>
             <tr>
               <td>  
                     <input type="checkbox" class="chk_item" value="<%# Eval("uid") %>"  name="chk_item" lay-skin="primary" > <%# Eval("uid") %> 
                   
               </td>
               <td>   <img  class="avtor"  onerror="imgerrorfun(this);" id='img<%#Eval("uid") %>'  src='<%#Eval("avtor") %>'>    </td> 
               <td><%#Eval("username") %></td>
               <td><%#Eval("displayname") %></td>
               <td><%#Eval("department") %></td>
               <td><%#Eval("tel") %></td>
               <td><%#Eval("email") %></td>
             
                 
                
                <td>
                
                      <a href="###" 
                                class="layui-btn  layui-btn-normal layui-btn-sm" 
                                 onclick="Pop('UserSetRight.aspx?id=<%#Eval("uid") %>',500,400,'角色设置');return false;" >
                              角色

                             </a>

                     <a href="###" class="layui-btn  layui-btn-sm"
                          onclick="Pop('UserEditUser.aspx?id=<%#Eval("uid") %>',980,540,'用户详情');"  >
                   编辑</a>



                            <asp:LinkButton runat="server" ID="DeleteButton" 
                                               OnClientClick="return confirm('确定删除吗？')"
                                              CommandName="Delete"
                                        class="layui-btn layui-btn-danger layui-btn-sm"
                                       >   删除</asp:LinkButton>


 
                </td>  
           </tr>
         </ItemTemplate>
      
          
     </asp:ListView>
   

      
   



          



 
  
  
  



 <div  class="paging"  >

 <asp:DataPager ID="DataPager1" 
      class="layui-box layui-laypage layui-laypage-default"  
       
     PagedControlID="lv_lists" runat="server" PageSize=10>
 <Fields>
            
        <asp:NextPreviousPagerField 
                PreviousPageText="上一页" 
                FirstPageText="|<" 
                ShowPreviousPageButton="true"
                ShowFirstPageButton="false" 
                ShowNextPageButton="false" 
                ShowLastPageButton="false"
                ButtonCssClass="btn btn-default" 
                RenderNonBreakingSpacesBetweenControls="false" 
                RenderDisabledButtonsAsLabels="false" />


           <asp:NumericPagerField  
                ButtonType="Link" 
                CurrentPageLabelCssClass="currentpage"  
                RenderNonBreakingSpacesBetweenControls="false" 
              
                ButtonCount="10" 
                NextPageText="..." 
               />

     

     <asp:NextPreviousPagerField  
               NextPageText="下一页" 
               LastPageText=">|" 
               ShowNextPageButton="true"
               ShowLastPageButton="false" 
               ShowPreviousPageButton="false" 
               ShowFirstPageButton="false"
              
               RenderNonBreakingSpacesBetweenControls="false" 
               RenderDisabledButtonsAsLabels="false"/>
      

  </Fields> 
</asp:DataPager>
</div>

  
  
  
  
  
  
  
  
  
    <asp:SqlDataSource ID="SqlDataSource1" 
    
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    runat="server"  
      DeleteCommand="delete from users_users where uid=@uid "
       SelectCommand=" SELECT uid, isenable, avtor,  username, displayname, tel, email,department FROM [users_users]   where  1=1    and (@uid='' or uid=@uid)    and (@username='' or username+displayname like '%'+@username+'%')      and (@tel='' or tel like '%'+@tel+'%')  and  (@dept='' or department=@dept) and (@email='' or email like '%'+@email+'%')  order by uid desc
         "
   OnSelected="SqlDataSource1_Selected"  
        >
       
      <SelectParameters> 
            <asp:ControlParameter ControlID="txt_id" ConvertEmptyStringToNull=false Name="uid" /> 
           <asp:ControlParameter ControlID="txt_username" ConvertEmptyStringToNull=false Name="username" /> 
         <asp:ControlParameter ControlID="txt_tel" ConvertEmptyStringToNull=false Name="tel" /> 
         <asp:ControlParameter ControlID="txt_email" ConvertEmptyStringToNull=false Name="email" /> 
         <asp:ControlParameter ControlID="ddl_dept" ConvertEmptyStringToNull=false Name="dept" /> 
       
        </SelectParameters>


    </asp:SqlDataSource>
   

           




      </div>

       
                </ContentTemplate>
                </asp:UpdatePanel>

           

     


     
     
     





    

   <script>
       function fixPop() {
           $(".role").off();
           $(".edit").off();
           $(".role").click(function () {
               var uid = $(this).data("uid");
               Pop('UserSetRight.aspx?id=' + uid, 500, 400, '角色设置');
           });
           $(".edit").click(function () {
               var uid = $(this).data("uid");
               Pop('UserEditUser.aspx?id=' + uid, 980, 540, '用户详情');
           });




       }






       fixPop();

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

       }

       function moveDept() {
           var _uid = $("#hf_ids").val();
           Pop("UserMoveDept.aspx?uids=" + _uid, "500", "400", "修改部门");
       }




   </script>
      

 
    



     

    
    
    
          
 <script type="text/javascript">
        function imgerrorfun(obj) {
            var theimg = document.getElementById(obj.id);
            theimg.src = "images/avtor.png";
            theimg.onerror = null;
        }
</script> 

    <script>


        layui.use('form', function () {
            var form = layui.form; 

            form.on('checkbox(isenable)', function (data) {
                var value = data.elem.checked ? "1" : "0";
                var id = data.value;

                $.get("UserLists.aspx?t=setisenable&uid=" + id + "&isenable=" + value + "&r=" + Math.random());
                layer.msg("操作成功", { icon: 1 });
            });




        });


    </script>


</asp:Content>

 