我写了一些代码尝试更改库存分配详细信息上的一些字段。
以下是我的代码,我想改变的价值是现场' On Hand'。我总是使用“setValue'或者' setValueExt'在其他页面上执行此操作。但是在这个查询页面上,它并没有起作用。
我在使用' setValue'之后检查了缓存。方法,'手头'实际上是在缓存中更改了,但它没有刷新UI。
任何人都知道为什么?感谢。
public PXAction<PX.Objects.IN.InventoryAllocDetEnqFilter> changeIt;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Change it")]
protected void changeit()
{
var current = Base.Filter.Current;
var cache = Base.Filter.Cache;
var BaseUnit = current.BaseUnit;
var onHand = current.QtyOnHand;
var totalAddition = current.QtyTotalAddition;
var cgt = Convert.ToDecimal(current.QtyOnHand * 100);
cache.SetValue<InventoryAllocDetEnqFilter.qtyOnHand>(current, cgt);
}
答案 0 :(得分:0)
&#39; QtyOnHand&#39;值在&#39;过滤器&#39;中计算。代表。
在服务器回调上调用Delegate来刷新值。您的操作会更改&#39; QtyOnHand&#39;值,但委托在下一次服务器回调时覆盖它的值:
public PXFilter<InventoryAllocDetEnqFilter> Filter;
protected virtual IEnumerable filter()
{
PXCache cache = this.Caches[typeof(InventoryAllocDetEnqFilter)];
if (cache != null)
{
InventoryAllocDetEnqFilter filter = cache.Current as InventoryAllocDetEnqFilter;
if (filter != null)
{
filter.QtyOnHand = 0m;
filter.QtyTotalAddition = 0m;
filter.QtyPOPrepared = 0m;
filter.QtyPOOrders = 0m;
filter.QtyPOReceipts = 0m;
filter.QtyINReceipts = 0m;
filter.QtyInTransit = 0m;
filter.QtyInTransitToSO = 0m;
filter.QtyINAssemblySupply = 0m;
filter.QtyInTransitToProduction = 0m;
filter.QtyProductionSupplyPrepared = 0m;
filter.QtyProductionSupply = 0m;
filter.QtyPOFixedProductionPrepared = 0m;
filter.QtyPOFixedProductionOrders = 0m;
filter.QtyTotalDeduction = 0m;
filter.QtyHardAvail = 0m;
filter.QtyActual = 0m;
filter.QtyNotAvail = 0m;
filter.QtyExpired = 0m;
filter.QtySOPrepared = 0m;
filter.QtySOBooked = 0m;
filter.QtySOShipping = 0m;
filter.QtySOShippingReverse = 0m;
filter.QtySOShipped = 0m;
filter.QtySOShippedReverse = 0m;
filter.QtyINIssues = 0m;
filter.QtyINAssemblyDemand = 0m;
filter.QtyProductionDemandPrepared = 0m;
filter.QtyProductionDemand = 0m;
filter.QtyProductionAllocated = 0m;
filter.QtySOFixedProduction = 0m;
filter.QtySOBackOrdered = 0m;
filter.QtySOFixed = 0m;
filter.QtyPOFixedOrders = 0m;
filter.QtyPOFixedPrepared = 0m;
filter.QtyPOFixedReceipts = 0m;
filter.QtySODropShip = 0m;
filter.QtyPODropShipOrders = 0m;
filter.QtyPODropShipPrepared = 0m;
filter.QtyPODropShipReceipts = 0m;
filter.QtyAvail = 0m;
// InventoryId is required field
if (filter.InventoryID != null)
{
// 'included' checkboxes
InventoryItem inventoryItemRec = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<InventoryAllocDetEnqFilter.inventoryID>>>>.Select(this);
INAvailabilityScheme availSchemeRec = PXSelectJoin<INAvailabilityScheme,
InnerJoin<INItemClass, On<INAvailabilityScheme.availabilitySchemeID, Equal<INItemClass.availabilitySchemeID>>>,
Where<INItemClass.itemClassID, Equal<Required<INItemClass.itemClassID>>>>
.Select(this, inventoryItemRec.ItemClassID);
filter.InclQtyPOPrepared = availSchemeRec.InclQtyPOPrepared;
filter.InclQtyPOOrders = availSchemeRec.InclQtyPOOrders;
filter.InclQtyPOReceipts = availSchemeRec.InclQtyPOReceipts;
filter.InclQtyINReceipts = availSchemeRec.InclQtyINReceipts;
filter.InclQtyInTransit = availSchemeRec.InclQtyInTransit;
filter.InclQtySOPrepared = availSchemeRec.InclQtySOPrepared;
filter.InclQtySOBooked = availSchemeRec.InclQtySOBooked;
filter.InclQtySOShipping = availSchemeRec.InclQtySOShipping;
filter.InclQtySOShipped = availSchemeRec.InclQtySOShipped;
filter.InclQtyINIssues = availSchemeRec.InclQtyINIssues;
filter.InclQtyINAssemblyDemand = availSchemeRec.InclQtyINAssemblyDemand;
filter.InclQtyINAssemblySupply = availSchemeRec.InclQtyINAssemblySupply;
filter.InclQtyProductionDemandPrepared = availSchemeRec.InclQtyProductionDemandPrepared;
filter.InclQtyProductionDemand = availSchemeRec.InclQtyProductionDemand;
filter.InclQtyProductionAllocated = availSchemeRec.InclQtyProductionAllocated;
filter.InclQtyProductionSupplyPrepared = availSchemeRec.InclQtyProductionSupplyPrepared;
filter.InclQtyProductionSupply = availSchemeRec.InclQtyProductionSupply;
filter.InclQtySOBackOrdered = availSchemeRec.InclQtySOBackOrdered;
filter.InclQtySOReverse = availSchemeRec.InclQtySOReverse;
filter.BaseUnit = inventoryItemRec.BaseUnit;
// QtyOnHand , QtyExpired , QtyLocNotAvail calculation :
// simplified (without cost) version of code from IN401000
PXSelectBase<INLocationStatus> calcStatusCmd =
new PXSelectReadonly2<INLocationStatus,
//InnerJoin<INSiteStatus,
// On<INSiteStatus.inventoryID, Equal<INLocationStatus.inventoryID>,
// And<INSiteStatus.subItemID, Equal<INLocationStatus.subItemID>,
// And<INSiteStatus.siteID, Equal<INLocationStatus.siteID>>>>>,
InnerJoin<InventoryItem,
On<InventoryItem.inventoryID, Equal<INLocationStatus.inventoryID>>,
InnerJoin<INLocation,
On<INLocation.siteID, Equal<INLocationStatus.siteID>,
And<INLocation.locationID, Equal<INLocationStatus.locationID>>>,
InnerJoin<INSubItem,
On<INSubItem.subItemID, Equal<INLocationStatus.subItemID>>,
LeftJoin<INLotSerClass,
On<INLotSerClass.lotSerClassID, Equal<InventoryItem.lotSerClassID>>,
LeftJoin<INLotSerialStatus,
On<INLotSerialStatus.inventoryID, Equal<INLocationStatus.inventoryID>,
And<INLotSerClass.lotSerAssign, Equal<INLotSerAssign.whenReceived>,
And<INLotSerialStatus.subItemID, Equal<INLocationStatus.subItemID>,
And<INLotSerialStatus.siteID, Equal<INLocationStatus.siteID>,
And<INLotSerialStatus.locationID, Equal<INLocationStatus.locationID>,
And<INLotSerClass.lotSerClassID, IsNotNull,
And<INLotSerClass.lotSerTrack, NotEqual<INLotSerTrack.notNumbered>>>>>>>>,
InnerJoin<INSite,
On<INSite.siteID, Equal<INLocationStatus.siteID>,
And<Match<IN.INSite, Current<AccessInfo.userName>>>>
>>>>>>,
Where<INLocationStatus.inventoryID, Equal<Current<InventoryAllocDetEnqFilter.inventoryID>>>,
OrderBy<Asc<InventoryItem.inventoryCD,
Asc<INLocationStatus.siteID,
Asc<INSubItem.subItemCD,
Asc<INLocationStatus.locationID,
Asc<INLotSerialStatus.lotSerialNbr>>>>>>>(this);
if (!SubCDUtils.IsSubCDEmpty(filter.SubItemCD))
calcStatusCmd.WhereAnd<Where<INSubItem.subItemCD, Like<Current<InventoryAllocDetEnqFilter.subItemCDWildcard>>>>();
if (filter.SiteID != null)
calcStatusCmd.WhereAnd<Where<INLocationStatus.siteID, Equal<Current<InventoryAllocDetEnqFilter.siteID>>>>();
if (filter.LocationID != null)
calcStatusCmd.WhereAnd<Where<INLocationStatus.locationID, Equal<Current<InventoryAllocDetEnqFilter.locationID>>>>();
if (!string.IsNullOrEmpty(filter.LotSerialNbr))
calcStatusCmd.WhereAnd<Where<INLotSerialStatus.lotSerialNbr, Like<Current<InventoryAllocDetEnqFilter.lotSerialNbrWildcard>>>>();
PXResultset<INLocationStatus> calcStatusRecs = calcStatusCmd.Select();
// only 3 values here : QtyOnHand, QtyOnLocNotAvail, QtyExpired
foreach (PXResult<INLocationStatus, /*INSiteStatus,*/ InventoryItem, INLocation, INSubItem, INLotSerClass, INLotSerialStatus> it in calcStatusRecs)
{
INLocationStatus ls_rec = it;
//INSiteStatus ss_rec = it;
InventoryItem ii_rec = it;
//INSubItem si_rec = it;
INLocation l_rec = it;
INLotSerialStatus lss_rec = it;
filter.QtyOnHand += (lss_rec.QtyOnHand ?? ls_rec.QtyOnHand);
if (!(l_rec.InclQtyAvail ?? true))
{
filter.QtyNotAvail += lss_rec.QtyAvail ?? ls_rec.QtyAvail;
}
else
{
if ((lss_rec.ExpireDate != null) && (DateTime.Compare((DateTime)this.Accessinfo.BusinessDate, (DateTime)lss_rec.ExpireDate) > 0))
{
filter.QtyExpired += lss_rec.QtyOnHand;
}
}
}
foreach (InventoryAllocDetEnqResult it in this.ResultRecords.Select()) //???
{
Aggregate(filter, it);
}
filter.QtyTotalAddition =
((filter.InclQtyPOPrepared ?? false) ? filter.QtyPOPrepared : 0m)
+ ((filter.InclQtyPOOrders ?? false) ? filter.QtyPOOrders : 0m)
+ ((filter.InclQtyPOReceipts ?? false) ? filter.QtyPOReceipts : 0m)
+ ((filter.InclQtyINReceipts ?? false) ? filter.QtyINReceipts : 0m)
+ ((filter.InclQtyInTransit ?? false) ? filter.QtyInTransit : 0m)
+ ((filter.InclQtyINAssemblySupply ?? false) ? filter.QtyINAssemblySupply : 0m)
+ ((filter.InclQtyProductionSupplyPrepared ?? false) ? filter.QtyProductionSupplyPrepared : 0m)
+ ((filter.InclQtyProductionSupply ?? false) ? filter.QtyProductionSupply : 0m);
filter.QtyTotalDeduction =
filter.QtyExpired
+ ((filter.InclQtySOPrepared ?? false) ? filter.QtySOPrepared : 0m)
+ ((filter.InclQtySOBooked ?? false) ? filter.QtySOBooked : 0m)
+ ((filter.InclQtySOShipping ?? false) ? filter.QtySOShipping : 0m)
+ ((filter.InclQtySOShipped ?? false) ? filter.QtySOShipped : 0m)
+ ((filter.InclQtyINIssues ?? false) ? filter.QtyINIssues : 0m)
+ ((filter.InclQtyINAssemblyDemand ?? false) ? filter.QtyINAssemblyDemand : 0m)
+ ((filter.InclQtyProductionDemandPrepared ?? false) ? filter.QtyProductionDemandPrepared : 0m)
+ ((filter.InclQtyProductionDemand ?? false) ? filter.QtyProductionDemand : 0m)
+ ((filter.InclQtyProductionAllocated ?? false) ? filter.QtyProductionAllocated : 0m)
+ ((filter.InclQtySOBackOrdered ?? false) ? filter.QtySOBackOrdered : 0m);
filter.QtyAvail = filter.QtyOnHand + filter.QtyTotalAddition - (filter.QtyTotalDeduction + filter.QtyNotAvail);
filter.QtyHardAvail = filter.QtyOnHand - filter.QtyNotAvail - filter.QtyINIssues
- (filter.QtySOShipping - filter.QtySOShippingReverse) - (filter.QtySOShipped - filter.QtySOShippedReverse);
filter.QtyActual = filter.QtyOnHand - filter.QtyNotAvail - (filter.QtySOShipped - filter.QtySOShippedReverse);
}
}
}
yield return cache.Current;
cache.IsDirty = false;
}