<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pop_users.aspx.cs" Inherits="Book.m.pop_users" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>  
    <script src="../javascript/jquery-1.9.1.min.js"></script>
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../javascript/layer/layer.js"></script> 
    <link href="../style/patch.css" rel="stylesheet" />
    <script src="../javascript/common.js"></script>
    <script src="../javascript/jquery.cookie.js"></script>
    <style>
        .bgRed { 
         background-color: #b0bed9; color:#ffffff;  
        } 
    </style>

</head>
<body  style="margin:8px; font-size:12px;" >
    <form id="form1" runat="server">
     
         
        
     
    <style>
   table tr.selected {
    background-color:#b0bed9;  color:#ffffff; 
} 
   .email{ width:200px; overflow-x:hidden;  }
 
  </style>
   
   
        

<div style="margin:2px; text-align:left" >
	         
       <div>

    
        请选择部门 <asp:DropDownList runat="server" ID="ddl_dept"   CssClass="form-control"  style="display:inline-block; width:100px;" AppendDataBoundItems="true" AutoPostBack="true" OnSelectedIndexChanged="ddl_dept_SelectedIndexChanged">
              <asp:ListItem Text="所有"  Value=""></asp:ListItem>
              </asp:DropDownList>
 
    </div>


     <div>
     <asp:TextBox runat="server" ID="key"   placeholder="姓名关键字"  CssClass="form-control"  style="width:100px; display:inline-block"></asp:TextBox>
    
           <asp:Button runat="server" ID="btn_Search" Text="搜索" CssClass="btn btn-primary  " />

 &nbsp;&nbsp;| &nbsp;&nbsp;
    
          <button class="btn btn-success btn-flat" id="btnSelect"
              onclick="if(!Issel()) return false; parent.setPopAttend($('#sel').val());  parent.document.getElementById('popWinClose').click(); "
              > 确定</button>
  </div>

     
     
 
    
     
</div>
         
         
        
        
        <asp:ListView runat="server" ID="listview1" DataSourceID="sds">
            

             <LayoutTemplate>
               
                            <table class="table" style="border-top:solid 1px #eee"  id="tbl_users">

                                <tr runat="server" style="">
                                    <th style="display:none">ID</th>
                                    <th width="120px">登录名</th>
                                    <th  width="120">显示名</th> 
                                      <th width="120px">部门</th>
                                    <th  width="0"> </th>
                                  
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                      
            </LayoutTemplate>
           


            <ItemTemplate>
                <tr>
                   
                    <td style="display:none">
                       <%# Eval("uid") %>
                    </td>
                    
                     <td>
                       <%# Eval("username") %>
                    </td>
                    <td>
                        <%# Eval("displayname") %>
                    </td>
                    
                      <td>
                       <%# Eval("dept") %>
                     </td>

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





        <input type="text" id="sel"  style="display:none"/>
        



        <script>

            $('#tbl_users tr:not(:first-child)').dblclick(
                function () {  
                    $(this).addClass('selected'); 
                    var tds = $(this).find("td"); 
                    var uid = $(tds[0]).html().trim();
                    var username = $(tds[1]).html().trim()
                    var displayname = $(tds[2]).html().trim();
                    var result = "$"+username + "$" + displayname + "!"; 
                    parent.setPopAttend(result); 
                    parent.document.getElementById('popWinClose').click();
                });



            $('#tbl_users tr:not(:first-child)').click(
                function () {
                     $(this).toggleClass('selected');
                });


            function Issel() {
                var checked = 0;
                var result = '';

                var _c = 0;

                $('#tbl_users tr:not(:first-child)').each(function () {

                    if ($(this).hasClass("selected")) {
                        checked++;
                        var tds = $(this).find("td");

                        var uid = $(tds[0]).html().trim();
                        var username = $(tds[1]).html().trim()
                        var displayname = $(tds[2]).html().trim();  

                        result += uid + "$" + username + "$" + displayname + "$" + "!";

                    } 

                });




                if (checked > 0) {

                    $("#sel").val(result);
                    return true;
                }
                else {
                    layer.alert('请至少选择一条记录', 12);
                    return false;
                }
            }

        </script>













<div class="paging" style="text-align:center">
 <asp:DataPager ID="DataPager1"   class="btn-group btn-group-sm" EnableViewState="false"
       PagedControlID="listview1" runat="server" PageSize="10">
 <Fields>
           
     
            <asp:NextPreviousPagerField 
                PreviousPageText="上一页" 
                FirstPageText="首页" 
                ShowPreviousPageButton="true"
                ShowFirstPageButton="true" 
                ShowNextPageButton="false" 
                ShowLastPageButton="false"
                ButtonCssClass="btn btn-default" 
                RenderNonBreakingSpacesBetweenControls="false" 
                RenderDisabledButtonsAsLabels="false" />

            <asp:NumericPagerField 
                ButtonType="Link" 
                CurrentPageLabelCssClass="btn btn-primary disabled"  
                RenderNonBreakingSpacesBetweenControls="false"
                NumericButtonCssClass="btn btn-default" 
                ButtonCount="10" 
                NextPageText="..." 
                NextPreviousButtonCssClass="btn btn-default" />
            
           <asp:NextPreviousPagerField 
               NextPageText="下一页" 
               LastPageText="尾页" 
               ShowNextPageButton="true"
               ShowLastPageButton="true" 
               ShowPreviousPageButton="false" 
               ShowFirstPageButton="false"
               ButtonCssClass="btn btn-default" 
               RenderNonBreakingSpacesBetweenControls="false" 
               RenderDisabledButtonsAsLabels="false"/>
      

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






        <asp:SqlDataSource runat="server" ID="sds"
              ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
             SelectCommand="select uid, username,displayname,
             email,department dept from users_users
            where 1=1 and
            (@dept='' or department=@dept) and
            (@key='' or username+displayname+email like '%'+@key+'%')
            "  
            >

            <SelectParameters>
                <asp:ControlParameter Name="key" ControlID="key" ConvertEmptyStringToNull="false" /> 
                <asp:ControlParameter Name="dept" ControlID="ddl_dept"  ConvertEmptyStringToNull="false" /> 
            </SelectParameters>

        </asp:SqlDataSource>


    </form>
</body>
</html>
