我使用以下代码在“约会”页面中提取了属性值。
protected void FSAppointment_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (FSAppointment)e.Row;
AppointmentEntry graph = (AppointmentEntry)cache.Graph;
if (graph.ServiceOrderRelated.Current != null)
{
int? projectID = graph.ServiceOrderRelated.Current.ProjectID;
ProjectEntry projectGraph = PXGraph.CreateInstance<ProjectEntry>();
projectGraph.Project.Current = projectGraph.Project.Search<PMProject.contractID>(projectID);
foreach (CSAnswers att in projectGraph.Answers.Select())
{
if (att.AttributeID == "ESTHOURS")
{
cache.SetValueExt<FieldService.ServiceDispatch.FSAppointmentExt.usrProjectEstimatedRemainingHours>(row, att.Value);
return;
}
}
}
}
而且,现在我希望用户能够从“约会”页面更新该特定属性的值。
为此,我通过覆盖'约会'页面的Persist方法编写了以下代码。
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{
if (Base.ServiceOrderRelated.Current != null)
{
using (PXTransactionScope scope = new PXTransactionScope())
{
int? projectID = Base.ServiceOrderRelated.Current.ProjectID;
ProjectEntry projectGraph = PXGraph.CreateInstance<ProjectEntry>();
var project = projectGraph.Project.Search<PMProject.contractID>(projectID);
var answers = projectGraph.Answers.Select();
foreach (CSAnswers att in answers)
{
if (att.AttributeID == "ESTHOURS")
{
att.Value = "20";
}
}
projectGraph.Actions.PressSave();
}
}
baseMethod();
}
但它仍然没有更新价值。
答案 0 :(得分:1)
要实现的是,属性系统与通常的DAC-&gt; SQL系统不同。 CSAnswers是所有属性的非标准化值表。它们通过RefNoteID链接到DAC文档。请参阅CSAnswers中的select *,其中AttributeID =&#39; ESTHOURS&#39;在上面的代码中,您正在改变每个项目的时间&#39;。您还错过了一个语句,您可以通过该语句告诉图表使用您更改的对象更新缓存。像projectGraph.Answers.Update(att);
之类的东西