protected override void Master_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update) { ARTran row = (ARTran)e.Row; if (Math.Abs((decimal)row.BaseQty) >= 0.0000005m && (row.UnassignedQty >= 0.0000005m || row.UnassignedQty <= -0.0000005m)) { if (sender.RaiseExceptionHandling <ARTran.qty>(row, row.Qty, new PXSetPropertyException(Messages.BinLotSerialNotAssigned))) { throw new PXRowPersistingException(typeof(ARTran.qty).Name, row.Qty, Messages.BinLotSerialNotAssigned); } } try { returnRecords = null; if (!MemoAvailabilityCheckQty(sender, row)) { RaiseAvailabilityException(sender, row, typeof(ARTran.qty), Messages.InvoiceCheck_DecreaseQty, true, sender.GetValueExt <ARTran.origInvoiceNbr>(row), sender.GetValueExt <ARTran.inventoryID>(row), returnRecords == null ? string.Empty : string.Join(", ", returnRecords.Select(x => x.DocumentNbr))); } } finally { returnRecords = null; } OrderAvailabilityCheck(sender, row, onPersist: true); } base.Master_RowPersisting(sender, e); }
public static void RaiseOrHideError <T>(PXCache cache, object row, bool isIncorrect, string message, PXErrorLevel errorLevel, params object[] parameters) where T : IBqlField { if (isIncorrect) { cache.RaiseExceptionHandling <T>(row, PXFieldState.UnwrapValue(cache.GetValueExt <T>(row)), new PXSetPropertyException(message, errorLevel, parameters)); } else { cache.RaiseExceptionHandling <T>(row, PXFieldState.UnwrapValue(cache.GetValueExt <T>(row)), null); } }
public static Dictionary <string, List <object> > GetPropertyValuesPairs(PXCache valuesCache, IEnumerable items, IEnumerable <string> fields) { Dictionary <string, List <object> > dinamicValuesDic = new Dictionary <string, List <object> >(); List <string> mergeableFields = new List <string>(); foreach (string field in fields) { CRMergeableAttribute att = CRHelper.GetCustomAttribute <CRMergeableAttribute>(valuesCache, field); if (att == null || att.Enabled) { mergeableFields.Add(field); } } foreach (object row in items) { foreach (string field in mergeableFields) { if (!dinamicValuesDic.ContainsKey(field)) { dinamicValuesDic.Add(field, new List <object>()); } List <object> currentValuesList = dinamicValuesDic[field]; object currentValue = valuesCache.GetValueExt(row, field); if (!currentValuesList.Contains(currentValue)) { currentValuesList.Add(currentValue); } } } return(dinamicValuesDic); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); PXButtonDelegate del = delegate(PXAdapter adapter) { PXCache cache = adapter.View.Graph.Caches[typeof(SOLineSplit)]; if (cache.Current != null) { object val = cache.GetValueExt(cache.Current, _FieldName); PXLinkState state = val as PXLinkState; if (state != null) { helper.NavigateToRow(state.target.FullName, state.keys, PXRedirectHelper.WindowMode.NewWindow); } else { helper.NavigateToRow((Guid?)cache.GetValue(cache.Current, _FieldName), PXRedirectHelper.WindowMode.NewWindow); } } return(adapter.Get()); }; string ActionName = sender.GetItemType().Name + "$" + _FieldName + "$Link"; sender.Graph.Actions[ActionName] = (PXAction)Activator.CreateInstance(typeof(PXNamedAction <>).MakeGenericType(typeof(SOOrder)), new object[] { sender.Graph, ActionName, del, new PXEventSubscriberAttribute[] { new PXUIFieldAttribute { MapEnableRights = PXCacheRights.Select } } }); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (sender.Graph.PrimaryItemType == null) { return; } PXButtonDelegate delgate = delegate(PXAdapter adapter) { PXCache cache = adapter.View.Graph.Caches[typeof(SOOrderShipment)]; if (cache.Current != null) { var helper = new EntityHelper(cache.Graph); object val = cache.GetValueExt(cache.Current, _FieldName); var state = val as PXRefNoteBaseAttribute.PXLinkState; if (state != null) { helper.NavigateToRow(state.target.FullName, state.keys, PXRedirectHelper.WindowMode.NewWindow); } else { helper.NavigateToRow((Guid?)cache.GetValue(cache.Current, _FieldName), PXRedirectHelper.WindowMode.NewWindow); } } return(adapter.Get()); }; string actionName = $"{ sender.GetItemType().Name }~{ _FieldName }~Link"; PXNamedAction.AddHiddenAction(sender.Graph, sender.Graph.PrimaryItemType, actionName, delgate); }
public void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value) { (item as BqlFormula.ItemContainer)?.InvolvedFields.Add(typeof(Field)); object fs = cache.GetValueExt(BqlFormula.ItemContainer.Unwrap(item), typeof(Field).Name); value = fs is PXFieldState ? ((PXFieldState)fs).Value : fs; }
public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { object val; if (_PersistingCheck != PXPersistingCheck.Nothing && ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update) && (val = sender.GetValue(e.Row, _FieldOrdinal)) != null && (decimal)val != 1m) { val = (decimal)val * 100m; if (_MapErrorTo == null) { if (sender.RaiseExceptionHandling(_FieldName, e.Row, val, new PXSetPropertyException(PXMessages.LocalizeFormat(Messages.WrongValue, _FieldName)))) { throw new PXRowPersistingException(_FieldName, null, Messages.WrongValue, _FieldName); } } else { string name = _MapErrorTo.Name; name = char.ToUpper(name[0]) + name.Substring(1); val = sender.GetValueExt(e.Row, name); if (val is PXFieldState) { val = ((PXFieldState)val).Value; } if (sender.RaiseExceptionHandling(name, e.Row, val, new PXSetPropertyException(PXMessages.LocalizeFormat(Messages.WrongValue, name, _FieldName)))) { throw new PXRowPersistingException(_FieldName, null, Messages.WrongValue, _FieldName); } } } }
protected virtual void Ledger_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { Ledger ledger = (Ledger)e.Row; if (ledger.DefBranchID != null && (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)) { object BranchCD = sender.GetValueExt <Ledger.defBranchID>(e.Row); if (BranchCD is PXFieldState) { BranchCD = ((PXFieldState)BranchCD).Value; } IN.INSite site; if ((site = PXSelect <IN.INSite, Where <IN.INSite.branchID, Equal <Required <IN.INSite.branchID> > > > .SelectWindowed(this, 0, 1, ledger.DefBranchID)) != null) { sender.RaiseExceptionHandling <Ledger.defBranchID>(e.Row, BranchCD, new PXSetPropertyException(Messages.BranchUsedWithSite, site.SiteCD)); } FA.FixedAsset asset; if ((asset = PXSelect <FA.FixedAsset, Where <FA.FixedAsset.branchID, Equal <Required <FA.FixedAsset.branchID> > > > .SelectWindowed(this, 0, 1, ledger.DefBranchID)) != null) { sender.RaiseExceptionHandling <Ledger.defBranchID>(e.Row, BranchCD, new PXSetPropertyException(Messages.BranchUsedWithFixedAsset, asset.AssetCD)); } } }
public static object GetNewValueByIncoming(PXCache cache, object row, string fieldName, bool externalCall) { object incoming = null; if (externalCall) { incoming = cache.GetValuePending(row, fieldName); if (incoming != null) { return(incoming); } } try { incoming = cache.GetValueExt(row, fieldName); return(PXFieldState.UnwrapValue(incoming)); } catch { } return(cache.GetValue(row, fieldName)); }
protected virtual void BranchFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { PXFieldState state = (PXFieldState)sender.GetValueExt(e.Row, _FieldName); if (state != null && state.Value != null) { sender.SetValue(e.Row, _FieldName, null); sender.SetValueExt(e.Row, _FieldName, state.Value); } }
private static PXSetPropertyException VerifyingAndGetError(PXUIVerifyAttribute attr, PXCache sender, object row) { if (row == null) { return(null); } if (attr == null) { throw new PXException(ErrorMessages.AttributeNotDefined, typeof(PXUIVerifyAttribute).Name); } if (attr.Condition != null && !GetConditionResult(sender, row, attr.Condition)) { List <object> messageParams = new List <object>(); foreach (Type arg in attr._args) { if (typeof(IConstant).IsAssignableFrom(arg)) { IConstant constantInstance = Activator.CreateInstance(arg) as IConstant; messageParams.Add(constantInstance?.Value); } else if (attr.MessageArgumentsAreFieldNames) { messageParams.Add(PXUIFieldAttribute.GetDisplayName(sender, arg.Name)); } else if (arg.IsGenericType && arg.GetGenericTypeDefinition() == typeof(Current <>)) { Type field = arg.GetGenericArguments()[0]; PXCache cache = sender.Graph.Caches[BqlCommand.GetItemType(field)]; messageParams.Add(cache.GetValue(cache.Current, field.Name)); } else { var value = sender.GetValueExt(row, arg.Name); if (value is PXFieldState) { messageParams.Add(((PXFieldState)value).Value); } else { messageParams.Add(value); } } } return(new PXSetPropertyException(attr._Message, attr._ErrorLevel, messageParams.ToArray())); } return(null); }
public void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { if (string.IsNullOrEmpty((string)e.NewValue) || e.NewValue.ToString().Length.Equals(10) || TWNGUIValidation.ActivateTWGUI(new PXGraph()).Equals(false)) { return; } object obj = null; string vATCode = null; switch (this.BqlTable.Name) { case nameof(APRegister): obj = sender.GetValueExt <APRegisterExt.usrVATInCode>(e.Row); break; case nameof(ARRegister): obj = sender.GetValueExt <ARRegisterExt.usrVATOutCode>(e.Row); break; case nameof(TWNGUITrans): obj = sender.GetValueExt <TWNGUITrans.gUIFormatcode>(e.Row); break; case nameof(TWNManualGUIAP): obj = sender.GetValueExt <TWNManualGUIAP.vATInCode>(e.Row); break; case nameof(TWNManualGUIAR): obj = sender.GetValueExt <TWNManualGUIAR.vatOutCode>(e.Row); break; case nameof(TWNManualGUIBank): obj = sender.GetValueExt <TWNManualGUIBank.vATInCode>(e.Row); break; case nameof(TWNManualGUIExpense): obj = sender.GetValueExt <TWNManualGUIExpense.vATInCode>(e.Row); break; } vATCode = obj is null ? string.Empty : obj.ToString(); if (!vATCode.IsIn(TWGUIFormatCode.vATOutCode33, TWGUIFormatCode.vATOutCode34) || vATCode.IsIn(TWGUIFormatCode.vATInCode21, TWGUIFormatCode.vATInCode23, TWGUIFormatCode.vATInCode25) ) { throw new PXSetPropertyException(e.NewValue.ToString().Length > 10 ? TWMessages.GUINbrLength : TWMessages.GUINbrMini, PXErrorLevel.Error); } }
protected virtual void OrganizationLedgerLink_RowDeleting(PXCache cache, PXRowDeletingEventArgs e) { var link = e.Row as OrganizationLedgerLink; PXSetPropertyException ex = CanBeLinkDeleted(link); if (ex != null) { cache.RaiseExceptionHandling(VisibleField.Name, link, cache.GetValueExt(link, VisibleField.Name), ex); e.Cancel = true; } }
public void InitSegmentData(GLConsolSetup item) { foreach (SegmentValue segValue in PXSelect <SegmentValue, Where <SegmentValue.dimensionID, Equal <Required <SegmentValue.dimensionID> > > > .Select(this, "SUBACCOUNT")) { if (!segmentValueTriple.ContainsKey(segValue.SegmentID ?? 0)) { segmentValueTriple[segValue.SegmentID ?? 0] = new Dictionary <string, string>(); } segmentValueTriple[segValue.SegmentID ?? 0][segValue.Value] = segValue.MappedSegValue; } foreach (Segment segDetail in PXSelect <Segment, Where <Segment.dimensionID, Equal <Required <Segment.dimensionID> > > > .Select(this, "SUBACCOUNT")) { segmentPairs[segDetail.SegmentID ?? 0] = segDetail.Length ?? 0; segmentNames[segDetail.SegmentID ?? 0] = segDetail.Descr; segmentNumChars[segDetail.SegmentID ?? 0] = segDetail.ConsolNumChar ?? 0; if (segDetail.Validate != true && segmentValueTriple.ContainsKey(segDetail.SegmentID ?? 0)) { segmentValueTriple.Remove(segDetail.SegmentID ?? 0); } } // Init Segment start index short consolSegmentId = GLSetup.Current.ConsolSegmentId ?? 0; int startIndex = 0; for (short segmentId = 1; segmentId < consolSegmentId; segmentId++) { startIndex += segmentPairs[segmentId]; } segmentStartIndex = startIndex; PXCache cache = this.Caches[typeof(GLConsolSetup)]; PXDBCryptStringAttribute.SetDecrypted <GLConsolSetup.password>(cache, true); if (item != null) { consolSetup = item; consolSetup.Password = cache.GetValueExt <GLConsolSetup.password>(consolSetup).ToString(); PXDBCryptStringAttribute.SetDecrypted <GLConsolSetup.password>(cache, false); segmentInsertData = consolSetup.SegmentValue; pasteFlag = consolSetup.PasteFlag ?? false; } }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (_Condition != null) { List <Type> fields = new List <Type>(); //_Condition.Parse(sender.Graph, null, null, fields, null, null, null); var exp = PX.Data.SQLTree.SQLExpression.None(); _Condition.AppendExpression(ref exp, sender.Graph, new BqlCommandInfo(false) { Fields = fields, BuildExpression = false }, new BqlCommand.Selection()); foreach (Type t in fields) { if (t.IsNested && (BqlCommand.GetItemType(t) == sender.GetItemType() || sender.GetItemType().IsSubclassOf(BqlCommand.GetItemType(t)))) { if (!t.Name.Equals(_FieldName, StringComparison.OrdinalIgnoreCase)) { sender.FieldUpdatedEvents[t.Name.ToLower()] += delegate(PXCache cache, PXFieldUpdatedEventArgs e) { dependentFieldUpdated(cache, e.Row); }; } } } if (this.CheckOnRowSelected) { sender.RowSelected += delegate(PXCache cache, PXRowSelectedEventArgs e) { var ex = VerifyingAndGetError(this, sender, e.Row); object newValue = null; if (ex != null && ex.ErrorLevel == PXErrorLevel.Error) { newValue = sender.GetValueExt(e.Row, _FieldName); if (newValue is PXFieldState) { newValue = ((PXFieldState)newValue).Value; } } cache.RaiseExceptionHandling(FieldName, e.Row, newValue, ex); }; } } }
private object GetFieldValue(IBqlTable item, string fieldname, string fieldvalue = null) { PXCache sourceCache = this.Caches[item.GetType()]; object copy = sourceCache.CreateCopy(item); if (fieldvalue != null) { sourceCache.SetValueExt(copy, fieldname, fieldvalue); } else { object newValue; sourceCache.RaiseFieldDefaulting(fieldname, copy, out newValue); sourceCache.SetValue(copy, fieldname, newValue); } return(sourceCache.GetValueExt(copy, fieldname)); }
protected virtual void RaiseAvailabilityException(PXCache sender, object row, Type field, string errorMessage, bool onPersist, params object[] args) { var propertyException = new PXSetPropertyException(errorMessage, args); if (onPersist) { object value = sender.GetValueExt(row, field.Name); bool raised = sender.RaiseExceptionHandling(field.Name, row, value, propertyException); if (raised) { throw new PXRowPersistingException(field.Name, value, errorMessage, args); } } else { throw propertyException; } }
protected virtual void EPActivityApprove_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (row.UIStatus == CR.ActivityStatusListAttribute.Approved || row.Released == true) { Filter.View.Ask((string.Format(Messages.ActivityIs, sender.GetValueExt <EPActivityApprove.uistatus>(row))), MessageButtons.OK); e.Cancel = true; } else if (row.TimeCardCD != null) { Filter.View.Ask(Messages.ActivityAssignedToTimeCard, MessageButtons.OK); e.Cancel = true; } }
void IPXRowPersistingSubscriber.RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if (!this.CheckOnRowPersisting) { return; } try { Verifying(sender, e.Row); } catch (PXSetPropertyException ex) { var newValue = sender.GetValueExt(e.Row, _FieldName); if (newValue is PXFieldState) { newValue = ((PXFieldState)newValue).Value; } sender.RaiseExceptionHandling(_FieldName, e.Row, newValue, ex); } }
protected virtual void INLotSerClass_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { INLotSerClass cls = (INLotSerClass)e.Row; if (cls == null) { return; } if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) { if (cls.LotSerTrack != INLotSerTrack.NotNumbered && cls.LotSerNumShared == true) { var fieldState = (PXStringState)sender.GetValueExt(cls, lotSerNumValueFieldName); if (fieldState == null || fieldState.Value == null) { var exception = new PXSetPropertyException(ErrorMessages.FieldIsEmpty, fieldState.DisplayName); PXUIFieldAttribute.SetError <INLotSerClassLotSerNumVal.lotSerNumVal>(lotSerNumVal.Cache, null, exception.Message); } } } }
public static void SendNotification(AppointmentEntry graphAppointmentEntry, PXCache sourceCache, string notificationCD, int?branchID, IDictionary <string, string> parameters, IList <Guid?> attachments = null) { if (sourceCache.Current == null) { throw new PXException(PX.Objects.CR.Messages.EmailNotificationError); } Guid?setupID = new NotificationUtility(graphAppointmentEntry).SearchSetupID(FSNotificationSource.Appointment, notificationCD); if (setupID == null) { sourceCache.RaiseExceptionHandling <FSAppointment.srvOrdType>( sourceCache.Current, ((FSAppointment)sourceCache.Current).SrvOrdType, new PXSetPropertyException( PX.Objects.CR.Messages.EmailNotificationSetupNotFound, PXErrorLevel.Warning, notificationCD)); return; } if (branchID == null) { branchID = graphAppointmentEntry.Accessinfo.BranchID; } if (parameters == null) { parameters = new Dictionary <string, string>(); foreach (string key in sourceCache.Keys) { object value = sourceCache.GetValueExt(sourceCache.Current, key); parameters[key] = value != null?value.ToString() : null; } } Send(graphAppointmentEntry, sourceCache, (Guid)setupID, branchID, parameters, attachments); }
protected override void Master_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update) { ARTran row = (ARTran)e.Row; if (Math.Abs((decimal)row.BaseQty) >= 0.0000005m && (row.UnassignedQty >= 0.0000005m || row.UnassignedQty <= -0.0000005m)) { if (sender.RaiseExceptionHandling <ARTran.qty>(row, row.Qty, new PXSetPropertyException(Messages.BinLotSerialNotAssigned))) { throw new PXRowPersistingException(typeof(ARTran.qty).Name, row.Qty, Messages.BinLotSerialNotAssigned); } } if (!MemoAvailabilityCheckQty(sender, row)) { RaiseAvailabilityException(sender, row, typeof(ARTran.qty), Messages.InvoiceCheck_QtyNegative, true, sender.GetValueExt <ARTran.inventoryID>(row), sender.GetValueExt <ARTran.subItemID>(row), sender.GetValueExt <ARTran.origInvoiceNbr>(row)); } OrderAvailabilityCheck(sender, row, onPersist: true); } base.Master_RowPersisting(sender, e); }
protected virtual void POVendorInventory_RowDeleted(PXCache cache, PXRowDeletedEventArgs e) { if (Item.Cache.GetStatus(this.Item.Current).IsIn(PXEntryStatus.Deleted, PXEntryStatus.InsertedDeleted)) { return; } InventoryItem upd = PXCache <InventoryItem> .CreateCopy(this.Item.Current); POVendorInventory vendor = e.Row as POVendorInventory; object isdefault = cache.GetValueExt <POVendorInventory.isDefault>(e.Row); if (isdefault is PXFieldState) { isdefault = ((PXFieldState)isdefault).Value; } if ((bool?)isdefault == true) { upd.PreferredVendorID = null; upd.PreferredVendorLocationID = null; this.Item.Update(upd); } }
void IPXFieldVerifyingSubscriber.FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { if (this.CheckOnVerify) { var row = sender.CreateCopy(e.Row); sender.SetValue(row, _FieldName, e.NewValue); try { Verifying(sender, row); sender.RaiseExceptionHandling(_FieldName, e.Row, null, null); } catch (PXSetPropertyException ex) { var newValue = sender.GetValueExt(row, _FieldName); if (newValue is PXFieldState) { newValue = ((PXFieldState)newValue).Value; } sender.RaiseExceptionHandling(_FieldName, e.Row, newValue, ex); } } }
protected void InsertPropertyValue(FieldValue field, Dictionary <Type, object> targets) { Type t = Type.GetType(field.CacheName); PXCache cache = Base.Caches[t]; object target = targets[t]; PXStringState state = InitValueFieldState(field) as PXStringState; if (state != null) { if (state.AllowedValues == null || !state.AllowedValues.Any() || state.AllowedValues.Count() == 1 && field.AttributeID == null) { return; } if (state.AllowedValues.Count() == 1) { field.Hidden = true; field.Value = state.AllowedValues[0]; } else if (target != null) { state.Required = true; object value = cache.GetValueExt(target, field.Name); if (value is PXFieldState) { value = ((PXFieldState)value).Value; } field.Value = value != null?value.ToString() : null; } } Base.Caches[typeof(FieldValue)].Insert(field); }
protected object GetNewValueByIncomig(PXCache cache, object row, string fieldName, bool externalCall) { object incoming = null; if (externalCall) { incoming = cache.GetValuePending(row, fieldName); if (incoming != null) { return(incoming); } } try { incoming = cache.GetValueExt(row, fieldName); var state = incoming as PXFieldState; if (state != null) { return(state.Value); } if (incoming != null) { return(incoming); } } catch { } return(cache.GetValue(row, fieldName)); }
private void CheckFields(PXCache cache, object row, params Type[] fields) { var errors = new Dictionary <string, string>(fields.Length); foreach (Type field in fields) { var value = cache.GetValue(row, field.Name); if (value == null || (value is string && string.IsNullOrEmpty(value as string))) { var state = cache.GetValueExt(row, field.Name) as PXFieldState; var fieldDisplayName = state == null || string.IsNullOrEmpty(state.DisplayName) ? field.Name : state.DisplayName; var errorMessage = PXMessages.LocalizeFormatNoPrefix(Messages.EmptyValueErrorFormat, fieldDisplayName); var fieldName = cache.GetField(field); errors.Add(fieldName, errorMessage); PXUIFieldAttribute.SetError(cache, row, fieldName, errorMessage); } } if (errors.Count > 0) { throw new PXOuterException(errors, GetType(), row, ErrorMessages.RecordRaisedErrors, null, cache.GetItemType().Name); } }
protected virtual void dependentFieldUpdated(PXCache sender, object row) { //if (PXUIFieldAttribute.GetError(sender, row, _FieldName) != null) // return; var newValue = sender.GetValueExt(row, _FieldName); if (newValue is PXFieldState) { newValue = ((PXFieldState)newValue).Value; } try { if (this.CheckOnVerify) { Verifying(sender, row); } sender.RaiseExceptionHandling(_FieldName, row, newValue, null); } catch (PXSetPropertyException ex) { sender.RaiseExceptionHandling(_FieldName, row, newValue, ex); } }
public void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value) { object fs; value = (fs = cache.GetValueExt(item, typeof(Field).Name)) is PXFieldState ? ((PXFieldState)fs).Value : fs; }
protected override void InventoryItem_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { base.InventoryItem_RowSelected(sender, e); InventoryItem row = (InventoryItem)e.Row; if (row == null) { return; } PXUIFieldAttribute.SetEnabled <InventoryItem.cOGSSubID>(sender, row, (postclass.Current != null && postclass.Current.COGSSubFromSales == false)); PXUIFieldAttribute.SetEnabled <InventoryItem.stdCstVarAcctID>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetEnabled <InventoryItem.stdCstVarSubID>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetEnabled <InventoryItem.stdCstRevAcctID>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetEnabled <InventoryItem.stdCstRevSubID>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetEnabled <InventoryItem.pendingStdCost>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetEnabled <InventoryItem.pendingStdCostDate>(sender, row, row?.ValMethod == INValMethod.Standard); PXUIFieldAttribute.SetVisible <InventoryItem.defaultSubItemOnEntry>(sender, null, insetup.Current.UseInventorySubItem == true); PXUIFieldAttribute.SetEnabled <POVendorInventory.isDefault>(this.VendorItems.Cache, null, true); INAcctSubDefault.Required(sender, new PXRowSelectedEventArgs(row)); PXUIFieldAttribute.SetVisible <InventoryItem.defaultSubItemOnEntry>(sender, null, insetup.Current.UseInventorySubItem == true); Boxes.Cache.AllowInsert = row.PackageOption != INPackageOption.Manual && PXAccess.FeatureInstalled <FeaturesSet.autoPackaging>(); Boxes.Cache.AllowUpdate = row.PackageOption != INPackageOption.Manual && PXAccess.FeatureInstalled <FeaturesSet.autoPackaging>(); Boxes.Cache.AllowSelect = PXAccess.FeatureInstalled <FeaturesSet.autoPackaging>(); if (row.PackageOption == INPackageOption.Quantity) { PXUIFieldAttribute.SetEnabled <InventoryItem.packSeparately>(Item.Cache, Item.Current, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.qty>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.uOM>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxQty>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxWeight>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxVolume>(Boxes.Cache, null, false); } else if (row.PackageOption == INPackageOption.Weight) { PXUIFieldAttribute.SetEnabled <InventoryItem.packSeparately>(Item.Cache, Item.Current, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.qty>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.uOM>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxQty>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxWeight>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxVolume>(Boxes.Cache, null, false); } else if (row.PackageOption == INPackageOption.WeightAndVolume) { PXUIFieldAttribute.SetEnabled <InventoryItem.packSeparately>(Item.Cache, Item.Current, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.qty>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.uOM>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxQty>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxWeight>(Boxes.Cache, null, true); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxVolume>(Boxes.Cache, null, true); } else if (row.PackageOption == INPackageOption.Manual) { Boxes.Cache.AllowSelect = false; PXUIFieldAttribute.SetEnabled <InventoryItem.packSeparately>(Item.Cache, Item.Current, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.qty>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.uOM>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxQty>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxWeight>(Boxes.Cache, null, false); PXUIFieldAttribute.SetVisible <INItemBoxEx.maxVolume>(Boxes.Cache, null, false); } if (PXAccess.FeatureInstalled <FeaturesSet.autoPackaging>()) { ValidatePackaging(row); } FieldsDependOnStkItemFlag(sender, row); var hasChildObject = sender.GetValueExt <InventoryItem.hasChild>(row); bool hasChild = ((hasChildObject is PXFieldState s) ? (bool?)s.Value : (bool?)hasChildObject) == true; sender.Adjust <PXUIFieldAttribute>().For <InventoryItem.itemClassID>(a => a.Enabled = !hasChild) .SameFor <InventoryItem.stkItem>() .SameFor <InventoryItem.baseUnit>() .SameFor <InventoryItem.decimalBaseUnit>() .SameFor <InventoryItem.purchaseUnit>() .SameFor <InventoryItem.decimalPurchaseUnit>() .SameFor <InventoryItem.salesUnit>() .SameFor <InventoryItem.decimalSalesUnit>(); }