public static void OnBeforeUpdateStep( IOpportunity opportunity, ISession session) { //Sage.Entity.Interfaces.IOpportunity opp = BindingSource.Current as Sage.Entity.Interfaces.IOpportunity; if(opportunity.BusinessPotential <= 0) { //DialogService.ShowMessage("Please Enter proper Business Potential..."); //throw (new Exception("Please Enter proper Business Potential...")); throw new Sage.Platform.Application.ValidationException("Please Enter Proper Business Potential..."); } if (opportunity.Status == "Closed - Won") { //pklStatus.PickListValue = opportunity.Status; //throw new Sage.Platform.Application.ValidationException("You are not authorised to change the status to Closed - Won."); } else { if ((opportunity.Status == "Lost" || opportunity.Status == "Dropped" || opportunity.Status == "Future Opportunity") && string.IsNullOrEmpty(opportunity.Notes)) { //DialogService.ShowMessage("Please mention comments for changing the status."); throw new Sage.Platform.Application.ValidationException("Please mention comments for changing the status."); } //System.Web.HttpContext.Current.Response.Redirect(string.Format("Opportunity.aspx?modeid=Detail")); } }
private string ScheduleActivity(string scheduleContext) { string activityId = string.Empty; try { string[] args = scheduleContext.Split(new Char[] { ',' }); string spaId = args[0]; string contactId = args[1]; string opportunityId = args[2]; string leaderId = args[3]; ISalesProcessAudit spAudit = EntityFactory.GetById <ISalesProcessAudit>(spaId); if (spAudit != null) { IContact contact = EntityFactory.GetById <IContact>(contactId); IOpportunity opp = EntityFactory.GetById <IOpportunity>(opportunityId); IUser leader = EntityFactory.GetById <IUser>(leaderId); Activity activity = (Activity)spAudit.SalesProcess.ScheduleActivity(spaId, opp, leader, contact, true); activityId = (string)activity.Id; } } catch { activityId = string.Empty; } return(activityId); }
private void EditActualAmount(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType) { if (DialogService != null) { IOpportunity entity = BindingSource.Current as IOpportunity; if (GetOpportunityStatusMatch(entity, "ClosedWon")) { DialogService.SetSpecs(200, 200, 400, 600, "OpportunityClosedWon", "", true); } else if (GetOpportunityStatusMatch(entity, "ClosedLost")) { DialogService.SetSpecs(200, 200, 400, 600, "OpportunityClosedLost", "", true); } else { DialogService.SetSpecs(200, 200, 200, 300, "UpdateSalesPotential", "", true); } if (BusinessRuleHelper.IsMultiCurrencyEnabled()) { string exchangeRateCode = string.Empty; double exchangeRate = 0.0; GetExchageRateData(exchangeRateType, out exchangeRateCode, out exchangeRate); DialogService.DialogParameters.Clear(); DialogService.DialogParameters.Add("ExchangeRateType", exchangeRateType); DialogService.DialogParameters.Add("ExchangeRateCode", exchangeRateCode); DialogService.DialogParameters.Add("ExchangeRate", exchangeRate); } DialogService.ShowDialog(); } }
private void GetExchageRateData(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType, out string exchangeRateCode, out double exchangeRate) { string _exchangeRateCode = string.Empty; double?_exchangeRate = 0.0; if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate) { IOpportunity opp = BindingSource.Current as IOpportunity; _exchangeRateCode = opp.ExchangeRateCode; _exchangeRate = opp.ExchangeRate; } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.MyRate) { _exchangeRateCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); if (myExchangeRate != null) { _exchangeRate = myExchangeRate.Rate.GetValueOrDefault(1); } } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.BaseRate) { var optionSvc = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true); _exchangeRateCode = optionSvc.BaseCurrency; IExchangeRate er = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); _exchangeRate = er.Rate.GetValueOrDefault(1); if (_exchangeRate.Equals(0)) { _exchangeRate = 1; } } exchangeRateCode = _exchangeRateCode; exchangeRate = Convert.ToDouble(_exchangeRate); }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { _OppFulfilmentTemplate = GetParentEntity() as IOpportunity; LoadGrid(); LoadcomboBox(); Sage.Entity.Interfaces.IOpportunity _entity = BindingSource.Current as Sage.Entity.Interfaces.IOpportunity; if (_entity != null) { if (_entity.OppFulFilTasks.Count > 0) { ddlTemplates.Visible = false; cmdAddTemplate.Visible = false; } else { ddlTemplates.Visible = true; cmdAddTemplate.Visible = true; } } //Senior Opps if (IsMember("Senior Operations", "G")) { cmdRemoveTemplate.Visible = true; } else { cmdRemoveTemplate.Visible = false; } }
private bool GetOpportunityStatusMatch(IOpportunity opportunity, string statusType) { if (opportunity == null) { return(false); } switch (statusType) { case "ClosedWon": var resourceObject = GetLocalResourceObject("Status_ClosedWon"); return(resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Closed - Won")); case "ClosedLost": resourceObject = GetLocalResourceObject("Status_ClosedLost"); return(resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Closed - Lost")); case "Open": resourceObject = GetLocalResourceObject("Status_Open"); return(resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Open")); case "Inactive": resourceObject = GetLocalResourceObject("Status_Inactive"); return(resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Inactive")); } return(false); }
public static void OnAfterInsertStep( IOpportunity opportunity) { // TODO: Complete business rule implementation string mId = opportunity.Id.ToString(); opportunity.OpportunityCIUDF.Meeting_Id = mId.Substring(6,6); opportunity.OpportunityCIUDF.Save(); }
/// <summary> /// Loads the sales process. /// </summary> /// <param name="opportunityId">The opportunity id.</param> private void LoadSalesProcess(string opportunityId) { IOpportunity opp = EntityFactory.GetRepository <IOpportunity>().FindFirstByProperty("Id", opportunityId); if (opp != null) { txtOpportunity.Text = opp.Description; } ISalesProcesses salesProcess = Sage.SalesLogix.SalesProcess.Helpers.GetSalesProcess(opportunityId); _salesProcess = salesProcess; if (salesProcess != null) { txtSalesProcess.Text = salesProcess.Name; LoadSnapShot(salesProcess); IList <ISalesProcessAudit> list = salesProcess.GetSalesProcessAudits(); grdStages.DataSource = list; grdStages.DataBind(); } else { List <ISalesProcessAudit> list = new List <ISalesProcessAudit>(); grdStages.DataSource = list; grdStages.DataBind(); } }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { if (this.Visible) { this._opportunity = GetParentEntity() as IOpportunity; string opportunityId = this.EntityContext.EntityID.ToString(); luOppContact.SeedProperty = "Opportunity.Id"; luOppContact.SeedValue = opportunityId; txtOpportunityId.Value = opportunityId; //set the current userId SLXUserService service = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService; IUser user = service.GetUser() as IUser; currentUserId.Value = user.Id.ToString(); //set the primary opp contactid IContact primeContact = GetPrimaryOppContact(opportunityId); if (primeContact != null) { primaryOppContactId.Value = primeContact.Id.ToString(); } else { primaryOppContactId.Value = string.Empty; } //set the account manager id accountManagerId.Value = _opportunity.AccountManager.Id.ToString(); //Set the opportunity contact count txtOppContactCount.Value = Convert.ToString(GetOppContactCount(opportunityId)); LoadSalesProcessDropDown(); LoadSalesProcess(opportunityId); } }
public static void SetupIntegrationContractStep(IInsertOpportunity form, EventArgs args) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; if (opportunity == null) { return; } Sage.Platform.SData.IAppIdMappingService oMappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.SData.IAppIdMappingService>(false); if (oMappingService != null && oMappingService.IsIntegrationEnabled()) { if (!opportunity.CanChangeOperatingCompany()) { form.lueERPApplication.Enabled = false; form.luePriceList.Enabled = false; } else { form.lueERPApplication.Enabled = true; form.luePriceList.Enabled = (form.lueERPApplication.LookupResultValue != null); } } else { form.clIntegrationContract.Visible = false; } }
/// <summary> /// Handles the ClickAction event of the btnAddStage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnAddStage_ClickAction(object sender, EventArgs e) { IOpportunity CurrentOpportunity = this.BindingSource.Current as IOpportunity; if (DialogService != null) { // InsertChildDialogActionItem //DialogService.SetSpecs(400, 600, "AddEditStage", "Add Stage"); // InsertChildDialogActionItem DialogService.SetSpecs(400, 600, "AddEditStage", "Add Stage"); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOppFulFilStage); DialogService.SetChildIsertInfo( typeof(Sage.Entity.Interfaces.IOppFulFilStage), typeof(Sage.Entity.Interfaces.IOpportunity), typeof(Sage.Entity.Interfaces.IOppFulFilStage).GetProperty("Opportunity"), typeof(Sage.Entity.Interfaces.IOpportunity).GetProperty("OppFulFilStages")); //DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOppFulFilStage); //DialogService.SetChildIsertInfo( // typeof(Sage.Entity.Interfaces.IOppFulFilStage), // typeof(Sage.Entity.Interfaces.IOpportunity), // typeof(Sage.Entity.Interfaces.IOppFulFilStage).GetProperty("Opportunity"), // typeof(Sage.Entity.Interfaces.IOpportunity).GetProperty("OppFulFilStages")); DialogService.DialogParameters.Add("OpportunityId", CurrentOpportunity.Id); DialogService.ShowDialog(); } }
/// <summary> /// Loads the grid. /// </summary> private void LoadGrid() { IOpportunity Opportunityfulfilment = EntityFactory.GetById <IOpportunity>(_OppFulfilmentTemplate.Id); grdStages.DataSource = GetStageAndTasks(Opportunityfulfilment); grdStages.DataBind(); }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(IOpportunity opportunity, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) { myRate = myExchangeRate.Rate.GetValueOrDefault(1); } string currentCode = opportunity.ExchangeRateCode; curOpenSalesPotential.CurrentCode = currentCode; curOpenSalesPotential.ExchangeRate = exchangeRate; curMyCurSalesPotential.CurrentCode = myCurrencyCode; curMyCurSalesPotential.ExchangeRate = myRate; curActualWon.CurrentCode = currentCode; curActualWon.ExchangeRate = exchangeRate; curMyCurActualWon.CurrentCode = myCurrencyCode; curMyCurActualWon.ExchangeRate = myRate; curPotentialLost.CurrentCode = currentCode; curPotentialLost.ExchangeRate = exchangeRate; curMyCurPotentialLost.CurrentCode = myCurrencyCode; curMyCurPotentialLost.ExchangeRate = myRate; curWeighted.CurrentCode = currentCode; curWeighted.ExchangeRate = exchangeRate; curMyCurWeighted.CurrentCode = myCurrencyCode; curMyCurWeighted.ExchangeRate = myRate; }
public Cancelation(IOpportunity opportunity, Guid publisherId, object publisher) { Id = Guid.NewGuid(); OpportunityId = opportunity.Id; PublisherId = publisherId; Publisher = publisher; Category = opportunity.Category; Information = opportunity.Information; }
public CourseItem( ICourse course, IOpportunity opportunity, IProvider provider) { Course = course ?? throw new ArgumentNullException(nameof(course)); Opportunity = opportunity ?? throw new ArgumentNullException(nameof(opportunity)); Provider = provider ?? throw new ArgumentNullException(nameof(provider)); }
public static void GetFirstServiceWonStep( IOpportunity opportunity, out System.DateTime result) { // TODO: Complete business rule implementation using (ISession session = new SessionScopeWrapper()) { string sql = "select min(actualclose) from opportunity_product where opportunityid='"+opportunity.Id.ToString()+"'"; DateTime fswon = session.CreateSQLQuery(sql).UniqueResult<DateTime>(); result=fswon; } }
/// <summary> /// Gets the opportunity. /// </summary> /// <param name="opportunityId">The opportunity id.</param> /// <returns></returns> private static IOpportunity GetOpportunity(string opportunityId) { IOpportunity opp = null; using (new SessionScopeWrapper()) { opp = EntityFactory.GetById <IOpportunity>(opportunityId); } return(opp); }
public static void GetWonServiceRevStep(IOpportunity opportunity, out System.Decimal result) { // TODO: Complete business rule implementation using (ISession session = new SessionScopeWrapper()) { string sql = "select sum(extendedprice) from opportunity_product where status='Execution' and opportunityid='" + opportunity.Id.ToString() + "'"; decimal fswon = session.CreateSQLQuery(sql).UniqueResult<decimal>(); result = fswon; } }
/// <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> /// Handles the OnChange event of the ExchangeRate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ExchangeRate_OnChange(object sender, EventArgs e) { IOpportunity opportunity = BindingSource.Current as IOpportunity; if (opportunity != null) { opportunity.ExchangeRate = Convert.ToDouble(String.IsNullOrEmpty(numExchangeRateValue.Text) ? "1" : numExchangeRateValue.Text); opportunity.ExchangeRateDate = DateTime.UtcNow; UpdateMultiCurrencyExchangeRate(opportunity, opportunity.ExchangeRate.Value); } }
public Offer(IOpportunity <TTarget, TProduct> opportunity, Guid publisherId, object publisher, double amount, string category, object information) { Id = Guid.NewGuid(); Opportunity = opportunity; PublisherId = publisherId; Publisher = publisher; Amount = amount; Category = category; Information = information; }
protected void grdReseller_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { IOpportunity opportunity = (IOpportunity)e.Row.DataItem; //Sales Potential Sage.SalesLogix.Web.Controls.Currency curr = (Sage.SalesLogix.Web.Controls.Currency)e.Row.Cells[2].Controls[1]; curr.ExchangeRate = opportunity.ExchangeRate.GetValueOrDefault(1); curr.CurrentCode = opportunity.ExchangeRateCode; } }
private void SetPrimaryContactFromOppContacts(IOpportunity opportunity) { var contact = GetPrimaryOppContact(opportunity.Contacts) ?? GetPrimaryContact(opportunity.Account.Contacts); if (Contact.LookupResultValue == null) { Contact.LookupResultValue = contact; } LeadId.LookupResultValue = null; }
/// <summary> /// Gets the opp account manager. /// </summary> /// <param name="opportunityId">The opportunity id.</param> /// <returns></returns> private static IUser GetOppAccountManager(string opportunityId) { IUser user = null; IOpportunity opp = null; using (ISession session = new SessionScopeWrapper()) { opp = EntityFactory.GetById <IOpportunity>(opportunityId); user = opp.AccountManager; } return(user); }
public static void ValidateCommissionStep(IOpportunity opportunity, out Boolean result) { // TODO: Complete business rule implementation result = false; using (ISession session = new SessionScopeWrapper()) { string strSQL = "select count(*) from salesorder where salescommission>0 and salescommission2>0 and accountid='"+opportunity.Account.Id.ToString()+"' and opportunityid='"+opportunity.Id.ToString()+"'"; int salesorder = session.CreateSQLQuery(strSQL).UniqueResult<int>(); if (salesorder > 0) { result = true; } } }
public static void chkbxOverrideSalesPotential_OnChangeStep(IEditSalesPotential form, EventArgs args) { if (!form.chkbxOverrideSalesPotential.Checked) { form.curSalesPotential.IsReadOnly = true; IOpportunity opportunity = form.CurrentEntity as IOpportunity; opportunity.CalculateSalesPotential(); } else { form.curSalesPotential.IsReadOnly = true; } }
private static IList <IContact> GetOppContacts(string opportunityId) { List <IContact> contacts = new List <IContact>(); IOpportunity opp = null; opp = EntityFactory.GetById <IOpportunity>(opportunityId); foreach (IOpportunityContact oppCon in opp.Contacts) { contacts.Add(oppCon.Contact); } return(contacts); }
/// <summary> /// Sets the status to Open if the dialog is cancelled. This is limited because it does not know the /// prior status so it resets to a pre-determined value. /// </summary> /// <param name="form">the instance of the OpportunityClosedWon dialog</param> /// <param name="args">empty</param> public static void cmdCancel_OnClickStep1(IOpportunityClosedWon form, EventArgs args) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; if (!(opportunity.Closed ?? false)) { object resOpen = form.GetResource("Opp_Status_Open").ToString(); if (resOpen != null) { opportunity.Status = resOpen.ToString(); } } }
public static void GetInitialSalesRepStep( IOpportunity opportunity, out System.String result) { // TODO: Complete business rule implementation string fswon = string.Empty; try{ using (ISession session = new SessionScopeWrapper()) { string sql = "select username from userinfo where userid='"+opportunity.Account.AccountConferon.InitialSalesRep.ToString()+"'"; fswon = session.CreateSQLQuery(sql).UniqueResult<string>(); } }catch(Exception){} result=fswon; }
public static void OnLoad1Step(IOpportunityContacts form, EventArgs args) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; if (opportunity.Account == null) { form.lueAssociateContact.Enabled = false; } else { form.lueAssociateContact.Enabled = true; } }
/// <summary> /// Sets the status to Open if the dialog is cancelled. This is limited because it does not know the /// prior status so it resets to a pre-determined value. /// </summary> /// <param name="form">the instance of the OpportunityClosedWon dialog</param> /// <param name="args">empty</param> public static void cmdCancel_OnClickStep1(IOpportunityClosedWon form, EventArgs args) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; if (!(opportunity.Closed ?? false)) { object resOpen = System.Web.HttpContext.GetGlobalResourceObject("Opportunity", "Opp_Status_Open"); if (resOpen != null) { opportunity.Status = resOpen.ToString(); //"Open"; } } }
public static void OnBeforeInsertStep( IOpportunity opportunity, ISession session) { if(opportunity.BusinessPotential <= 0) { throw new Sage.Platform.Application.ValidationException("Please Enter Proper Business Potential..."); } if(opportunity.Products.Count <= 0) { throw new Sage.Platform.Application.ValidationException("Product required..."); } }
public static void SLXSocial_OnCreateStep( IOpportunity opportunity) { var appCtx = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Application.IContextService>(); if(appCtx.HasContext("NewEntityParameters")){ var entityParams = appCtx["NewEntityParameters"] as System.Collections.Generic.Dictionary<String,String>; if(entityParams != null && entityParams.ContainsKey("OpportunityDescription")) { opportunity.Description = (String)entityParams["OpportunityDescription"]; } if(entityParams != null && entityParams.ContainsKey("OpportunityNotes")) { opportunity.Notes = (String)entityParams["OpportunityNotes"]; } appCtx.RemoveContext("NewEntityParameters"); } }
protected void dtpDateOpened_DateTimeValueChanged(object sender, EventArgs e) { IOpportunity opportunity = BindingSource.Current as IOpportunity; opportunity.DateOpened = dtpDateOpened.DateTimeValue; if (opportunity != null) { lblSummary.Text = String.Format(GetLocalResourceObject("lblSummary.Caption").ToString(), opportunity.DaysOpen); lblSummaryActivity.Text = String.Format(GetLocalResourceObject("lblSummaryActivity.Caption").ToString(), opportunity.DaysSinceLastActivity); } }
private bool ValuesSet(EntityHistory hist) { switch (hist.EntityType.Name) { case "IAccount": IAccount account = EntityFactory.GetById <IAccount>(hist.EntityId.ToString()); Account.LookupResultValue = account; Contact.LookupResultValue = GetPrimaryContact(account.Contacts); return(true); case "IContact": IContact contact = EntityFactory.GetById <IContact>(hist.EntityId.ToString()); Contact.LookupResultValue = contact; Account.LookupResultValue = contact.Account; return(true); case "IOpportunity": IOpportunity opportunity = EntityFactory.GetById <IOpportunity>(hist.EntityId.ToString()); Opportunity.LookupResultValue = opportunity; Account.LookupResultValue = opportunity.Account; foreach (IOpportunityContact oppContact in opportunity.Contacts) { if (oppContact.IsPrimary.HasValue) { if ((bool)oppContact.IsPrimary) { Contact.LookupResultValue = oppContact.Contact; break; } } } return(true); case "ITicket": ITicket ticket = EntityFactory.GetById <ITicket>(hist.EntityId.ToString()); Ticket.LookupResultValue = ticket; Account.LookupResultValue = ticket.Account; Contact.LookupResultValue = ticket.Contact; return(true); case "ILead": SetDivVisible(VisibleDiv.Lead); ILead lead = EntityFactory.GetById <ILead>(hist.EntityId.ToString()); LeadId.LookupResultValue = lead; Company.Text = lead.Company; return(true); } return(false); }
public static void SetupIntegrationContractStep(IInsertOpportunity form, EventArgs args) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; if (opportunity == null) { return; } Sage.Platform.SData.IAppIdMappingService oMappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.SData.IAppIdMappingService>(false); if (oMappingService != null && oMappingService.IsIntegrationEnabled()) { if (!opportunity.CanChangeOperatingCompany()) { form.lueERPApplication.Enabled = false; form.luePriceList.Enabled = false; } else { form.lueERPApplication.Enabled = true; object oValue = form.lueERPApplication.LookupResultValue; string sValue = string.Empty; if (oValue != null) { sValue = oValue.ToString(); } if (string.IsNullOrEmpty(sValue)) { form.luePriceList.Text = string.Empty; form.luePriceList.LookupResultValue = null; form.luePriceList.Enabled = false; } else { form.luePriceList.Enabled = true; } SalesLogix.HighLevelTypes.LookupPreFilter filterAppId = new SalesLogix.HighLevelTypes.LookupPreFilter(); filterAppId.LookupEntityName = "Sage.Entity.Interfaces.IAppIdMapping"; filterAppId.PropertyName = "Id"; filterAppId.OperatorCode = "!="; filterAppId.FilterValue = oMappingService.LocalAppId; filterAppId.PropertyType = "System.String"; form.lueERPApplication.LookupPreFilters.Add(filterAppId); } } else { form.clIntegrationContract.Visible = false; } }
/// <summary> /// Gets the opp contacts. /// </summary> /// <param name="opportunityId">The opportunity id.</param> /// <returns></returns> private static IList <IContact> GetOppContacts(string opportunityId) { List <IContact> contacts = new List <IContact>(); IOpportunity opp = null; using (ISession session = new SessionScopeWrapper()) { opp = EntityFactory.GetById <IOpportunity>(opportunityId); foreach (IOpportunityContact oppCon in opp.Contacts) { contacts.Add(oppCon.Contact); } } return(contacts); }
/// <summary> /// Sets the flag, LostReplaced, on the opportunity competitor indicating that this opportunity /// competitor was associated as a competitor lost to. /// </summary> /// <param name="form">The opportunity closed lost form.</param> /// <param name="args">The event arguments.<see cref="System.EventArgs"/> instance containing the event data.</param> public static void lueCompetitorLoss_OnChange(IOpportunityClosedLost form, EventArgs args) { ICompetitor competitor = form.lueCompetitorLoss.LookupResultValue as ICompetitor; if (competitor != null) { IOpportunity opportunity = form.CurrentEntity as IOpportunity; opportunity.SetOppCompetitorReplacedFlag(competitor); } Sage.Platform.WebPortal.Services.IPanelRefreshService panelRefresh = form.Services.Get <Sage.Platform.WebPortal.Services.IPanelRefreshService>(); if (panelRefresh != null) { panelRefresh.RefreshMainWorkspace(); } }
public static void ValidateRequiredInsertStep( IOpportunity opportunity, out Boolean result) { // TODO: Complete business rule implementation bool validate = true; if (opportunity.AccountManager.ToString()==null || string.IsNullOrEmpty(opportunity.AccountManager.ToString())){ validate = false; throw new Sage.Platform.Application.ValidationException("AccountManager is required."); } if (opportunity.OpportunityCIUDF.Main_arrival_Date.ToString()==null || string.IsNullOrEmpty(opportunity.OpportunityCIUDF.Main_arrival_Date.ToString())){ validate = false; throw new Sage.Platform.Application.ValidationException("Main Arrival Date is required."); } if (opportunity.OpportunityCIUDF.Main_departure_Date.ToString()==null || string.IsNullOrEmpty(opportunity.OpportunityCIUDF.Main_departure_Date.ToString())){ validate = false; throw new Sage.Platform.Application.ValidationException("Main Departure Date is required."); } if (opportunity.Owner==null ){ validate = false; throw new Sage.Platform.Application.ValidationException("Sales Domain is required."); } if (opportunity.Type==null || string.IsNullOrEmpty(opportunity.Type)){ validate = false; throw new Sage.Platform.Application.ValidationException("Event Type is required."); } if (opportunity.OpportunityCIUDF.Frequency==null || string.IsNullOrEmpty(opportunity.OpportunityCIUDF.Frequency.ToString())){ validate = false; throw new Sage.Platform.Application.ValidationException("Frequency is required."); } if (opportunity.LeadSource==null){ validate = false; throw new Sage.Platform.Application.ValidationException("Opp. Lead Source is required."); } //if (opportunity.OpportunityCIUDF.FirstTimeEvent==false || string.IsNullOrEmpty(opportunity.OpportunityCIUDF.FirstTimeEvent.ToString())){ if (opportunity.OpportunityCIUDF.FirstTimeEvent==null) { validate = false; throw new Sage.Platform.Application.ValidationException("First Time Event is required."); } result=validate; }
public static void DuplicateOpportunityStep( IOpportunity opportunity) { // TODO: Complete business rule implementation IOpportunity opty = EntityFactory.Create<IOpportunity>(); opty.Description = "Copy of "+opportunity.Description; opty.Account = opportunity.Account; opty.Closed = false; opty.OpportunityCIUDF.Lost = false; opty.OpportunityCIUDF.Cancelled = false; opty.OpportunityCIUDF.FirstTimeEvent = null; opty.CreateUser = "******"; opty.OpportunityCIUDF.CreateUser = "******"; opty.Win = null; opty.EstimatedClose = opportunity.EstimatedClose; opty.LeadSource = opportunity.LeadSource; opty.AccountManager = opportunity.AccountManager; opty.OpportunityCIUDF.Main_arrival_Date = opportunity.OpportunityCIUDF.Main_arrival_Date; opty.OpportunityCIUDF.Main_departure_Date = opportunity.OpportunityCIUDF.Main_departure_Date; opty.OpportunityCIUDF.Main_arrival_day = opportunity.OpportunityCIUDF.Main_arrival_day; opty.OpportunityCIUDF.Main_departure_day = opportunity.OpportunityCIUDF.Main_departure_day; opty.OpportunityCIUDF.Location = opportunity.OpportunityCIUDF.Location; opty.Owner = opportunity.Owner; foreach(IOpportunityProduct op in opportunity.Products) { IOpportunityProduct opprd = EntityFactory.Create<IOpportunityProduct>(); opprd.Opportunity = opty; opprd.Product = op.Product; opprd.Price = op.Price; opprd.Status = "Satisfaction"; opprd.CloseProbability = 20; opprd.CreateUser = "******"; opprd.ExtendedPrice = op.ExtendedPrice; opprd.PriceEffectiveDate = op.PriceEffectiveDate; opty.Products.Add(opprd); } opty.Save(); }
/// <summary> /// Does the action. /// </summary> /// <param name="spaId">The spa id.</param> private void DoAction(string spaId) { string result = string.Empty; ISalesProcessAudit spAudit = Helpers.GetSalesProcessAudit(spaId); this._opportunity = GetOpportunity(spAudit.EntityId); this._salesProcess = Helpers.GetSalesProcess(spAudit.EntityId); if (spAudit == null) return; try { result = _salesProcess.CanCompleteStep(spaId); if (result == string.Empty) { string actionType = spAudit.ActionType; switch (actionType.ToUpper()) { case "NONE": break; case "MAILMERGE": result = DoMailMerge(spAudit); break; case "SCRIPT": result = DoWebAction(spAudit); break; case "FORM": result = DoWebForm(spAudit); break; case "PHONECALL": result = DoActivity(spAudit); break; case "TODO": result = DoActivity(spAudit); break; case "MEETING": result = DoActivity(spAudit); break; case "LITREQUEST": result = DoLitRequest(spAudit); break; case "CONTACTPROCESS": result = DoContactProcess(spAudit); break; case "ACTIVITYNOTEPAD": result = GetLocalResourceObject("ActvityNotePadNotSupported").ToString(); //"Activity Note Pad not in availble in Web."; break; default: break; } } } catch (Exception ex) { result = ex.Message; } if (DialogService != null) { if (!string.IsNullOrEmpty(result)) { string msg = string.Format(GetLocalResourceObject("MSG_ProcessActionResult").ToString(), spAudit.StepName, result); DialogService.ShowMessage(msg); } } }
/// <summary> /// Shows the sales process info. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <returns></returns> private bool ShowSalesProcessInfo(IOpportunity opportunity) { bool result = false; if ((opportunity.Status.Equals(GetLocalResourceObject("Status_Open").ToString())) || (opportunity.Status.Equals(GetLocalResourceObject("Status_Inactive").ToString()))) { IRepository<ISalesProcesses> rep = EntityFactory.GetRepository<ISalesProcesses>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); ICriteria crit = qry.CreateCriteria(); crit.Add(ep.Eq("EntityId", opportunity.Id.ToString())); IProjection proj = qry.GetProjectionsFactory().Count("Id"); crit.SetProjection(proj); int count = (int)crit.UniqueResult(); result = (count > 0); } return result; }
/// <summary> /// Adds the attachments to lead. /// </summary> /// <param name="sourceLead">The source lead.</param> /// <param name="account">The account.</param> /// <param name="contact">The contact.</param> private void AddAttachmentsToLead(ILead sourceLead, IAccount account, IContact contact, IOpportunity opportunity) { IList<IAttachment> attachments = EntityFactory.GetRepository<IAttachment>().FindByProperty("LeadId", sourceLead.Id.ToString()); foreach (IAttachment attachment in attachments) sourceLead.AddAttachmentsContactID(contact, account, opportunity, attachment); }
/// <summary> /// Loads the snap shot. /// </summary> /// <param name="stage">The stage.</param> private void LoadSnapShot(ISalesProcessAudit stage) { if (stage != null) { this._opportunity = GetParentEntity() as IOpportunity; this._opportunity.Stage = stage.StageName; valueCurrnetStage.Text = stage.StageName; valueProbabilty.Text = stage.Probability.ToString() + "%"; valueDaysInStage.Text = Convert.ToString(this._salesProcess.DaysInStage(stage.Id.ToString())); valueEstDays.Text = Convert.ToString(_salesProcess.EstimatedDaysToClose()); dtpEstClose.DateTimeValue = (DateTime)_salesProcess.EstimatedCloseDate(); } else { valueCurrnetStage.Text = "''"; valueProbabilty.Text = "0%"; valueDaysInStage.Text = "0"; valueEstDays.Text = "0"; dtpEstClose.DateTimeValue = DateTime.MinValue; dtpEstClose.Text = string.Empty; } }
private bool GetOpportunityStatusMatch(IOpportunity opportunity, string statusType) { if (opportunity == null) return false; switch (statusType) { case "ClosedWon": return ReferenceEquals(opportunity.Status, GetLocalResourceObject("Status_ClosedWon")) || opportunity.Status == "Closed - Won"; case "ClosedLost": return ReferenceEquals(opportunity.Status, GetLocalResourceObject("Status_ClosedLost")) || opportunity.Status == "Closed - Lost"; case "Open": return ReferenceEquals(opportunity.Status, GetLocalResourceObject("Status_Open")) || opportunity.Status == "Open"; case "Inactive": return ReferenceEquals(opportunity.Status, GetLocalResourceObject("Status_Inactive")) || opportunity.Status == "Inactive"; } return false; }
/// <summary> /// Analyze opportunities published on Exchange. /// </summary> public abstract void Handle(IOpportunity<MultiLineTextList, IViewModelBase> message);
private bool GetOpportunityStatusMatch(IOpportunity opportunity, string statusType) { if (opportunity == null) return false; switch (statusType) { case "ClosedWon": var resourceObject = GetLocalResourceObject("Status_ClosedWon"); return resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Closed - Won"); case "ClosedLost": resourceObject = GetLocalResourceObject("Status_ClosedLost"); return resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Closed - Lost"); case "Open": resourceObject = GetLocalResourceObject("Status_Open"); return resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Open"); case "Inactive": resourceObject = GetLocalResourceObject("Status_Inactive"); return resourceObject != null && (opportunity.Status == resourceObject.ToString() || opportunity.Status == "Inactive"); } return false; }
protected IOpportunityProduct CreateOpportunityProduct(IOpportunity opportunity, string ProductId, double Quantity, double Price, string AMProductName) { if (opportunity == null) { throw new ArgumentException("There was a problem reading the opportunity."); } if (String.IsNullOrEmpty(ProductId)) { throw new ArgumentException("ProductId must have a value."); } IProduct product = Sage.Platform.EntityFactory.GetById<IProduct>(ProductId); if (product != null) { // Add the Product and the Custom Values IOpportunityProduct oppProd = EntityFactory.Create<IOpportunityProduct>(); oppProd.Product = product; oppProd.Opportunity = opportunity; bool isInList = false; // Check If Product is already on the List foreach (IOpportunityProduct op in opportunity.Products) { if (string.Compare(Convert.ToString(op.Product.Id), Convert.ToString(oppProd.Product.Id)) == 0) { op.Quantity++; isInList = true; break; } } if (!isInList) { oppProd.Sort = Convert.ToInt32(opportunity.Products.Count) + 1; oppProd.Quantity = Quantity; //1; ssommerfeldt oppProd.Discount = 0; if (oppProd.Product.ProductProgram.Count != 0) { foreach (IProductProgram prodProgram in oppProd.Product.ProductProgram) { if (prodProgram.DefaultProgram == true) { oppProd.CalculatedPrice = Convert.ToDecimal(Price); //ssommmerfeldt prodProgram.Price; oppProd.Program = prodProgram.Program; oppProd.Price = Convert.ToDecimal(Price);// ssommerfeldt prodProgram.Price; } } } else { oppProd.CalculatedPrice = Convert.ToDecimal(Price);// ssommerfeldtConvert.ToDecimal(oppProd.Product.Price); oppProd.Price = Convert.ToDecimal(Price);// ssommerfeldtoppProd.Product.Price; } oppProd.ExtendedPrice = oppProd.CalculatedPrice * Convert.ToDecimal(oppProd.Quantity); //============== // Other Fields //============== oppProd.Discount = 0; oppProd.OpportunityProductEx.ConnectingToPI = ""; if (oppProd.Product.Name.IndexOf("Maintenance", 0) > 0 && !String.IsNullOrEmpty(AMProductName)) { //Check it is a Maintenance Product oppProd.OpportunityProductEx.Maintenance_product = AMProductName; } return oppProd; } } return null; }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { _OppFulfilmentTemplate = GetParentEntity() as IOpportunity; LoadGrid(); LoadcomboBox(); Sage.Entity.Interfaces.IOpportunity _entity = BindingSource.Current as Sage.Entity.Interfaces.IOpportunity ; if (_entity != null) { if (_entity.OppFulFilTasks.Count > 0) { ddlTemplates.Visible = false; cmdAddTemplate.Visible = false; } else { ddlTemplates.Visible = true; cmdAddTemplate.Visible = true; } } //Senior Opps if (IsMember("Senior Operations", "G")) { cmdRemoveTemplate.Visible = true; } else { cmdRemoveTemplate.Visible = false; } }
public static DataTable GetStageAndTasks(IOpportunity OpportunityFulfilment) { DataTable table = GetDataTable(); DataTable returntable = GetDataTable(); //========================================= //Create Return Table //========================================= foreach (IOppFulFilStage stage in OpportunityFulfilment.OppFulFilStages) { DataRow row = table.NewRow(); row["id"] = string.Format("{0}:S", stage.Id); row["Type"] = "STAGE"; row["Description"] = stage.Description; row["Status"] = stage.Status; if (stage.StageSequence == null) { row["StageSequence"] = 0; } else { row["StageSequence"] = stage.StageSequence; } row["TaskSequence"] = 0; table.Rows.Add(row); if (stage.OppFulFilTasks.Count == 0) { DataRow row2 = table.NewRow(); row2["id"] = string.Format("{0}:T", "PLACE_HOLDER"); row2["Type"] = "PLACE_HOLDER"; row2["Description"] = "There are no tasks assigned to this stage"; if (stage.StageSequence == null) { row2["StageSequence"] = 0; } else { row2["StageSequence"] = stage.StageSequence; } row2["TaskSequence"] = 0; table.Rows.Add(row2); } else { foreach (IOppFulFilTask task in stage.OppFulFilTasks) { DataRow row3 = table.NewRow(); row3["id"] = string.Format("{0}:T", task.Id); row3["Type"] = "TASK"; row3["Description"] = task.Description; row3["Status"] = task.Status; row3["Priority"] = task.Priority; if (task.Completed != null) { row3["Completed"] = task.Completed; } try { row3["StageSequence"] = stage.StageSequence; } catch { row3["StageSequence"] = 0; } try { row3["TaskSequence"] = task.TaskSequence; } catch { row3["TaskSequence"] = 1; } try { row3["NeededDate"] = task.DueDate; } catch { } try { row3["CompletedDate"] = task.CompletedDate ; } catch { } try { row3["WeightedPercentage"] = task.WeightedPercentage; } catch { row3["WeightedPercentage"] = 0; } table.Rows.Add(row3); } continue; } } //======================================================================== // Sort by Stage and Task // The Select Method just returns an Array of Rows //======================================================================== foreach (DataRow tmpRow in table.Select("", "StageSequence, TaskSequence")) { DataRow row4 = returntable.NewRow(); row4["id"] = tmpRow["id"]; row4["Type"] = tmpRow["Type"]; row4["Description"] = tmpRow["Description"]; row4["Status"] = tmpRow["Status"]; row4["Priority"] = tmpRow["Priority"]; row4["StageSequence"] = tmpRow["StageSequence"]; row4["TaskSequence"] = tmpRow["TaskSequence"]; row4["NeededDate"] = tmpRow["NeededDate"]; row4["CompletedDate"] = tmpRow["CompletedDate"]; row4["WeightedPercentage"] = tmpRow["WeightedPercentage"]; row4["Completed"] = tmpRow["Completed"]; returntable.Rows.Add(row4); } return returntable; }
/// <summary> /// Analyze opportunities published on Exchange. /// </summary> public override void Handle(IOpportunity<MultiLineTextList, IViewModelBase> message) { History.Events.ThinkingAboutTargetEvent.Publish(System.Guid.Empty); //WE ONLY CARE ABOUT STUDY OPPORTUNITIES if (message.Category != StudyResources.CategoryStudy) return; //WE DON'T CARE ABOUT MESSAGES WE PUBLISH OURSELVES if (message.PublisherId == Id) return; //CURRENTLY, WE ONLY CARE IF THE JOB INFO IS A STUDY JOB INFO<MLTLIST> if (!(message.JobInfo is StudyJobInfo<MultiLineTextList, IViewModelBase>)) return; //WE ONLY CARE IF WE UNDERSTAND THE STUDYJOBINFO.CRITERIA var studyJobInfo = (StudyJobInfo<MultiLineTextList, IViewModelBase>)message.JobInfo; if (!(studyJobInfo.Criteria is StudyJobCriteria)) return; //WE HAVE A GENUINE OPPORTUNITY WE WOULD BE INTERESTED IN //MAKE THE OFFER FOR THE JOB var offer = new Offer<MultiLineTextList, IViewModelBase>(message, this.Id, this, GetOfferAmount(), StudyResources.CategoryStudy, null); //FIRST ADD THIS OFFER TO OUR LIST OF OFFERS _OpenOffers.Add(offer); //PUBLISH THE OFFER Exchange.Ton.Publish(offer); }
/// <summary> /// Does the action. /// </summary> /// <param name="spaId">The spa id.</param> private void DoAction(string spaId) { string result = string.Empty; ISalesProcessAudit spAudit = Helpers.GetSalesProcessAudit(spaId); this._opportunity = GetOpportunity(spAudit.EntityId); this._salesProcess = Helpers.GetSalesProcess(spAudit.EntityId); if (spAudit == null) return; try { result = _salesProcess.CanCompleteStep(spaId); if (result == string.Empty) { string actionType = spAudit.ActionType; switch (actionType.ToUpper()) { case "NONE": break; case "MAILMERGE": result = DoMailMerge(spAudit); break; case "SCRIPT": result = DoWebAction(spAudit); break; case "FORM": result = DoWebForm(spAudit); break; case "PHONECALL": result = DoActivity(spAudit); break; case "TODO": result = DoActivity(spAudit); break; case "MEETING": result = DoActivity(spAudit); break; case "LITREQUEST": result = DoLitRequest(spAudit); break; case "CONTACTPROCESS": result = DoContactProcess(spAudit); break; case "ACTIVITYNOTEPAD": result = GetLocalResourceObject("ActvityNotePadNotSupported").ToString(); //"Activity Note Pad not in availble in Web."; break; default: break; } } } catch (Exception ex) { if (ErrorHelper.CanShowExceptionMessage(ex)) { result = ex.Message; } else { log.Error( string.Format("The call to SmartParts_OpportunitySalesProcess_SalesProcess.DoAction('{0}') failed", spAudit), ex); result = Resources.SalesLogix.WereSorryMsg; } } if (DialogService != null) { if (!string.IsNullOrEmpty(result)) { // MSG_ProcessActionResult: For step |B|{0}|/B| : + NewLine + {1} string msg = HttpUtility.HtmlEncode(string.Format(GetLocalResourceObject("MSG_ProcessActionResult").ToString(), spAudit.StepName, result)).Replace("|B|", "<b>").Replace( "|/B|", "</b>").Replace(Environment.NewLine, "<br />"); DialogService.ShowHtmlMessage(msg); } } }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { if (this.Visible) { this._opportunity = GetParentEntity() as IOpportunity; string opportunityId = this.EntityContext.EntityID.ToString(); luOppContact.SeedProperty = "Opportunity.Id"; luOppContact.SeedValue = opportunityId; txtOpportunityId.Value = opportunityId; //set the current userId SLXUserService service = ApplicationContext.Current.Services.Get<IUserService>() as SLXUserService; IUser user = service.GetUser() as IUser; currentUserId.Value = user.Id.ToString(); //set the primary opp contactid IContact primeContact = GetPrimaryOppContact(opportunityId); if (primeContact != null) primaryOppContactId.Value = primeContact.Id.ToString(); else primaryOppContactId.Value = string.Empty; //set the account manager id accountManagerId.Value = _opportunity.AccountManager.Id.ToString(); //Set the opportunity contact count txtOppContactCount.Value = Convert.ToString(GetOppContactCount(opportunityId)); LoadSalesProcessDropDown(); LoadSalesProcess(opportunityId); string _UserId = "", AccManager = ""; Sage.Platform.Security.IUserService _IUserService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); _UserId = _IUserService.UserId; //get login Userid AccManager = Convert.ToString(this._opportunity.AccountManager.Id); if ((AccManager.Trim() == _UserId.Trim() || Convert.ToString(this._opportunity.Account.AccountManager.Id) == _UserId.Trim()) && (this._opportunity.Status != "Closed - Won" && this._opportunity.Status.ToUpper() != "LOST" && this._opportunity.Status.ToUpper() != "DROPPED")) { } else { ddlStages.Enabled = false; ddLSalesProcess.Enabled = false; SalesProcessGrid.Enabled = false; btnStages.Enabled = false; cmdCompleteDate.Enabled = false; cmdCompleteStep.Enabled = false; cmdDoAction.Enabled = false; cmdSelectContactNext.Enabled=false; cmdSelectUserNext.Enabled = false; cmdStartDate.Enabled = false; } } }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { if (this.Visible) { this._opportunity = GetParentEntity() as IOpportunity; string opportunityId = this.EntityContext.EntityID.ToString(); luOppContact.SeedProperty = "Opportunity.Id"; luOppContact.SeedValue = opportunityId; txtOpportunityId.Value = opportunityId; //set the current userId SLXUserService service = ApplicationContext.Current.Services.Get<IUserService>() as SLXUserService; IUser user = service.GetUser() as IUser; currentUserId.Value = user.Id.ToString(); //set the primary opp contactid IContact primeContact = GetPrimaryOppContact(opportunityId); if (primeContact != null) primaryOppContactId.Value = primeContact.Id.ToString(); else primaryOppContactId.Value = string.Empty; //set the account manager id accountManagerId.Value = _opportunity.AccountManager.Id.ToString(); //Set the opportunity contact count txtOppContactCount.Value = Convert.ToString(GetOppContactCount(opportunityId)); LoadSalesProcessDropDown(); LoadSalesProcess(opportunityId); } }
/// <summary> /// Formats the email body. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <returns></returns> private string FormatEmailBody(IOpportunity opportunity) { IContextService context = ApplicationContext.Current.Services.Get<IContextService>(true); TimeZone timeZone = (TimeZone) context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string oppProducts = String.Empty; bool oppWon = GetOpportunityStatusMatch(opportunity, "ClosedWon"); bool oppLost = GetOpportunityStatusMatch(opportunity, "ClosedLost"); string emailBody = String.Format("{0} \r\n", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppDesc.Caption"), CheckForNullValue(opportunity.Description)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppAccount.Caption"), CheckForNullValue(opportunity.Account != null ? opportunity.Account.AccountName : String.Empty)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppAcctMgr.Caption"), CheckForNullValue(opportunity.AccountManager)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppReseller.Caption"), CheckForNullValue(opportunity.Reseller)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppEstClose.Caption"), opportunity.EstimatedClose.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime) opportunity.EstimatedClose).ToString (datePattern) : String.Empty); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppCloseProb.Caption"), CheckForNullValue(opportunity.CloseProbability)); emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppComments.Caption"), CheckForNullValue(opportunity.Notes)); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppValue.Caption")); //emailBody += BusinessRuleHelper.AccountingSystemHandlesSO() // ? String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"), // curERPOpenBaseSalesPotential.FormattedText) // : String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"), // curOpenBaseSalesPotential.FormattedText); emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppWeighted.Caption"), curBaseWeighted.FormattedText); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppSummary.Caption")); if (oppWon || oppLost) { emailBody += String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppWonLostSummary.Caption").ToString(), dtpClosedWonSummary.Text, Convert.ToString(opportunity.DaysOpen))); emailBody += oppWon ? String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppReasonWon.Caption").ToString(), CheckForNullValue(opportunity.Reason))) : String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppReasonLost.Caption").ToString(), CheckForNullValue(opportunity.Reason))); } else { emailBody += String.Format("{0} \r\n", String.Format(GetLocalResourceObject("EmailOppStageSummary.Caption").ToString(), CheckForNullValue(opportunity.Stage))); } emailBody += String.Format("{0} \r\n\r\n", String.Format(GetLocalResourceObject("lblEmailOppType.Caption").ToString(), CheckForNullValue(opportunity.Type))); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppProducts.Caption")); oppProducts = Enumerable.Aggregate(opportunity.Products, oppProducts, (current, oppProduct) => current + String.Format("{0} ({1}); ", oppProduct.Product, oppProduct.Quantity)); if (!string.IsNullOrEmpty(oppProducts)) emailBody += String.Format("{0} \r\n\r\n", CheckForNullValue(oppProducts.Substring(0, oppProducts.Length - 2))); if (oppWon || oppLost) emailBody += String.Format("{0} \r\n{1} \r\n\r\n", GetLocalResourceObject("EmailOppCompetitors.Caption"), GetOpportunityCompetitors()); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppContacts.Caption")); emailBody = Enumerable.Aggregate(opportunity.Contacts, emailBody, (current, oppContact) => current + String.Format("{0} \r\n", String.Format("{0}, {1}; {2}", oppContact.Contact.Name, oppContact.Contact.Title, oppContact.SalesRole))); return HttpUtility.JavaScriptStringEncode(emailBody); }
public static OpportunityRepresentation from(IOpportunity opp) { OpportunityRepresentation or = new OpportunityRepresentation(); or.ID = opp.Id.ToString(); or.Description = opp.Description; or.EstimatedClose = opp.EstimatedClose ?? DateTime.Now; or.Potential = opp.SalesPotential ?? 0; or.Probability = opp.CloseProbability ?? 0; or.Stage = opp.Stage; or.NextStep = opp.NextStep; or.DaysSinceLastActivity = opp.DaysSinceLastActivity; IActivity act = getNextActivity(opp.Id.ToString()); if (act != null) { or.NextActivityId = act.Id.ToString(); or.NextActivityName = String.Format("{0} <{1}>", (act.Description ?? ""), act.StartDate.ToShortDateString()); } ISalesProcesses sp = Sage.SalesLogix.SalesProcess.Helpers.GetSalesProcess(opp.Id.ToString()); if (sp != null) { IList<ISalesProcessAudit> list = sp.GetSalesProcessAudits(); foreach (ISalesProcessAudit spa in list) { if ((spa.ProcessType == "STAGE") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent)) { or.DaysInStage = sp.DaysInStage(spa.StageId); //break; } if ((spa.ProcessType == "STEP") && (spa.IsCurrent != null) && ((bool)spa.IsCurrent)) { or.NextStep = spa.StepName; } } } return or; }
/// <summary> /// Formats the email body. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <returns></returns> private string FormatEmailBody(IOpportunity opportunity) { IContextService context = ApplicationContext.Current.Services.Get<IContextService>(true); TimeZone timeZone = (TimeZone) context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string oppProducts = String.Empty; bool oppWon = opportunity.Status.Equals(GetLocalResourceObject("Status_ClosedWon").ToString()); bool oppLost = opportunity.Status.Equals(GetLocalResourceObject("Status_ClosedLost").ToString()); string emailBody = String.Format("{0} %0A", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailOppDesc.Caption"), CheckForNullValue(opportunity.Description)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailOppAccount.Caption"), CheckForNullValue(opportunity.Account != null ? opportunity.Account.AccountName : String.Empty)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("EmailOppAcctMgr.Caption"), CheckForNullValue(opportunity.AccountManager)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("EmailOppReseller.Caption"), CheckForNullValue(opportunity.Reseller)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("EmailOppEstClose.Caption"), opportunity.EstimatedClose.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime) opportunity.EstimatedClose).ToString( datePattern) : String.Empty); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("EmailOppCloseProb.Caption"), CheckForNullValue(opportunity.CloseProbability)); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("EmailOppComments.Caption"), CheckForNullValue(opportunity.Notes)); emailBody += String.Format("{0} %0A", GetLocalResourceObject("EmailOppValue.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("EmailOppPotential.Caption"), curOpenBaseSalesPotential.FormattedText); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("EmailOppWeighted.Caption"), curBaseWeighted.FormattedText); emailBody += String.Format("{0} %0A", GetLocalResourceObject("EmailOppSummary.Caption")); if (oppWon || oppLost) { emailBody += String.Format("{0} %0A", String.Format( GetLocalResourceObject("EmailOppWonLostSummary.Caption").ToString(), dtpClosedWonSummary.Text, Convert.ToString(opportunity.DaysOpen))); if (oppWon) emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("EmailOppReasonWon.Caption").ToString(), CheckForNullValue(opportunity.Reason))); else emailBody += String.Format("{0} %0A", String.Format( GetLocalResourceObject("EmailOppReasonLost.Caption").ToString(), CheckForNullValue(opportunity.Reason))); } else { emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("EmailOppStageSummary.Caption").ToString(), CheckForNullValue(opportunity.Stage))); } emailBody += String.Format("{0} %0A%0A", String.Format(GetLocalResourceObject("lblEmailOppType.Caption").ToString(), CheckForNullValue(opportunity.Type))); emailBody += String.Format("{0} %0A", GetLocalResourceObject("EmailOppProducts.Caption")); foreach (IOpportunityProduct oppProduct in opportunity.Products) oppProducts += String.Format("{0} ({1}); ", oppProduct.Product, oppProduct.Quantity); if (!string.IsNullOrEmpty(oppProducts)) emailBody += String.Format("{0} %0A%0A", CheckForNullValue(oppProducts.Substring(0, oppProducts.Length - 2))); if (oppWon || oppLost) emailBody += String.Format("{0} %0A{1} %0A%0A", GetLocalResourceObject("EmailOppCompetitors.Caption"), GetOpportunityCompetitors()); emailBody += String.Format("{0} %0A", GetLocalResourceObject("EmailOppContacts.Caption")); foreach (IOpportunityContact oppContact in opportunity.Contacts) emailBody += String.Format("{0} %0A", String.Format("{0}, {1}; {2}", oppContact.Contact.Name, oppContact.Contact.Title, oppContact.SalesRole)); return PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20")); }
private bool ProductIsAssociatedToOpportunity(IOpportunity opportunity, IProduct product) { bool isInList = false; foreach (IOpportunityProduct op in opportunity.Products) { if (op.Product.Id.Equals(product.Id)) { isInList = true; break; } } return isInList; }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(IOpportunity opportunity, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById<IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) myRate = myExchangeRate.Rate.GetValueOrDefault(1); string currentCode = opportunity.ExchangeRateCode; curOpenSalesPotential.CurrentCode = currentCode; curOpenSalesPotential.ExchangeRate = exchangeRate; curMyCurSalesPotential.CurrentCode = myCurrencyCode; curMyCurSalesPotential.ExchangeRate = myRate; curActualWon.CurrentCode = currentCode; curActualWon.ExchangeRate = exchangeRate; curMyCurActualWon.CurrentCode = myCurrencyCode; curMyCurActualWon.ExchangeRate = myRate; curPotentialLost.CurrentCode = currentCode; curPotentialLost.ExchangeRate = exchangeRate; curMyCurPotentialLost.CurrentCode = myCurrencyCode; curMyCurPotentialLost.ExchangeRate = myRate; curWeighted.CurrentCode = currentCode; curWeighted.ExchangeRate = exchangeRate; curMyCurWeighted.CurrentCode = myCurrencyCode; curMyCurWeighted.ExchangeRate = myRate; }
public void Publish(IOpportunity opportunity) { _EventAggregator.Publish(opportunity); }