如何用按钮标记复选框

问题描述 投票:0回答:1

我有以下情况。我在网格详细信息中创建了一个按钮。在选择一条记录并单击按钮时,该复选框已标记,但我无法将其注册到数据库中。

我已附上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);

        }

    }**

enter image description here

enter image description here

acumatica acumatica-kb
1个回答
0
投票

似乎您正在为按钮使用“计算”​​操作。我看到您在对象newRowE上设置该值的位置,但实际上尚未使用该值更新数据库。

最好更新视图,但是在这种情况下,直接访问高速缓存以保存它是最简单的方法,因为它是DAC扩展。您需要完成2个步骤来更新并保存缓存。如果您在其他地方执行此操作,并且已经通过其他方式(例如用户交互)进行了保存,则手动保存步骤将是多余的。您可以尝试以下2种方法(如果一种情况在其他情况下更适合您)。

Base.Caches[typeof(PMBudget)].Update(newRowE);
Base.Save.Press();

-或-

Base.Caches[typeof(PMBudget)].SetValueExt<PMBudgetExt.UsrMarkforPO>(row, true)
Base.Caches[typeof(PMBudget)].Persist(PXDBOperation.Update);

-或-

Base.CostBudget.Update(row);
Base.Save.Press();
© www.soinside.com 2019 - 2024. All rights reserved.