Example #1
0
        private void CargarCuotas(int idPrestamo = 0)
        {
            try
            {
                if (idPrestamo > 0)
                {
                    var lstCuotas = new LN.Prestamo().ListarCuotas(idPrestamo);
                    this.bePrestamo.Cuotas = lstCuotas;
                }
                else
                {
                    if (this.bePrestamo.Cuotas == null)
                    {
                        this.bePrestamo.Cuotas = new List <BE.UI.Cuota>();
                    }
                }

                int nroCuotas = this.bePrestamo.Cuotas.Count();

                BindingSource source = new BindingSource();
                source.DataSource = this.bePrestamo.Cuotas;

                this.dgvCuotas.DataSource   = source;
                this.txtCantidadCuotas.Text = nroCuotas.ToString();

                this.FormatoCuotas();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public void CargarListadoPrestamos()
        {
            try
            {
                int anho = int.Parse(this.cboAnho.SelectedValue.ToString());
                int mes  = int.Parse(this.cboMes.SelectedValue.ToString());

                var lstUiPrestamos = new LN.Prestamo().ListarSinCuotas(anho, mes);

                var source = new BindingSource();
                source.DataSource = lstUiPrestamos;

                this.dgvPrestamos.DataSource = source;

                int    nroRegistros   = lstUiPrestamos.Count;
                double totalAdelantos = lstUiPrestamos.Sum(x => x.Monto);

                this.txtNroRegistros.Text   = nroRegistros.ToString();
                this.txtTotalPrestamos.Text = totalAdelantos.ToString("N2");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvPrestamos.CurrentRow != null)
                {
                    if (Util.ConfirmationMessage("¿Desea eliminar al prestamo seleccionado?") == false)
                    {
                        return;
                    }

                    var uiAdelato = (BE.UI.Prestamo) this.dgvPrestamos.CurrentRow.DataBoundItem;

                    int  idPrestamo = uiAdelato.IdPrestamo;
                    bool rpta       = new LN.Prestamo().Eliminar(idPrestamo);

                    if (rpta == true)
                    {
                        Util.InformationMessage("Se eliminó el prestamo");
                        this.CargarListadoPrestamos();
                    }
                }
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
Example #4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones
                if (this.cboEmpleado.SelectedIndex == 0)
                {
                    this.cboEmpleado.Focus();
                    throw new Exception("Seleccione un empleado");
                }


                if (this.txtMonto.Text.Trim().Length == 0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del bono");
                }

                if (double.Parse(this.txtMonto.Text) == 0.0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del bono");
                }

                if (int.Parse(this.txtCantidadCuotas.Text) == 0.0 ||
                    this.bePrestamo.Cuotas.Count == 0)
                {
                    throw new Exception("Ingrese una o mas cuotas");
                }


                #endregion

                #region Guardar

                this.bePrestamo.Fecha          = this.dtpFecha.Value;
                this.bePrestamo.CodigoEmpleado = this.cboEmpleado.SelectedValue.ToString();
                this.bePrestamo.Motivo         = this.txtMotivo.Text;
                this.bePrestamo.Monto          = double.Parse(this.txtMonto.Text);
                this.bePrestamo.Pagado         = this.chkPagado.Checked;
                this.bePrestamo.NumeroCuotas   = int.Parse(this.txtCantidadCuotas.Text);

                bool   rpta       = false;
                string msg        = "";
                var    lnPrestamo = new LN.Prestamo();
                if (this.bePrestamo.IdPrestamo == 0) //Nuevo
                {
                    rpta = lnPrestamo.Insertar(ref this.bePrestamo);
                    if (true)
                    {
                        msg = "Se registro el nuevo adelanto";
                    }
                }
                else  //Actualizar
                {
                    rpta = lnPrestamo.Actualizar(this.bePrestamo,
                                                 this.lstIdCuotasNuevas,
                                                 this.lstIdCuotasEliminadas);
                    if (true)
                    {
                        msg = "Se actualizo el adelanto";
                    }
                }

                if (rpta == true)
                {
                    Util.InformationMessage(msg);
                    this.frmList.CargarListadoPrestamos();
                    this.Close();
                }

                #endregion
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }