Mar*_* A. 0 acumatica acumatica-kb
我有以下场景。我在网格详细信息中创建了一个按钮。在选择记录并单击按钮时,复选框被标记,但我无法将其注册到数据库中。
我已附上 DAC 和图表
你可以帮我解决这个问题,欢迎评论。
提前致谢。
namespace PX.Objects.PM
{
public class PMBudgetExt : PXCacheExtension<PX.Objects.PM.PMBudget>
{
#region UsrVendorID
[PXDBInt]
[PXUIField(DisplayName = "Vendor ID", Visibility = PXUIVisibility.Visible)]
[PXDimensionSelectorAttribute("VENDOR", typeof(Search<VendorR.bAccountID, Where<VendorR.type, Equal<BAccountType.vendorType>,
And<VendorR.status, Equal<BAccount.status.active>>>>),
typeof(VendorR.acctCD), new Type[] { typeof(VendorR.acctCD), typeof(VendorR.acctName) },DescriptionField = typeof(VendorR.acctName))]
[PXUIEnabled(typeof(Where<PMBudgetExt.usrMarkforPO, Equal<False>>))]
public virtual int? UsrVendorID { get; set; }
public abstract class usrVendorID : PX.Data.BQL.BqlInt.Field<usrVendorID> { }
#endregion
#region UsrMarkforPO
[PXDBBool()]
[PXDefault(false)]
[PXUIField(DisplayName = "Mark for PO" )]
public virtual bool? UsrMarkforPO { get; set; }
public abstract class usrMarkforPO : PX.Data.BQL.BqlBool.Field<usrMarkforPO> { }
#endregion
#region UsrAcctName
[PXString(60)]
[PXUIField(DisplayName = "Vendor Name", Visibility = PXUIVisibility.SelectorVisible,Enabled =false)]
public virtual string UsrAcctName { get; set; }
public abstract class usrAcctName : PX.Data.BQL.BqlString.Field<usrAcctName> { }
#endregion
#region UsrPOProcessed
[PXDBBool()]
[PXDefault(false)]
[PXUIField(DisplayName="PO Processed")]
public virtual bool? UsrPOProcessed { get; set; }
public abstract class usrPOProcessed : PX.Data.BQL.BqlBool.Field<usrPOProcessed> { }
#endregion
}
}
**public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
public PXAction<PX.Objects.PM.PMProject> Calculate;
[PXButton]
[PXUIField(DisplayName = "Mark for PO")]
public virtual void calculate ()
{
PMProject pro = Base.Project.Current;
PMCostBudget row = Base.CostBudget.Current;
PMCostBudget newRow = Base.CostBudget.Current;
PMBudgetExt newRowE = PXCache<PMBudget>.GetExtension<PMBudgetExt>(newRow);
string valor = "";
foreach (CSAnswers item in Base.Answers.Select())
{
if (item.AttributeID == "PROJTYPE")
{
valor = item.Value;
break;
}
}
if (newRowE.UsrMarkforPO == false && newRowE.UsrVendorID != null && row.RevisedQty > 0 && pro.DefaultBranchID != null && pro.Status == ProjectStatus.Active && valor != null)
{
newRowE.UsrMarkforPO = true;
}
}
public delegate IEnumerable CopyProjectDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable CopyProject(PXAdapter adapter, CopyProjectDelegate baseMethod)
{
foreach (PMCostBudget item in Base.CostBudget.Select())
{
PMBudgetExt newRowE = PXCache<PMBudget>.GetExtension<PMBudgetExt>(item);
if (newRowE != null && newRowE.UsrMarkforPO == true)
{
newRowE.UsrMarkforPO = false;
}
}
return baseMethod(adapter);
}
protected void PMCostBudget_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (PMCostBudget)e.Row;
PMCostBudget newRow = (PMCostBudget)e.Row;
if (newRow == null) return;
PMBudgetExt newRowE = PXCache<PMBudget>.GetExtension<PMBudgetExt>(newRow);
if (newRowE == null) return;
foreach (POVendorInventory res in PXSelect<POVendorInventory,
Where<POVendorInventory.inventoryID,
In<Required<POVendorInventory.inventoryID>>>>.Select(Base, row.InventoryID))
{
if (res != null && res.IsDefault == true)
{
newRowE.UsrVendorID = res.VendorID;
}
}
}
protected void PMCostBudget_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PMCostBudget row = (PMCostBudget)e.Row;
PMCostBudget newRow = (PMCostBudget)e.Row;
if (newRow == null) return;
PMBudgetExt newRowE = PXCache<PMBudget>.GetExtension<PMBudgetExt>(newRow);
if (newRowE == null) return;
BAccount2 ba = PXSelect<BAccount2, Where<BAccount2.bAccountID,
In<Required<BAccount2.bAccountID>>>>.Select(Base, newRowE.UsrVendorID);
if (ba == null) newRowE.UsrAcctName = string.Empty;
if (ba != null) newRowE.UsrAcctName = ba.AcctName;
PXUIFieldAttribute.SetEnabled<PMBudgetExt.usrMarkforPO>(cache, e.Row, false);
}
}**
Run Code Online (Sandbox Code Playgroud)
您似乎正在使用按钮的“计算”操作。我看到您在对象 newRowE 上设置值的位置,但您实际上尚未使用该值更新数据库。
最好更新视图,但在这种情况下,直接访问缓存来保存它可能是最简单的,因为它是 DAC 扩展。您需要完成 2 个步骤来更新缓存并保存它。如果您在其他地方执行此操作并且已经通过其他方式(例如用户交互)进行了保存,那么手动保存步骤将是多余的。您可以通过以下 3 种方法执行数据库更新(如果其中一种方案在其他情况下更适合您)。
Base.Caches[typeof(PMBudget)].Update(newRowE);
Base.Save.Press();
Run Code Online (Sandbox Code Playgroud)
-或者-
Base.Caches[typeof(PMBudget)].SetValueExt<PMBudgetExt.UsrMarkforPO>(row, true)
Base.Caches[typeof(PMBudget)].Persist(PXDBOperation.Update);
Run Code Online (Sandbox Code Playgroud)
-或者-
Base.CostBudget.Update(row);
Base.Save.Press();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |