Пример #1
0
        protected void ButtonCalcular_Click(object sender, EventArgs e)
        {
            detalle.Clear();
            int     tiempo = int.Parse(TextBoxTiempoMeses.Text);
            decimal tasa = (Decimal.Parse(TextBoxInteresAnual.Text) / 100);
            decimal cuota = Decimal.Parse(TextBoxCapital.Text) * (tasa / 12) / (decimal)(1 - Math.Pow((double)(1 + (tasa / 12)), -tiempo));
            decimal capital = Decimal.Parse(TextBoxCapital.Text);
            decimal totalC = 0, totalI = 0;

            for (int i = 1; i <= int.Parse(TextBoxTiempoMeses.Text); ++i)
            {
                PrestamoDetalle pd = new PrestamoDetalle();
                pd.PrestamoId = int.Parse(TextBoxPrestamoID.Text);
                pd.numCuota   = i;
                pd.Valor      = Math.Round(cuota, 2);
                pd.Interes    = decimal.Round(capital * (tasa / 12), 2);
                pd.Capital    = decimal.Round(cuota - pd.Interes, 2);
                pd.Balance    = decimal.Round(capital - pd.Capital, 2);
                capital       = pd.Balance;

                totalC += pd.Capital;
                totalI += pd.Interes;

                detalle.Add(pd);
            }
            CuotasGridView.DataSource = detalle.ToList();
            CuotasGridView.DataBind();
            ViewState["Detalle"]     = detalle;
            TextBoxCapitalTotal.Text = Decimal.Floor(totalC).ToString();
            TextBoxInteresTotal.Text = totalI.ToString();
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "Popup", "alert('Cuotas calculadas')", true);
            _Visible();
        }
Пример #2
0
 private void LlenaCampos(Prestamo prestamo)
 {
     Limpiar();
     PrestamoIDTextbox.Text = prestamo.PrestamoID.ToString();
     LlenaComboCuentaID();
     CapitalTexbox.Text        = prestamo.Capital.ToString();
     InteresesTextBox.Text     = prestamo.Interes.ToString();
     TiempoTextBox.Text        = prestamo.Tiempo.ToString();
     TotalTextBox.Text         = prestamo.TotalAPagar.ToString();
     CuotasGridView.DataSource = prestamo.Detalle;
     CuotasGridView.DataBind();
 }
Пример #3
0
 private void Limpiar()
 {
     PrestamoIDTextbox.Text    = "0";
     FechadateTime.Text        = DateTime.Now.ToString("yyyy-MM-dd");
     CapitalTexbox.Text        = string.Empty;
     InteresesTextBox.Text     = string.Empty;
     TiempoTextBox.Text        = string.Empty;
     TotalTextBox.Text         = string.Empty;
     CuotasGridView.DataSource = null;
     CuotasGridView.DataBind();
     LlenaComboCuentaID();
     ViewState["Cuota"] = null;
 }
Пример #4
0
 private void LlenarCampos(Prestamos prestamo1)
 {
     TextBoxPrestamoID.Text            = prestamo1.PrestamosId.ToString();
     TextBoxFecha.Text                 = prestamo1.Fecha.ToString("yyyy-MM-dd");
     CuentasDropDownList.SelectedValue = prestamo1.CuentaId.ToString();
     TextBoxCapital.Text               = prestamo1.Capital.ToString();
     TextBoxInteresAnual.Text          = prestamo1.InteresAnual.ToString();
     TextBoxTiempoMeses.Text           = prestamo1.TiempoMeses.ToString();
     TextBoxCapitalTotal.Text          = prestamo1.CapitaTotal.ToString();
     TextBoxInteresTotal.Text          = prestamo1.InteresTotal.ToString();
     CuotasGridView.DataSource         = prestamo1.Detalle.ToList();
     CuotasGridView.DataBind();
     ViewState["Detalle"] = prestamo1.Detalle;
 }
Пример #5
0
 private void ClearAll()
 {
     TextBoxCapital.Text               = String.Empty;
     TextBoxFecha.Text                 = String.Empty;
     TextBoxInteresAnual.Text          = String.Empty;
     TextBoxPrestamoID.Text            = String.Empty;
     TextBoxTiempoMeses.Text           = String.Empty;
     TextBoxCapitalTotal.Text          = String.Empty;
     TextBoxInteresTotal.Text          = String.Empty;
     CuentasDropDownList.DataTextField = String.Empty;
     CuotasGridView.DataSource         = null;
     CuotasGridView.DataBind();
     active = false;
     ViewState["Active"] = active;
     Invisible();
 }
Пример #6
0
        protected void CalcularButton_Click(object sender, EventArgs e)
        {
            int id;

            if (Convert.ToInt32(CuentaDropDownList.SelectedValue) != 0)
            {
                id = Convert.ToInt32(CuentaDropDownList.SelectedValue);
            }


            if (Convert.ToInt32(CuentaDropDownList.SelectedValue) != 0)
            {
                ViewState["Cuota"] = CalculodeCuotas();
            }


            CuotasGridView.DataSource = ViewState["Cuota"];
            CuotasGridView.DataBind();

            TotalTextBox.Text = MontoApagar.ToString();
        }