У меня есть следующий сценарий. Я создал кнопку в деталях сетки. Во время выбора записи и нажатия на кнопку флажок отмечен, но я не могу заставить ее зарегистрироваться в базе данных.
Я прикрепил DA C и График
Вы можете помочь мне с этим, какие комментарии приветствуются.
Заранее спасибо.
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);
}
}**