函数调用BO保留原有的行,新增更新行U


比较原始的方法:

使用GetProperties方法获取所有属性,一个一个属性去赋值

C# 全选
this.output="";
try
{
 
   Erp.Tablesets.ARInvoiceTableset ds1 = this.ThisLib.GetByID(this.input); 
   Erp.Tablesets.InvcHeadRow Row1= ds1.InvcHead.LastOrDefault();
   
   Erp.Tablesets.TaxConnectStatusRow Row2= ds1.TaxConnectStatus.LastOrDefault();

    Erp.Tablesets.InvcHeadRow r11 = new Erp.Tablesets.InvcHeadRow(); 
            
            var properties11 = typeof(Erp.Tablesets.InvcHeadRow).GetProperties().Select(prop => prop.Name).ToList();;
    
            foreach (var property in properties11)      
            { 
                     
                    try
                    {
                        r11[property] = Row1[property];

                    }
                    catch
                    {
                        // 忽略无法复制的属性
                    }
                //}               
            } 
     Erp.Tablesets.InvcHeadRow r12 = new Erp.Tablesets.InvcHeadRow(); 
            
            var properties12 = typeof(Erp.Tablesets.InvcHeadRow).GetProperties().Select(prop => prop.Name).ToList();;
    
            foreach (var property in properties12)      
            { 
                     
                    try
                    {
                        r12[property] = Row1[property];

                    }
                    catch
                    {
                        // 忽略无法复制的属性
                    }
                //}               
            }        
            r12.Description= this.remark;
            r12.RowMod="U";
            
     Erp.Tablesets.TaxConnectStatusRow r21 = new Erp.Tablesets.TaxConnectStatusRow(); 
            
            var properties21 = typeof(Erp.Tablesets.TaxConnectStatusRow).GetProperties().Select(prop => prop.Name).ToList();;
    
            foreach (var property in properties21)      
            { 
                     
                    try
                    {
                        r21[property] = Row2[property];

                    }
                    catch
                    {
                        // 忽略无法复制的属性
                    }
                //}               
            }  
       Erp.Tablesets.TaxConnectStatusRow r22 = new Erp.Tablesets.TaxConnectStatusRow(); 
            
            var properties22 = typeof(Erp.Tablesets.TaxConnectStatusRow).GetProperties().Select(prop => prop.Name).ToList();;
    
            foreach (var property in properties22)      
            { 
                     
                    try
                    {
                        r22[property] = Row2[property];

                    }
                    catch
                    {
                        // 忽略无法复制的属性
                    }
                //}               
            }        
           r22.ETCOffline=true;
           r22.RowMod="U";
    ds1 = new  Erp.Tablesets.ARInvoiceTableset();   
    ds1.InvcHead.Add(r11);
    ds1.InvcHead.Add(r12);
    ds1.TaxConnectStatus.Add(r21);
    ds1.TaxConnectStatus.Add(r22);
   //this.ThisLib.update(ds1);
   this.ThisLib.update(ds1, "MIC003", "InvcHead", false,false,false ,false , 10002, 1,"" ,false , 600,false,"" );

}catch(System.Exception ex)
{
   
   this.output=ex.ToString();
   PublishInfoMessage(ex.ToString(), Ice.Common.BusinessObjectMessageType.Error, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}   

改进一点:

利用Epicor的BufferCopy方法,直接复制行对象。免去遍历属性

C# 全选
var data = this.ThisLib.BoARInvoiceGetByID(10008);

Erp.Tablesets.ARInvoiceTableset ds = new Erp.Tablesets.ARInvoiceTableset();
var oldRow = ds.InvcHead.NewRow();
ds.InvcHead.Add(oldRow);
BufferCopy.Copy(data.InvcHead[0],oldRow);


var updateRow = (Erp.Tablesets.InvcHeadRow)ds.InvcHead.NewRow();
ds.InvcHead.Add(updateRow);
BufferCopy.Copy(data.InvcHead[0],updateRow);

updateRow.RowMod = "U";
updateRow.Description = "_123";
updateRow["AluminumBasedPrice_c"] = 7.5m;
updateRow["CopperBasedPrice_c"] = 8.5m;
updateRow["Si_steelBasedPrice_c"] = 9.5m;

this.ThisLib.BoArInvoiceUpdate(ds);
this.output3 = ds;

最终推荐方法:

在原有ds对象上添加一行。

C# 全选
var data = this.ThisLib.BoARInvoiceGetByID(10008);

var updateRow = (Erp.Tablesets.InvcHeadRow)data.InvcHead.NewRow();
data.InvcHead.Add(updateRow);
BufferCopy.Copy(data.InvcHead[0],updateRow);

updateRow.RowMod = "U";
updateRow.Description = "_123";
updateRow["AluminumBasedPrice_c"] = 7.5m;
updateRow["CopperBasedPrice_c"] = 8.5m;
updateRow["Si_steelBasedPrice_c"] = 9.5m;

this.ThisLib.BoArInvoiceUpdate(data);
this.output3 = data;

 

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:没有了
下一篇:带日期条件的BAQ
评论列表

发表评论

评论内容
昵称:
关联文章

PVE硬盘对应SATA口查询

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码