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);
    }
        public IHttpActionResult SignOut()
        {
            try
            {
                var caller = User as ClaimsPrincipal;

                var userName = caller?.Claims.FirstOrDefault(x => x.Type == "preferred_username")?.Value;
                var client   = caller?.Claims.FirstOrDefault(x => x.Type == "client_id")?.Value;
                var session  = new AccessTokenSession
                {
                    ClientId = client,
                    userId   = userName
                };
                if (StaticData.AccessToken.ContainsKey(session))
                {
                    StaticData.AccessToken.Remove(session);
                }

                var res = new ApiResponse <object>
                {
                    Message = ((int)RuleExceptionCodeCommon.ValidResult).ToString()
                };
                return(Json(res));
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                var res = new ApiResponse <object>
                {
                    Message = BusinessRuleHelper.GetExceptionCode(ex).ToString()
                };

                return(Json(res));
            }
        }
        public IHttpActionResult GetAllAcademicFiels()
        {
            ApiResponse <List <AcademicField> > res;

            try
            {
                var result = AcademicFieldProvider.GetAll().ToList();
                res = new ApiResponse <List <AcademicField> >
                {
                    Result    = result,
                    BRuleCode = (int)RuleExceptionCodeCommon.ValidResult,
                    Message   = RuleExceptionCodeCommon.ValidResult.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <List <AcademicField> >
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
            }
            return(Json(res));
        }
示例#4
0
    /// <summary>
    /// Loads the view.
    /// </summary>
    private void LoadView()
    {
        var value = BusinessRuleHelper.GetPickListValueByCode("Lead Source Status", "A");

        if (!String.IsNullOrEmpty(value))
        {
            var leadSourcePreFilter = new LookupPreFilter {
                PropertyName = "Status", OperatorCode = "=", FilterValue = value, PropertyType = "System.String"
            };
            luLeadSource.LookupPreFilters.Add(leadSourcePreFilter);
        }
        //New Stage
        if (_stage.Id == null)
        {
            _stage.Campaign     = (ICampaign)_parentEntity;
            _stage.Status       = GetLocalResourceObject("Status_Open").ToString();
            _stage.CampaignCode = _stage.Campaign.CampaignCode;
            _stage.StartDate    = DateTime.UtcNow;
        }
        else //Existing Stage
        {
            if (_mode == "Complete")//Complete the stage.
            {
                _stage.EndDate = DateTime.UtcNow;
                _stage.Status  = GetLocalResourceObject("Status_Completed").ToString();
            }
        }
        grdTasks.DataSource = _stage.CampaignTasks;
        grdTasks.DataBind();
        LoadBudget(_stage);
    }
示例#5
0
        public IHttpActionResult SavePartyBasicDitails(ApiRequest <RetailParty> request)
        {
            ApiResponse <List <PartyRole> > res;

            try
            {
                PartyProvider.SavePartyBasicInformation(request);
                res = new ApiResponse <List <PartyRole> >
                {
                    // Result = mode.ToList(),
                    BRuleCode = (int)RuleExceptionCodeCommon.ValidResult,
                    Message   = RuleExceptionCodeCommon.ValidResult.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <List <PartyRole> >
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
            }
            return(Json(res));
        }
    /// <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;
    }
示例#7
0
        public IHttpActionResult SaveOrUpdatePartyRoles(ApiRequest <PartyRole> customer)
        {
            ApiResponse <PartyRole> res;

            try
            {
                customer.Entity.CreatedBy = customer.Entity.ModifiedBy = customer.AuthenticatedUserName;
                PartyRolesProvider.SaveOrUpdate(customer.Entity);
                res = new ApiResponse <PartyRole>
                {
                    BRuleCode = (int)RuleExceptionCodeCommon.ValidResult,
                    Message   = RuleExceptionCodeCommon.ValidResult.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <PartyRole>
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
            }
            return(Json(res));
        }
示例#8
0
        public IHttpActionResult GetAllPartyRoles()
        {
            ApiResponse <List <PartyRole> > res;

            try
            {
                var mode = PartyRolesProvider.GetAllPartyRoles();
                res = new ApiResponse <List <PartyRole> >
                {
                    Result    = mode.ToList(),
                    BRuleCode = (int)RuleExceptionCodeCommon.ValidResult,
                    Message   = RuleExceptionCodeCommon.ValidResult.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <List <PartyRole> >
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
            }
            return(Json(res));
        }
示例#9
0
    /// <summary>
    /// Loads the view with the defaulted data.
    /// </summary>
    protected void LoadView()
    {
        ImportManager importManager = GetImportManager();

        if (importManager != null)
        {
            if (importManager.SourceFileName != null)
            {
                txtImportFile.Value = importManager.SourceFileName;
            }
            chkAddToGroup.Checked = importManager.Options.AddToGroup;
            if (chkAddToGroup.Checked)
            {
                groupOptions.Style.Add("display", String.Empty);
            }
            SetDefaultTargetProperties(importManager);
            LoadAddHocGroups();
            Page.Session["importManager"] = importManager;
        }
        IsImportPathValid();
        var value = BusinessRuleHelper.GetPickListValueByCode("Lead Source Status", "A");

        if (!String.IsNullOrEmpty(value))
        {
            var leadSourcePreFilter = new LookupPreFilter {
                PropertyName = "Status", OperatorCode = "=", FilterValue = value, PropertyType = "System.String"
            };
            lueLeadSource.LookupPreFilters.Add(leadSourcePreFilter);
        }
    }
示例#10
0
        public IHttpActionResult GetPageTypeEnum()
        {
            ApiPagedCollectionResponse <EnumResponseDto> res;

            try
            {
                var pageType = Enum.GetValues(typeof(PageType)).Cast <PageType>();

                var lsDtos = pageType.Select(trType => new EnumResponseDto
                {
                    Code  = ((int)trType).SafeString(),
                    Title = trType.SafeString()
                }).ToList();

                res = new ApiPagedCollectionResponse <EnumResponseDto>
                {
                    Result       = lsDtos,
                    TotalRecords = lsDtos.Count,
                    Message      = MessageResultEnum.OperationSuccessFullyDone.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiPagedCollectionResponse <EnumResponseDto>
                {
                    Message   = MessageResultEnum.OperationFailed.GetEnumDescription(),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
                return(Json(res));
            }
            return(Json(res));
        }
示例#11
0
        public IHttpActionResult GetAllServiceRepositories(
            [FromBody] BaseReportFilter <ReportFilter> filter)
        {
            var res = new ApiPagedCollectionResponse <ServiceRepositoryDto>
            {
                Result = new List <ServiceRepositoryDto>()
            };

            try
            {
                var repo = AuthorizeProvider.GetAllServiceRepositories(filter);
                repo = SetKendoFilter(filter, repo);


                res = new ApiPagedCollectionResponse <ServiceRepositoryDto>
                {
                    Result = repo,

                    Message      = ((int)RuleExceptionCodeCommon.ValidResult).ToString(),
                    TotalRecords = repo.Count
                };
            }

            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res.Message = BusinessRuleHelper.GetExceptionCode(ex).ToString();
            }

            return(Json(res));
        }
    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();
        }
    }
        public IHttpActionResult SaveOrUpdateRegion(ApiRequest <Region> request)
        {
            ApiResponse <List <Region> > res;

            try
            {
                if (request.Entity.Id > 0)
                {
                    request.Entity.Modified   = DateTime.Now;
                    request.Entity.ModifiedBy = request.AuthenticatedUserName;
                }
                else
                {
                    request.Entity.Created   = DateTime.Now;
                    request.Entity.CreatedBy = request.AuthenticatedUserName;
                }
                var result = RegionProvider.SaveOrUpdate(request.Entity);
                res = new ApiResponse <List <Region> >
                {
                    //Result = request.Entity,
                    BRuleCode = (int)RuleExceptionCodeCommon.ValidResult,
                    Message   = RuleExceptionCodeCommon.ValidResult.GetEnumDescription()
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <List <Region> >
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };
            }
            return(Json(res));
        }
示例#14
0
 protected IContact GetAssignToContact()
 {
     if (!chkAssignToSameContact.Checked)
     {
         // get the primary contact for the source account - if it is not the current contact
         IContact assignToContact = BusinessRuleHelper.GetPrimaryContact(Contact.Account);
         if (assignToContact != null && !assignToContact.Equals(Contact))
         {
             return(assignToContact);
         }
     }
     else
     {
         IContact assignToContact = (IContact)((lueReassignOpenItems.LookupResultValue != null) ?
                                               lueReassignOpenItems.LookupResultValue :
                                               ((lueReassignClosedItems.LookupResultValue != null) ?
                                                lueReassignClosedItems.LookupResultValue :
                                                ((lueReassignSupportItems.LookupResultValue != null) ?
                                                 lueReassignSupportItems.LookupResultValue :
                                                 BusinessRuleHelper.GetPrimaryContact(Contact.Account))));
         if (assignToContact != null && !assignToContact.Equals(Contact))
         {
             return(assignToContact);
         }
     }
     return(null);
 }
示例#15
0
        public IHttpActionResult GetAllPageAccessBasedOnRoles(
            [FromBody] BaseReportFilter <ReportFilter> filter)
        {
            var res = new ApiPagedCollectionResponse <FlatServiceAccess>
            {
            };

            try
            {
                var data = AuthorizeProvider.GetAllPageAccessBasedOnRoles(Applications.IranMarketerFund);

                res = new ApiPagedCollectionResponse <FlatServiceAccess>
                {
                    Message      = (RuleExceptionCodeCommon.ValidResult).GetEnumDescription(),
                    BRuleCode    = (int)RuleExceptionCodeCommon.ValidResult,
                    Result       = data,
                    TotalRecords = data.Count
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res.Message   = BusinessRuleHelper.GetException(ex);
                res.BRuleCode = BusinessRuleHelper.GetExceptionCode(ex);
            }
            return(Json(res));
        }
示例#16
0
    /// <summary>
    /// Updates controls which are set to use multi currency.
    /// </summary>
    /// <param name="salesOrder">The sales order.</param>
    /// <param name="exchangeRate">The exchange rate.</param>
    private void UpdateMultiCurrencyExchangeRate(ISalesOrder salesOrder, 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);
        }
        curDiscount.CurrentCode    = salesOrder.CurrencyCode;
        curDiscount.ExchangeRate   = exchangeRate;
        curMyDiscount.CurrentCode  = myCurrencyCode;
        curMyDiscount.ExchangeRate = myRate;
        curSubTotal.CurrentCode    = String.IsNullOrEmpty(lueCurrencyCode.LookupResultValue.ToString())
                              ? salesOrder.CurrencyCode
                              : lueCurrencyCode.LookupResultValue.ToString();
        curTotal.CurrentCode       = curSubTotal.CurrentCode;
        curTotal.ExchangeRate      = exchangeRate;
        curMyTotal.CurrentCode     = myCurrencyCode;
        curMyTotal.ExchangeRate    = myRate;
        curSubTotal.CurrentCode    = salesOrder.CurrencyCode;
        curSubTotal.ExchangeRate   = exchangeRate;
        curMySubTotal.CurrentCode  = myCurrencyCode;
        curMySubTotal.ExchangeRate = myRate;
        curTax.CurrentCode         = salesOrder.CurrencyCode;
        curTax.ExchangeRate        = exchangeRate;
        curMyTax.CurrentCode       = myCurrencyCode;
        curMyTax.ExchangeRate      = myRate;
        curShipping.CurrentCode    = salesOrder.CurrencyCode;
        curShipping.ExchangeRate   = exchangeRate;
        curMyShipping.CurrentCode  = myCurrencyCode;
        curMyShipping.ExchangeRate = myRate;
    }
示例#17
0
 private void LoadAccountTasks(EntityPage page)
 {
     if (page.IsDetailMode)
     {
         divEntityAccountList.Style.Add("display", "none");
         divEntityAccountDetails.Style.Add("display", "block");
         IAccount account = EntityFactory.GetRepository <IAccount>().Get(page.EntityContext.EntityID);
         if (account == null)
         {
             return;
         }
         if (BusinessRuleHelper.IsIntegrationContractEnabled())
         {
             if (account.PromotedToAccounting.HasValue && account.PromotedToAccounting.Value)
             {
                 lblLinkAccount.Text        = GetLocalResourceObject("lblLinkAnotherAccount.Caption").ToString();
                 lblNotLinkedStatus.Visible = false;
                 lblLinkedStatus.Visible    = true;
                 IAppIdMapping slxFeed = IntegrationHelpers.GetSlxAccountingFeed();
                 lblLinkAccount.Enabled = !slxFeed.RestrictToSingleAccount.HasValue ||
                                          !slxFeed.RestrictToSingleAccount.Value;
                 updateAccountPanel.Update();
             }
             else
             {
                 lblLinkAccount.Text        = GetLocalResourceObject("lblLinkAccount.Caption").ToString();
                 lblNotLinkedStatus.Visible = true;
                 lblLinkedStatus.Visible    = false;
                 lblLinkAccount.Enabled     = true;
             }
         }
         else
         {
             rowlnkLinkAccount.Style.Add("display", "none");
             rowlnkLinkAccount_List.Style.Add("display", "none");
             rowlnkLinkStatus.Style.Add("display", "none");
         }
         lblLastUpdate.Text = String.Format(GetLocalResourceObject("lblLastUpdate.Caption").ToString(),
                                            TimeZone.UTCDateTimeToLocalTime((DateTime)account.ModifyDate));
         if (page.IsNewEntity)
         {
             updateAccountPanel.Update();
         }
     }
     else
     {
         divEntityAccountList.Style.Add("display", "block");
         divEntityAccountDetails.Style.Add("display", "none");
         lblLinkStatus.Visible = false;
         if (!BusinessRuleHelper.IsIntegrationContractEnabled())
         {
             rowlnkLinkAccount.Style.Add("display", "none");
             rowlnkLinkAccount_List.Style.Add("display", "none");
             rowlnkLinkStatus.Style.Add("display", "none");
         }
     }
 }
示例#18
0
    protected IContact GetAssignToContact()
    {
        // get the primary contact for the source account - if it is not the current contact
        IContact assignToContact = BusinessRuleHelper.GetPrimaryContact(Contact.Account);

        if (assignToContact != null && !assignToContact.Equals(Contact))
        {
            return(assignToContact);
        }
        return(null);
    }
示例#19
0
    /// <summary>
    /// Handles the Init event of the Page 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 Page_Init(object sender, EventArgs e)
    {
        grdProducts.Columns[6].Visible = BusinessRuleHelper.IsMultiCurrencyEnabled();

        _Context = ApplicationContext.Current.Services.Get <IContextService>();
        _State   = _Context.GetContext("AddProductStateInfo") as AddProductStateInfo;
        if (_State == null)
        {
            _State = new AddProductStateInfo();
        }
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        OpportunitiesOptions options = null;

        options = OpportunitiesOptions.Load(Server.MapPath(@"App_Data\LookupValues"));
        // set defaults
        if (options.OpportunityStatus != String.Empty)
        {
            pklOpportunityStatus.PickListValue = options.OpportunityStatus;
        }
        if (options.OpportunityType != String.Empty)
        {
            pklOpportunityType.PickListValue = options.OpportunityType;
        }
        if (options.Probability != String.Empty)
        {
            pklOpportunityProbability.PickListValue = options.Probability;
        }
        Utility.SetSelectedValue(_estimatedCloseToMonths, options.EstimatedCloseToMonths);

        //Set the default to none if ther is not a match.
        try
        {
            _salesProcess.SelectedValue = options.SalesProcess;
        }
        catch (Exception)
        {
            _salesProcess.SelectedValue = "NONE";
        }

        if (options.DefaultContacts != String.Empty)
        {
            _defaultContacts.SelectedIndex = Convert.ToInt32(options.DefaultContacts);
        }
        _useDefaultNamingConventions.Checked    = options.UseDefaultNamingConventions;
        _estimatedCloseToLastDayOfMonth.Checked = options.EstimatedCloseToLastDayOfMonth;
        var systemInfo = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.SalesLogix.Services.ISystemOptionsService>(true);

        if (systemInfo.MultiCurrency)
        {
            lblDefCurrency.Visible = true;
            luDefCurrency.Visible  = true;
            if (options.DefCurrencyCode != String.Empty)
            {
                luDefCurrency.LookupResultValue = EntityFactory.GetById <IExchangeRate>(options.DefCurrencyCode);
            }
        }
        else
        {
            lblDefCurrency.Visible = false;
            luDefCurrency.Visible  = false;
        }
        _addProducts.Visible = !BusinessRuleHelper.IsIntegrationContractEnabled();
    }
示例#21
0
    private void PopulateTree()
    {
        //ToDo: Refactor: Use Plugin manager to do this
        XmlDocument xmlTemplates = BusinessRuleHelper.GetMailMergeTemplates(_userId);

        if (xmlTemplates != null)
        {
            //Todo: Refactor: Remove inline storage of template list.
            templateXml.Text = xmlTemplates.OuterXml;
        }
    }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ISalesOrder salesOrder = BindingSource.Current as ISalesOrder;

        if (salesOrder != null)
        {
            if (BusinessRuleHelper.IsMultiCurrencyEnabled())
            {
                UpdateMultiCurrencyExchangeRate(salesOrder, salesOrder.ExchangeRate.GetValueOrDefault(1));
            }
        }
    }
