Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIOHelper iOHelper = new FileIOHelper();
            var       list     = iOHelper.ListAllMortgages();

            if (list.Count == 0)
            {
                list.Add("No Data stored!");
            }

            GridView1.DataSource = list;
            GridView1.DataBind();
        }
Beispiel #2
0
        //private static Tuple<bool,float> ValidateInput (string)
        //{
        //    Tuple<bool, float> resultTuple;

        //}

        protected void ComputeMortgage_Click(object sender, EventArgs e)
        {
            string inPrin  = PrincipleAmount.Text;
            string inYears = OtherYears.Text;
            string inRate  = DropDownList1.SelectedItem.Text;

            double years = 0;

            bool check = false;

            if (double.TryParse(inPrin, out double principal) == false)
            {
                ResultPayment.Text = $"Please input a Principle Amount";
                check = true;
            }

            if (RadioButtonList1.SelectedIndex == 2)
            {
                if (double.TryParse(inYears, out years) == false)
                {
                    ResultPayment.Text = $"Please select an Loan Duration";
                    check = true;
                }
            }
            if (RadioButtonList1.SelectedIndex == 0)
            {
                years = 15;
            }
            if (RadioButtonList1.SelectedIndex == 1)
            {
                years = 30;
            }

            if (double.TryParse(inRate, out double rate) == false)
            {
                ResultPayment.Text = $"Please select an Interest Rate";
                check = true;
            }

            if (check == false)
            {
                double monthly         = ComputeMonthlyPayment(principal, years, rate);
                string formattedOutput = string.Format("The monthly payment is {0:C}", monthly);
                ResultPayment.Text = formattedOutput;

                //IIOHelper fileIOHelper = new DatabaseIOHelper();
                FileIOHelper fileIOHelper = new FileIOHelper();
                fileIOHelper.AddMortgages(formattedOutput);
            }
        }
        protected void ClearButton_Click(object sender, EventArgs e)
        {
            IIOHelper iOHelper = new FileIOHelper();

            iOHelper.ClearAllMortgages();
        }