<%@ Page Title="" Language="C#" MasterPageFile="~/helpdesk/Pc.master" AutoEventWireup="true" CodeBehind="pc_ip.aspx.cs" Inherits="helpdesk.helpdesk.pc_ip" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">


    <div class="alert alert-danger">
    
            <asp:Label runat="server" ID="ip_intro" ClientIDMode="Static"> 
      
           </asp:Label>

       <a href="#"   onclick="layer.open({ type: 1, area: ['500px', '300px'], content: $('#update_intro') });">修改说明</a>

        <a href="genip.aspx" target="_blank">重置IP排序</a>

    </div>

     
     
    <div class="well">

        类别：<asp:DropDownList runat="server"  CssClass="form-control" style="width:150px;display:inline" ClientIDMode="Static" ID="ddl_types">

            <asp:ListItem Text="所有" Value=""></asp:ListItem>
               <asp:ListItem Text="PC" Value="PC"></asp:ListItem>
               <asp:ListItem Text="外设" Value="外设"></asp:ListItem>

           </asp:DropDownList>
        &nbsp;&nbsp;
        IP地址段 从
        <asp:TextBox runat="server" ID="ip1" placeholder="例如：192.168.1.0"  CssClass="form-control" style="width:200px;display:inline" ClientIDMode="Static"></asp:TextBox>
        到
        <asp:TextBox runat="server" ID="ip2" placeholder="例如：192.168.1.255" CssClass="form-control"   style="width:200px;display:inline" ClientIDMode="Static"></asp:TextBox>


         &nbsp;&nbsp;


        所属组织   <asp:TextBox runat="server" ID="belongto" placeholder="例如：集团" CssClass="form-control"   style="width:100px;display:inline" ClientIDMode="Static"></asp:TextBox>





        <asp:Button runat="server" ID="btn_search"  OnClientClick="calip();" CssClass="btn btn-success" Text="查询" />

           <a href="javascript:void(0)"; onclick="ept('export_data.aspx?types=ip')" class="btn  bg-blue  "> 导出</a> 
    </div>

     

    <div  style="display:none" >
          <asp:TextBox runat="server" ID="txt_ip1"  Text="0"    ClientIDMode="Static"></asp:TextBox>
        到
        <asp:TextBox runat="server" ID="txt_ip2"  Text="0" ClientIDMode="Static"></asp:TextBox>

    </div>


	<asp:ListView ID="lv_lists" runat="server"  DataSourceID="sds" 
    ItemContainerID="layoutTableTemplate"  
        
                        
 >
 
 
    <LayoutTemplate>
 
   <table  class="table table-hover"> 
	<tr>
       
        <th  width="90px"  >设备类别</th>
		<th width="80px">IP地址</th>
		<th width="200px">MAC地址</th>
		<th  width="105px" >设备名称</th>
	    <th  width="90px" >所属组织</th>
		<th  width="105px">使用部门</th>
		<th   width="120px" >使用者</th>
        <th   width="120px" >制造商</th>
	</tr>
        
      <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
         
          
  
	
        </table>
 
        
 
    </LayoutTemplate>

   
    
    <ItemTemplate>
    
 <tr>
 
     
       <td   ><%#Eval("设备类别")%></td>
		<td ><%#Eval("IP地址")%></td>
		<td>  <%#Eval("MAC地址")%></td>
		<td   ><%#Eval("设备名称")%></td>
	    <td   ><%#Eval("所属组织")%></td>
		<td  ><%#Eval("使用部门")%></td>
		<td     >
	    	<%#Eval("使用者")%>
		</td>

        <td    >
	    	<%#Eval("制造商")%>
		</td>    
		  
 
</tr>  
    </ItemTemplate>

</asp:ListView>     








    

<div>
 <asp:DataPager ID="DataPager1"   class="btn-group btn-group-sm"  
      PagedControlID="lv_lists" runat="server" PageSize=20>
 <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  IP地址,设备类别,MAC地址,设备名称,设备类型,所属组织,使用部门,使用者,制造商,ip10  from
        (
SELECT '外设' as 设备类别, IP as IP地址, MAC AS MAC地址, assetname as 设备名称, types 设备类型, belongto 所属组织,dept 使用部门,enduser 使用者,  manufacturer 制造商, ip10  from  [helpdesk_pc_asset] where ((ip<>'') and  (usestatus!='报废')  )  
union all
select 'PC' as 设备类别, ip, mac, pcname as assetname, usetype as types, belongto, dept,enduser, mainboardmanufacture as manufacturer,ip10  from helpdesk_pc where (ip<>'' ) and (usestatus!='报废')
        ) A


         where(
                  ((@_types='') or (设备类别=@_types) ) 
                  and (@_belongto='' or 所属组织 like '%'+@_belongto+'%') 
                  and ( ( @_ip1=0) or (ip10>=@_ip1) ) 
                  and ( (@_ip2=0) or (ip10<=@_ip2))  
                  
            ) 


order by  ip10 asc  
        
        "

        >



    <SelectParameters>
           <asp:ControlParameter DefaultValue="" Name="_types" ControlID="ddl_types" ConvertEmptyStringToNull="false" />
           <asp:ControlParameter DefaultValue="0" Name="_ip1" ControlID="txt_ip1"  DbType="Double" />
           <asp:ControlParameter DefaultValue="0" Name="_ip2" ControlID="txt_ip2" DbType="Double"  />
           <asp:ControlParameter DefaultValue="" Name="_belongto" ControlID="belongto" ConvertEmptyStringToNull="false" />
    </SelectParameters>







    </asp:SqlDataSource>











    <div id="update_intro" style="display:none; text-align:center; margin:10px">

        <asp:TextBox runat="server" ID="txt_intro" ClientIDMode="Static" Height="180px" Width="470"  TextMode="MultiLine" CssClass="form-control"></asp:TextBox>
       <br />
       <input type="button" onclick="save_intro();" value="保存"   class="btn btn-primary" />

    </div>



    <script>


        $("#txt_intro").val($("#ip_intro").text());


        function save_intro()
        {
            $("#ip_intro").html($("#txt_intro").val());

            $.post("ajax/update_intro.aspx", { txt: escape($("#txt_intro").val()) }) 

            layer.closeAll();
        }



        function calip()
        {
            var ip1_10 = ipto10($("#ip1").val());
            var ip2_10 = ipto10($("#ip2").val()); 
            $("#txt_ip1").val(ip1_10);
            $("#txt_ip2").val(ip2_10);

        }


    function ipto10(ip)
        {
            if (ip == "")
             return 0; 
            ips = ip.split('.'); 
            result = Number(ips[0]) * 16777216 + Number(ips[1]) * 65536 + Number(ips[2]) * 256 + Number(ips[3]); 
            return result;
        }

    </script>



</asp:Content>
