<%@ Page Title="" Language="C#" MasterPageFile="~/bps/basic.Master" AutoEventWireup="true" CodeBehind="add_bom_item.aspx.cs" Inherits="bps.bps.add_bom_item" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script src="../javascript/layer/layer.js"></script>
    <div style="margin:10px; font-size:12px;">

   <style>
       .num {
        width:70px;
       }
   </style>
      
   
     <div class="form-inline">

     
 <asp:DropDownList runat="server"  Width="200px"  CssClass="form-control inline" ID="ddl_cat1" AutoPostBack="True" OnSelectedIndexChanged="ddl_cat1_SelectedIndexChanged"></asp:DropDownList>
      <asp:DropDownList runat="server"  Width="200px"  ID="ddl_cat2" CssClass="form-control inline" AutoPostBack="True" OnSelectedIndexChanged="ddl_cat2_SelectedIndexChanged"></asp:DropDownList>
    
      
     物品名称 <asp:TextBox runat="server" ID="txt_key" CssClass="form-control inline" Width="220px" placeholder="物品编号/物品名称/VNr"></asp:TextBox>
    <asp:Button ID="btn_search"   OnClick="btn_search_Click" runat="server" Text="搜索" class="btn btn-sm  btn-primary btn-flat" />
       
  </div>
 


    

<asp:ListView ID="ListView1" runat="server"  EnableViewState="false"
    DataKeyNames="id" 
    DataSourceID="SqlDataSource1" 
  
     >
                   <LayoutTemplate>
                  
              <table id="itemPlaceholderContainer" runat="server" class="table  ">
                                        <tr    >
                                           
                                    
                                            <th runat="server"  width="100px">物品编号</th>
                                            <th runat="server"  width="140px">物料名称</th>  
                                        
                                             <th runat="server"  width="170px">规格型号</th>  
                                

                                             <th   runat="server"  width="80px">V.Nr</th>  

                                            <th runat="server"  width="70px">单位</th>
                                       

                                            <th runat="server"  width="80px">参考价格</th>
                                               
                                               <th runat="server"  width="70px">货币</th>  

                                               <th runat="server"  width="60px">数量</th>  


                                          <th runat="server"    width="70px">添加</th>  

                                              
                                          
                                       
                                        </tr>
                                        <tr id="itemPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                
                    </LayoutTemplate>
    
      
                    <ItemTemplate>
                        <tr>
                          
                            
                            
                            <td>
                                 <asp:HiddenField runat="server" ID="hf_id"   value='<%# Eval("id") %>'/>
                                <asp:Label ID="lbl_code" runat="server" Text='<%# Eval("code") %>' />
                         
                            </td>
                            
                            <td>
                               
                                <asp:Label ID="lbl_catname" runat="server" Text='<%# Eval("catname") %>' />
                            </td>
                             

                              <td>
                                <asp:Label ID="lbl_spec" runat="server" Text='<%# Eval("spec") %>' />
                             </td>



                            
                            <td>
                                    <asp:Label ID="lbl_supplycode" runat="server" Text='<%# Eval("supplycode") %>' />
                       
                            </td>


                            <td>
                                <asp:Label ID="lbl_piece" runat="server" Text='<%# Eval("piece") %>' />

                      
                            </td>


                          


                            
                             <td    >
                                <asp:Label ID="lbl_price" runat="server" Text='<%# Eval("price") %>' />
                             </td>
                           
                            
                           
                                <td>
                                <asp:Label ID="lbl_currency" runat="server" Text='<%# Eval("currency") %>' />

                      
                            </td>

                            
                              <td>
                              <input type="text"  class="num" value="1"/>

                            </td>


                              <td>
                              
                                   <a href="###" onclick="_add(this,<%#Eval("id")%> );">添加</a>

                            </td>
                           
                            


                          
                           

                          
                           

                     

                            
                        </tr>
                    </ItemTemplate>
                   
   

     </asp:ListView>
                 
 











<div>
 <asp:DataPager ID="DataPager1"   class="btn-group btn-group-sm"  
      PagedControlID="ListView1" 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 ID="SqlDataSource1" 
    
     ConnectionString='<%$ ConnectionStrings:ConnectionString %>'
    runat="server"  
        SelectCommand=" select purchase_categories.id, code, catname, spec, purchase_supply.supplycode, piece, price,currency,moq,leadtime, [parentid], shipmethod, [iscat]  FROM [purchase_categories]  left join purchase_supply on purchase_supply.supplycode=purchase_categories.supplycode  WHERE ([iscat] = 0) and    (@pid=0 or parentid=@pid or parentid in (select id from purchase_categories where parentid=@pid)     )       and (@key='' or catname+' '+code+' '+purchase_categories.supplycode like '%'+@key+'%')     ORDER BY [id] DESC" 
      
      OnSelecting="SqlDataSource1_Selecting" 
         
 
  >
       
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="iscat" Type="Int32" />
            <asp:Parameter DefaultValue="0" Name="pid" Type="Int32" />
            <asp:ControlParameter ControlID="txt_key" Name="key" Type="String"  ConvertEmptyStringToNull="false" />
          
       </SelectParameters>
         
 
  
  
 
 
 </asp:SqlDataSource>

 






        
    <script>

        function _add(obj,_mid)
        {
            _num=1;
            _num= $(obj).parent().parent().find("input:eq(1)").val(); 
            
            var _bomid=<%=Request.QueryString["id"] %>;
           
            $.get("ajax/ajax_bom_add_item.aspx?t=single&bomid="+_bomid+"&mid="+_mid+"&num="+_num); 
            $(obj).hide();
            layer.msg("添加成功，刷新后显示");
            
        }



    </script>













     </div>

 

</asp:Content>
