问题描述
概念是:当我在调查屏幕上保存特定记录时,“ investigationID”字段应保存在另一个名为“偏差报告”的屏幕中(您可以看到以下图像)
调查屏幕图像
偏差屏幕图像(“ investigationID”字段值存储)
但是在这里,当我尝试删除调查屏幕上的粒子“ investigationID”记录时,我遇到了问题。该值应在偏差屏幕的屏幕上变为空(您可以在上图...>黄色标记为“偏差屏幕”的屏幕上看到)
相关代码:
我在RowPersisted事件中编写了代码(保存时,此surveyID字段应保存在偏差屏幕中(您可以在“偏差屏幕图像”中看到......正在保存):
protected void TSInvestigation_RowPersisted(PXCache cache,PXRowPersistedEventArgs e)
{
var row = (TSInvestigation)e.Row;
if (row == null)
return;
if (row.InvestigationCD.Trim() != "<NEW>" /*row.InvestigationCD != null && TSInvestigationView.Cache.GetStatus(row) == PXEntryStatus.Inserted*/)
{
DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
DeviationReportMaintGraph.Clear();
//TSInvestigation get = this.TSInvestigationView.Current;
//TSDeviationReport retbatch = DeviationReportMaintGraph.TSDeviationReportView.Insert(new TSDeviationReport());
//TSDeviationReport retbatch = PXSelect<TSDeviationReport>.Select(DeviationReportMaintGraph);
if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
{
TSDeviationReport tSDeviation = PXSelect<TSDeviationReport,Where<TSDeviationReport.deviationCD,Equal<required<TSDeviationReport.deviationCD>>>>.Select(this,row.DeviationDocID);
if (tSDeviation != null)
{
tSDeviation.InvestigationID = row.InvestigationCD;
DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
DeviationReportMaintGraph.Actions.PressSave();
//DeviationReportMaintGraph.TSDeviationReportView.Cache.Update(tSDeviation);
//DeviationReportMaintGraph.Actions.PressSave();
}
}
}
}
我在RowDeleted事件中编写了代码(当我在调查屏幕上删除该行时,相关的surveycd字段应在“偏差屏幕图像”中看到的“偏差屏幕”上变为空值)
protected void TSInvestigation_RowDeleted(PXCache cache,PXRowDeletedEventArgs e)
{
var row = (TSInvestigation)e.Row;
if (row == null)
return;
DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
DeviationReportMaintGraph.Clear();
//TSInvestigation get = this.TSInvestigationView.Current;
if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
{
TSDeviationReport tSDeviation = PXSelect<TSDeviationReport,row.DeviationDocID);
if (tSDeviation != null /*|| tSDeviation == null*/)
{
tSDeviation.InvestigationID = null;
DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
DeviationReportMaintGraph.Actions.PressSave();
}
}
}
解决方法
您在InvestigationID
字段中设置了错误的值-应该是row.InvestigationID
,而不是row.InvestigationCD