凯云水利水电工程造价系统 (六)中间单价(2)

凯云水利水电工程造价系统 (六)中间单价(2)

接这中间单价(2)
3.9-3.2.3 删除

(1)对中间单价定额组成进行删除:


(图 19)

(2)选中一行数据,点击删除,把值传到界面层的方法的代码:

//删除中间单价定额组成
function DeleteCenterPriceQuoteMachine(){
var CenterPrice=$('#w中间单价列表').datagrid('getSelected');
var CenterPriceQuoteMachine=$('#w中间单价定额组成').datagrid('getSelected');
//先选中要删除的中间单价定额组成

if(confirm('是否将要删除此条明细?')){
//确认是否要删除此条数据
$.getJSON("/ZhongJianDanJia/DeleteCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPriceQuoteMachine.CenterPriceQuoteComeposeID,
function(data){
if (data>0){
$.getJSON("/ZhongJianDanJia/SelectedCenterPriceComepose?CenterPriceID="+CenterPrice.CenterPriceID,
function(data){
$('#w中间单价定额组成').datagrid('loadData',data);
});

}
});
}
}

3.9-3.2.4 字单价计算

(1)就是计算某条定额组成下的几条定额人材机:

  可以单价某条定额组成计算,也可以点击字单价计算按钮,进行计算:


(图 20)

