/// <summary> /// Invokes the association lookup for competitors. /// </summary> /// <param name="form">the instance of the OpportunityCompetitor dialog</param> /// <param name="args">empty</param> public static void lueAssociateCompetitor_OnChangeStep(IOpportunityCompetitors form, EventArgs args) { if (form.lueAssociateCompetitor.LookupResultValue != null) { IOpportunity parentEntity = form.CurrentEntity as IOpportunity; ICompetitor relatedEntity = form.lueAssociateCompetitor.LookupResultValue as ICompetitor; var dialogService = form.Services.Get <IWebDialogService>(); if ((parentEntity != null) && (relatedEntity != null)) { if (parentEntity.Competitors.Any(oc => oc.Competitor == relatedEntity)) { if (dialogService != null) { string msg = string.Format(form.GetResource("DuplicateCompetitorMsg").ToString(), relatedEntity.CompetitorName); dialogService.ShowMessage(msg, form.GetResource("DuplicateCompetitorMsgTitle").ToString()); } } else { IOpportunityCompetitor relationshipEntity = EntityFactory.Create <IOpportunityCompetitor>(); relationshipEntity.Opportunity = parentEntity; relationshipEntity.Competitor = relatedEntity; parentEntity.Competitors.Add(relationshipEntity); if (!MySlx.MainView.IsInsertMode()) { parentEntity.Save(); } if (dialogService != null) { dialogService.SetSpecs(0, 0, 400, 600, "EditOpportunityCompetitor", string.Empty, true); dialogService.EntityType = typeof(IOpportunityCompetitor); string id; dialogService.CompositeKeyNames = "OpportunityId,CompetitorId"; if (PortalUtil.ObjectIsNewEntity(relationshipEntity)) { id = relationshipEntity.InstanceId.ToString(); ChangeManagementEntityFactory.RegisterInstance(relationshipEntity, relationshipEntity.InstanceId); relationshipEntity.SetOppCompetitorDefaults(relatedEntity); } else { id = string.Format("{0},{1}", relationshipEntity.OpportunityId, relationshipEntity.CompetitorId); } dialogService.EntityID = id; dialogService.ShowDialog(); } } } form.lueAssociateCompetitor.LookupResultValue = null; //34026 } }