public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); sender.Graph.FieldUpdating.RemoveHandler(sender.GetItemType(), _FieldName, this.GetAttribute <PXSelectorAttribute>().SubstituteKeyFieldUpdating); sender.Graph.FieldUpdating.AddHandler(sender.GetItemType(), _FieldName, FieldUpdating); }
protected virtual void InitializeFields(PXCache sender) { Type cacheType = _SingleSelect.GetTables()[0]; var tables = GetTables(sender); _Fields = GetSlot(_FieldName + '_' + sender.GetItemType().FullName + '_' + System.Threading.Thread.CurrentThread.CurrentUICulture.Name, new DefinitionParams(sender, cacheType, _Field, _Selector, _DescriptionField, _ControlTypeField, _EntryMaskField, _ListField, _FieldName), tables.ToArray()); if (_Fields != null) { var ai = new Dictionary <string, int>(); for (int i = 0; i < _Fields.Length; i++) { string key = _Fields[i].Name; int idxUnderscore = key.IndexOf('_'); ai.Add(idxUnderscore > 0 ? key.Substring(0, idxUnderscore) : key, i); } _AttributeIndices = ai; int attributesIdx = sender.Fields.IndexOf(_FieldName); for (int i = 0; i < _Fields.Length; i++) { int idx = i; PXFieldState field = (PXFieldState)((ICloneable)_Fields[idx]).Clone(); field.Visible = DefaultVisible; //field.Visibility = PXUIVisibility.Invisible; sender.Fields.Insert(++attributesIdx, field.Name); string name = field.Name.Substring(0, field.Name.Length - _FieldName.Length - 1); sender.Graph.FieldSelecting.AddHandler(sender.GetItemType(), field.Name, (c, a) => AttributeFieldSelecting(c, a, field, name, idx)); sender.Graph.FieldUpdating.AddHandler(sender.GetItemType(), field.Name, (c, a) => AttributeFieldUpdating(c, a, field, name, idx)); sender.Graph.CommandPreparing.AddHandler(sender.GetItemType(), field.Name, (c, a) => AttributeCommandPreparing(c, a, field, name, idx)); } } }
public override void ProccessItem(PXGraph graph, TPrimary item) { PXCache cache = graph.Caches[typeof(TPrimary)]; TPrimary newItem = (TPrimary)cache.CreateInstance(); PXCache <TPrimary> .RestoreCopy(newItem, item); string entityType = CSAnswerType.GetAnswerType(cache.GetItemType()); string entityID = CSAnswerType.GetEntityID(cache.GetItemType()); PXView primaryView = graph.Views[graph.PrimaryView]; object[] searches = new object[primaryView.Cache.BqlKeys.Count]; string[] sortcolumns = new string[primaryView.Cache.BqlKeys.Count]; for (int i = 0; i < cache.BqlKeys.Count(); i++) { sortcolumns[i] = cache.BqlKeys[i].Name; searches[i] = cache.GetValue(newItem, sortcolumns[i]); } int startRow = 0, totalRows = 0; List <object> result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows); newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0])); foreach (FieldValue fieldValue in Fields.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID == null && o.Selected == true)) { PXFieldState state = cache.GetStateExt(newItem, fieldValue.Name) as PXFieldState; PXIntState intState = state as PXIntState; PXStringState strState = state as PXStringState; if ((intState != null && intState.AllowedValues != null && intState.AllowedValues.Length > 0 && intState.AllowedValues.All(v => v != int.Parse(fieldValue.Value))) || (strState != null && strState.AllowedValues != null && strState.AllowedValues.Length > 0 && strState.AllowedValues.All(v => v != fieldValue.Value))) { throw new PXSetPropertyException(ErrorMessages.UnallowedListValue, fieldValue.Value, fieldValue.Name); } if (state != null && !Equals(state.Value, fieldValue.Value)) { cache.SetValueExt(newItem, fieldValue.Name, fieldValue.Value); cache.Update(newItem); } result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows); newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0])); } PXCache attrCache = cache.Graph.Caches[typeof(CSAnswers)]; foreach (FieldValue attrValue in Attributes.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID != null && o.Selected == true)) { CSAnswers attr = (CSAnswers)attrCache.CreateInstance(); attr.AttributeID = attrValue.AttributeID; attr.EntityID = cache.GetValue(newItem, entityID) as int?; attr.EntityType = entityType; attr.Value = attrValue.Value; attrCache.Update(attr); } }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); sender.Graph.FieldUpdating.AddHandler( sender.GetItemType(), nameof(POLandedCostDoc.hold), (cache, e) => { PXBoolAttribute.ConvertValue(e); var item = e.Row as POLandedCostDoc; if (item != null) { StatusSet(cache, item, (bool?)e.NewValue); } }); sender.Graph.FieldVerifying.AddHandler( sender.GetItemType(), nameof(POLandedCostDoc.status), (cache, e) => { e.NewValue = cache.GetValue <POLandedCostDoc.status>(e.Row); }); sender.Graph.RowSelected.AddHandler( sender.GetItemType(), (cache, e) => { var document = e.Row as POLandedCostDoc; if (document != null) { StatusSet(cache, document, document.Hold); } }); }
public virtual void SubscribeForSourceSpecificationItemImpl(PXCache sender, HashSet <PXCache> subscribedCaches, CalendarOrganizationIDProvider.SourceSpecificationItem sourceSpecification) { if (!sender.Graph.IsImport && !sender.Graph.IsContractBasedAPI) { sender.Graph.RowUpdating.AddHandler(sender.GetItemType(), RowUpdating); } sender.Graph.RowUpdated.AddHandler(sender.GetItemType(), RowUpdated); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (MasterFinPeriodIDType != null) { sender.Graph.FieldDefaulting.AddHandler(sender.GetItemType(), MasterFinPeriodIDType.Name, MasterFinPeriodIDFieldDefaulting); } if (UseMasterCalendarSourceType != null) { if (OrganizationSourceType != null) { sender.Graph.FieldUpdated.AddHandler( BqlCommand.GetItemType(OrganizationSourceType), OrganizationSourceType.Name, CalendarOrganizationIDSourceFieldUpdated); } if (BranchSourceType != null) { sender.Graph.FieldUpdated.AddHandler( BqlCommand.GetItemType(BranchSourceType), BranchSourceType.Name, CalendarOrganizationIDSourceFieldUpdated); } } }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); sender.Graph.RowPersisted.AddHandler(sender.GetItemType(), RowPersisted); _chunks = new Dictionary <object, List <object> >(); _persisted = new HashSet <object>(); }
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 static void NewChild(PXCache cache, object parentrow, Type ParentType, out object child) { foreach (PXEventSubscriberAttribute attr in cache.GetAttributes(null)) { if (attr is PXParentAttribute && ((PXParentAttribute)attr).ParentType.IsAssignableFrom(ParentType)) { Type childType = cache.GetItemType(); PXView parentView = ((PXParentAttribute)attr).GetParentSelect(cache); Type parentType = parentView.BqlSelect.GetFirstTable(); PXView childView = ((PXParentAttribute)attr).GetChildrenSelect(cache); BqlCommand selectChild = childView.BqlSelect; IBqlParameter[] pars = selectChild.GetParameters(); Type[] refs = selectChild.GetReferencedFields(false); child = Activator.CreateInstance(childType); PXCache parentcache = cache.Graph.Caches[parentType]; for (int i = 0; i < Math.Min(pars.Length, refs.Length); i++) { Type partype = pars[i].GetReferencedType(); object val = parentcache.GetValue(parentrow, partype.Name); cache.SetValue(child, refs[i].Name, val); } return; } } child = null; }
public override void CacheAttached(PXCache sender) { if (sender.Graph.GetType() == typeof(AttrGraph)) { return; } if (sender.Graph.GetType() == typeof(PXGraph) || sender.Graph.GetType() == typeof(PX.Data.Maintenance.GI.GenericInquiryDesigner)) { _IsActive = true; } base.CacheAttached(sender); InitializeFields(sender); Type selectType = _SingleSelect.GetType(); Type itemType = sender.GetItemType(); while (itemType != typeof(object) && selectType == _SingleSelect.GetType()) { selectType = BqlCommand.Parametrize(itemType, selectType); itemType = itemType.BaseType; } _View = new PXView(sender.Graph, true, BqlCommand.CreateInstance(selectType)); }
public override void ProccessItem(PXGraph graph, TPrimary item) { int?assingmentMapId = GetAssignmentMapId(graph); if (assingmentMapId == null) { throw new PXException(Messages.AssignmentMapIdEmpty); } PXCache cache = graph.Caches[typeof(TPrimary)]; if (!cache.GetItemType().IsAssignableFrom(typeof(TPrimary))) { PXCache primary = graph.Views[graph.PrimaryView].Cache; PXCache itemCache = (PXCache)Activator.CreateInstance(typeof(PXCache <TPrimary>), primary.Graph); object[] searches = new object[primary.Keys.Count]; string[] sortcolumns = new string[primary.Keys.Count]; for (int i = 0; i < primary.Keys.Count; i++) { searches[i] = itemCache.GetValue(item, primary.Keys[i]); sortcolumns[i] = primary.Keys[i]; } int startRow = 0, totalRows = 0; graph.Views[graph.PrimaryView].Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows); item = (TPrimary)graph.Views[graph.PrimaryView].Cache.Current; } TPrimary upd = (TPrimary)cache.CreateCopy(item); if (!processor.Assign(upd, assingmentMapId)) { throw new PXException(Messages.AssignmentError); } cache.Update(upd); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); sender.Graph.FieldSelecting.AddHandler(sender.GetItemType(), _FieldName, FieldSelectingHandler); }
private void ValidateNotMainRowLevelSources(PXCache cache, object oldRow, object newRow, bool externalCall, FinPeriod newMainOrgFinPeriod) { ValidationResult validationResult = ValidateRowLevelSources( CalendarOrganizationIDProvider, cache, newRow, organizationID => FinPeriodRepository .GetFinPeriodByMasterPeriodID(organizationID, newMainOrgFinPeriod.MasterFinPeriodID).IsSuccess, skipMain: true); if (validationResult.HasErrors) { foreach (var branchValue in validationResult.BranchValuesWithErrors) { if (branchValue.SpecificationItem.BranchSourceType != null && (branchValue.SpecificationItem.BranchSourceFormulaType != null || PXAccess.FeatureInstalled <FeaturesSet.branch>())) { PXCache branchCache = cache.Graph.Caches[BqlCommand.GetItemType(branchValue.SpecificationItem.BranchSourceType)]; object newBranch = branchCache.GetItemType().IsAssignableFrom(newRow.GetType()) ? newRow : branchCache.Current; object oldBranch = branchCache.GetItemType().IsAssignableFrom(oldRow.GetType()) ? oldRow : branchCache.Current; string organizationCD = PXAccess.GetOrganizationCD( PXAccess.GetParentOrganizationID(branchValue.SourceBranchIDs.Single())); var exception = new PXSetPropertyException( Messages.RelatedFinPeriodForMasterDoesNotExistForCompany, FormatForError(newMainOrgFinPeriod.MasterFinPeriodID), organizationCD); SetErrorAndResetToOldForField( branchCache, oldBranch, newBranch, branchValue.SpecificationItem.BranchSourceType.Name, exception, externalCall); } } } }
public override void CacheAttached(PXCache sender) { foreach (var fieldName in sender.Fields) { sender.Graph.FieldSelecting.AddHandler(sender.GetItemType(), fieldName, (s, e) => AnyFieldSelecting(s, e, fieldName)); } }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (sender.GetBqlField("CuryID") != null && (_Matches = CurrencyInfo.CuryIDStringAttribute.GetMatchesDictionary(sender)) != null) { sender.Graph.RowSelecting.AddHandler(sender.GetItemType(), RowSelectingCollectMatches); } }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (ProjectField != null) { sender.Graph.FieldUpdated.AddHandler(sender.GetItemType(), ProjectField.Name, OnProjectUpdated); } }
public override void CacheAttached(PXCache cache) { base.CacheAttached(cache); var actionName = $"{cache.GetItemType().Name}${_FieldName}$Link"; cache.Graph.Actions[actionName] = (PXAction)Activator.CreateInstance( typeof(PXNamedAction <>).MakeGenericType(typeof(CommitmentInquiry.ProjectBalanceFilter)), cache.Graph, actionName, (PXButtonDelegate)RedirectToRelatedScreen, GetEventSubscriberAttributes()); }
protected virtual object GetSourceRow(PXCache sourceCache, object extRow) { if (extRow == null || sourceCache.GetItemType() != extRow.GetType()) { return(sourceCache.Current); } return(extRow); }
protected virtual object GetSourceRow(PXCache sourceCache, object extRow) { if (extRow == null || !sourceCache.GetItemType().IsAssignableFrom(extRow.GetType())) { return(sourceCache.Current); } return(extRow); }
public override void CacheAttached(PXCache cache) { var actionName = $"{cache.GetItemType().Name}${_FieldName}$Link"; cache.Graph.Actions[actionName] = (PXAction)Activator.CreateInstance( typeof(PXNamedAction <>).MakeGenericType(GetDacOfPrimaryView(cache)), cache.Graph, actionName, (PXButtonDelegate)ViewSubcontract, GetEventSubscriberAttributes()); cache.Graph.Actions[actionName].SetVisible(false); }
private EPActivity InsertActivity(PXCache cache) { CRHelper.AssertNull(cache, "cache"); CRHelper.AssertInheritance(typeof(EPActivity), cache.GetItemType(), "cache.GetItemType()"); EPActivity activity = (EPActivity)cache.Insert(); activity.RefNoteID = NoteID; return(activity); }
public override void CacheAttached(PXCache cache) { entityHelper = new EntityHelper(cache.Graph); descriptionFieldName = _FieldName + "_Description"; base.CacheAttached(cache); cache.Fields.Add(descriptionFieldName); cache.Graph.FieldSelecting.AddHandler(cache.GetItemType(), descriptionFieldName, DescriptionFieldSelecting); CreateRedirectAction(cache); }
private void CreateRedirectAction(PXCache cache) { var buttonDelegate = GetRedirectionDelegate(cache); var actionName = cache.GetItemType().Name + "$" + _FieldName + "$Link"; cache.Graph.Actions[actionName] = (PXAction)Activator .CreateInstance(typeof(PXNamedAction <>).MakeGenericType(GetDacOfPrimaryView(cache)), cache.Graph, actionName, buttonDelegate, GetEventSubscriberAttributes()); cache.Graph.Actions[actionName].SetVisible(false); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); _ChildType = sender.GetItemType(); _persisted = new Dictionary <long?, object>(); sender.Graph.RowPersisting.AddHandler <CATran>(CATran_RowPersisting); sender.Graph.RowPersisted.AddHandler <CATran>(CATran_RowPersisted); }
public override void SubscribeForSourceSpecificationItemImpl(PXCache sender, HashSet <PXCache> subscribedCaches, CalendarOrganizationIDProvider.SourceSpecificationItem sourceSpecification) { base.SubscribeForSourceSpecificationItemImpl(sender, subscribedCaches, sourceSpecification); if (MasterFinPeriodIDType != null) { sender.Graph.RowInserted.AddHandler(sender.GetItemType(), RowInserted); } }
private void RaiseExceptionForEmptyAttributeValue(CSAnswers attribute) { var message = string.Format(CommonMessages.FieldIsEmpty, attribute.AttributeID); var documentType = documentCache.GetItemType(); var document = entityHelper.GetEntityRow(documentType, attribute.RefNoteID); var fieldName = document.GetType().GetProperties() .FirstOrDefault(x => x.GetCustomAttributes(typeof(UiInformationFieldAttribute)).Any())?.Name; documentCache.RaiseExceptionHandling(fieldName, document, true, new PXSetPropertyException(message, PXErrorLevel.RowError)); }
public void Verify(PXCache cache, object item, System.Collections.Generic.List <object> pars, ref bool?result, ref object value) { PXCache c = cache.Graph.Caches[BqlCommand.GetItemType(typeof(Field))]; object row = null; if (c.GetItemType().IsAssignableFrom(cache.GetItemType())) { row = BqlFormula.ItemContainer.Unwrap(item); } c.RaiseFieldDefaulting <Field>(row, out value); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); foreach (PXDBStringAttribute attr in sender.GetAttributesReadonly(_FieldName).Where(attr => attr is PXDBStringAttribute).Cast <PXDBStringAttribute>()) { _Length = attr.Length; } if (_Length > 0) { sender.Graph.FieldUpdating.AddHandler(sender.GetItemType(), _FieldName.ToLower(), MultiSelectFieldUpdating); } }
protected virtual void AddFieldToAttributeGrid(PXCache cache, int attributeNumber) { string fieldName = $"AttributeValue{attributeNumber}"; FillAttributeViewName(attributeNumber); if (!cache.Fields.Contains(fieldName)) { cache.Fields.Add(fieldName); Base.FieldSelecting.AddHandler( cache.GetItemType(), fieldName, (s, e) => AttributeValueFieldSelecting(attributeNumber, e, fieldName)); Base.FieldUpdating.AddHandler( cache.GetItemType(), fieldName, (s, e) => AttributeValueFieldUpdating(attributeNumber, e)); } }