private void btnAlta_Click(object sender, EventArgs e) { try { if (cbxCliente.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un cliente"); } else if (lstTipoPrestamos.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un tipo de prestamo"); } else { var STRidcliente = cbxCliente.SelectedItem; string[] ob = STRidcliente.ToString().Split('-'); int idcliente = Convert.ToInt32(ob[0]); string _STRplazo = txtPlazo.Text; int _plazo = 0; string _STRmonto = txtMonto.Text; double _monto = 0; string msj = ""; msj += Validaciones.ValidarNumero(_STRplazo, "Plazo", ref _plazo); msj += Validaciones.ValidarMonto(_STRmonto, "Monto", ref _monto); double tna = Convert.ToDouble(txtTNA.Text); string linea = txtLinea.Text; double cuotacapital = Math.Round(_monto / _plazo, 2); double cuotainteres = Math.Round(cuotacapital * (tna / 12 / 100), 2); double cuotatotal = Math.Round(cuotacapital + cuotainteres, 2); if (!string.IsNullOrWhiteSpace(msj)) { MessageBox.Show(msj); } else { Prestamo P = new Prestamo(tna, linea, _plazo, idcliente, _monto, cuotatotal); _prestamoServicio.InsertarPrestamo(P); MessageBox.Show("Se dio de alta el prestamo"); CargarPrestamos(); LimpiarCampos(); } } } catch (Exception eee) { MessageBox.Show(eee.Message); } }
private void btnAlta_Click_1(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.errores)) { throw new Exception("Error en los campos: " + "\n" + this.errores); } else { prestamoservicio.InsertarPrestamo(p.Prestamo); } LimpiarFrmPrestamo(); }
private void btnAlta_Click(object sender, EventArgs e) { try { VerificarErrores(); Prestamo p = DevolverPrestamoSegunDatos(); prestamoServ.InsertarPrestamo(p); MessageBox.Show("Se ha agregado correctamente el prestamo"); LimpiarSeleccion(); ActualizarListaPrestamos(); } catch (FormatException fex) { MessageBox.Show(fex.Message); MessageBox.Show(fex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }