示例#1
0
        private void _CheckExchangeRate()
        {
            Currency selectedCur = cbCurrencies.SelectedItem as Currency;

            if (!selectedCur.IsPivot)
            {
                _exchangeRate = ServicesProvider.GetInstance().GetExchangeRateServices().SelectExchangeRate(
                    DateTime.Now, selectedCur);
                while (_exchangeRate == null)
                {
                    ExchangeRateForm xrForm = new ExchangeRateForm(DateTime.Now, selectedCur);
                    xrForm.ShowDialog();
                    if (xrForm.ExchangeRate != null)
                    {
                        if (xrForm.ExchangeRate.Currency.Equals(selectedCur) &&
                            xrForm.ExchangeRate.Date.Day.Equals(DateTime.Now.Day))
                        {
                            _exchangeRate = xrForm.ExchangeRate;
                        }
                    }
                }
            }
            else
            {
                _exchangeRate = new ExchangeRate {
                    Rate = 1
                };
            }
        }
示例#2
0
        private bool MaxAmountExceed()
        {
            OCurrency maxGuarantorAmount = ServicesProvider.GetInstance().GetGeneralSettings().MaxGuarantorAmount;
            OCurrency tempAmount;

            if (code.IsPivot)
            {
                tempAmount = _guarantor.Amount;
            }
            else
            {
                ExchangeRateServices rateServices = ServicesProvider.GetInstance().GetExchangeRateServices();
                ExchangeRate         currentRate  = rateServices.SelectExchangeRate(TimeProvider.Now, code);
                if (currentRate == null)
                {
                    ExchangeRateForm xrForm = new ExchangeRateForm(TimeProvider.Now.Date, code);
                    xrForm.ShowDialog();
                    currentRate = xrForm.ExchangeRate;
                }
                tempAmount = _guarantor.Amount / currentRate.Rate;
            }

            if (tempAmount > maxGuarantorAmount)
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        private bool CheckDateChange()
        {
            _exchangeRate = null;
            if (ServicesProvider.GetInstance().GetCurrencyServices().FindAllCurrencies().Count == 1)
            {
                _exchangeRate = new ExchangeRate
                {
                    Currency = _loan.Product.Currency,
                    Date     = _newStartDate,
                    Rate     = 1
                };
            }
            buttonSave.Enabled = false;

            try
            {
                if (!ServicesProvider.GetInstance().GetExchangeRateServices().RateExistsForEachCurrency
                        (ServicesProvider.GetInstance().GetCurrencyServices().FindAllCurrencies(), _newStartDate))
                {
                    buttonAddExchangeRate.Enabled = lblPivotCurrency.Enabled;
                    var xrForm =
                        new ExchangeRateForm(new DateTime(_newStartDate.Year, _newStartDate.Month, _newStartDate.Day),
                                             _loan.Product.Currency);
                    xrForm.ShowDialog();
                }
                _exchangeRate = ServicesProvider.GetInstance().GetAccountingServices().FindExchangeRate(_newStartDate,
                                                                                                        _loan.Product.
                                                                                                        Currency);
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                if (_exchangeRate != null)
                {
                    buttonSave.Enabled       = true;
                    lblPivotCurrency.Visible =
                        ServicesProvider.GetInstance().GetCurrencyServices().FindAllCurrencies().Count > 1 &&
                        !_loan.Product.Currency.IsPivot;
                    lblFeesCurrencyPivot.Visible  = lblPivotCurrency.Visible;
                    buttonAddExchangeRate.Visible = false;
                }
                else
                {
                    buttonSave.Enabled            = false;
                    buttonAddExchangeRate.Enabled = true;
                    lblPivotCurrency.Visible      = true;
                    lblFeesCurrencyPivot.Visible  = true;
                }
            }
            bool lde = InitializeLoanDisburseEvent();

            return(lde);
        }
示例#4
0
        private void ButtonAddExchangeRateClick(object sender, EventArgs e)
        {
            ExchangeRateForm exchangeRate = new ExchangeRateForm(_newStartDate, _loan.Product.Currency);

            exchangeRate.ShowDialog();

            _exchangeRate = exchangeRate.ExchangeRate;
            InitializeExternalCurrency();
            buttonSave.Enabled = _exchangeRate != null;
        }
示例#5
0
        private void SetExchangeRate()
        {
            _exchangeRate = null;
            if (ServicesProvider.GetInstance().GetCurrencyServices().FindAllCurrencies().Count == 1)
            {
                _exchangeRate = new ExchangeRate
                {
                    Currency = _FundingLine.Currency,
                    Date     = dateTimePickerEvent.Value,
                    Rate     = 1
                };
            }
            buttonSave.Enabled = false;

            DateTime _date = dateTimePickerEvent.Value;

            try
            {
                if (!ServicesProvider.GetInstance().GetExchangeRateServices().RateExistsForEachCurrency
                        (ServicesProvider.GetInstance().GetCurrencyServices().FindAllCurrencies(), _date.Date)
                    /*&& (User.CurrentUser.HasAdminRole || User.CurrentUser.HasSuperAdminRole)*/)
                {
                    buttonAddRate.Enabled = true;
                    var _xrForm =
                        new ExchangeRateForm(new DateTime(dateTimePickerEvent.Value.Year, _date.Month, _date.Day),
                                             _FundingLine.Currency);
                    _xrForm.ShowDialog();
                }
                _exchangeRate = ServicesProvider.GetInstance().GetAccountingServices().FindExchangeRate(_date.Date, _FundingLine.Currency);
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                if (_exchangeRate != null)
                {
                    buttonSave.Enabled    = true;
                    buttonAddRate.Visible = false;
                }
                else
                {
                    buttonSave.Enabled = false;
                    //buttonAddRate.Enabled = User.CurrentUser.isAdmin || User.CurrentUser.isSuperAdmin;
                    buttonAddRate.Enabled = true;
                }
            }
        }