public static void lueLeadCompetitor_OnChangeStep( ILeadProducts_Details form, EventArgs args) { // TODO: Complete business rule implementation }
public static void lueLeadProduct_OnChangeStep( ILeadProducts_Details form, EventArgs args) { if (form.lueLeadProduct.LookupResultValue != null) { Sage.Entity.Interfaces.ILead parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.ILead; Sage.Entity.Interfaces.IProduct relatedEntity = form.lueLeadProduct.LookupResultValue as Sage.Entity.Interfaces.IProduct; 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.ILeadProduct oc in parentEntity.Products) { if (oc.Product == relatedEntity) { found = true; break; } } if (found) { if (smartpart != null && smartpart.DialogService != null) { string msg = string.Format(form.GetResource("DuplicateCompetitorMsg").ToString(), relatedEntity.Name); smartpart.DialogService.ShowMessage(msg, form.GetResource("DuplicateCompetitorMsgTitle").ToString()); } } else { Sage.Entity.Interfaces.ILeadProduct relationshipEntity = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ILeadProduct>(); relationshipEntity.Lead = parentEntity; relationshipEntity.Product = relatedEntity; parentEntity.Products.Add(relationshipEntity); if (page.ModeId.ToUpper() != "INSERT") { parentEntity.Save(); } if (smartpart.DialogService != null) { smartpart.DialogService.SetSpecs(0, 0, 400, 600, "EditLeadProduct", string.Empty, true); smartpart.DialogService.EntityType = typeof(Sage.Entity.Interfaces.ILeadProduct); string id = string.Empty; //smartpart.DialogService.CompositeKeyNames = "Leadid,CompetitorID"; id = (string)relationshipEntity.Id;//string.Format("{0},{1}", relationshipEntity.Leadid, 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.SetLeadProductDefaults(relatedEntity); } smartpart.DialogService.EntityID = id; smartpart.DialogService.ShowDialog(); } } } form.lueLeadProduct.LookupResultValue = null; //34026 } }