// Confirmar la operación en curso private void AceptarOperacion() { SistemaARA.Negocio.Pagos oPagosNegocio = new SistemaARA.Negocio.Pagos(); SistemaARA.Entidades.Pago oPago = new SistemaARA.Entidades.Pago(); try { //Valido los datos del formulario Validar(); oPago.idInstitucion = mIdInstitucion; oPago.fecha = Convert.ToDateTime(txbCuota.Text); oPago.fechaPago = Convert.ToDateTime(dtpFechaPago.Text); if (Operacion == General.TipoOperacion.Alta) { oPagosNegocio.Add(oPago); MessageBox.Show("Pago de cuota registrado exitosamente.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { oPagosNegocio.Update(oPago); MessageBox.Show("Pago de cuota actualizado exitosamente.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } // Indico que todo salio bien y cierro el formulario Cancelado = false; this.Hide(); } catch (Exception ex) { // Muestro cualquier error de la aplicacion o por validación MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { // Libera objetos oPago = null; oPagosNegocio = null; } }
// Inicializa el formulario private void IniciarFormulario() { // Obtener cuotas desde la base de datos. // Siempre retorna una coleccion de objetos. SistemaARA.Entidades.Cuotas oCuotas; SistemaARA.Negocio.Cuotas oCuotasNegocio = new SistemaARA.Negocio.Cuotas(); SistemaARA.Entidades.Pagos oPagos; SistemaARA.Negocio.Pagos oPagosNegocio = new SistemaARA.Negocio.Pagos(); // Verifica la operacion en curso if (Operacion == General.TipoOperacion.Edicion) { this.Text = "Pago cuota - Edición"; try { oPagos = oPagosNegocio.GetOne(IdInstitucion, FechaCuota); if (oPagos.Count > 0) { txbCuota.Text = oPagos[0].fecha.ToString("MM") + "/" + oPagos[0].fecha.Year.ToString(); oCuotas = oCuotasNegocio.GetOne(oPagos[0].fecha); txbImporte.Text = oCuotas[0].importe.ToString(); dtpFechaPago.Value = oPagos[0].fechaPago; } else { MessageBox.Show("El pago de cuota solicitado no existe. Verifique que no haya sido eliminado.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); gpbDatosPagoCuota.Enabled = false; btnAceptar.Enabled = false; } } catch (Exception ex) { // Muestro cualquier error que ocurra MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // Libero memoria de objetos oCuotas = null; oCuotasNegocio = null; } } else { this.Text = "Pago cuota - Alta"; dtpFechaPago.Text = DateTime.Today.ToString(); try { oCuotas = oCuotasNegocio.GetOne(FechaCuota); SistemaARA.Entidades.Cuota oCuota = oCuotas[0]; txbCuota.Text = oCuota.fecha.ToString("MM") + "/" + oCuota.fecha.Year.ToString(); txbImporte.Text = oCuota.importe.ToString(); } catch (Exception ex) { // Muestro cualquier error que ocurra MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // Libero memoria de objetos oCuotas = null; oCuotasNegocio = null; } } }