protected void Page_Load(object sender, EventArgs e)
 {
     usuario = (Usuario)Session["Usuario"];
     if(!IsPostBack)
     {
         int prestamo = Convert.ToInt32(Request.QueryString["prestamo"]);
         CronogramasServiceClient client = new CronogramasServiceClient();
         gvData.DataSource = client.ConsultarCronograma(prestamo, usuario.IdCli);
         gvData.DataBind();
     }
 }
Beispiel #2
0
        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;
            }
            
        }