/// <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 } }
/// <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 }
/// <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 }
public static void LoadAction1Step1(IOpportunityCompetitors form, EventArgs args) { Sage.Platform.WebPortal.SmartParts.WebActionEventArgs e = args as Sage.Platform.WebPortal.SmartParts.WebActionEventArgs; if (e != null) { Sage.Entity.Interfaces.IOpportunityCompetitor competitor = e.PassThroughObject as Sage.Entity.Interfaces.IOpportunityCompetitor; if (competitor != null) { competitor.Rating = competitor.Competitor.Rating; competitor.Strengths = competitor.Competitor.Strengths; competitor.Weaknesses = competitor.Weaknesses; competitor.Strategy = competitor.Competitor.Strategy; competitor.Notes = competitor.Competitor.Notes; Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart smartpart = form.NativeForm as Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart; if (smartpart != null) { Sage.Platform.WebPortal.EntityPage page = (Sage.Platform.WebPortal.EntityPage)smartpart.Page; if (page.ModeId.ToUpper() != "INSERT") { try { competitor.Save(); } catch (NHibernate.NonUniqueObjectException nuo) { // this needs to be localized string msg = "The competitor is already associated with this opportunity"; smartpart.DialogService.ShowMessage(msg); } } } } } form.lueAssociateCompetitor.LookupResultValue = null; //34026 }
public static void OnLoad1Step( IOpportunityCompetitors form, EventArgs args) { }
/// <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) { Sage.Entity.Interfaces.IOpportunity parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IOpportunity; Sage.Entity.Interfaces.ICompetitor relatedEntity = form.lueAssociateCompetitor.LookupResultValue as Sage.Entity.Interfaces.ICompetitor; Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart smartpart = form.NativeForm as Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart; Sage.Platform.WebPortal.EntityPage page = (Sage.Platform.WebPortal.EntityPage)smartpart.Page; if ((parentEntity != null) && (relatedEntity != null)) { // check for duplicates bool found = false; foreach (Sage.Entity.Interfaces.IOpportunityCompetitor oc in parentEntity.Competitors) { if (oc.Competitor == relatedEntity) { found = true; break; } } if (found) { if (smartpart != null && smartpart.DialogService != null) { string msg = string.Format(form.GetResource("DuplicateCompetitorMsg").ToString(), relatedEntity.CompetitorName); smartpart.DialogService.ShowMessage(msg, form.GetResource("DuplicateCompetitorMsgTitle").ToString()); } } else { Sage.Entity.Interfaces.IOpportunityCompetitor relationshipEntity = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IOpportunityCompetitor>(); relationshipEntity.Opportunity = parentEntity; relationshipEntity.Competitor = relatedEntity; parentEntity.Competitors.Add(relationshipEntity); if (page.ModeId.ToUpper() != "INSERT") { parentEntity.Save(); } if (smartpart.DialogService != null) { smartpart.DialogService.SetSpecs(0, 0, 400, 600, "EditOpportunityCompetitor", string.Empty, true); smartpart.DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOpportunityCompetitor); string id = string.Empty; smartpart.DialogService.CompositeKeyNames = "OpportunityId,CompetitorId"; id = string.Format("{0},{1}", relationshipEntity.OpportunityId, relationshipEntity.CompetitorId); if (Sage.Platform.WebPortal.PortalUtil.ObjectIsNewEntity(relationshipEntity)) { id = relationshipEntity.InstanceId.ToString(); Sage.Platform.ChangeManagement.ChangeManagementEntityFactory.RegisterInstance(relationshipEntity, relationshipEntity.InstanceId); if (relationshipEntity != null && relatedEntity != null) relationshipEntity.SetOppCompetitorDefaults(relatedEntity); } smartpart.DialogService.EntityID = id; smartpart.DialogService.ShowDialog(); } } } form.lueAssociateCompetitor.LookupResultValue = null; //34026 } }
/// <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) { Sage.Entity.Interfaces.IOpportunity parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IOpportunity; Sage.Entity.Interfaces.ICompetitor relatedEntity = form.lueAssociateCompetitor.LookupResultValue as Sage.Entity.Interfaces.ICompetitor; Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart smartpart = form.NativeForm as Sage.Platform.WebPortal.SmartParts.EntityBoundSmartPart; Sage.Platform.WebPortal.EntityPage page = (Sage.Platform.WebPortal.EntityPage)smartpart.Page; if ((parentEntity != null) && (relatedEntity != null)) { // check for duplicates bool found = false; foreach (Sage.Entity.Interfaces.IOpportunityCompetitor oc in parentEntity.Competitors) { if (oc.Competitor == relatedEntity) { found = true; break; } } if (found) { if (smartpart != null && smartpart.DialogService != null) { string msg = string.Format(form.GetResource("DuplicateCompetitorMsg").ToString(), relatedEntity.CompetitorName); smartpart.DialogService.ShowMessage(msg, form.GetResource("DuplicateCompetitorMsgTitle").ToString()); } } else { Sage.Entity.Interfaces.IOpportunityCompetitor relationshipEntity = Sage.Platform.EntityFactory.Create <Sage.Entity.Interfaces.IOpportunityCompetitor>(); relationshipEntity.Opportunity = parentEntity; relationshipEntity.Competitor = relatedEntity; parentEntity.Competitors.Add(relationshipEntity); if (page.ModeId.ToUpper() != "INSERT") { parentEntity.Save(); } if (smartpart.DialogService != null) { smartpart.DialogService.SetSpecs(0, 0, 400, 600, "EditOpportunityCompetitor", string.Empty, true); smartpart.DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOpportunityCompetitor); string id = string.Empty; smartpart.DialogService.CompositeKeyNames = "OpportunityId,CompetitorId"; id = string.Format("{0},{1}", relationshipEntity.OpportunityId, relationshipEntity.CompetitorId); if (Sage.Platform.WebPortal.PortalUtil.ObjectIsNewEntity(relationshipEntity)) { id = relationshipEntity.InstanceId.ToString(); Sage.Platform.ChangeManagement.ChangeManagementEntityFactory.RegisterInstance(relationshipEntity, relationshipEntity.InstanceId); if (relationshipEntity != null && relatedEntity != null) { relationshipEntity.SetOppCompetitorDefaults(relatedEntity); } } smartpart.DialogService.EntityID = id; smartpart.DialogService.ShowDialog(); } } } form.lueAssociateCompetitor.LookupResultValue = null; //34026 } }