Exemple #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();
        }
Exemple #2
0
 private void btnEliminar2_Click(object sender, EventArgs e)
 {
     try
     {
         PrestamoDetalle pd = (PrestamoDetalle)dtgDetallePrestamo.CurrentRow.DataBoundItem;
         prestamo.detalle_prestamo.Remove(pd);
         ActualizarDataGrid();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #3
0
        private void btnAgregar2_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidarCampos())
                {
                    PrestamoDetalle pd = new PrestamoDetalle();
                    pd.cantidad          = Convert.ToDouble(txtCantidad.Text);
                    pd.libro             = (Libro)cboLibro.SelectedItem;
                    pd.fecha_vencimiento = dtpFechaVencimiento.Value;
                    pd.estado            = Estado.No_Entregado;
                    prestamo.detalle_prestamo.Add(pd);

                    ActualizarDataGrid();


                    LimpiarFormulario(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }