private void calcularvalorCuota() { try { double saldo = double.Parse(Convert.ToDouble(TxtValorDeuda.Text).ToString()); double ValInteres = int.Parse(numValorInteres.Text); double ValorCuotaInteres; double Interes = 0; double NumCuotas = int.Parse(numCuotasFinan.Text); int cuotas = int.Parse(numCuotasFinan.Text); if (numValorInteres.Value == 0) { Interes = ValInteres; ValorCuotaInteres = saldo / NumCuotas; } else { Interes = ValInteres; ValInteres = Interes / 100; ValorCuotaInteres = (ValInteres * saldo) / (1 - Math.Pow(1 + ValInteres, -cuotas)); } TxtTotalRefi.Text = (ValorCuotaInteres * NumCuotas).ToString("n2"); TxtValorCuota.Text = ValorCuotaInteres.ToString("n2"); CalcularCuotasFinacianciacion(double.Parse(Convert.ToDouble(TxtValorDeuda.Text).ToString()), Convert.ToInt16(Interes), ValorCuotaInteres, int.Parse(numCuotasFinan.Text)); } catch (Exception ex) { MessageBox.Show("Error al calcular valor cuota: " + ex, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void numCuotasFinan_Click(object sender, EventArgs e) { if (TxtTotal.Text != "") { double inicial = Convert.ToDouble(TxtValorInicial.Text); int saldo = int.Parse(Convert.ToDouble(TxtValorSaldo.Text).ToString()); double ValInteres = int.Parse(numValorInteres.Text); double ValorCuotaInteres; double Interes = 0; double NumCuotas = int.Parse(numCuotasFinan.Text); int cuotas = int.Parse(numCuotasFinan.Text); if (numCuotasFinan.Value <= 18) { ValInteres = 0; Interes = ValInteres; ValorCuotaInteres = saldo / NumCuotas; } else { if (numValorInteres.Value == 0) { ValInteres = 1; } Interes = ValInteres; ValInteres = Interes / 100; ValorCuotaInteres = (ValInteres * saldo) / (1 - Math.Pow(1 + ValInteres, -cuotas)); } numValorInteres.Text = Interes.ToString(); TxtTotal.Text = (ValorCuotaInteres * NumCuotas + inicial).ToString("n0"); TxtValorCuotaInteres.Text = ValorCuotaInteres.ToString("n0"); CalcularCuotasFinaciadas(int.Parse(Convert.ToDouble(TxtValorNeto.Text).ToString()), int.Parse(Convert.ToDouble(TxtValorInicial.Text).ToString()), Convert.ToInt16(Interes), ValorCuotaInteres, int.Parse(numCuotasFinan.Text)); } }