private void SetInputData(InputDataAmortization input)
 {
     nudValue.Value        = (decimal)input.Value;
     nudYears.Value        = input.NumberOfYears;
     nudCurrencyRate.Value = (decimal)input.CurrencyRate;
     if (input.PercentageRate != null)
     {
         nudPercentageRate.Value   = (decimal)input.PercentageRate;
         nudPercentageRate.Enabled = true;
         chbPercentageRate.Checked = true;
         nudCurrencyRate.Enabled   = false;
     }
     else
     {
         nudPercentageRate.Value   = nudPercentageRate.Minimum;
         nudPercentageRate.Enabled = false;
         chbPercentageRate.Checked = false;
         nudCurrencyRate.Enabled   = true;
     }
     if (input.Digression == 0)
     {
         this.operationType    = OperationTypes.ACQUISITION;
         chbDigression.Checked = false;
         nudDigression.Enabled = false;
         nudDigression.Value   = 0;
     }
     else
     {
         operationType         = OperationTypes.BALANCE_AND_RESIDUAL;
         chbDigression.Checked = true;
         nudDigression.Enabled = true;
         nudDigression.Value   = (decimal)input.Digression;
     }
 }
        private void UpdateData(InputDataAmortization input)
        {
            ClearChart();
            Amortization a = new Amortization(input);
            List <OutputDataAmortization> listResult = null;

            if (this.operationType == OperationTypes.ACQUISITION)
            {
                listResult     = a.calculateValueOfAcquisitions();
                this.lblP.Text = "";
                this.chartAmortization.Titles.Add("Отчисления от стойността на придобиване");
            }
            else if (this.operationType == OperationTypes.BALANCE_AND_RESIDUAL)
            {
                listResult     = a.calculateBalanceAndResidual();
                this.lblP.Text = String.Format("p = {0:N2} %", input.PercentageRate);
                this.chartAmortization.Titles.Add("Отчисления на балансовата или остатъчната стойност");
            }
            this.dataGridView1.DataSource = listResult;

            Series seriesAmortizationSum = this.chartAmortization.Series[0];
            Series seriesBalance         = this.chartAmortization.Series[1];


            if (seriesAmortizationSum.Enabled || seriesBalance.Enabled)
            {
                foreach (OutputDataAmortization oda in listResult)
                {
                    seriesAmortizationSum.Points.AddXY(oda.NumberOfYear, oda.AmortizationSum.ToString("C"));
                    seriesBalance.Points.AddXY(oda.NumberOfYear, oda.Balance.ToString("C"));
                }
            }
        }
示例#3
0
 public static void Write(String filePath, InputDataAmortization objectToWrite)
 {
     using (Stream stream = File.Open(filePath, FileMode.Create))
     {
         var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
         binaryFormatter.Serialize(stream, objectToWrite);
     }
 }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            DialogResult result = this.openFileDialog1.ShowDialog();

            if (result == DialogResult.OK && this.openFileDialog1.FileName != "")
            {
                InputDataAmortization input = AmortizationIO.Read(this.openFileDialog1.FileName);
                SetInputData(input);
                UpdateData(input);
            }
        }
        private InputDataAmortization GetInputData()
        {
            InputDataAmortization input = null;
            double value        = (double)nudValue.Value;
            uint   years        = (uint)nudYears.Value;
            double currencyRate = (double)nudCurrencyRate.Value;
            double digression   = (double)nudDigression.Value;

            if (!nudPercentageRate.Enabled)
            {
                input = new InputDataAmortization(value, currencyRate, years, digression, null);
            }
            else
            {
                input = new InputDataAmortization(value, currencyRate, years, digression, (float)nudPercentageRate.Value);
            }
            return(input);
        }
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            InputDataAmortization input = GetInputData();

            UpdateData(input);
        }
示例#7
0
 public Amortization(InputDataAmortization input)
 {
     this.Input = input;
 }