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

       <link href="../javascript/datatables/datatables.css" rel="stylesheet" />
      <script src="../javascript/datatables/datatables.min.js"></script>

    
        <style>
          .xxx  {
              background-color: #DFF0D8;  
            font-weight:bold 
          }
        </style>
    

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

    
 <!--buttons toolbar-->
  
     <div class="alert form-inline" style="border:solid 1px #ccc">
  
      
      
                
     外设类别： <asp:DropDownList ID="ddl_types"  AppendDataBoundItems="true"  EnableViewState="false" ClientIDMode="Static" 
           class="form-control" style="display:inline-block; width:150px" runat="server">
             <asp:ListItem Text="所有" Value=""></asp:ListItem>
        </asp:DropDownList>


           使用状态  <asp:DropDownList runat="server" ID="ddl_status" Width="120px" ClientIDMode="Static"   AppendDataBoundItems="true"  CssClass="form-control"  >
         <asp:ListItem Text="==所有==" Value=""></asp:ListItem> 
        <asp:ListItem Text="在用"  Value="在用"></asp:ListItem>
        <asp:ListItem Text="在库"  style="color:#09a800"  Value="在库"></asp:ListItem>
        <asp:ListItem Text="报废"   style="color:#d44950" Value="报废"></asp:ListItem>
        <asp:ListItem Text="维修"  style="color:orange" Value="维修"></asp:ListItem>

     </asp:DropDownList>
  
          
     &nbsp;&nbsp;&nbsp;&nbsp;      
                 
                
     关键字：  
      
    


 <asp:TextBox ID="txt_search" CssClass="form-control" 
     placeholder="" ClientIDMode="Static" 
      style="display:inline-block; width:250px" runat="server" ToolTip=""></asp:TextBox>
                


           &nbsp;&nbsp;&nbsp;&nbsp;  |  &nbsp;&nbsp;&nbsp;&nbsp; 

          <input type="submit"  style="display:none" onclick="return false;"/>

          <a href="Pc_AddEditAsset.aspx" class="btn btn-sm  bg-green  btn-flat">添加新外设</a>
            
        <asp:Button   runat="server" ID="btndelete" Text="删除"   
           OnClientClick=" if(!IsSel()){ return false;} "   
          class="btn  btn-sm btn-danger  btn-flat" onclick="btndelete_Click"  
          />
          
  &nbsp;&nbsp;&nbsp;&nbsp;  |  &nbsp;&nbsp;&nbsp;&nbsp; 
          <a href="javascript:void(0)"; onclick="ept('Export_Data.aspx?types=asset')" class="btn  btn-sm  btn-primary   btn-flat"> 导出</a>

       <a href="javascript:void(0)"; onclick="ept('Import_Data.aspx?types=asset')" class="btn btn-sm  bg-teal   btn-flat"> 导入</a>

           
   &nbsp;&nbsp;&nbsp;&nbsp;  |  &nbsp;&nbsp;&nbsp;&nbsp; 
   
   








            
         </div>   
  




  
   <!--/buttons toolbar-->
   
  
     <asp:GridView ID="gv_list" 
         AllowPaging="false"  
         EnableViewState="false" 
         GridLines="None"
         ClientIDMode="Static"
         DataSourceID="SqlDataSource1" 
         AutoGenerateColumns="false" 
         runat="server" 
         class="table table-hover" 
         AllowSorting="false" 
         Width="99%"
         OnPreRender="gv_list_PreRender" >
    
    <Columns>
    
   
     
     
      <asp:BoundField DataField="id" HeaderText="ID" HeaderStyle-Width="60px"  />
      <asp:HyperLinkField DataTextField="assetname" DataNavigateUrlFields="id" DataNavigateUrlFormatString="Pc_AddEditAsset.aspx?id={0}"   HeaderText="外设名称"    HeaderStyle-Width="190px" />
      <asp:BoundField  HeaderText="外设类别" DataField="types"   HeaderStyle-Width="100px"   />
      <asp:BoundField  HeaderText="使用状态" DataField="usestatus"     SortExpression="usestatus"   HeaderStyle-Width="100px"   />
      <asp:BoundField  HeaderText="制造商" DataField="manufacturer"  SortExpression="manufacturer" HeaderStyle-Width="100px"   />
      <asp:BoundField  HeaderText="存储位置" DataField="storeplace"  HeaderStyle-Width="100px"  />
      <asp:BoundField  HeaderText="使用部门" DataField="dept"  HeaderStyle-Width="100px"  />
      <asp:BoundField  HeaderText="IP" DataField="ip"      HeaderStyle-Width="120px"   />

        <asp:TemplateField>
            <HeaderStyle Width="100" />
            <HeaderTemplate>采购日期</HeaderTemplate>
            <ItemTemplate> 
                <%# DtHelper.GetDay(Eval("buydate")) %>  
            </ItemTemplate>
        </asp:TemplateField>

      
     <asp:BoundField  HeaderText="备注" DataField="notes"     HeaderStyle-Width="200px"   />
  

    </Columns>
    
    </asp:GridView>
  
         

     <asp:SqlDataSource ID="SqlDataSource1" runat="server"  CacheDuration="120" CacheExpirationPolicy="Absolute" CacheKeyDependency="pclist" EnableCaching="true"
         ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
         SelectCommand="select id, storeplace, assetname, manufacturer, serialno, belongto, dept, usestatus, types, buydate, ip ,notes  from helpdesk_pc_asset    ORDER BY [id] DESC">
           
         
     </asp:SqlDataSource>

  
  
  <script>


      var lang = {
          "sProcessing": "处理中...",
          "sLengthMenu": "每页 _MENU_ 项",
          "sZeroRecords": "没有匹配结果",
          "sInfo": "   当前显示第 _PAGE_页 共 _PAGES_ 页，共 _TOTAL_ 条 ",
          "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
          "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
          "sInfoPostFix": "",
          "sSearch": "搜索:",
          "sUrl": "",
          "sEmptyTable": "表中数据为空",
          "sLoadingRecords": "载入中...",
          "sInfoThousands": ",",
          "oPaginate": {
              "sFirst": "首页",
              "sPrevious": "上页",
              "sNext": "下页",
              "sLast": "末页",
              "sJump": "跳转"
          },
          "oAria": {
              "sSortAscending": ": 以升序排列此列",
              "sSortDescending": ": 以降序排列此列"
          }
      };



      $(document).ready(function () {
          $('#gv_list').dataTable({
              language: lang,  //提示信息
              autoWidth: false, //禁用自动调整列宽 
              pageLength: 10,
              order: [[0, "desc"]],
             lengthMenu: [[10,20, 50, -1], [10, 20,50, "All"]],
             dom: 'irtp',//lfrtip frtip
          });



          oTable = $('#gv_list').DataTable();

          $('#txt_search').keyup(function () {
              oTable.search($(this).val()).draw();
          })




          $("#ddl_types").change(function () {
              oTable.column(2).search($(this).val()).draw();
          });



          $("#ddl_status").change(function () {

              oTable.column(3).search($(this).val()).draw();

          });



          $('#gv_list tbody').on('click', 'tr', function () {
              $(this).toggleClass('xxx');
          });



          formatData();


      });




      function formatData() {

          $('#gv_list tbody tr').each(
           function () {

               var _v = $(this).find("td:eq(4)").html();


               switch (_v) {
                   case "报废":
                       $(this).css("color", "#ff0000");
                       break;

                   case "维修":
                       $(this).css("color", "orange");
                       break;


                   case "在库":
                       $(this).css("color", "#09a800");
                       break;

               }


           }

           );

      }







      function IsSel() {

          var checked = 0;
          var result = "";
          var _c = 0;

          var rows = $("tr.xxx");

          for (var i = 0; i < rows.length; i++) {
              checked++;
              var __id = $(rows[i]).find("td:eq(0)").html().trim();
              result = __id + "," + result;
          }

          result = result + "-1";

          if (checked > 0) {
              $("#hf_ids").val(result);

              return true;
          }
          else {
              $("#hf_ids").val("");
              layer.alert("请选择需要删除的资产");
              return false;
          }
      }



  </script>
  
  




</asp:Content>
