/// <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
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds the selected competitor as a new opportunity competitor.
 /// </summary>
 /// <param name="form">The form.</param>
 /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 public static void LoadAction1Step1(IOpportunityCompetitors form, EventArgs args)
 {
     Sage.Platform.WebPortal.SmartParts.WebActionEventArgs e = args as Sage.Platform.WebPortal.SmartParts.WebActionEventArgs;
     if (e != null)
     {
         ICompetitor            competitor            = form.lueAssociateCompetitor.LookupResultValue as ICompetitor;
         IOpportunityCompetitor opportunityCompetitor = e.PassThroughObject as IOpportunityCompetitor;
         if (opportunityCompetitor != null && competitor != null)
         {
             opportunityCompetitor.SetOppCompetitorDefaults(competitor);
         }
     }
     form.lueAssociateCompetitor.LookupResultValue = null;             //34026
 }