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

   


        <style>
        table.add th {
         font-weight:normal; text-align:right
        }
           table.table-sm th {
             text-align:left !important; font-weight:bold
            }
    </style> 

 

    <script src="../UserControl/mat_js.aspx?index=1&id=<%=id %>"></script>

        <script src="../javascript/suggest/bootstrap-suggest.min.js"></script>


   

             <asp:Panel runat="server" ID="pnl_rotate">
                 <asp:TextBox runat="server" ID="proid" Visible="false"></asp:TextBox>
   
   <table class="table add table-condensed"    >
                    
        <tr>
              <th  width="100px" >供应商名<font color=red>*</font>：</th>
            <td width="200px">
              
 <div class="input-group" style="width:240px;">                   
  <asp:TextBox class="form-control"   ValidationGroup="Add" ID="sname" Text=""  
       style="width:240px;margin-right:0px" runat="server"></asp:TextBox>                             
                   
                      
    <div class="input-group-btn" style="width:1px;">                                                    
     <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
    </div>       
                                              
</div>
            

           </td>

          <th  width="100px" >供应商号<font color=red>*</font>：</th>
            <td width="200px">
                <asp:TextBox class="form-control"    ID="scode" Text=""  runat="server"></asp:TextBox>
           </td>

          

             <th  width="100px" >交货期(天)：</th>
            <td width="200px">
                <asp:TextBox class="form-control"  Text="0"    ID="leadtime"    runat="server"></asp:TextBox>
           </td> 

        </tr>



        <tr>
          <th  width="100px" >价格<font color=red>*</font>：</th>
            <td width="200px">
                 
               <asp:TextBox id="price" Runat="Server"  Text="0"   style="display:inline-block; width:150px"  class="form-control inline"  ValidationGroup="Add"></asp:TextBox> 
 
    <asp:DropDownList runat="server"  style="display:inline-block; width:100px" 
           AppendDataBoundItems="true"   class="form-control inline"   ID="ddl_currency"> 
    </asp:DropDownList>  

           </td>

            <th  width="100px" >最低购买量：</th>
            <td width="200px">
                <asp:TextBox class="form-control"   value="0"  ID="minnum" Text=""  runat="server"></asp:TextBox>
           </td>

             <th  width="100px" >最低购买量量：</th>
            <td width="200px">
               <asp:TextBox class="form-control"   value="99999"  ID="maxnum" Text=""  runat="server"></asp:TextBox>
           </td> 

        </tr>




        <tr>
          <th  width="100px" >报价有效期 从：</th>
            <td width="200px">
                <asp:TextBox class="form-control" onclick="laydate();"   ValidationGroup="Add" ID="dt_pricedatefrom" Text=""  runat="server"></asp:TextBox>
           </td>

            <th  width="100px" >到：</th>
            <td width="200px">
                <asp:TextBox class="form-control  "  onclick="laydate();"  ValidationGroup="Add" ID="dt_pricedateto" Text=""  runat="server"></asp:TextBox>
           </td>

          <th  width="100px" >  </th>
            <td width="200px">
                <asp:TextBox class="form-control"  Visible="false"  ValidationGroup="Add" ID="supplyproname" Text=""  runat="server"></asp:TextBox>
           </td>
        </tr>


        <tr>
            

            <th  width="100px" >供应商内部料号：</th>
            <td width="200px">
                <asp:TextBox class="form-control"   ValidationGroup="Add" ID="supplyprocode" Text=""  runat="server"></asp:TextBox>
           </td>

          
            <th>
             运输方式
            </th>
            <td>

    <asp:DropDownList runat="server" 
       class="form-control  "   ID="ddl_shipmethod"> 
    </asp:DropDownList>  
            </td>







             <th>价格说明</th>
            <td>

                <asp:TextBox class="form-control"   ValidationGroup="Add" ID="note" Text=""  runat="server"></asp:TextBox>
            </td>



        </tr>


       <tr>
           <td colspan="6" align="center">

                  <asp:Button runat="server" ID="btn_add" Text="添加" CssClass="btn btn-primary btn-sm" OnClick="btn_add_Click" />
           </td>
       </tr>
    </table>


    </asp:Panel>


    <script>
        $("#sname").bsSuggest({
            inputWarnColor: 'rgba(255,255,255)',
            indexId: 1, //data.value 的第几个数据，作为input输入框的内容
            indexKey:0, //data.value 的第几个数据，作为input输入框的内容
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: false, //以分隔符号分割的多关键字支持
            separator: ",", //多关键字支持时的分隔符，默认为空格
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            effectiveFields: ["supplyname", "supplycode"],
            effectiveFieldsAlias: { supplyname: "供应商名", supplycode: "供应商" },
            showHeader: true,
            url: 'ajax/get_supply_by_name.aspx?t=frommat&name=', /*优先从url ajax 请求 json 帮助数据，注意最后一个参数为关键字请求参数*/

            processData: function (json) {
                // url 获取数据时，对数据的处理，作为 getData 的回调函数                
                var i, len, data = { value: [] };
                if (!json || json.length == 0) {
                    return false;
                }
                len = json.length;

                for (i = 0; i < len; i++) {
                    data.value.push({
                        "supplyname": json[i].supplyname,
                        "supplycode": json[i].supplycode
                    });
                }

                return data;
            }

        }).on('onSetSelectValue', function (e, keyword, data) {

            $("#scode").val(keyword.id);
            
        });
           </script>














    <asp:GridView ID="GridView1" runat="server"
         CssClass="table table-hover" GridLines="None"
         AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> 
            <asp:BoundField DataField="scode" HeaderText="供应商号" SortExpression="scode" HeaderStyle-Width="80px" />
            <asp:BoundField DataField="sname" HeaderText="供应商名" SortExpression="sname" HeaderStyle-Width="200px"/>
            <asp:BoundField DataField="price" HeaderText="价格" SortExpression="price" HeaderStyle-Width="80px"/>
            <asp:BoundField DataField="currency" HeaderText="货币" SortExpression="currency" HeaderStyle-Width="60px"/>
            <asp:BoundField DataField="minnum" HeaderText="最低数量" SortExpression="minnum" HeaderStyle-Width="60px"/>
            <asp:BoundField DataField="maxnum" HeaderText="最高数量" SortExpression="maxnum" HeaderStyle-Width="60px"/>
            <asp:BoundField DataField="leadtime" HeaderText="交货期" SortExpression="leadtime" HeaderStyle-Width="80px"/>
            <asp:BoundField DataField="shipmethod" HeaderText="运输方式" SortExpression="shipmethod" HeaderStyle-Width="80px"/>
            <asp:BoundField DataField="supplyprocode" HeaderText="内部料号" SortExpression="supplyprocode" HeaderStyle-Width="80px"/>
             <asp:BoundField DataField="pricedatefrom" HeaderText="有效期从" SortExpression="pricedatefrom"  DataFormatString="{0:yyyy-MM-dd}" HeaderStyle-Width="80px"/>
            <asp:BoundField DataField="pricedateto" HeaderText="有效期到" SortExpression="pricedateto"  DataFormatString="{0:yyyy-MM-dd}" HeaderStyle-Width="80px"/>
            <asp:BoundField DataField="note" HeaderText="价格说明" SortExpression="note" HeaderStyle-Width="200px"/>
        </Columns>
        </asp:GridView>



    <asp:SqlDataSource ID="SqlDataSource1"
         ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
         runat="server" 
        DeleteCommand="DELETE FROM [purchase_supply_product] WHERE [id] = @id" 
              
         SelectCommand="SELECT [id], [proid], [mcode], [scode], [sname], [price], [currency], [minnum], [maxnum], [leadtime], [shipmethod], [supplyprocode], [supplyproname], [pricedatefrom], [pricedateto], [note] FROM [purchase_supply_product] where proid=@proid ORDER BY [id] DESC" 
        UpdateCommand="UPDATE [purchase_supply_product] SET   [mcode] = @mcode, [scode] = @scode, [sname] = @sname, [price] = @price, [currency] = @currency, [minnum] = @minnum, [maxnum] = @maxnum, [leadtime] = @leadtime, [shipmethod] = @shipmethod, [supplyprocode] = @supplyprocode, [supplyproname] = @supplyproname, [pricedatefrom] = @pricedatefrom, [pricedateto] = @pricedateto, [note] = @note WHERE [id] = @id">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
          <asp:QueryStringParameter Name="proid" QueryStringField="id" />
        </SelectParameters>

        <UpdateParameters>
            <asp:Parameter Name="proid" Type="Int32" />
            <asp:Parameter Name="mcode" Type="String" />
            <asp:Parameter Name="scode" Type="String" />
            <asp:Parameter Name="sname" Type="String" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="currency" Type="String" />
            <asp:Parameter Name="minnum" Type="Decimal" />
            <asp:Parameter Name="maxnum" Type="Decimal" />
            <asp:Parameter Name="leadtime" Type="String" />
            <asp:Parameter Name="shipmethod" Type="String" />
            <asp:Parameter Name="supplyprocode" Type="String" />
            <asp:Parameter Name="supplyproname" Type="String" />
            <asp:Parameter Name="pricedatefrom" Type="DateTime" />
            <asp:Parameter Name="pricedateto" Type="DateTime" />
            <asp:Parameter Name="note" Type="String" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
        </asp:SqlDataSource>

</asp:Content>