不管是哪种计算,所用的方法都是同一个:

 //计算
    function Count(rowIndex, rowData, changes){
    var D=0;
    var CenterPriceID=$('#w中间单价列表').datagrid('getSelected');
                                                                              
var d=$('#w中间定额人材机组成').datagrid('getData');
//获取定额人材机的所有数据
var CenterPrice=$('#w中间单价定额组成').datagrid('getSelected');
//选中要进行中间单价定额组成的一行
    for(var i=0;i<d.rows.length;i++){
        D+=d.rows[i].AdjustFormula*1;
                                                                                   
    }
                                                                             
    $.getJSON("/ZhongJianDanJia/UpdataCenterPriceComepose?CenterPriceID="+CenterPriceID.CenterPriceID+"&" 
            +"Name="+CenterPrice.Name.trim()+"&"
            +"Unit="+CenterPrice.Unit.trim()+"&"  
            +"Counts="+CenterPrice.Counts+"&"
            +"Remark="+D*Count*1+"&"
            +"ManpowerFactor="+CenterPrice.ManpowerFactor.trim()+"&"
            +"MachineFactor="+CenterPrice.MachineFactor.trim()+"&"
            +"MaterialFacto="+CenterPrice.MaterialFacto.trim()+"&"   
            +"Code="+CenterPrice.Code.trim()+"&"
            +"CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
        function(data){
                                                                                    
            if(data>0){
                                                                               
        $.getJSON("/ZhongJianDanJia/SelectedCenterPriceComepose?CenterPriceID="+CenterPriceID.CenterPriceID,
            function(data){
            $('#w中间单价定额组成').datagrid('loadData',data);
                                                                                        
        setTimeout(function(){ $('#w中间单价定额组成').datagrid('selectRow',indexs);},500);
        });
        }
    });

3.9-3.3 中间单价定额人材机
3.9-3.3.1 添加人材机

(1)点击添加人材机按钮,弹出添加人材机的窗体:


(图 21)

然后可以单击各个列表的数据,把单击的数据传到下面的 datagrid中,单价数据所用到的方法:


(图 22)
//点击机械列表

       var gg=0;
       function onClickRowmachinery(){
             
               
     
             var d= $('#inquiremachinery').datagrid('getSelected');
            //选中机械列表的一行
             var e=$('#w中间定额人材机组成').datagrid('getData');
             //获取定人材机的所有数据
             for(var j=0;j<e.rows.length;j++){
              //循环所有的数据
             if( d.Code.trim()==e.rows[j]["Code"].trim())
             { 
             //如果所添加的数据的代号已经存在了,就gg=1;
                   gg=1; 
                
              }
                 else
                 {
                
                   }

       }
       if(gg!=1){
        //只有当gg!=1,也就是代号不相等时,才能执行下面的代码)
           gg=0;
             d.Code;
             d.Name;
             d.Unit;
             d.BudgetPrice;
             d.Remark;
           d.MachineryPriceID;
           //获取选中的机械列表的数据
             var f = $('#nihao').datagrid('getData');
             //获取人材机组成下面的datagrid的数据 
              $('#nihao').datagrid("insertRow", {
                index: f.rows.length,
                 row: {}
               });
               //新增一行
              $('#nihao').datagrid('selectRow',  f.rows.length-1);
              //查出最后一行
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["daihao"]=d.Code;
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["mingcheng"]=  d.Name;
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["danwei"]=  d.Unit;  
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["MachineryPriceID"]= d.MachineryPriceID;
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["yusuanjiage"]=   d.BudgetPrice;  
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["Remark"]= d.Remark;
             $('#nihao').datagrid('getData').rows[f.rows.length-1]["leixing"]="机械";
             $('#nihao').datagrid('refreshRow',  f.rows.length-1);
       }
         else{
             gg=0;
             alert("已添加此数据,请点击下一条");
         }
       }



           //点击材料列表
       var t=0;
       var p=0;
       var gg="";
       function  onClickRowmaterial(){
               var d= $('#materialunitprice').datagrid('getSelected') ;
               //选中材料列表的一行
                var e=$('#w中间定额人材机组成').datagrid('getData');
                 //获取定人材机的所有数据
          for(var j=0;j<e.rows.length;j++){
             if( d.Code.trim()==e.rows[j]["Code"].trim()){ 
             //如果所添加的数据的代号已经存在了,就gg=1;
                   gg=1;
                   
                
                 }else{
                
             }

       }
           if(gg!=1){
            //只有当gg!=1,也就是代号不相等时,才能执行下面的代码)
           gg=0;
                d.Code;
                d.Name;
                d.Unit;
                d.BuildProjectID;
                d.BudgetPrice;
                d.Remark;
                t = d.MaterialPriceID;
               //获取选中的机械列表的数据
              
               var f= $('#nihao').datagrid('getData') 
                //获取人材机组成下面的datagrid的数据 
                 $('#nihao').datagrid("insertRow", {
                index: f.rows.length,
                 row: {}
               });
                //新增一行
               $('#nihao').datagrid('selectRow',  f.rows.length-1);
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["daihao"]=d.Code;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["mingcheng"]=  d.Name;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["danwei"]=  d.Unit;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["MaterialPriceID"]=  d.MaterialPriceID;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["yusuanjiage"]=   d.BudgetPrice;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["Remark"]= d.Remark;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["leixing"]="材料";
               $('#nihao').datagrid('refreshRow',  f.rows.length-1);

     
       
       }
           else{
           gg=0;
           alert("已添加此数据,请点击下一条");
           }
       }
       

              //点击人工列表
       var t=0;
       var p=0;
       var gg=0;
       function  onClickRenGongl(){
  
         
               var d= $('#inquiremanualwork').datagrid('getSelected') ;
               var e=$('#w中间定额人材机组成').datagrid('getData');
          for(var j=0;j<e.rows.length;j++){
             if( d.Number.trim()==e.rows[j]["Code"].trim()){ 
                   gg=1;
                   
                
                 }else{
                
             }

       }
       if(gg!=1){
            gg=0;
                d.name1; 
                d.Number;
                d.Unit;
                d.BuildProjectID;
                d.BudgetPrice;
                d.Remark;
                t = d.RenGongDanJiaID;
              
               var f= $('#nihao').datagrid('getData'); 
                 $('#nihao').datagrid("insertRow", {
                    index: f.rows.length,
                    row: {}
               });
               $('#nihao').datagrid('selectRow',  f.rows.length-1);
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["daihao"]=d.Number;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["mingcheng"]=  d.Name;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["danwei"]=  d.Unit;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["MaterialPriceID"]= d.RenGongDanJiaID;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["yusuanjiage"]=   d.BudgetPrice;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["Remark"]= d.Remark;
                $('#nihao').datagrid('getData').rows[f.rows.length-1]["leixing"]="人工";
               $('#nihao').datagrid('refreshRow',  f.rows.length-1);
}
else{
    gg=0;
    alert("已添加此数据,请点击下一条");
}
       }
       //点击配合比单价
       var gg=0;
       function OnClickMicPrice(){
            
           var MixProportionPriceID=$('#w配合比').datagrid('getSelected');
           var d=$('#w中间定额人材机组成').datagrid('getData');
          for(var j=0;j<d.rows.length;j++){
             if( MixProportionPriceID.Code.trim()==d.rows[j]["Code"].trim()){ 
                   gg=1;
                   
                
                 }else{
                
             }

       }
       
          if (gg!=1){
          
           gg=0;
           MixProportionPriceID.Code;
           MixProportionPriceID.MixProportionPriceName;
           MixProportionPriceID.Unit;
           MixProportionPriceID.Budget;
           MixProportionPriceID.Remark;
           var f=$('#nihao').datagrid('getData');
           $('#nihao').datagrid("insertRow",{
               index:f.rows.length,
               row:{}
           });
                   $('#nihao').datagrid('selectRow',  f.rows.length-1);
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["daihao"]=MixProportionPriceID.Code;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["mingcheng"]= MixProportionPriceID.MixProportionPriceName;
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["danwei"]= MixProportionPriceID.Unit;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["yusuanjiage"]= MixProportionPriceID.Budget;  
               $('#nihao').datagrid('getData').rows[f.rows.length-1]["Remark"]=MixProportionPriceID.Remark;
                $('#nihao').datagrid('getData').rows[f.rows.length-1]["leixing"]="配合比";
               $('#nihao').datagrid('refreshRow',  f.rows.length-1);
}
else{

       gg=0;
       alert("已添加此数据,请点击下一条");
}


        }



(图 23)

点击保存。所触发的界面层的方法:

//新增人才机组成
function InsertInsertQuoteMachine(){
     
var CenterPrice=$('#w中间单价定额组成').datagrid('getSelected');
//选中中间单价定额组成
var d=$('#w中间定额人材机组成').datagrid('getData');
 //获取中间定额人材机的所有数据 
if(CenterPrice ){
  //如果选中了中间单价定额组成,就执行下面的代码       
        var QuoteMachineComepose=$('#nihao').datagrid('getData');
    for(var i=0;i<QuoteMachineComepose.rows.length;i++){ 
        $.getJSON("/ZhongJianDanJia/InsertQuoteMachine?CenterPriceQuoteMachineID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
                +"Code="+$('#nihao').datagrid('getData').rows[i]["daihao"].trim()+"&"
                +"Name="+$('#nihao').datagrid('getData').rows[i]["mingcheng"].trim()+"&"
                +"Unit="+$('#nihao').datagrid('getData').rows[i]["danwei"].trim()+"&"
                +"BudgetPrice="+$('#nihao').datagrid('getData').rows[i]["yusuanjiage"]+"&"
                +"QuoteAmout="+""+"&"
                +"AdjustFormula="+""+"&"
                +"CountNumber="+""+"&"
                +"Remark="+""+"&"
                +"types="+$('#nihao').datagrid('getData').rows[i]["leixing"].trim(),
                function(data){
                                                  
                    for(var i=0;i<QuoteMachineComepose.rows.length;i++){
                        $('#nihao').datagrid('deleteRow',i);
                        }
                    $('#w添加人材机').window('close');
                    $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
                    function(data){
                                                      
                            $('#w中间定额人材机组成').datagrid('loadData',data);
                    }); 
                });
                           
                             
                            }
                              

       
           
} 
else{
    alert("请选中中间单价定额组成,")
}
}

把新增的数据,从界面层传到控制器的方法的代码:

 #region  新增人才机组成
           public ContentResult InsertQuoteMachine(string CenterPriceQuoteMachineID, string Code, string Name, string Unit, string BudgetPrice, string QuoteAmout, string AdjustFormula, string CountNumber, string Remark, string types)
           //这些参数对应的是界面层进行传值的参数
           {
          int i = myCenterPrice.InsertQuoteMachine(Convert.ToInt32(CenterPriceQuoteMachineID),Code, Name, Unit, BudgetPrice, QuoteAmout, AdjustFormula, CountNumber, Remark, types);
               return Content(i.ToString());
             //把转化成字符串的值返回给界面层
           }
        #endregion

把新增的数据从控制器传到逻辑层的方法:
 #region 新增人才机组成
        public int InsertQuoteMachine(int CenterPriceQuoteMachineID,string Code,string  Name,string  Unit,string BudgetPrice,string  QuoteAmout,string AdjustFormula,string  CountNumber,string Remark,string types)
        {
            SqlParameter[] mySqlParameter = { 
                                                new SqlParameter("@Type",SqlDbType.Char),
                                                new SqlParameter("@CenterPriceQuoteComeposeID",SqlDbType.Int),
                                                new SqlParameter("@Code",SqlDbType.Char),
                                                new SqlParameter("@Name",SqlDbType.Char),
                                                new SqlParameter("@Unit",SqlDbType.Char),
                                                new SqlParameter("@BudgetPrice",SqlDbType.Char),
                                                new SqlParameter("@QuoteAmout",SqlDbType.Char),
                                                new SqlParameter("@AdjustFormula",SqlDbType.Char),
                                                new SqlParameter("@CountNumber",SqlDbType.Char),
                                                new SqlParameter("@Remark",SqlDbType.Char),
                                                new SqlParameter("@types",SqlDbType.Char),
                                              //和存储过程中声明的变量要对应
                                            };
            mySqlParameter[0].Value = "InsertQuoteMachine";
           //和数据层的存储过程名对应
            mySqlParameter[1].Value = CenterPriceQuoteMachineID;
            mySqlParameter[2].Value = Code;
            mySqlParameter[3].Value = Name;
            mySqlParameter[4].Value = Unit;
            mySqlParameter[5].Value = BudgetPrice;
            mySqlParameter[6].Value = QuoteAmout;
            mySqlParameter[7].Value = AdjustFormula;
            mySqlParameter[8].Value = CountNumber;
            mySqlParameter[9].Value = Remark;
            mySqlParameter[10].Value = types;
            int i = myDALMethod.DAL_OPTableDB_Par("CenterPrice", mySqlParameter);
            return i;
             //返回数据给控制器
        }
        #endregion

把新增的数据通过参数,从逻辑层传到数据层的SQL语句:
--新增人才机组成
     if @Type='InsertQuoteMachine'
     begin
        insert  SYS_CenterPriceQuoteMachineList(CenterPriceQuoteComeposeID, Code, Name, Unit, BudgetPrice, QuoteAmout, AdjustFormula, CountNumber, Remark, types11)
        values   (@CenterPriceQuoteComeposeID, @Code, @Name, @Unit, @BudgetPrice, @QuoteAmout, @AdjustFormula,@CountNumber,@Remark, @types)
     end

(图 24)

编辑中间定额人材机一行时,所执行的方法:

//编辑
var editIndex = undefined;
var INDEX="";
function onClickRowMingXi(index) {
INDEX=index;
if (editIndex != index) {
$('#w中间定额人材机组成').datagrid('beginEdit', index);
$('#w中间定额人材机组成').datagrid('endEdit', editIndex);
editIndex = index;
}
}



function onAfterEdit(index,data,dd){
                                                                              
    var updaterow=$('#w中间定额人材机组成').datagrid('getChanges');
     //当中间定额人材机组成一行后值发生改变时,就把值赋值给   updaterow                                                                      
var CenterPrice=$('#w中间单价定额组成').datagrid('getSelected');
 //选中中间单价定额组成
var rowsCount=updaterow.length;
 //获取被改变值的长度
if(rowsCount>0){
//如果其长度>0,则说明有值发生改变,就执行下面的代码
        var id=data.CenterPriceQuoteMachineID;
        var Code=data.Code.trim();
        var Name=data.Name.trim();
        var Unit=data.Unit.trim();
        var BudgetPrice=data.BudgetPrice.trim();
        var QuoteAmout=data.QuoteAmout.trim();
        var CountNumber=data.CountNumber.trim();
        var types11=data.types11.trim();
        var PriceTatil=CountNumber*1*BudgetPrice;
        if(QuoteAmout*1>CountNumber*1 ||QuoteAmout*1==CountNumber*1){
        //判断计算数量必须小于或等译定额数量
        $.getJSON("/ZhongJianDanJia/UpdateQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
        +"Code="+Code+"&"
        +"Name="+Name+"&"
        +"Unit="+Unit+"&"
        +"BudgetPrice="+BudgetPrice+"&"
        +"QuoteAmout="+QuoteAmout+"&"
        +"AdjustFormula="+PriceTatil+"&"
        +"CountNumber="+CountNumber+"&"
        +"Remark="+""+"&"
        +"types="+types11+"&"
        +"CenterPriceQuoteMachineID="+id,
        function(data){
        if(data>0){
        $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
            function(data){
                                                      
    $('#w中间定额人材机组成').datagrid('loadData',data);
    }); 
    }
        }); 
        }
        else{
            alert("计算数量必须小于或等于定额数量!");
        }

    }
                                                                              
}


3.9-3.3.2  删除

(1)对定额人材机进行删除


(图 25)

点击删除按钮,所触发的界面层的方法的代码:

//删除人才机组成
    function DeleteQuoteMachine(){
        var d=$('#w中间定额人材机组成').datagrid('getSelected');
 //选中要删除的定额人材机组成
        var CenterPriceQuoteMachine=$('#w中间单价定额组成').datagrid('getSelected');;
        if(confirm('是否将要删除此条明细?')){
         //确定是否要删除
            $.getJSON("/ZhongJianDanJia/DeleteQuoteMachine?CenterPriceQuoteMachineID="+d.CenterPriceQuoteMachineID,
                function(data){
                    if (data>0){
            $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPriceQuoteMachine.CenterPriceQuoteComeposeID,
        function(data){
            $('#w中间定额人材机组成').datagrid('loadData',data);
            });  
            }
            });
                                                                                       
                                                                              
    }
    }

把删除的值从界面层传到控制器的方法的代码:

#region 删除人才机组成
           public ContentResult DeleteQuoteMachine(int CenterPriceQuoteMachineID)
           {
               int i = myCenterPrice.DeleteQuoteMachine(CenterPriceQuoteMachineID);
               //根据定额人材机ID来删除一行数据
               return Content(i.ToString());
              //返回数据给控制器
           }
#endregion

把删除的值从控制器传给逻辑层的方法的代码:

 #region  删除人才机组成
        public int DeleteQuoteMachine(int CenterPriceQuoteMachineID)
        {
            SqlParameter[] mySqlParameter = { 
                                                new SqlParameter ("@Type",SqlDbType.Char),
                                                new SqlParameter ("@CenterPriceQuoteMachineID",SqlDbType.Int),
                                            };
            mySqlParameter[0].Value = "DeleteQuoteMachine";
             //和数据层的存储过程名对应
            mySqlParameter[1].Value=CenterPriceQuoteMachineID;
            int i=myDALMethod.DAL_OPTableDB_Par("CenterPrice",mySqlParameter);
            return i;
             //返回数据给控制器
        }
        #endregion

把删除的值从逻辑层传到数据层SQL语句:

--删除人才机组成
     if @Type='DeleteQuoteMachine'
     begin
        delete SYS_CenterPriceQuoteMachineList
        where CenterPriceQuoteMachineID=@CenterPriceQuoteMachineID
     end

3.9-3.3.3 替换

(图 26)

替换之前,要在定额人材机选好要替换的数据,然后可以在机械列表、人工列表、材料单价、配合比进行选择,选择好之后,再点击左上角的保存图标,进行保存:

点击保存所触发的界面层的方法的代码:

//替换
function replace(){
                                                                       
var CenterPriceQuoteMachine=$('#w中间定额人材机组成').datagrid('getSelected');
var w机械列表=$('#inquiremachinery1').datagrid('getSelected');
//把选中机械列表的值赋值给w机械列表
                                                                            
    var w人工列表=$('#inquiremanualwork1').datagrid('getSelected');
       //把选中人工列表的值赋值给w人工列表

var w材料单价=$('#materialunitprice1').datagrid('getSelected');
//把选中材料单价的值赋值给w材料单价
    var w配合比单价=$('#w配合比单价').datagrid('getSelected');
 //把选中配合比单价的值赋值给w配合比单价
                                                                        
    var CenterPrice=$('#w中间单价定额组成').datagrid('getSelected');
                                                                           
    if(CenterPriceQuoteMachine){
     //只有选中定额人材机,才能执行下面的代码
    if(w机械列表){
        //如果选中机械列表,就执行下面的代码                                                                     
        if(CenterPriceQuoteMachine.Code.trim()!==w机械列表.Code.trim() && CenterPriceQuoteMachine.Name.trim()!==w机械列表.Name){
            //只有替换的两个代号不能相同,才能进行替换
        $.getJSON("/ZhongJianDanJia/UpdateQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
            +"Code="+w机械列表.Code.trim()+"&"
            +"Name="+w机械列表.Name.trim()+"&"
            +"Unit="+w机械列表.Unit.trim()+"&"
            +"BudgetPrice="+w机械列表.BudgetPrice.trim()+"&"
            +"QuoteAmout="+""+"&"
            +"AdjustFormula="+""+"&"
            +"CountNumber="+""+"&"
            +"Remark="+w机械列表.Remark.trim()+"&"
            +"types="+"机械"+"&"
            +"CenterPriceQuoteMachineID="+CenterPriceQuoteMachine.CenterPriceQuoteMachineID,
            function(data){
            if (data>0){
            $.getJSON("/JiXieDanJia/inquiremachinery",
            function (data) {
            $('#inquiremachinery1').datagrid('loadData', data);
                           
                });
        $('#w替换').window('close');
        $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
    function(data){
        $('#w中间定额人材机组成').datagrid('loadData',data);
        }); 
        }
        }); 
        }
        else{
             //如果代号相同,则就会提醒
            alert("数据相同,不能替换,请选中其它数据!");
        }
    }


else{
   //否则如果选中人工单价列表,就执行下面的代码
        if(w人工列表 )
        {   
        if(CenterPriceQuoteMachine.Code.trim()!==w人工列表.Number && CenterPriceQuoteMachine.Name.trim()!==w人工列表.Name){
        $.getJSON("/ZhongJianDanJia/UpdateQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
            +"Code="+w人工列表.Number.trim()+"&"
            +"Name="+w人工列表.Name.trim()+"&"
            +"Unit="+w人工列表.Unit.trim()+"&"
            +"BudgetPrice="+w人工列表.BudgetPrice.trim()+"&"
            +"QuoteAmout="+""+"&"
            +"AdjustFormula="+""+"&"
            +"CountNumber="+""+"&"
            +"Remark="+""+"&"
            +"types="+"人工"+"&"
            +"CenterPriceQuoteMachineID="+CenterPriceQuoteMachine.CenterPriceQuoteMachineID,
            function(data){
            if (data>0){
            $.getJSON("/RenGongDanJia/SelectRenGongDanJia/?IntBuildProjectID="+@Session["项目ID"],
            function (data) {
            $('#inquiremanualwork1').datagrid('loadData', data);
                           
                });
        $('#w替换').window('close');
        $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
        function(data){
        $('#w中间定额人材机组成').datagrid('loadData',data);
        }); 
        }
        }); 
        }
        else{
            alert("数据相同,不能替换,请选中其它数据!");
        }
            }
else{
 //否则如果选中材料单价,就执行下面的代码
    if(w材料单价){
        if(CenterPriceQuoteMachine.Code!==w材料单价.Code && CenterPriceQuoteMachine.Name!==w材料单价.Name){
            $.getJSON("/ZhongJianDanJia/UpdateQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
            +"Code="+w材料单价.Code.trim()+"&"
            +"Name="+w材料单价.Name.trim()+"&"
            +"Unit="+w材料单价.Unit.trim()+"&"
            +"BudgetPrice="+w材料单价.BudgetPrice+"&"
            +"QuoteAmout="+""+"&"
            +"AdjustFormula="+""+"&"
            +"CountNumber="+""+"&"
            +"Remark="+""+"&"
            +"types="+"材料"+"&"
            +"CenterPriceQuoteMachineID="+CenterPriceQuoteMachine.CenterPriceQuoteMachineID,
            function(data){
            if (data>0){
            $.getJSON("/CaiLiaoDanJia/SelectAllCaiLiao?BuildProjectID="+ @Session["项目ID"],
            function(data){
            $('#materialunitprice1').datagrid('loadData', data);
                           
            });
        $('#w替换').window('close');
        $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
        function(data){
        $('#w中间定额人材机组成').datagrid('loadData',data);
        }); 
        }
        }); 
        }
        else{
            alert("数据相同,不能替换,请选中其它数据!");
        }
                                                                                  
    }
else{
//否则如果选中配合比单价,就执行下面的代码
    if(w配合比单价){
            if(CenterPriceQuoteMachine.Code!==w配合比单价.Code && CenterPriceQuoteMachine.Name!==w配合比单价.MixProportionPriceName){
            $.getJSON("/ZhongJianDanJia/UpdateQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
            +"Code="+w配合比单价.Code.trim()+"&"
            +"Name="+w配合比单价.MixProportionPriceName.trim()+"&"
            +"Unit="+w配合比单价.Unit.trim()+"&"
            +"BudgetPrice="+w配合比单价.Budget.trim()+"&"
            +"QuoteAmout="+""+"&"
            +"AdjustFormula="+""+"&"
            +"CountNumber="+""+"&"
            +"Remark="+w配合比单价.Remark.trim()+"&"
            +"types="+"配合比"+"&"
            +"CenterPriceQuoteMachineID="+CenterPriceQuoteMachine.CenterPriceQuoteMachineID,
            function(data){
            if(data>0){
        $.getJSON("/PeiHeBiDanJia/BindingMixProportionPrice?BuildProjectID="+@Session["项目ID"],
        function(data){
            $('#w配合比单价').datagrid('loadData', data);
        }  
    );
    $('#w替换').window('close');
    $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
    function(data){
                                                      
        $('#w中间定额人材机组成').datagrid('loadData',data);
        }); 
        }
            }); 
                                                                                    
            }
            else{
            alert("数据相同,不能替换,请选中其它数据!");
            }
    }

    }
    }
    }
    }
    else{
    alert("请选中中间定额人材机组成");
    }
}


把替换的数据传到控制器的方法的代码:

#region  修改人才机组成(替换)
  public ContentResult UpdateQuoteMachine(string CenterPriceQuoteComeposeID, string Code, string Name, string Unit, string BudgetPrice, string QuoteAmout, string AdjustFormula, string CountNumber, string Remark, string types, string  CenterPriceQuoteMachineID)
           {
   int i = myCenterPrice.UpdateQuoteMachine(Convert.ToInt32(CenterPriceQuoteComeposeID), Code, Name, Unit, BudgetPrice, QuoteAmout,AdjustFormula, CountNumber, Remark, types,Convert.ToInt32(CenterPriceQuoteMachineID));
  //调用逻辑层的方法	
               return Content(i.ToString());
           //把数据返回给界面层
           }
        #endregion

把替换的数据通过参数从控制器传到逻辑层的方法:

#region 修改人才机组成(替换)
        public int UpdateQuoteMachine(int CenterPriceQuoteComeposeID, string Code, string Name, string Unit, string BudgetPrice, string QuoteAmout, string AdjustFormula, string CountNumber, string Remark, string types, int CenterPriceQuoteMachineID)
        {
            SqlParameter[] mySqlParameter = { 
                                                new SqlParameter("@Type",SqlDbType.Char),
                                                new SqlParameter("@CenterPriceQuoteComeposeID",SqlDbType.Int),
                                                new SqlParameter("@Code",SqlDbType.Char),
                                                new SqlParameter("@Name",SqlDbType.Char),
                                                new SqlParameter("@Unit",SqlDbType.Char),
                                                new SqlParameter("@BudgetPrice",SqlDbType.Char),
                                                new SqlParameter("@QuoteAmout",SqlDbType.Char),
                                                new SqlParameter("@AdjustFormula",SqlDbType.Char),
                                                new SqlParameter("@CountNumber",SqlDbType.Char),
                                                new SqlParameter("@Remark",SqlDbType.Char),
                                                new SqlParameter("@types",SqlDbType.Char),
                                                new SqlParameter("@CenterPriceQuoteMachineID",SqlDbType.Int)
                                           //要和数据层声明的参数名对应,进行传参
                                            };
            mySqlParameter[0].Value = "UpdateQuoteMachine";
              //和数据层的存储过程名对应
            mySqlParameter[1].Value = CenterPriceQuoteComeposeID;
            mySqlParameter[2].Value = Code;
            mySqlParameter[3].Value = Name;
            mySqlParameter[4].Value = Unit;
            mySqlParameter[5].Value = BudgetPrice;
            mySqlParameter[6].Value = QuoteAmout;
            mySqlParameter[7].Value = AdjustFormula;
            mySqlParameter[8].Value = CountNumber;
            mySqlParameter[9].Value = Remark;
            mySqlParameter[10].Value = types;
            mySqlParameter[11].Value = CenterPriceQuoteMachineID;
            int i = myDALMethod.DAL_OPTableDB_Par("CenterPrice", mySqlParameter);
            return i;
             //返回数据给控制器
        }
        #endregion

把修改的数据传到数据层的SQL语句:

