private void btnAceptar_Click(object sender, EventArgs e) { DialogResult respuesta; respuesta = MessageBox.Show("¿Registar pago?", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (respuesta == DialogResult.Yes) { Pago oPago = new Pago(); oPago.CUO_Codigo = Convert.ToInt32(cmbCuota.SelectedValue); oPago.PAG_Fecha = Convert.ToDateTime(dtpFecha.Text); oPago.PAG_Importe = Convert.ToDecimal(txtImporte.Text); TrabajarPagos.agregarPago(oPago); MessageBox.Show("El pago se ha efectuado.", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); TrabajarCuotas.cambiarEstadoCuota(oPago.CUO_Codigo); int nro = Convert.ToInt32(cmbPrestamo.SelectedValue); if (TrabajarCuotas.traerCuotaPrestamo(nro).Rows.Count <= 0) { TrabajarPrestamos.cambiarEstadoPrestamo(nro); } } ClaseUtil.limpiarFormulario(this); }
private void cmbDestino_SelectedIndexChanged(object sender, EventArgs e) { if (cmbDestino.SelectedIndex != -1) { string desc = cmbDestino.Text; int filas = TrabajarPrestamos.buscarPrestamoDestino(desc).Rows.Count; if (filas > 0) { dgvPrestamos.DataSource = TrabajarPrestamos.buscarPrestamoDestino(desc); DataTable tabla = TrabajarPrestamos.buscarPrestamoDestino(desc); txtOtorgados.Text = Convert.ToString(filas); txtPendientes.Text = tabla.Compute("Count(Estado)", "Estado = 'Pendiente'").ToString(); txtCancelados.Text = tabla.Compute("Count(Estado)", "Estado = 'Cancelado'").ToString(); txtAnulados.Text = tabla.Compute("Count(Estado)", "Estado = 'Anulado'").ToString(); } else { MessageBox.Show("No hay préstamos con destino «" + desc + "».", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); dgvPrestamos.DataSource = TrabajarPrestamos.traerPrestamos(); ClaseUtil.limpiarFormulario(gbPrestamos); } ClaseUtil.limpiarFormulario(this); } }
private void btnVer_Click(object sender, EventArgs e) { string dni = Convert.ToString(cmbCliente.SelectedValue); int nro = Convert.ToInt32(txtPrestamo.Text); if (TrabajarPrestamos.buscarPrestamoCliente(dni, nro).Rows.Count <= 0) { MessageBox.Show("Verifique Cliente y Nro. de Préstamo.", "¡Búsqueda sin resultados!", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClaseUtil.limpiarFormulario(gbCuotas); ClaseUtil.limpiarFormulario(gbImportes); } else { txtDNI.Text = (string)cmbCliente.SelectedValue; txtCliente.Text = cmbCliente.Text; txtNPrestamo.Text = Convert.ToString(nro); dgvDetallesPrestamo.DataSource = TrabajarPrestamos.buscarCuotas(nro); dgvDetallesPrestamo.Columns[0].Visible = false; DataTable tabla = TrabajarPrestamos.buscarCuotas(nro); txtPagadas.Text = tabla.Compute("Count(Estado)", "Estado = 'Pagada'").ToString(); txtPendientes.Text = tabla.Compute("Count(Estado)", "Estado = 'Pendiente'").ToString(); txtImportePendiente.Text = "$" + tabla.Compute("Sum(Importe)", "Estado = 'Pendiente'").ToString(); txtImportePago.Text = "$" + tabla.Compute("Sum(Importe)", "Estado = 'Pagada'").ToString(); } }
private void btnRegistrar_Click(object sender, EventArgs e) { DialogResult resultado = MessageBox.Show("Desea Registrar el Prestamo", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (resultado == DialogResult.Yes) { Prestamo oPrestamo = new Prestamo(); oPrestamo.CliDNI = (string)cmbClientes.SelectedValue; oPrestamo.DesCodigo = (int)cmbDestinos.SelectedValue; oPrestamo.PerCodigo = (int)cmbPeriodos.SelectedValue; oPrestamo.PreFecha = dtpfecha.Value; oPrestamo.PreImporte = Convert.ToDecimal(txtImporte.Text); oPrestamo.PreCantidadCuotas = Convert.ToInt32(txtCantidadCuotas.Text); oPrestamo.PreTasaInteres = Convert.ToDouble(txtTasaInteres.Text); oPrestamo.PreEstado = "Iniciado"; TrabajarPrestamos.InsertarPrestamo(oPrestamo); Cuota oCuota = new Cuota(); oCuota.CuoImporte = (oPrestamo.PreImporte * Convert.ToDecimal(oPrestamo.PreTasaInteres) / 100) + (oPrestamo.PreImporte / oPrestamo.PreCantidadCuotas); oCuota.CuoEstado = "No Pagada"; DateTime fechaActual = oPrestamo.PreFecha; for (int i = 0; i < oPrestamo.PreCantidadCuotas; i++) { oCuota.CuoNumero = i; fechaActual.AddMonths(i); oCuota.CuoVencimiento = fechaActual; TrabajarCuotas.insertarCuota(oCuota); } MessageBox.Show("Prestamo Registrado", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); } }
private void Frm_ListaPrestamos_Load(object sender, EventArgs e) { dgvPrestamos.DataSource = TrabajarPrestamos.traerPrestamos(); cmbDestino.SelectedIndexChanged -= new EventHandler(cmbDestino_SelectedIndexChanged); cmbDestino.DataSource = TrabajarDestinos.traerDestino(); cmbDestino.DisplayMember = "descripción"; cmbDestino.ValueMember = "código"; cmbDestino.SelectedIndex = -1; cmbDestino.SelectedIndexChanged += new EventHandler(cmbDestino_SelectedIndexChanged); }
private void loadCmbPrestamo(string dni) { if (TrabajarPrestamos.traerPrestamosCliente(dni).Rows.Count > 0) { cmbPrestamo.SelectedIndexChanged -= new EventHandler(cmbPrestamo_SelectedIndexChanged); cmbPrestamo.DataSource = TrabajarPrestamos.traerPrestamosCliente(dni); cmbPrestamo.DisplayMember = "pre_numero"; cmbPrestamo.ValueMember = "pre_numero"; cmbPrestamo.SelectedIndex = -1; cmbPrestamo.SelectedIndexChanged += new EventHandler(cmbPrestamo_SelectedIndexChanged); } else { MessageBox.Show("El cliente no tiene préstamos asociados.", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClaseUtil.limpiarFormulario(this); } }
private void btnAnular_Click(object sender, EventArgs e) { if (txtNroPrestamo.Text != String.Empty) { int nro = Convert.ToInt32(txtNroPrestamo.Text); if (TrabajarPrestamos.buscarCuotaxPrestamo(nro).Rows.Count > 0) { MessageBox.Show("No es posible cancelar el préstamos.\nEl préstamo posee cuotas pagadas.", "¡ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { TrabajarPrestamos.AnularPrestamo(nro); MessageBox.Show("El préstamo se anuló correctamente.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvPrestamos.DataSource = TrabajarPrestamos.traerPrestamos(); } } else { MessageBox.Show("Ingrese Nro. de Préstamos.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnBuscar_Click(object sender, EventArgs e) { DateTime fDesde = Convert.ToDateTime(dtpFechaDesde.Text); DateTime fHasta = Convert.ToDateTime(dtpFechaHasta.Text); int filas = TrabajarPrestamos.buscarPorFechas(fDesde, fHasta).Rows.Count; if (filas > 0) { dgvPrestamos.DataSource = TrabajarPrestamos.buscarPorFechas(fDesde, fHasta); DataTable tabla = TrabajarPrestamos.buscarPorFechas(fDesde, fHasta); txtOtorgados.Text = Convert.ToString(filas); txtPendientes.Text = tabla.Compute("Count(Estado)", "Estado = 'Pendiente'").ToString(); txtCancelados.Text = tabla.Compute("Count(Estado)", "Estado = 'Cancelado'").ToString(); txtAnulados.Text = tabla.Compute("Count(Estado)", "Estado = 'Anulado'").ToString(); } else { MessageBox.Show("No hay préstamos registrados en ese periodo.", "¡Búqueda sin Resultados!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); dgvPrestamos.DataSource = TrabajarPrestamos.traerPrestamos(); ClaseUtil.limpiarFormulario(gbPrestamos); } ClaseUtil.limpiarFormulario(this); }
private void btnGuardar_Click(object sender, EventArgs e) { DialogResult respuesta; respuesta = MessageBox.Show("¿Desea generar el préstamo?", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (respuesta == DialogResult.Yes) { Prestamo oPrestamo = new Prestamo(); Cuota oCuota = new Cuota(); decimal importe = Convert.ToDecimal(txtImporte.Text); decimal tasa = Convert.ToDecimal(txtTasaInteres.Text); int cuota = Convert.ToInt32(txtCuotas.Text); decimal totalImporte = (importe + ((importe * tasa) / 100)) / cuota; DateTime fecha = Convert.ToDateTime(dtpFecha.Text, new CultureInfo("es-ES")); oPrestamo.CLI_DNI = (string)cmbCliente.SelectedValue; oPrestamo.DES_Codigo = (Int32)cmbDestino.SelectedValue; oPrestamo.PER_Codigo = (Int32)cmbPeriodo.SelectedValue; oPrestamo.PRE_Fecha = Convert.ToDateTime(dtpFecha.Text); oPrestamo.PRE_Importe = importe; oPrestamo.PRE_TasaInteres = Convert.ToDecimal(txtTasaInteres.Text); oPrestamo.PRE_CantidadCuotas = Convert.ToInt32(txtCuotas.Text); oPrestamo.PRE_Estado = "Pendiente"; int ultimoID = TrabajarPrestamos.agregarPrestamo(oPrestamo); try { Thread.Sleep(300); oCuota.PRE_Numero = ultimoID; oCuota.CUO_Importe = totalImporte; oCuota.CUO_Estado = "Pendiente"; for (int i = 1; i <= cuota; i++) { //verifica el periodo seleccionado y en base a eso suma dias, meses o años if ((Int32)cmbPeriodo.SelectedValue == 1) { fecha = fecha.AddDays(7); oCuota.CUO_Vencimiento = fecha; } else if ((Int32)cmbPeriodo.SelectedValue == 2) { fecha = fecha.AddDays(30); oCuota.CUO_Vencimiento = fecha; } else if ((Int32)cmbPeriodo.SelectedValue == 3) { fecha = fecha.AddYears(1); oCuota.CUO_Vencimiento = fecha; } oCuota.CUO_Numero = i; TrabajarCuotas.agregarCuota(oCuota); } MessageBox.Show("El préstamo ha sido registrado.", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); ClaseUtil.limpiarFormulario(this); this.Show(); }catch (Exception ex) { MessageBox.Show(ex.Message); } } }