public void Enviar(string ruta, Prestamo prestamo) { if (!MessageQueue.Exists(ruta)) { MessageQueue.Create(ruta); } MessageQueue cola = new MessageQueue(ruta); Message mensaje = new Message(); mensaje.Label = "Cronograma Offline"; mensaje.Body = prestamo; cola.Send(mensaje); }
public List <Prestamo> listaPrestamo(string codigo) { try { SqlConnection oCnn = new SqlConnection(Conexion.SqlCnn()); SqlCommand comando = new SqlCommand(); comando.CommandType = System.Data.CommandType.Text; comando.CommandText = "select p.codigo, p.fechor,p.monto,p.tea,p.tcea,p.cuotas from prestamo p join cliente c on (p.cliente = c.IdCliente) where c.IdCliente = @CODIGO"; comando.Connection = oCnn; comando.Parameters.AddWithValue("@CODIGO", codigo); oCnn.Open(); SqlDataReader reader = comando.ExecuteReader(); if (reader.HasRows) { lista = new List<Prestamo>(); while (reader.Read()) { prestamoBE = new Prestamo(); prestamoBE.Codigo = reader.GetInt32(0); prestamoBE.Fechor = reader.GetDateTime(1); prestamoBE.Monto = (Double)reader.GetDecimal(2); prestamoBE.Tea = (Double)reader.GetDecimal(3); prestamoBE.Tcea = (Double)reader.GetDecimal(4); prestamoBE.Cuotas = reader.GetInt32(5); lista.Add(prestamoBE); } } reader.Close(); oCnn.Close(); comando.Dispose(); return lista; } catch(Exception ex) { Console.WriteLine("Error: " + ex); return null; } }
public Prestamo CrearPrestamo(int tarjeta, int cuentaorigen, int moneda, double monto, int cuotas, double tea, double tcea, double montoc, DateTime fechor, int cliente, int cuentadestino) { Tarjeta tarjetaExistente = TarjetaDAO.Obtener(tarjeta); Cuenta cuentaorigenExistente = CuentaDAO.Obtener(cuentaorigen); Moneda monedaExistente = MonedaDAO.Obtener(moneda); Cuenta cuentadestinoExistente = CuentaDAO.Obtener(cuentadestino); Cliente clienteExistente = ClienteDAO.obtenerCliente(cliente); Prestamo prestamo = null; if (cuentadestinoExistente.Tipo.Trim().ToUpper() == "T") { throw new FaultException<ServiceException>(new ServiceException() { codigo = 99, mensaje = "Cuenta destino es CTS. Seleccione otra cuenta de abono." }, new FaultReason("Validación de negocio")); } else if (cuentadestinoExistente.Tipo.Trim().ToUpper() == "C") { throw new FaultException<ServiceException>(new ServiceException() { codigo = 98, mensaje = "Cuenta destino es Crédito. Seleccione otra cuenta de abono." }, new FaultReason("Validación de negocio")); } else if (string.IsNullOrWhiteSpace(clienteExistente.MailCli01) || string.IsNullOrWhiteSpace(clienteExistente.TelCli01)) { throw new FaultException<ServiceException>(new ServiceException() { codigo = 97, mensaje = "El campo teléfono o correo no pueden estar vacíos. ¡Actualice sus datos!" }, new FaultReason("Validación de negocio")); } else if (monto>cuentaorigenExistente.Disponible) { throw new FaultException<ServiceException>(new ServiceException() { codigo = 96, mensaje = "Monto de préstamo es mayor al disponible. Seleccione otra opción." }, new FaultReason("Validación de negocio")); } Prestamo prestamoACrear = new Prestamo() { Tarjeta = tarjetaExistente, Cuentaorigen = cuentaorigenExistente, Moneda = monedaExistente, Monto = monto, Cuotas = cuotas, Tea = tea, Tcea = tcea, Montoc = montoc, Fechor = fechor, Cliente = clienteExistente, Cuentadestino = cuentadestinoExistente }; prestamo = PrestamoDAO.Crear(prestamoACrear); if (prestamo != null) { //Genera el calendario CronogramasServiceClient client = new CronogramasServiceClient(); try { //throw new Exception(); Cronogramas[] lista = client.RegistrarCronograma(prestamo.Codigo, prestamo.Cliente.IdCli, prestamo.Cuotas, prestamo.Fechor, Convert.ToDecimal(prestamo.Montoc)); if (lista != null) { return prestamo; } else { return null; } } catch { //manda a la cola CronogramaCola cola = new CronogramaCola(); cola.Enviar(@".\private$\prestamoCalendarioOffline", prestamo); return prestamo; } } else { return null; } }
public Prestamo ModificarPrestamo(int codigo, int tarjeta, int cuentaorigen, int moneda, double monto, int cuotas, double tea, double tcea, double montoc, DateTime fechor, int cliente, int cuentadestino) { Tarjeta tarjetaExistente = TarjetaDAO.Obtener(tarjeta); Cuenta cuentaorigenExistente = CuentaDAO.Obtener(cuentaorigen); Cuenta cuentadestinoExistente = CuentaDAO.Obtener(cuentadestino); Moneda monedaExistente = MonedaDAO.Obtener(moneda); Cliente clienteExistente = ClienteDAO.obtenerCliente(cliente); Prestamo prestamoAModificar = new Prestamo() { Codigo = codigo, Tarjeta = tarjetaExistente, Cuentaorigen = cuentaorigenExistente, Moneda = monedaExistente, Monto = monto, Cuotas = cuotas, Tea = tea, Tcea = tcea, Montoc = montoc, Fechor = fechor, Cliente = clienteExistente, Cuentadestino = cuentadestinoExistente, }; return PrestamoDAO.Modificar(prestamoAModificar); }