private void btnGenerarReporte_Click(object sender, EventArgs e) { if (cbxCliente.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un cliente de la lista", "MENSAJE DEL SISTEMA"); } else { var obj = cbxCliente.SelectedItem; string[] idv = obj.ToString().Split('-'); int dni = Convert.ToInt32(idv[0]); Cliente C = _clienteServicio.TraerClientePorDNI(dni); frmReportePrestamosPorCliente FORM = new frmReportePrestamosPorCliente(C.Id); FORM.Owner = this; FORM.Show(); } }
private void btnAgregarPrestamo_Click(object sender, EventArgs e) { try { if (cbxCliente.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un cliente"); } else { var obj = cbxCliente.SelectedItem; string[] idv = obj.ToString().Split('-'); int dni = Convert.ToInt32(idv[0]); Cliente C = _clienteServicio.TraerClientePorDNI(dni); int _idCliente = C.Id; string _STRejemplar = txtEjemplar.Text; int _ejemplar = 0; string _STRplazo = numPlazo.Value.ToString(); int _plazo = 0; DateTime fechaalta = dateFechaAlta.Value; DateTime fechatentantiva = dateFechaDevTentativa.Value; DateTime fechabaja = DateTime.Now; bool _abierto = true; string msj = ""; msj += Validaciones.ValidarNumero(_STRejemplar, "Ejemplar", ref _ejemplar); msj += Validaciones.ValidarPlazo(_STRplazo, "Plazo", ref _plazo); if (!string.IsNullOrWhiteSpace(msj)) { MessageBox.Show(msj, "ERRORES"); } else if (fechaalta > DateTime.Now) { throw new FechaFuturaException(); } else { Prestamo P = new Prestamo(_idCliente, _ejemplar, _plazo, _abierto, fechaalta, fechatentantiva, fechabaja); int id = _prestamoServicio.InsertarPrestamo(P); MessageBox.Show("Se agrego el prestamo con ID: " + id.ToString(), "Mensaje del Sistema"); LimpiarBotones(); } } } catch (FechaFuturaException ee) { MessageBox.Show(ee.Message, "Mensaje del Sistema"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }