UPMGroup GroupFromParticipantControl() { UPMRepeatableEditGroup repeatableEditGroup = new UPMRepeatableEditGroup(this.TabIdentifierForRecordIdentification(this.LinkRecordIdentification)); repeatableEditGroup.LabelText = this.TabLabel(); repeatableEditGroup.AddGroupLabelText = upText_AddNewGroup; repeatableEditGroup.AddingEnabled = this.AddRecordEnabled; foreach (UPCRMRepParticipant participant in this.ParticipantsControl.Participants) { string repIdString = participant.Key; UPMIdentifier participantIdentifier = UPMStringIdentifier.IdentifierWithStringId(repIdString); UPMStandardGroup group = new UPMStandardGroup(participantIdentifier); NSNumber num = participant.Options.ObjectForKey("must"); group.Deletable = this.DeleteRecordEnabled && !num.IntegerValue; UPMDependsEditField editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, group); editField.MainField.FieldValue = participant.RepIdString; if (this.ParticipantsControl.HasRepAcceptance && participant.CanChangeAcceptanceState) { editField.DependField.FieldValue = participant.AcceptanceText; } else { editField.DependField.FieldValue = null; } editField.DependField2.FieldValue = participant.RequirementText; group.AddField(editField); repeatableEditGroup.AddGroup(group); this.AddGroupForKey(group, repIdString); } this.Group = repeatableEditGroup; this.ControllerState = UPGroupModelControllerStateFinished; return(repeatableEditGroup); }
UPMDependsEditField CreateEditFieldWithParticipantIdentifierEditGroup(UPMIdentifier participantIdentifier, UPMGroup editGroup) { UPMDependsEditField dependsEditField = new UPMDependsEditField(UPMStringIdentifier.IdentifierWithStringId(NSString.StringWithFormat("depenfEditField_%@", participantIdentifier.Description))); dependsEditField.MainField = this.CreateMainEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, editGroup); dependsEditField.DependField = this.CreateDependEditFieldWithParticipantIdentifierCatalogEditGroup(participantIdentifier, this.ParticipantsControl.AcceptanceCatalog, editGroup); dependsEditField.DependField2 = this.CreateDependEditFieldWithParticipantIdentifierCatalogEditGroup(participantIdentifier, this.ParticipantsControl.RequirementCatalog, editGroup); dependsEditField.initialSelectableOnly = true; return(dependsEditField); }
UPMEditField CreateMainEditFieldWithParticipantIdentifierEditGroup(UPMIdentifier participantIdentifier, UPMGroup editGroup) { UPMRepEditField editField = new UPMRepEditField(participantIdentifier); editField.Group = editGroup; editField.GroupModelController = this; editField.MultiSelectMode = true; editField.HelpIdentifier = UPMStringIdentifier.IdentifierWithStringId("RepPartitipant"); UPCRMRepType repType = UPCRMReps.RepTypeFromString(this.ParticipantsField.Field.RepType); UPMRepContaner repContaner = UPRepsService.CreateRepContanerForRepType(repType); editField.RepContaner = repContaner; editField.ContinuousUpdate = true; return(editField); }
UPMStandardGroup CreateNewGroup(NSDictionary initialValues) { UPCRMRepParticipant participant = this.ParticipantsControl.AddNewRepParticipant(); participant.Options = firstItemOptions; firstItemOptions = null; UPMIdentifier participantIdentifier = UPMStringIdentifier.IdentifierWithStringId(participant.Key); UPMStandardGroup group = new UPMStandardGroup(participantIdentifier); group.Deletable = true; UPMDependsEditField editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, group); editField.MainField.FieldValue = participant.RepIdString; editField.DependField.FieldValue = string.Empty; editField.DependField2.FieldValue = participant.RequirementText; group.AddField(editField); this.AddGroupForKey(group, participant.Key); return(group); }
UPMEditField CreateDependEditFieldWithParticipantIdentifierCatalogEditGroup(UPMIdentifier participantIdentifier, UPCatalog catalog, UPMGroup editGroup) { UPCRMField field; if (catalog == this.ParticipantsControl.RequirementCatalog) { field = this.ParticipantsControl.RequirementField; } else if (catalog == this.ParticipantsControl.AcceptanceCatalog) { field = this.ParticipantsControl.AcceptanceField; } UPMParticipantCatalogEditField editField = new UPMParticipantCatalogEditField(UPMStringIdentifier.IdentifierWithStringId(NSString.StringWithFormat("dependField_%@_%@_%ld", participantIdentifier.Description, field.InfoAreaId, (long)field.FieldId))); editField.GroupModelController = this; editField.Group = editGroup; if (catalog != null) { ArrayList possibleValues = catalog.Values; ArrayList explicitKeyOrder; NSDictionary possibleValuesAsString = catalog ? catalog.TextValuesForFieldValues() : null; UPConfigurationUnitStore configStore = UPConfigurationUnitStore.DefaultStore(); UPConfigCatalogAttributes acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(field.InfoAreaId, field.FieldId); possibleValues.EnumerateObjectsUsingBlock(delegate(object obj, uint idx, bool stop) { UPMCatalogPossibleValue possibleValue = new UPMCatalogPossibleValue(); UPMStringField valueField = new UPMStringField(UPMStringIdentifier.IdentifierWithStringId("x")); UPCatalogValue catalogValue = (UPCatalogValue)obj; valueField.StringValue = catalogValue.Text; possibleValue.TitleLabelField = valueField; UPConfigCatalogValueAttributes configCatalogValueAttributes = acceptanceCatalogAttributes.ValuesByCode().ObjectForKey(NSNumber.NumberWithInt(catalogValue.CodeKey.IntValue)); if (configCatalogValueAttributes) { string colorString = configCatalogValueAttributes.ColorKey(); if (colorString) { possibleValue.IndicatorColor = UPColor.ColorWithString(colorString); } possibleValue.ImageString = configCatalogValueAttributes.ImageName(); } editField.AddPossibleValueForKey(possibleValue, catalogValue.CodeKey); }); if (((string)possibleValuesAsString.ObjectForKey("0")).Length == 0) { editField.NullValueKey = "0"; } if (catalog != null && acceptanceCatalogAttributes != null && !UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByAttributeFilter")) { explicitKeyOrder = this.ExplicitKeyOrderByCatalogAttributeCodeOrder(acceptanceCatalogAttributes, catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)); } else if (catalog != null && UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByCode")) { explicitKeyOrder = catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false); } else { explicitKeyOrder = catalog.ExplicitKeyOrderEmptyValueIncludeHidden(false, false); } if (explicitKeyOrder != null) { editField.ExplicitKeyOrder = explicitKeyOrder; } editField.ContinuousUpdate = true; } return(editField); }