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


      <style>

        #gv_list tr td{ cursor:pointer}
    </style>

   
          <div    class="form-inline"  style="  padding:10px;" >  
         
 产品编号：<asp:TextBox runat="server"  Width="100"  ID="txt_productcode" CssClass="form-control"></asp:TextBox>
            
名称：<asp:TextBox runat="server" Width="120" ID="txt_productname" CssClass="form-control"></asp:TextBox>

版本号：<asp:TextBox runat="server" Width="90" ID="txt_revision" CssClass="form-control"></asp:TextBox>

客户名称：<asp:TextBox runat="server"  Width="130" ID="txt_customername" CssClass="form-control" ></asp:TextBox>
              &nbsp;&nbsp;
<asp:CheckBox runat="server" ID="cb_status" Text="仅审批通过" AutoPostBack="true"  />

              &nbsp;&nbsp;



                  <asp:Button runat="server" ID="btn_search" Text="查询" CssClass="btn btn-success" />
                 

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


       <button class="btn btn-primary btn-flat" id="btnSelect"
              onclick="submitAndClose(); "
              > 确定</button>
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <button class="btn btn-danger btn-flat" onclick=" parent.layer.closeAll();"> 关闭</button>
      </div>




   
     <asp:GridView runat="server" ID="gv_list" ClientIDMode="Static" DataKeyNames="id" PageSize="10" GridLines="None" DataSourceID="sds"  CssClass="table table-hover"
         AutoGenerateColumns="false"  
         AllowPaging="True">
        <Columns>
         
            <asp:TemplateField>
                <HeaderStyle Width="30px" />
                <ItemTemplate>
                    <input type="checkbox"   value="<%#Eval("id") %>-<%#Eval("productcode") %>-<%#Eval("revision") %>-<%#Eval("productname") %>"   class="itemgroup" />

                </ItemTemplate>

            </asp:TemplateField>

               <asp:BoundField DataField="productcode" HeaderText="产品编号" HeaderStyle-Width="120px" />

             <asp:BoundField DataField="productname" HeaderText="产品名称" HeaderStyle-Width="100px" />

             <asp:BoundField DataField="customername" HeaderText="客户名称" HeaderStyle-Width="200px" />

             <asp:BoundField DataField="revision" HeaderText="版本" HeaderStyle-Width="300px" />


           
        </Columns>
        <PagerStyle CssClass="pagination-ys" />

    </asp:GridView>




    <asp:SqlDataSource runat="server" ID="sds"
         ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
     SelectCommand="
        select productname,productcode,revision,customername,id ,status from purchase_bom 
         where  (@productname='' or productname like '%'+@productname+'%')
          and  (@productcode='' or productcode like '%'+@productcode+'%')
          and  (@customername='' or customername like '%'+@customername+'%')
          and  (@revision=-9 or revision=@revision)
          and (@status=''  or auditstatus=@status    )
        
        ORDER BY [id] DESC" 
          
       
  >

        <SelectParameters>
            <asp:ControlParameter ControlID="txt_productname" ConvertEmptyStringToNull="false" Name="productname" />
            <asp:ControlParameter ControlID="txt_productcode" ConvertEmptyStringToNull="false" Name="productcode" />
            <asp:ControlParameter ControlID="txt_customername" ConvertEmptyStringToNull="false" Name="customername" />
            <asp:ControlParameter ControlID="txt_revision" DefaultValue="-9" DbType="Decimal"  Name="revision" />
             <asp:ControlParameter ControlID="cb_status"  DbType="Boolean"  Name="status" ConvertEmptyStringToNull="false"/>

        </SelectParameters>
         

        
       
    
    </asp:SqlDataSource>












     <script>



         $("#gv_list").on("click", "tr", function () {

             $(".itemgroup").prop("checked", false);

             $(this).parent().find("tr").each(
                 function () {
                     $(this).removeClass("selected");
                 });


             var input = $(this).find("input");

             if ($(input).prop("disabled")) {
             }
             else {


                 if ($(input).prop("checked")) {
                     $(input).prop("checked", false);
                     $(this).removeClass("selected");
                 }

                 else {
                     $(input).prop("checked", true);
                     $(this).addClass("selected");
                 }
             }



         });







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

             var _c = 0;
             $(".itemgroup").each(
              function () {
                  if ($(this).is(':checked')) {
                      checked++;
                      result = $(this).val();
                  }
              }

             ); 

             parent.setPopProductCode(result);
             parent.layer.close(parent.layer.getFrameIndex(window.name));

         }


        </script>






</asp:Content>
