Example #1
0
        private void btnSimular_Click(object sender, EventArgs e)
        {
            string        mensaje = "";
            List <string> errores = new List <string>();

            errores.Add(Validacion.ValidarNumero(txtMonto.Text, "monto"));
            errores.Add(Validacion.ValidarNumero(txtPlazo.Text, "plazo"));
            if (errores.Any())
            {
                foreach (string error in errores)
                {
                    if (error != "")
                    {
                        mensaje += error + "\n";
                    }
                }
            }
            if (mensaje == "")
            {
                Prestamo simulacro = new Prestamo(ObtenerTipoPrestamoSeleccionado(), Convert.ToDouble(txtMonto.Text), Convert.ToInt32(txtMonto.Text));
                txtCapital.Text = (simulacro.CuotaCapital()).ToString();
                txtInteres.Text = simulacro.CuotaInteres().ToString();
                txtCuota.Text   = simulacro.Cuota().ToString();
            }
            else
            {
                MessageBox.Show(mensaje);
            }
        }
        private void btnSimular_Click(object sender, EventArgs e)
        {
            try
            {
                VerificarErrores();

                Prestamo simulacro = DevolverPrestamoSegunDatos();
                txtCapital.Text = (simulacro.CuotaCapital()).ToString();
                txtInteres.Text = simulacro.CuotaInteres().ToString();
                txtCuota.Text   = simulacro.Cuota().ToString();
            }
            catch (FormatException fex)
            {
                MessageBox.Show(fex.Message);
                MessageBox.Show(fex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }