예제 #1
0
        protected void ClearButton_Click(object sender, EventArgs e)
        {
            //IIOHelper iOHelper = new FileIOHelper(ServerPathHelper.GetPath("~/app_data/log.txt"));
            IIOHelper iOHelper = new DatabaseIOHelper();

            iOHelper.ClearAllMortgages();
        }
예제 #2
0
        public 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);
                string formattedPrinciple = principal.ToString();
                string formattedYears     = years.ToString();
                string formattedRate      = rate.ToString();
                ResultPayment.Text              = formattedOutput;
                PrincipleAmount.Text            = formattedPrinciple;
                OtherYears.Text                 = formattedYears;
                DropDownList1.SelectedItem.Text = formattedRate;

                IIOHelper fileIOHelper = new DatabaseIOHelper();
                //FileIOHelper fileIOHelper = new FileIOHelper(ServerPathHelper.GetPath("~/app_data/log.txt"));
                fileIOHelper.AddMortgages(formattedOutput, formattedPrinciple, formattedYears, formattedRate);
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //IIOHelper iOHelper = new FileIOHelper(ServerPathHelper.GetPath("~/app_data/log.txt"));
            IIOHelper iOHelper = new DatabaseIOHelper();
            var       dt       = iOHelper.ListAllMortgages();

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

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }