/// <summary> /// Handles the OnClick event of the Save 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 Save_OnClick(object sender, EventArgs e) { var user = (IUser)BindingSource.Current; var userId = user.Id.ToString(); _userOptionService = PageWorkItem.BuildTransientItem <UserOptionsService>(); _userOptionService.SetUserId(userId); _userOptionService.SetCommonOption("InsertSecCodeID", "General", ownAccount.LookupResultValue.ToString(), !chkbxAllowChange.Checked); switch (cboTemplateType.SelectedIndex) { // Contact case 0: // Contact _userOptionService.SetCommonOption("DefaultMemoTemplate", "General", txtEmailBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultMemoTemplateID", "General", txtEmailBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLetterTemplate", "General", txtLetterBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLetterTemplateID", "General", txtLetterBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultFaxTemplate", "General", txtFaxBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultFaxTemplateID", "General", txtFaxBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); break; // Lead case 1: _userOptionService.SetCommonOption("DefaultLeadMemoTemplate", "General", txtEmailBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLeadMemoTemplateID", "General", txtEmailBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLeadLetterTemplate", "General", txtLetterBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLeadLetterTemplateID", "General", txtLetterBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLeadFaxTemplate", "General", txtFaxBaseTemplate.Text, !chkbxAllowChangeTemplates.Checked); _userOptionService.SetCommonOption("DefaultLeadFaxTemplateID", "General", txtFaxBaseTemplateId.Value, !chkbxAllowChangeTemplates.Checked); break; } }
/// <summary> /// Loads the view. /// </summary> private void LoadView() { var user = (IUser)BindingSource.Current; var userId = user.Id.ToString(); if (_userOptionService == null) { _userOptionService = PageWorkItem.BuildTransientItem <UserOptionsService>(); } _userOptionService.SetUserId(userId); ownAccount.LookupResultValue = _userOptionService.GetCommonOption("InsertSecCodeID", "General", false, Owner.SystemEveryone, String.Empty); chkbxAllowChange.Checked = !_userOptionService.GetCommonOptionLocked("InsertSecCodeID", "General"); chkbxAllowChangeTemplates.Checked = !_userOptionService.GetCommonOptionLocked("DefaultMemoTemplate", "General"); switch (cboTemplateType.SelectedIndex) { // Contact case 0: txtEmailBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultMemoTemplate", "General"); txtEmailBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultMemoTemplateID", "General"); txtLetterBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultLetterTemplate", "General"); txtLetterBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultLetterTemplateID", "General"); txtFaxBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultFaxTemplate", "General"); txtFaxBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultFaxTemplateID", "General"); break; // Lead case 1: txtEmailBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultLeadMemoTemplate", "General"); txtEmailBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultLeadMemoTemplateID", "General"); txtLetterBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultLeadLetterTemplate", "General"); txtLetterBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultLeadLetterTemplateID", "General"); txtFaxBaseTemplate.Text = _userOptionService.GetCommonOption("DefaultLeadFaxTemplate", "General"); txtFaxBaseTemplateId.Value = _userOptionService.GetCommonOption("DefaultLeadFaxTemplateID", "General"); break; } if ((user.Type == UserType.WebViewer) || (user.Type == UserType.AddOn)) { txtFaxBaseTemplate.Attributes.Add("DISABLED", ""); txtFaxBaseTemplate.Attributes["onclick"] = ""; txtLetterBaseTemplate.Attributes.Add("DISABLED", ""); txtLetterBaseTemplate.Attributes["onclick"] = ""; txtEmailBaseTemplate.Attributes.Add("DISABLED", ""); txtEmailBaseTemplate.Attributes["onclick"] = ""; chkbxAllowChangeTemplates.Enabled = false; } }
///// <summary> ///// Gets the system info option. ///// </summary> ///// <param name="optionName">Name of the option.</param> ///// <returns></returns> //public static Boolean GetSystemInfoOption(String optionName) //{ //This function has been depricated, use ISystemOptionsService instead. //SystemInformation systemInfo = SystemInformationRules.GetSystemInfo(); //DelphiStreamReader stream = new DelphiStreamReader(systemInfo.Data); //TValueType valueType; //if (stream.FindProperty(optionName, out valueType)) // return valueType.Equals(TValueType.vaTrue); //return false; //} /// <summary> /// Adds the base and user currency rates to client context. /// </summary> /// <description> /// Assemble the multi-currency rate information and add it to the ClientContextService for use by the currency control and column. /// </description> /// <param name="pageWorkItem">The page work item.</param> public static void AddBaseUserCurrencyRatesToClientContext(PageWorkItem pageWorkItem) { //Assemble the multi-currency rate information and add it to the ClientContextService for use by the //Currency column control. var ccs = pageWorkItem.Services.Get<ClientContextService>(); //Get Exchange Rate Type: Base Rate. var optionSvc = ApplicationContext.Current.Services.Get<ISystemOptionsService>(); var baseCode = optionSvc.BaseCurrency; if (!string.IsNullOrEmpty(baseCode)) { //Set the rate from My Rate code. var erBase = EntityFactory.GetById<IExchangeRate>(baseCode); var baseRate = erBase.Rate.GetValueOrDefault(1).ToString(); if (baseRate == "0") baseRate = "1"; //Set Base Rate and Code on the service. if (ccs.CurrentContext.ContainsKey("BaseRateCode")) { ccs.CurrentContext["BaseRateCode"].Equals(baseCode); } else { ccs.CurrentContext.Add("BaseRateCode", baseCode); } if (ccs.CurrentContext.ContainsKey("BaseRate")) { ccs.CurrentContext["BaseRate"].Equals(baseRate); } else { ccs.CurrentContext.Add("BaseRate", baseRate); } } //Get Exchange Rate Type, My Rate from User Options Service. var userOption = ApplicationContext.Current.Services.Get<IUserOptionsService>(); var userExCode = !string.IsNullOrEmpty(userOption.GetCommonOption("Currency", "General")) ? userOption.GetCommonOption("Currency", "General") : baseCode; if (!string.IsNullOrEmpty(userExCode)) { //Set the rate from My Rate code. var er = EntityFactory.GetById<IExchangeRate>(userExCode); var userExRate = er.Rate.GetValueOrDefault(1).ToString(); if (userExRate == "0") userExRate = "1"; //Set My Rate and Code on the service. if (ccs.CurrentContext.ContainsKey("MyRateCode")) { ccs.CurrentContext["MyRateCode"].Equals(userExCode); } else { ccs.CurrentContext.Add("MyRateCode", userExCode); } if (ccs.CurrentContext.ContainsKey("MyRate")) { ccs.CurrentContext["MyRate"].Equals(userExRate); } else { ccs.CurrentContext.Add("MyRate", userExRate); } } }
///// <summary> ///// Gets the system info option. ///// </summary> ///// <param name="optionName">Name of the option.</param> ///// <returns></returns> //public static Boolean GetSystemInfoOption(String optionName) //{ //This function has been depricated, use ISystemOptionsService instead. //SystemInformation systemInfo = SystemInformationRules.GetSystemInfo(); //DelphiStreamReader stream = new DelphiStreamReader(systemInfo.Data); //TValueType valueType; //if (stream.FindProperty(optionName, out valueType)) // return valueType.Equals(TValueType.vaTrue); //return false; //} /// <summary> /// Adds the base and user currency rates to client context. /// </summary> /// <description> /// Assemble the multi-currency rate information and add it to the ClientContextService for use by the currency control and column. /// </description> /// <param name="pageWorkItem">The page work item.</param> public static void AddBaseUserCurrencyRatesToClientContext(PageWorkItem pageWorkItem) { //Assemble the multi-currency rate information and add it to the ClientContextService for use by the //Currency column control. var ccs = pageWorkItem.Services.Get <ClientContextService>(); //Get Exchange Rate Type: Base Rate. var optionSvc = ApplicationContext.Current.Services.Get <ISystemOptionsService>(); var baseCode = optionSvc.BaseCurrency; if (!string.IsNullOrEmpty(baseCode)) { //Set the rate from My Rate code. var erBase = EntityFactory.GetById <IExchangeRate>(baseCode); var baseRate = erBase.Rate.GetValueOrDefault(1).ToString(); if (baseRate == "0") { baseRate = "1"; } //Set Base Rate and Code on the service. if (ccs.CurrentContext.ContainsKey("BaseRateCode")) { ccs.CurrentContext["BaseRateCode"].Equals(baseCode); } else { ccs.CurrentContext.Add("BaseRateCode", baseCode); } if (ccs.CurrentContext.ContainsKey("BaseRate")) { ccs.CurrentContext["BaseRate"].Equals(baseRate); } else { ccs.CurrentContext.Add("BaseRate", baseRate); } } //Get Exchange Rate Type, My Rate from User Options Service. var userOption = ApplicationContext.Current.Services.Get <IUserOptionsService>(); var userExCode = !string.IsNullOrEmpty(userOption.GetCommonOption("Currency", "General")) ? userOption.GetCommonOption("Currency", "General") : baseCode; if (!string.IsNullOrEmpty(userExCode)) { //Set the rate from My Rate code. var er = EntityFactory.GetById <IExchangeRate>(userExCode); var userExRate = er.Rate.GetValueOrDefault(1).ToString(); if (userExRate == "0") { userExRate = "1"; } //Set My Rate and Code on the service. if (ccs.CurrentContext.ContainsKey("MyRateCode")) { ccs.CurrentContext["MyRateCode"].Equals(userExCode); } else { ccs.CurrentContext.Add("MyRateCode", userExCode); } if (ccs.CurrentContext.ContainsKey("MyRate")) { ccs.CurrentContext["MyRate"].Equals(userExRate); } else { ccs.CurrentContext.Add("MyRate", userExRate); } } }