protected virtual void ARDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { ARDiscount row = e.Row as ARDiscount; if (row != null) { if (row.Type == DiscountType.Document) { e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, new string[] { DiscountTarget.Customer, DiscountTarget.CustomerAndBranch, DiscountTarget.CustomerPrice, DiscountTarget.CustomerPriceAndBranch, DiscountTarget.Unconditional }, new string[] { Messages.Customer, Messages.CustomerAndBranch, Messages.CustomerPrice, Messages.CustomerPriceAndBranch, Messages.Unconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Customer); return; } } List <string> values = new List <string>(); List <string> labels = new List <string>(); values.AddRange(new string[] { DiscountTarget.Customer, DiscountTarget.Inventory, DiscountTarget.InventoryPrice, DiscountTarget.CustomerAndInventory, DiscountTarget.CustomerAndInventoryPrice, DiscountTarget.CustomerPrice, DiscountTarget.CustomerPriceAndInventory, DiscountTarget.CustomerPriceAndInventoryPrice }); labels.AddRange(new string[] { Messages.Customer, Messages.Discount_Inventory, Messages.InventoryPrice, Messages.CustomerAndInventory, Messages.CustomerAndInventoryPrice, Messages.CustomerPrice, Messages.CustomerPriceAndInventory, Messages.CustomerPriceAndInventoryPrice }); if (PXAccess.FeatureInstalled <FeaturesSet.warehouse>()) { values.AddRange(new string[] { DiscountTarget.Warehouse, DiscountTarget.WarehouseAndInventory, DiscountTarget.WarehouseAndCustomer, DiscountTarget.WarehouseAndInventoryPrice, DiscountTarget.WarehouseAndCustomerPrice }); labels.AddRange(new string[] { Messages.Warehouse, Messages.WarehouseAndInventory, Messages.WarehouseAndCustomer, Messages.WarehouseAndInventoryPrice, Messages.WarehouseAndCustomerPrice }); } values.AddRange(new string[] { DiscountTarget.Branch, DiscountTarget.Unconditional }); labels.AddRange(new string[] { Messages.Branch, Messages.Unconditional }); e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, values.ToArray(), labels.ToArray().Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Inventory); }
protected virtual void PMAllocationDetail_OffsetAccountGroupOrigin_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { PMAllocationDetail row = e.Row as PMAllocationDetail; if (row != null) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); allowedValues.Add(PMOrigin.Source); allowedValues.Add(PMOrigin.Change); allowedLabels.Add(Messages.GetLocal(Messages.Origin_Source)); allowedLabels.Add(Messages.GetLocal(Messages.Origin_Change)); if (row.UpdateGL == true) { allowedValues.Add(PMOrigin.FromAccount); allowedLabels.Add(Messages.GetLocal(Messages.Origin_FromAccount)); } else { allowedValues.Add(PMOrigin.None); allowedLabels.Add(Messages.GetLocal(Messages.Origin_None)); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, typeof(PMAllocationDetail.offsetAccountGroupOrigin).Name, false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, PMOrigin.Source); ((PXStringState)e.ReturnState).Enabled = row.UpdateGL != true; } }
protected virtual void ItemAttributeValueFieldSelecting(int attributeNumber, PXFieldSelectingEventArgs e, string fieldName) { var row = (MatrixInventoryItem)e.Row; PXStringState state = (PXStringState)PXStringState.CreateInstance(e.ReturnState, null, true, fieldName, false, null, null, null, null, null, null); state.Enabled = false; e.ReturnState = state; if (attributeNumber < MatrixItemsForCreation.Current?.AttributeIDs?.Length) { e.ReturnValue = 0 <= attributeNumber && attributeNumber < row?.AttributeValues?.Length ? row.AttributeValues[attributeNumber] : null; state.Visible = true; state.Visibility = PXUIVisibility.Visible; if (CRAttribute.Attributes.TryGetValue(MatrixItemsForCreation.Current.AttributeIDs[attributeNumber], out CRAttribute.Attribute attribute)) { state.DisplayName = attribute.Description; state.AllowedValues = attribute.Values.Select(v => v.ValueID).ToArray(); state.AllowedLabels = attribute.Values.Select(v => v.Description).ToArray(); } } else { state.Value = null; e.ReturnValue = null; state.DisplayName = null; state.Visible = false; state.Visibility = PXUIVisibility.Invisible; } }
protected virtual void SegmentValue_Value_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e) { if (e.Row == null || cache.HasAttributes(e.Row)) { Segment seg = Segment.Current as Segment; short i; if (seg != null && seg.SegmentID != null) { StringBuilder bld = new StringBuilder(); if (seg.AutoNumber != true) { bld.Append((seg.CaseConvert == 1) ? ">" : ""); bld.Append((seg.CaseConvert == 2) ? "<" : ""); } for (i = 0; i < seg.Length; i++) { if (seg.AutoNumber == true) { bld.Append("C"); } else { bld.Append(seg.EditMask); } } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, null, null, "Value", null, null, bld.ToString(), null, null, null, null); } } }
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { CRFieldNewValues row = e.Row as CRFieldNewValues; if (row != null && _valuesDic.ContainsKey(row.DataField)) { if (string.Compare(row.DataFieldType, typeof(bool).Name, true) == 0) { e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null, -1, null, null, null, base._FieldName, null, null, null, PXErrorLevel.Undefined, null, null, PXUIVisibility.Undefined, null, null, null); } else if (!string.IsNullOrEmpty(row.SelectorViewName)) { e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), false, null, -1, null, null, null, base._FieldName, row.SelectorDescriptionName, row.SelectorDescription, null, null, PXErrorLevel.Undefined, null, null, PXUIVisibility.Undefined, row.SelectorViewName, null, null); } else { string[] values = Array.ConvertAll <object, string>(_valuesDic[row.DataField], CRHelper.ObjectToString); e.ReturnState = PXStringState.CreateInstance(e.ReturnState, null, base._FieldName, null, -1, null, values, _labelsDic.ContainsKey(row.DataField) ? _labelsDic[row.DataField] : values, (bool?)true); } } }
public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { if (string.IsNullOrEmpty(InputMask)) { InputMask = "### d\\ays ## hrs ## mins"; } if (_AttributeLevel == PXAttributeLevel.Item || e.IsAltered) { string inputMask = _inputMasks[(int)this._Format]; int lenght = _lengths[(int)this._Format]; inputMask = PXMessages.LocalizeNoPrefix(inputMask); e.ReturnState = PXStringState.CreateInstance(e.ReturnState, lenght, null, _FieldName, _IsKey, null, String.IsNullOrEmpty(inputMask) ? null : inputMask, null, null, null, null); } int maskLenght = 0; foreach (char c in InputMask) { if (c == '#' || c == '0') { maskLenght += 1; } } if (e.ReturnValue != null) { int mins = 0; int.TryParse(e.ReturnValue.ToString(), out mins); TimeSpan span = new TimeSpan(0, 0, mins, 0); int hours = (this._Format == TimeSpanFormatType.LongHoursMinutes) ? span.Days * 24 + span.Hours : span.Hours; var returnValue = string.Format(_outputFormats[(int)this._Format], span.Days, hours, span.Minutes); e.ReturnValue = returnValue.Length < 0 ? (new String(' ', maskLenght - returnValue.Length)) + returnValue : returnValue; } }
private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); Type gType = null; if (graphType != null) { gType = GraphHelper.GetType(graphType); } else if (entityType != null) { Type eType = System.Web.Compilation.PXBuildManager.GetType(entityType, false); gType = (eType == null) ? null : EntityHelper.GetPrimaryGraphType(this, eType); } if (gType != null) { PXSiteMapNode node = PXSiteMap.Provider.FindSiteMapNodeUnsecure(gType); if (node != null) { allowedValues.Add(entityType); allowedLabels.Add(node.Title); } } return(PXStringState.CreateInstance(returnState, 60, null, "Entity", false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, null)); }
private PXFieldState CreateFieldStateForFieldName(object returnState, Type type) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); Dictionary <string, string> fields = new Dictionary <string, string>(); foreach (var field in PXCache.GetBqlTable(type) .GetProperties(BindingFlags.Instance | BindingFlags.Public) .SelectMany(p => p.GetCustomAttributes(true).Where(atr => atr is PXMassMergableFieldAttribute), (p, atr) => p)) { PXFieldState fs = this.Caches[type].GetStateExt(null, field.Name) as PXFieldState; if (!fields.ContainsKey(field.Name)) { fields[field.Name] = fs != null ? fs.DisplayName : field.Name; } } foreach (var item in fields.OrderBy(i => i.Value)) { allowedValues.Add(item.Key); allowedLabels.Add(item.Value); } return(PXStringState.CreateInstance(returnState, 60, null, "FieldName", false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, null)); }
protected virtual void APDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { APDiscount row = e.Row as APDiscount; if (row != null) { if (row.Type == SO.DiscountType.Document) { e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, new string[] { DiscountTarget.Vendor }, new string[] { Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Unconditional); return; } } if (!PXAccess.FeatureInstalled <FeaturesSet.accountLocations>()) { e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.Vendor }, new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Inventory); return; } e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.VendorLocation, DiscountTarget.VendorLocationAndInventory, DiscountTarget.Vendor }, new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.Vendor_Location, Messages.VendorLocationaAndInventory, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Inventory); }
protected PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName) { Type type = GraphHelper.GetType(entityType); if (type != null) { Type gType = EntityHelper.GetPrimaryGraphType(this, type); if (!String.IsNullOrEmpty(graphType)) { gType = GraphHelper.GetType(graphType); } string viewName = null; if (gType != null) { foreach ( CacheEntityItem view in EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName)) { if (view.SubKey == cacheName) { viewName = view.Key; break; } } } return(CreateFieldStateForFieldName(returnState, type, gType, viewName, EPRuleCondition.FieldLength)); } return(PXStringState.CreateInstance(returnState, EPRuleCondition.FieldLength, null, _FIELDNAME_STR, false, 1, null, (new List <string>()).ToArray(), (new List <string>()).ToArray(), false, null)); }
public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { if (e.Row != null) { string mask = this.FindMask(sender, e.Row); if (!string.IsNullOrEmpty(mask)) { if (!string.IsNullOrEmpty((string)e.ReturnValue)) { string viewAs = mask.Replace("#", "0").Replace("-", "").Replace("/", ""); this.ViewAsString = viewAs; base.FieldSelecting(sender, e); PXStringState state = e.ReturnState as PXStringState; if (state != null) { e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null); } } else { e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null); } } else { base.FieldSelecting(sender, e); } } else { base.FieldSelecting(sender, e); } }
private PXFieldState InitDefaultValueFieldSate() { var res = PXStringState.CreateInstance(null, null, null, typeof(PropertyValue.value).Name, false, 0, null, null, null, null, null); res.DisplayName = Messages.PropertyValue; return(res); }
private static void CreateStringControl(PXFieldSelectingEventArgs args, CSAttributeGroup attributeGroup) { var required = attributeGroup.Required == true ? 1 : -1; args.ReturnState = PXStringState.CreateInstance(args.ReturnState, null, null, nameof(CSAnswers.value), false, required, null, null, null, false, null); }
protected virtual void _(Events.FieldSelecting <PMBillingRule, PMBillingRule.accountSource> e) { if (e.Row != null) { IDictionary <string, string> accountSources = GetAccountSources(e.Row.Type); string[] allowedValues = accountSources.Keys.ToArray(); string[] allowedLabels = accountSources.Values.ToArray(); e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, typeof(PMBillingRule.accountSource).Name, true, 1, null, allowedValues, allowedLabels, true, allowedValues[0]); } }
private PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); Type type = GraphHelper.GetType(entityType); if (type != null) { Type gType = EntityHelper.GetPrimaryGraphType(this, type); if (!String.IsNullOrEmpty(graphType)) { gType = GraphHelper.GetType(graphType); } string viewName = null; if (gType != null) { foreach ( CacheEntityItem view in EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName)) { if (view.SubKey == cacheName) { viewName = view.Key; break; } } } Dictionary <string, string> fields = new Dictionary <string, string>(); foreach (CacheEntityItem e in EMailSourceHelper.TemplateEntity(this, viewName, type.FullName, gType != null ? gType.FullName : null, true)) { fields[e.SubKey] = e.Name; } foreach (var item in fields.OrderBy(i => i.Value)) { if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_')) { continue; } allowedValues.Add(item.Key); allowedLabels.Add(item.Value); } } return(PXStringState.CreateInstance(returnState, EPAssignmentRule.FieldLength, null, _FIELDNAME_STR, false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), false, null)); }
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { string perPost = e.ReturnValue as string; if (perPost != null && (e.Row == null || object.Equals(e.ReturnValue, sender.GetValue(e.Row, _FieldOrdinal)))) { e.ReturnValue = FormatForDisplay(perPost); } if (_AttributeLevel == PXAttributeLevel.Item || e.IsAltered) { e.ReturnState = PXStringState.CreateInstance(e.ReturnState, FiscalPeriodUtils.FULL_LENGHT, null, _FieldName, null, null, CS_DISPLAY_MASK, null, null, null, null); } }
private void CreateComboControl(CSAttributeGroup attributeGroup, PXFieldSelectingEventArgs args, bool isMultiSelect) { var details = GetAttributeDetails(attributeGroup.AttributeID); var values = details.ToDictionary(detail => detail.ValueID, detail => detail.Description); var required = attributeGroup.Required == true ? 1 : -1; args.ReturnState = PXStringState.CreateInstance(args.ReturnState, 255, null, nameof(CSAnswers.value), false, required, null, values.Keys.ToArray(), values.Values.ToArray(), true, null); ((PXStringState)args.ReturnState).MultiSelect = isMultiSelect; }
protected virtual void PMTask_Status_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { PMTask row = e.Row as PMTask; string status = GetStatusFromFlags(row); List <KeyValuePair <string, string> > list = GetValidStatusTargets(row, status); List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); foreach (var pair in list) { allowedValues.Add(pair.Key); allowedLabels.Add(Messages.GetLocal(pair.Value)); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, nameof(PMTask.Status), false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, allowedValues[0]); }
protected PXFieldState CreateFieldStateForFieldName(object returnState, Type entityType, Type gType, string viewName, int?fieldLength) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); List <string> uniqueLabels = new List <string>(); if (entityType != null) { Dictionary <string, string> fields = new Dictionary <string, string>(); foreach (CacheEntityItem c in EMailSourceHelper.TemplateEntity(this, viewName, entityType.FullName, gType != null ? gType.FullName : null, false)) { fields[c.SubKey] = c.Name; } Action <string, string> addValueLabel = (value, label) => { allowedValues.Add(value); allowedLabels.Add(label); uniqueLabels.Add(label); }; foreach (var item in fields.OrderBy(i => i.Value)) { if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_')) { continue; } if (!uniqueLabels.Contains(item.Value)) { addValueLabel(item.Key, item.Value); } else { string label = string.Format("{0} - {1}", item.Key, item.Value); addValueLabel(item.Key, label); } } } return(PXStringState.CreateInstance(returnState, fieldLength, null, _FIELDNAME_STR, false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), false, null)); }
public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { if (e.Row != null) { string mask = this.FindMask(sender, e.Row); if (!string.IsNullOrEmpty(mask)) { e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null); } else { base.FieldSelecting(sender, e); } } else { base.FieldSelecting(sender, e); } }
protected virtual void SiteMap_Title_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { SiteMap row = e.Row as SiteMap; if (row == null) { return; } if (row.NodeID == Guid.Empty) { e.ReturnState = PXStringState.CreateInstance(Accessinfo.CompanyName, 60, null, "Title", false, 0, null, null, null, true, null); } else { e.ReturnState = PXStringState.CreateInstance(row.Title, 60, null, "Title", false, 0, null, null, null, true, null); } }
protected PXFieldState InitValueFieldState(FieldValue field = null) { PXFieldState state; if (field != null && (state = Caches[typeof(TPrimary)].GetStateExt(null, field.Name) as PXFieldState) != null) { state.SetFieldName(typeof(FieldValue.value).Name); state.Value = field.Value; state.Enabled = true; return(state); } else { PXFieldState defState = PXStringState.CreateInstance(null, null, null, typeof(FieldValue.value).Name, false, 0, null, null, null, null, null); defState.DisplayName = Messages.PropertyValue; return(defState); } }
protected virtual void CarrierPluginDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { CarrierPluginDetail row = e.Row as CarrierPluginDetail; if (row != null) { string fieldName = typeof(CarrierPluginDetail.value).Name; switch (row.ControlType) { case CarrierPluginDetail.Combo: List <string> labels = new List <string>(); List <string> values = new List <string>(); foreach (KeyValuePair <string, string> kv in row.GetComboValues()) { values.Add(kv.Key); labels.Add(kv.Value); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, CarrierDetail.ValueFieldLength, null, fieldName, false, 1, null, values.ToArray(), labels.ToArray(), true, null); break; case CarrierPluginDetail.CheckBox: e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null, -1, null, null, null, fieldName, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null); break; case CarrierPluginDetail.Password: if (e.ReturnState != null) { string strValue = e.ReturnState.ToString(); string encripted = new string('*', strValue.Length); e.ReturnState = PXFieldState.CreateInstance(encripted, typeof(string), false, null, -1, null, null, null, fieldName, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null); } break; default: break; } } }
private PXFieldState CreateFieldStateForEntity(object returnState, string entityTypeName, string graphTypeName) { var values = new List <string>(); var labels = new List <string>(); var entityType = GraphHelper.GetType(entityTypeName); if (entityType != null) { var graphType = EntityHelper.GetPrimaryGraphType(Base, entityType); if (!string.IsNullOrEmpty(graphTypeName)) { graphType = GraphHelper.GetType(graphTypeName); } if (graphType == null) { var customAttributes = (PXCacheNameAttribute[])entityType.GetCustomAttributes(typeof(PXCacheNameAttribute), true); if (entityType.IsSubclassOf(typeof(CSAnswers))) { values.Add(entityType.FullName); var name = customAttributes.Length != 0 ? customAttributes[0].Name : entityType.Name; labels.Add(name); } } else { var cacheEntityItems = EMailSourceHelper.TemplateEntity( Base, null, entityType.FullName, graphType.FullName) .Cast <CacheEntityItem>() .Where(cacheEntityItem => cacheEntityItem.SubKey != typeof(CSAnswers).FullName); foreach (var cacheEntityItem in cacheEntityItems) { values.Add(cacheEntityItem.SubKey); labels.Add(cacheEntityItem.GetSubcontractViewName()); } } } return(PXStringState.CreateInstance(returnState, 60, default(bool), "Entity", false, 1, null, values.ToArray(), labels.ToArray(), true, null)); }
protected PXFieldState InitValueFieldState(FieldValue field) { Tuple <IEnumerable <string>, IEnumerable <string> > possibleValues = new Tuple <IEnumerable <string>, IEnumerable <string> >(new string[0], new string[0]); List <TMain> entities = new List <TMain>(PXSelectorAttribute.SelectAll <MergeParams.targetEntityID>(Base.Caches[typeof(MergeParams)], Base.Caches[typeof(MergeParams)].Current).RowCast <TMain>()); if (field.CacheName == typeof(TMain).FullName) { possibleValues = GetPossibleValues(Base, entities, field.Name); } else if (field.CacheName == typeof(Contact).FullName && field.CacheName != typeof(TMain).FullName) { PXSelectBase <Contact> cmd = new PXSelect <Contact>(Base); List <int?> defContactIDs = new List <int?>(entities.Select(entity => Base.Caches[typeof(TMain)].GetValue(entity, nameof(Document.DefContactID)) as int?).Where(c => c != null)); foreach (int?c in defContactIDs) { cmd.WhereOr <Where <Contact.contactID, Equal <Required <BAccount.defContactID> > > >(); } possibleValues = GetPossibleValues(Base, cmd.Select(defContactIDs.Cast <object>().ToArray()).RowCast <Contact>(), field.Name); } else if (field.CacheName == typeof(Address).FullName) { PXSelectBase <Address> cmd = new PXSelect <Address>(Base); List <int?> addressIDs = new List <int?>(entities.Select(entity => Base.Caches[typeof(TMain)].GetValue(entity, nameof(Document.DefAddressID)) as int?).Where(c => c != null)); foreach (int?a in addressIDs) { cmd.WhereOr <Where <Address.addressID, Equal <Required <Address.addressID> > > >(); } possibleValues = GetPossibleValues(Base, cmd.Select(addressIDs.Cast <object>().ToArray()).RowCast <Address>(), field.Name); } string[] values = possibleValues.Item1.ToArray(); string[] labels = possibleValues.Item2.ToArray(); return(PXStringState.CreateInstance(field.Value, null, null, typeof(FieldValue.value).Name, false, 0, null, values, labels, null, null)); }
private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); Type type = GraphHelper.GetType(entityType); if (type != null) { Type gType = EntityHelper.GetPrimaryGraphType(this, type); if (!String.IsNullOrEmpty(graphType)) { gType = GraphHelper.GetType(graphType); } if (gType == null) { PXCacheNameAttribute[] a = (PXCacheNameAttribute[])type.GetCustomAttributes(typeof(PXCacheNameAttribute), true); if (type.IsSubclassOf(typeof(CS.CSAnswers))) { allowedValues.Add(type.FullName); allowedLabels.Add(a.Length > 0 ? a[0].Name : type.Name); } } else { foreach (CacheEntityItem e in EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName)) { if (e.SubKey != typeof(CS.CSAnswers).FullName) { allowedValues.Add(e.SubKey); allowedLabels.Add(e.Name); } } } } return(PXStringState.CreateInstance(returnState, EPAssignmentRule.FieldLength, null, "Entity", false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, null)); }
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { if (e.ReturnValue != null) { byte[][] buffer = (byte[][])e.ReturnValue; using (var s = new GZipStream( new SparseMemoryStream(buffer), CompressionMode.Decompress)) { try { e.ReturnValue = PXReflectionSerializer.Deserialize(s); } catch { } } } e.ReturnState = PXStringState.CreateInstance( e.ReturnState, //value typeof(byte[][]), //dataType false, //isKey true, //nullable null, //required null, //precision -1, //length null, //defaultValue _FieldName, //fieldName null, //descriptionName null, //displayName null, //error PXErrorLevel.Undefined, //errorLevel null, //enabled null, //visible null, //readOnly PXUIVisibility.Undefined, //visibility null, //viewName null, //fieldList null //headerList ); }
protected virtual void _(Events.FieldSelecting <PMBillingRule, PMBillingRule.accountSource> e) { if (e.Row != null) { List <string> allowedValues = new List <string>(); List <string> allowedLabels = new List <string>(); if (e.Row.Type == PMBillingType.Transaction) { allowedValues.Add(PMAccountSource.None); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_SourceTransaction)); allowedValues.Add(PMAccountSource.BillingRule); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_BillingRule)); allowedValues.Add(PMAccountSource.Project); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Project)); allowedValues.Add(PMAccountSource.Task); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Task)); allowedValues.Add(PMAccountSource.InventoryItem); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_InventoryItem)); allowedValues.Add(PMAccountSource.Customer); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Customer)); allowedValues.Add(PMAccountSource.Employee); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Employee)); } else { allowedValues.Add(PMAccountSource.AccountGroup); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_AccountGroup)); allowedValues.Add(PMAccountSource.Project); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Project)); allowedValues.Add(PMAccountSource.Task); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_Task)); allowedValues.Add(PMAccountSource.InventoryItem); allowedLabels.Add(Messages.GetLocal(Messages.AccountSource_InventoryItem)); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, typeof(PMBillingRule.accountSource).Name, true, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, allowedValues[0]); } }
protected virtual void _(Events.FieldSelecting <KCSiteAssociation, KCSiteAssociation.siteMasterId> e) { KCSiteAssociation row = (KCSiteAssociation)e.Row; if (row == null) { return; } if (row != null) { List <string> allowedText = new List <string>(); List <string> allowedValues = new List <string>(); foreach (KCSiteMaster iSiteMaster in PXSelect <KCSiteMaster> .Select(this)) { allowedValues.Add(iSiteMaster.SiteMasterCD); allowedText.Add(string.Format(KCConstants.DualParameters, iSiteMaster.SiteMasterCD, iSiteMaster.Descr)); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(KCSiteMaster.siteMasterCD).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedText.ToArray(), false, null); } }
private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType) { List <string> strs = new List <string>(); List <string> strs1 = new List <string>(); Type type = GraphHelper.GetType(entityType); if (type != null) { Type primaryGraphType = EntityHelper.GetPrimaryGraphType(this, type); if (!string.IsNullOrEmpty(graphType)) { primaryGraphType = GraphHelper.GetType(graphType); } if (primaryGraphType != null) { foreach (CacheEntityItem cacheEntityItem in EMailSourceHelper.TemplateEntity(this, null, type.FullName, primaryGraphType.FullName)) { if (cacheEntityItem.SubKey == typeof(CSAnswers).FullName) { continue; } strs.Add(cacheEntityItem.SubKey); strs1.Add(cacheEntityItem.Name); } } else { PXCacheNameAttribute[] customAttributes = (PXCacheNameAttribute[])type.GetCustomAttributes(typeof(PXCacheNameAttribute), true); if (type.IsSubclassOf(typeof(CSAnswers))) { strs.Add(type.FullName); strs1.Add((customAttributes.Length != 0 ? customAttributes[0].Name : type.Name)); } } } bool?nullable = null; return(PXStringState.CreateInstance(returnState, new int?(60), nullable, "Entity", new bool?(false), new int?(1), null, strs.ToArray(), strs1.ToArray(), new bool?(true), null, null)); }