--修改人材机组成
     if @Type='UpdateQuoteMachine'
     begin
       update SYS_CenterPriceQuoteMachineList
       set  CenterPriceQuoteComeposeID=@CenterPriceQuoteComeposeID, Code=@Code, Name=@Name, Unit=@Unit, BudgetPrice=@BudgetPrice, QuoteAmout=@QuoteAmout,
                     AdjustFormula=@AdjustFormula, CountNumber=@CountNumber, Remark=@Remark, types11=@types
       where CenterPriceQuoteMachineID=@CenterPriceQuoteMachineID
     end

3.9-3.3.4 复制

(1)对现有的数据进行复制


(图 27)

点击复制,所触发的方法:

//复制
                var CopyRCode="";
                var CopyRName="";
                var CopyRUnit="";
                var CopyRBudgetPrice="";
                var CopyRTypes="";
                var BeiZhu="";
                //声明全局变量,用于粘贴功能
                function CopyCenterPriceQuoteMachine(){
                                                                   
                var CenterPriceQuoteMachine=$('#w中间定额人材机组成').datagrid('getSelected');
                 //选中要复制的数据
                if(CenterPriceQuoteMachine){
                CopyRCode=CenterPriceQuoteMachine.Code.trim();
                CopyRName=CenterPriceQuoteMachine.Name.trim();
                CopyRUnit=CenterPriceQuoteMachine.Unit.trim();
                CopyRBudgetPrice=CenterPriceQuoteMachine.BudgetPrice.trim();
                CopyRTypes=CenterPriceQuoteMachine.types11.trim();
                 //获取要复制的数据                                                      
                                                                    
                }
                else{
                alert("请先选中要复制的数据!");
                }
                                                                       
                }

3.9-3.3.5 粘贴

(1)复制成功之后,就点击粘贴


(图 28)

点击粘贴,所触发的界面层的方法的代码:
function PasteCenterPriceQuoteMachine(){
                                    var CenterPriceQuoteMachine=$('#w中间定额人材机组成').datagrid('getSelected');
                                    var CenterPrice=$('#w中间单价定额组成').datagrid('getSelected');
                                    var y=CopyRCode;
                                    var t=y.length;
                                    var e=y.substring(t-2,t);
                                    var tr=CopyRCode+"_复制";
                                    var i=tr.length;
                                    var d=tr.substring(i-3,i);
                                    if(confirm('是否需要粘贴?')){
                            if (e=="_复制"){

                            var code=tr+"-_复制";
                            $.getJSON("/ZhongJianDanJia/InsertQuoteMachine?CenterPriceQuoteMachineID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
                            +"Code="+code+"&"
                            +"Name="+CopyRName+"&"
                            +"Unit="+CopyRUnit+"&"
                            +"BudgetPrice="+CopyRBudgetPrice+"&"
                            +"QuoteAmout="+""+"&"
                            +"AdjustFormula="+""+"&"
                            +"CountNumber="+""+"&"
                            +"Remark="+""+"&"
                            +"types="+CopyRTypes,
                            function(data){
                                                    
                                $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
                                function(data){
                                                      
                                  $('#w中间定额人材机组成').datagrid('loadData',data);
                                  alert("粘贴成功!数据已经在最后一行!");
                                }); 
                            });
                            }
                        else{
                                                             
                            $.getJSON("/ZhongJianDanJia/InsertQuoteMachine?CenterPriceQuoteMachineID="+CenterPrice.CenterPriceQuoteComeposeID+"&"
                            +"Code="+tr+"&"
                            +"Name="+CopyRName+"&"
                            +"Unit="+CopyRUnit+"&"
                            +"BudgetPrice="+""+"&"
                            +"QuoteAmout="+""+"&"
                            +"AdjustFormula="+""+"&"
                            +"CountNumber="+""+"&"
                            +"Remark="+""+"&"
                            +"types="+CopyRTypes,
                            function(data){
                                                    
                                $.getJSON("/ZhongJianDanJia/SelectedCenterPriceQuoteMachine?CenterPriceQuoteComeposeID="+CenterPrice.CenterPriceQuoteComeposeID,
                                function(data){
                                                      
                                        $('#w中间定额人材机组成').datagrid('loadData',data);
                                        alert("粘贴成功!数据已经在最后一行!");
                                    }); 
                                    });                   
                                                                                
                                                                                
                                                        }
                                                    }
                                                                       
                                                                     
                                                else{}
                                                }



(图 29)
仅供学习参考。禁止商业用途,否则后果自负!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值