示例#23
0
    /// <summary>
    /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e)
    {
        var value = BusinessRuleHelper.GetPickListValueByCode("Lead Source Status", "A");

        if (!String.IsNullOrEmpty(value))
        {
            var leadSourcePreFilter = new LookupPreFilter {
                PropertyName = "Status", OperatorCode = "=", FilterValue = value, PropertyType = "System.String"
            };
            lueResponseLeadSource.LookupPreFilters.Add(leadSourcePreFilter);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var quote = BindingSource.Current as IQuote;

        if (quote != null)
        {
            if (BusinessRuleHelper.IsMultiCurrencyEnabled())
            {
                UpdateMultiCurrencyExchangeRate(quote, quote.ExchangeRate.GetValueOrDefault(1));
            }
        }
    }
    /// <summary>
    /// Called when [form bound].
    /// </summary>
    protected override void OnFormBound()
    {
        if (ClientBindingMgr != null)
        {
            // register these with the ClientBindingMgr so they can do their thing without causing the dirty data warning message...
            ClientBindingMgr.RegisterBoundControl(lnkEmail);
        }
        var salesOrder = BindingSource.Current as ISalesOrder;

        if (salesOrder != null)
        {
            if (BusinessRuleHelper.IsMultiCurrencyEnabled())
            {
                lueCurrencyCode.LookupResultValue =
                    EntityFactory.GetRepository <IExchangeRate>()
                    .FindFirstByProperty("CurrencyCode", salesOrder.CurrencyCode);
            }
            lueCurrencyCode.SeedValue = GetPeriodIdForCurrentDate();
            SetDisplayValues();
            double shipping = salesOrder.Freight ?? 0;
            if (string.IsNullOrEmpty(curBaseShipping.FormattedText))
            {
                curBaseShipping.Text = Convert.ToString(shipping);
            }
            if (string.IsNullOrEmpty(curShipping.FormattedText))
            {
                curShipping.Text = Convert.ToString(shipping);
            }
            if (string.IsNullOrEmpty(curMyShipping.FormattedText))
            {
                curMyShipping.Text = Convert.ToString(shipping);
            }
            var systemInfo = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true);
            if (systemInfo.ChangeSalesOrderRate)
            {
                divExchangeRateLabel.Visible = false;
                divExchangeRateText.Visible  = true;
            }
            else
            {
                divExchangeRateLabel.Visible = true;
                divExchangeRateText.Visible  = false;
                if (!string.IsNullOrEmpty(numExchangeRateValue.Text))
                {
                    lblExchangeRateValue.Text = Math.Round(Convert.ToDecimal(numExchangeRateValue.Text), 4).ToString();
                }
            }
        }
    }
    /// <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)
    {
        var    systemInfo = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true);
        string baseCode   = "";

        if (!string.IsNullOrEmpty(systemInfo.BaseCurrency))
        {
            baseCode = systemInfo.BaseCurrency;
        }
        var    currencyCode = EntityFactory.GetById <IExchangeRate>(lueCurrencyCode.LookupResultValue);
        string exhangeCode  = currencyCode != null ? currencyCode.CurrencyCode : opportunity.ExchangeRateCode;

        string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode();
        var    myExchangeRate = EntityFactory.GetRepository <IExchangeRate>()
                                .FindFirstByProperty("CurrencyCode", String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode);
        double myRate = 0;

        if (myExchangeRate != null)
        {
            myRate = myExchangeRate.Rate.GetValueOrDefault(1);
        }

        curOpenBaseSalesPotential.CurrentCode = baseCode;
        curBaseActualWon.CurrentCode          = baseCode;
        curBasePotentialLost.CurrentCode      = baseCode;
        curBaseWeighted.CurrentCode           = baseCode;

        curOpenSalesPotential.CurrentCode = exhangeCode;
        //curOpenSalesPotential.ExchangeRate = exchangeRate;
        curActualWon.CurrentCode = exhangeCode;
        //curActualWon.ExchangeRate = exchangeRate;
        curPotentialLost.CurrentCode = exhangeCode;
        //curPotentialLost.ExchangeRate = exchangeRate;
        curWeighted.CurrentCode  = exhangeCode;
        curWeighted.ExchangeRate = exchangeRate;

        curMyCurSalesPotential.CurrentCode  = myCurrencyCode;
        curMyCurSalesPotential.ExchangeRate = myRate;
        curMyCurActualWon.CurrentCode       = myCurrencyCode;
        curMyCurActualWon.ExchangeRate      = myRate;
        curMyCurPotentialLost.CurrentCode   = myCurrencyCode;
        curMyCurPotentialLost.ExchangeRate  = myRate;
        curMyCurWeighted.CurrentCode        = myCurrencyCode;
        curMyCurWeighted.ExchangeRate       = myRate;

        opportunity.DocSalesPotential = (opportunity.SalesPotential ?? 0) * exchangeRate;
    }
        //[NatianIdFixAttributes]
        public IHttpActionResult Login(UserLoginRequest filter)
        {
            ApiResponse <AuthenticationResponse> res;

            try
            {
                if (filter.ClientPassword.IsNullOrEmpty())
                {
                    filter.ClientPassword = IdentityServerSettings.ClientPassword;
                }

                var token = AuthenticationProvider.Login(filter.UserName, filter.Password, filter.ClientId,
                                                         filter.ClientPassword, IdentityServerSettings.TokenProviderAddress);

                res = new ApiResponse <AuthenticationResponse>
                {
                    Result = token,

                    Message = ((int)RuleExceptionCodeCommon.ValidResult).ToString()
                };

                //var session = new AccessTokenSession
                //{
                //    ClientId = filter.ClientId.ToLower(),
                //    userId = token.ApplicationUser.UserName.ToLower()
                //};

                //if (!token.AccessToken.IsNullOrEmpty())
                //    if (StaticData.AccessToken.ContainsKey(session))
                //        StaticData.AccessToken[session] = token.AccessToken;
                //    else
                //        StaticData.AccessToken.Add(session, token.AccessToken);

                return(Json(res));
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiResponse <AuthenticationResponse>
                {
                    Message   = BusinessRuleHelper.GetException(ex),
                    BRuleCode = BusinessRuleHelper.GetExceptionCode(ex)
                };

                return(Json(res));
            }
        }
示例#28
0
        public IHttpActionResult GetRegisteredUsers(string text = "")
        {
            ApiPagedCollectionResponse <object> res;

            try
            {
                var lst = new List <ApplicationUserDTO>();

                lst = AuthorizeProvider.GetUsers(text);

                var final =
                    lst.Select(
                        x =>
                        new
                {
                    x.UserName,
                    x.DisplayName,
                    x.DisplayNameEn,
                    x.DisplayNameFa,
                    x.Email,
                    x.IsAdmin,
                    x.IsCustomizedAccess,
                    x.PhoneNumber,
                    x.Status
                }).ToList();

                res = new ApiPagedCollectionResponse <object>
                {
                    Message = ((int)RuleExceptionCodeCommon.ValidResult).ToString(),
                    Result  = new List <object> {
                        final.OrderBy(x => x.UserName)
                    },
                    TotalRecords = final.Count
                };
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                res = new ApiPagedCollectionResponse <object>
                {
                    Message = BusinessRuleHelper.GetExceptionCode(ex).ToString()
                };
            }

            return(Json(res));
        }
    /// <summary>
    /// Called when [activating].
    /// </summary>
    protected override void OnActivating()
    {
        lblHowMany.Text = String.Empty;
        FilterOptions options = new FilterOptions();

        SetFilterControls(options);
        AddDistinctGroupItemsToList(lbxContactGroups, "Contact");
        AddDistinctGroupItemsToList(lbxLeadGroups, "Lead");
        var value = BusinessRuleHelper.GetPickListValueByCode("Lead Source Status", "A");

        if (!String.IsNullOrEmpty(value))
        {
            var leadSourcePreFilter = new LookupPreFilter {
                PropertyName = "Status", OperatorCode = "=", FilterValue = value, PropertyType = "System.String"
            };
            lueLeadSource.LookupPreFilters.Add(leadSourcePreFilter);
        }
    }
 private void EditSalesPotential(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType)
 {
     if (DialogService != null)
     {
         DialogService.SetSpecs(200, 400, "EditSalesPotential");
         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();
     }
 }