/// <summary> /// Sets the user option defaults. /// </summary> /// <param name="activity">The activity.</param> private void SetUserOptionDefaults(Sage.SalesLogix.Activity.Activity activity) { IUserOptionsService userOption = ApplicationContext.Current.Services.Get <IUserOptionsService>(); string alarmLeadUnit = userOption.GetCommonOption("AlarmDefaultLead", "ActivityAlarm"); string alarmLeadValue = userOption.GetCommonOption("AlarmDefaultLeadValue", "ActivityAlarm"); int alarmLeadMinutes = 15; //default if ((alarmLeadUnit != "") && (alarmLeadValue != "")) { try { alarmLeadMinutes = Convert.ToInt32(alarmLeadValue); } catch { alarmLeadMinutes = 15; } switch (alarmLeadUnit) { case "Days": alarmLeadMinutes = alarmLeadMinutes * 24 * 60; break; case "Hours": alarmLeadMinutes = alarmLeadMinutes * 60; break; } } activity.ReminderDuration = alarmLeadMinutes; }
private void SaveValues() { IAddress conaddress = Sage.Platform.EntityFactory.Create <IAddress>(); conaddress.Address1 = txtAddress1.Text; conaddress.Address2 = txtAddress2.Text; conaddress.City = txtCity.Text; conaddress.State = State.PickListValue; conaddress.PostalCode = txtPostal.Text; conaddress.Country = Country.PickListValue; conaddress.Description = GetLocalResourceObject("rscMailingDescription").ToString(); IAccount acc = Sage.Platform.EntityFactory.Create <IAccount>(); string ownerId = GetConfigValue(WebUserConfigOptions.LeadOwner); ownerId = ((ownerId == null) ? "SYST00000001" : ownerId); acc.Owner = Owner.GetByOwnerId(ownerId); acc.DoNotSolicit = false; acc.Type = GetConfigValue(WebUserConfigOptions.AccountType); acc.SubType = GetConfigValue(WebUserConfigOptions.AccountSubType); acc.AccountManager = Sage.Platform.EntityFactory.GetById <Sage.Entity.Interfaces.IUser>(GetConfigValue(WebUserConfigOptions.AccountManagerId)); if (rblRepresent.SelectedIndex == 0) { acc.AccountName = txtCompany.Text; acc.Division = txtDivision.Text; acc.MainPhone = txtCompanyPhone.Text; acc.TollFree = txtTollFree.Text; acc.Fax = txtCompanyFax.Text; acc.Industry = (Industry.PickListValue.Length > 63) ? Industry.PickListValue.Substring(0, 63) : Industry.PickListValue; acc.WebAddress = txtCompanyWeb.Text; double rev; if (Double.TryParse(txtRevenues.Text, out rev)) { acc.Revenue = (decimal)rev; } IAddress accaddress = Sage.Platform.EntityFactory.Create <IAddress>(); accaddress.Address1 = txtCompanyAddress.Text; accaddress.Address2 = txtCompanyAddress2.Text; accaddress.City = txtCompanyCity.Text; accaddress.State = CompanyState.PickListValue; accaddress.PostalCode = txtCompanyPostal.Text; accaddress.Country = CompanyCountry.PickListValue; accaddress.Description = GetLocalResourceObject("rscMailingDescription").ToString(); acc.Address = accaddress; acc.ShippingAddress = accaddress; acc.Save(); accaddress.EntityId = acc.Id.ToString(); accaddress.Save(); } else { acc.AccountName = txtLastName.Text + ", " + txtFirstName.Text; acc.MainPhone = txtPhone.Text; acc.Fax = txtFax.Text; acc.Address = conaddress; acc.ShippingAddress = conaddress; acc.Save(); } IContact con = Sage.Platform.EntityFactory.Create <IContact>(); con.FirstName = txtFirstName.Text; con.LastName = txtLastName.Text; con.Prefix = ddlPrefix.Text; con.Suffix = txtSuffix.Text; con.Salutation = txtFirstName.Text; con.Title = txtTitle.PickListValue; con.WorkPhone = txtPhone.Text; con.HomePhone = txtHomePhone.Text; con.Fax = txtFax.Text; con.Mobile = txtMobile.Text; con.Pager = txtPager.Text; con.PinNumber = txtPin.Text; con.WebAddress = txtWebUrl.Text; con.Email = txtEmail.Text; con.Address = conaddress; con.DoNotEmail = false; con.DoNotFax = false; con.DoNotMail = false; con.DoNotPhone = false; con.DoNotSolicit = false; con.Account = acc; con.AccountName = acc.AccountName; con.Owner = acc.Owner; con.Save(); conaddress.EntityId = con.Id.ToString(); conaddress.Save(); IContactLeadSource cl = Sage.Platform.EntityFactory.Create <IContactLeadSource>(); cl.Contact = con; string howDidYouHear = ddlHowDidYouHear.SelectedValue; if (!string.IsNullOrEmpty(howDidYouHear)) { cl.LeadSource = Sage.Platform.EntityFactory.GetById <ILeadSource>(howDidYouHear); } cl.LeadDate = DateTime.Now; cl.Save(); Sage.SalesLogix.Activity.Activity act = Sage.Platform.EntityFactory.Create <Sage.SalesLogix.Activity.Activity>(); act.ContactId = con.Id.ToString(); act.AccountId = acc.Id.ToString(); act.Description = GetLocalResourceObject("rscWebLeadFollowupDescription").ToString(); act.StartDate = DateTime.Now; act.Timeless = true; act.Alarm = false; act.AlarmTime = DateTime.Now; act.OriginalDate = DateTime.Now; switch (ddlHowContact.SelectedValue) { case "phone": act.Type = ActivityType.atPhoneCall; break; case "fax": act.Type = ActivityType.atToDo; act.Description += GetLocalResourceObject("rscDescSuffixFax").ToString(); break; case "mail": act.Type = ActivityType.atToDo; act.Description += GetLocalResourceObject("rscDescSuffixMail").ToString(); break; case "e-mail": act.Type = ActivityType.atToDo; act.Description += GetLocalResourceObject("rscDescSuffixEmail").ToString(); break; default: return; //don't save the activity if no type } act.Attendees.Add(GetConfigValue(WebUserConfigOptions.AccountManagerId)); act.Save(); }