<%@ Page Title="" Language="C#"   AutoEventWireup="true" CodeBehind="cal_rate.aspx.cs" Inherits="bps.bps.cale.cal_rate" %>
 

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

   
    <script src="../../javascript/jquery-1.12.4.min.js"></script>
    <script src="../../bootstrap/js/bootstrap.min.js"></script>
     <link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet" /> 
 

    <link href="../../style/patch.css" rel="stylesheet" />

     <style>
       .form-control,  .btn {
          border-radius:0px;
         }

     </style>
     
</head>
<body style="font-size:12px;">
    <form id="form1" runat="server">
             <div style="margin-left:20px;">

    <div>




   <h5 style="text-align:center; font-weight:bold; margin:20px auto"></h5>

     <style>
                     .txt {
                      font-weight:bold
                     }

                     .line {
                         width: 60px;
                         border: 0px;
                         border-bottom: solid 1px #000;
                     }

                     .price td, .price th {
                         text-align:center; 
                         vertical-align:middle; 
                     }
                 </style>

        <b>1.请输入你想计算的价格，系统给出总价</b>

        <table class="table table-bordered price">
                     <tr  >
                         <th rowspan="2" class="tdheader" width="150px">
                             项目
                         </th>

                         <th rowspan="2"  class="tdheader" width="150px">
                            材料费（M） 
                         </th>


                      
                          <th  colspan="2"   class="tdheader"  >
                              工时费用（H）  
                         </th>




                         <th rowspan="2"  class="tdheader" width="150px">
                             管理费<br />
                             G= (M+H)*R 
                         </th>

                           <th rowspan="2"  class="tdheader" width="150px">
                               利润费<br />
                                P= (M+H)*R  
                          </th>

    <th rowspan="2"  class="tdheader" width="150px">
                              调整费<br />
          A= (M+H)*R 
                          </th>


                         <th rowspan="2"  class="tdheader" width="180px">
                             BOM单价  <br />
                             (P=M+H+G+P+A) 
                             &nbsp;&nbsp;&nbsp;&nbsp;
                           
                         </th>

                     </tr>



                     <tr>
                       
                         
                           <td style="font-size:10px;  font-weight:bold"  width="100px" >
                             工时 
                         </td>
                        <td style="font-size:10px; font-weight:bold" width="100px">
                             工时费用
                         </td>


                     </tr>









                     <tr class="rate">
                         <th>
                             费率(R）
                         </th>

                         <td>
                              --
                         </td>


                         <td>
  <input  type="text"  value="0" id="workhour" class="line txt t1" style="width:80px;" />
                         </td>

                         
                         <td>
 <input  type="text" value="0" id="workprice" class="line txt t1" style="width:80px;" />
                         </td>

                           <td>
                               <input   type="text"  value="0" id="mgrrate" class="line txt t1"   /> %
                         </td>

                           <td>
                               <input   type="text"  value="0" id="profitrate" class="line txt t1" /> %
                         </td>

                        
                            <td>
                               <input   type="text" value="0" id="adjustrate" class="line txt t1" /> %
                          </td>
                         <td>
                             &nbsp;--
                         </td>
                     </tr>







<tr >
                        <th>费用</th>

                        <td  >
                             <input   type="text" value="0" id="materialfee" class="line txt t1" style="width:120px;" />
                       </td>

                          <td colspan="2"  >
                                <input   type="text" value="0" disabled="disabled"   id="workfee" class="line txt t1" style="width:120px;" />
                          </td>




                          <td >
                             <input   type="text" value="0"   onchange="mgrfee_change()"  id="mgrfee" class="line txt" style="width:120px;" />
                          </td>
     
                          <td>
                             <input  " type="text" value="0"   onchange="profitfee_change()" id="profitfee" class="line txt" style="width:120px;" />
                          </td>

                            <td>
                               <input  type="text" value="0"  onchange="adjustfee_change()"  id="adjustfee" class="line txt" style="width:120px;" /> 
                          </td>


                        <td>
                            <input   type="text" value="0"  disabled="disabled" id="price" class="line txt" style="width:120px;" />
                        </td>

                    </tr>


             

                 </table>




    
     <script>

         $(".price .t1").change(
             function()
             {
                 
                 calTotalPrice();
             }
             );


  

         function mgrfee_change()
         {
             var _s = G("materialfee") + G("workhour") * G("workprice");
            
                $("#mgrrate").val(100 * G("mgrfee") / _s);
                calTotalPrice();
              
         }

         function profitfee_change()
         {
             var _s = G("materialfee") + G("workhour") * G("workprice");
             $("#profitrate").val(100 * G("profitfee") / _s);

             calTotalPrice();

         }


         function adjustfee_change()
         {
          var _s = G("materialfee") + G("workhour") * G("workprice");
             $("#adjustrate").val(100 * G("adjustfee") / _s); 
             calTotalPrice(); 
         }


         function calTotalPrice()
         {  
             var _s = G("materialfee") + G("workhour") * G("workprice");

             var _p=_s * ( 100+   G("mgrrate")  + G("profitrate")  + G("adjustrate"));

             $("#workfee").val((G("workhour") * G("workprice")).toFixed(2));

             $("#mgrfee").val((_s * G("mgrrate") / 100.0).toFixed(2));

             $("#profitfee").val((_s * G("profitrate") / 100.0).toFixed(2));

             $("#adjustfee").val((_s * G("adjustrate") / 100.0).toFixed(2));


             _p = _p / 100.0;

             $("#price").val(_p.toFixed(2)); 
         }




             function G(_id)
             { 
                 return  parseFloat(  $("#"+_id).val());
             }

     </script>





 



  
    <br /><br /><b>2.快速计算器</b> <br />



      <input type='text' id='txt1' /> 
    <select id='select'>
         <option value="+">+</option>
         <option value="-">-</option>
         <option value="*">*</option>
         <option value="/">/</option>
    </select>
    <input type='text' id='txt2' /> 
    <input type='button' value=' = ' onclick = "count()"/>
    <input type='text' id='fruit' />   

    </div>

    <script type="text/javascript">
        function count() {
            var a = document.getElementById("txt1").value;
            var b = document.getElementById("txt2").value;
            //获取第一个输入框的值
            //获取第二个输入框的值
            //获取选择框的值
            var c = document.getElementById("select").value;
            a = parseFloat(a);
            b = parseFloat(b);
            //获取通过下拉框来选择的值来改变加减乘除的运算法则
            //设置结果输入框的值 
            switch (c) {
                case "+":
                    document.getElementById("fruit").value = parseFloat((a + b).toFixed(5));
                    break;
                case "-":
                    document.getElementById("fruit").value = parseFloat((a - b).toFixed(5));
                    break;
                case "*":
                    document.getElementById("fruit").value = parseFloat((a * b).toFixed(5));
                    break;
                case "/":
                    document.getElementById("fruit").value = parseFloat((a / b).toFixed(5));
                    break;
            }
        }
   </script> 

 </div>
        </form>
    </body>
    </html>
