函数调用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开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:没有了
下一篇:没有了
评论列表

发表评论

评论内容
昵称:
关联文章

函数调用BO保留原有新增更新U
SqlServer PIVOT函数快速实现转列,UNPIVOT实现列转行
winform使用webBrowser,C#直接调用js函数,并且支持array数组
vue中异步函数async和await用法
C# 7.0 - C# 7.3 中新增功能
新增功能
JS魔法堂:函数节流(throttle)与函数去抖(debounce)
更新日志
表结构修改>新增主键或者不能为空
FTP服务端软件 Serv-U
.NET6中一些常用组件配置及使用记录,持续更新中。。。
TS有两个对象,便利B对象属性,如果A对象有这个属性,就把B更新到A对象。
更新日志
Task 使用详细[基础操作,异步原则,异步函数,异步模式]
ASP.NET Core调用另一个控制器并生成返回视图html
css样式首缩进2个长度宽度 text-indent 属性
函数防抖、节流
CSS RGB函数 LESS问题
Electron调用C#类库dll
window远程桌面连接报错:出现身份验证错误。要求函数不受支持

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