如何将actionsave更改为只能保存新记录

时间:2016-09-20 04:30:24

标签: c# acumatica erp

我有输入屏幕来管理确认数据,在更改数据时,数据将保存为新记录。 有没有其他解决方案,抱歉我的英语不好,谢谢。

1 个答案:

答案 0 :(得分:1)

重新阅读你的问题后我更新了我的答案。 我会覆盖坚持。复制要复制的当前记录,从缓存中删除更新的记录,然后插入新行(根据需要更改密钥)。见例......

public override void Persist()
{
    //Get your current row to copy from
    MyDAC rowCopy = PXCache<MyDAC>.CreateCopy(myGraph.MyView.Current)

    //If not saving the updated row you need to remove it from the cache
    MyView.Cache.Remove(MyView.Cache.Current);
    //  If removing more than one just do a foreach on MyView.Cache.Updated

    //Change the key fields as needed...
    rowCopy.SomeKey = someNewValue;
    //Change any other fields as needed...
    //Insert into the cache your new row
    rowCopy = myGraph.MyView.Insert(rowCopy);

    base.Persist();

    //Set copy row as current
    myGraph.MyView.Current = rowCopy;
}