private void btnBereken_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

            if (xlApp == null)
            {
                MessageBox.Show("Excel is not properly installed!!");
                return;
            }


            Excel.Workbook  xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object          misValue = System.Reflection.Missing.Value;

            xlWorkBook  = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            Excel.Range formatRange;

            double[] test = null;
            double   dblGeleend, dblRente, dblNogTeBetalen;
            int      intLooptijd, intLooptijdper, intKeuze;

            dblGeleend      = Convert.ToDouble(txtGeleend.Text);
            dblNogTeBetalen = Convert.ToDouble(txtGeleend.Text);
            dblRente        = Convert.ToDouble(txtRente.Text);
            intKeuze        = Convert.ToInt32((cbKeuzeAflossing.SelectedItem as cComboboxItem.ComboboxItem).Value);
            intLooptijd     = Convert.ToInt32(txtLooptijd.Text);
            intLooptijdper  = Convert.ToInt32((cbAnnuiteit.SelectedItem as cComboboxItem.ComboboxItem).Value);
            intLooptijd     = cLooptijdBerekenen.Berekentijd(intLooptijdper, intLooptijd);

            xlWorkSheet.Cells[1, 1] = "Periode";
            xlWorkSheet.Cells[1, 2] = "Annuïteit";
            xlWorkSheet.Cells[1, 3] = "Rente";
            xlWorkSheet.Cells[1, 4] = "Aflossing";
            xlWorkSheet.Cells[1, 5] = "Nog te betalen";

            for (int i = 2; i < intLooptijd + 2; i++)
            {
                test = Berekeningen.Aflossing(intKeuze, dblGeleend, dblNogTeBetalen, dblRente, intLooptijd, intLooptijdper);
                xlWorkSheet.Cells[i, 1] = i - 1;
                xlWorkSheet.Cells[i, 2] = Math.Round(test[1], 2);
                xlWorkSheet.Cells[i, 3] = Math.Round(test[2], 2);
                xlWorkSheet.Cells[i, 4] = Math.Round(test[3], 2);
                xlWorkSheet.Cells[i, 5] = Math.Round(test[0], 2);

                formatRange = xlWorkSheet.get_Range("b" + i, "e" + i);
                formatRange.NumberFormat = "$ #,###,###.00";

                dblNogTeBetalen = test[0];
            }
            xlWorkBook.SaveAs("d:\\csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            System.Diagnostics.Process.Start(@"d:\\csharp-Excel.xls");
        }
        public ActionResult <Models.BerekeningenViewModel> Index(Models.BerekeningenViewModel collection)
        {
            // TODO: Add insert logic here
            var dateTimeBeginTijd = DateTime.Parse(collection.DateTimeBeginTijd);
            var dateTimeEindTijd  = DateTime.Parse(collection.DateTimeEindTijd);

            var mijnBerekeningen = new Berekeningen(dateTimeBeginTijd, dateTimeEindTijd);

            collection.Resultaat = $"Resultaat Uren:[{mijnBerekeningen.hours}], Minuten:[{mijnBerekeningen.minutes}]";

            return(View(collection));
        }
예제 #3
0
 public void Setup()
 {
     this.berekeningen = new Berekeningen();
 }