예제 #1
0
        public void ConsultarReservaciones()
        {
            try
            {
                string s;
                if ((s = this.ValidarCampos()) != null)
                {
                    this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null);
                    return;
                }

                ReservacionRDBOF       bo  = (ReservacionRDBOF)this.InterfazUsuarioADato();
                List <ReservacionRDBO> lst = this.controlador.Consultar(this.dctx, bo, true);

                if (lst.Count <= 0)
                {
                    this.vista.MostrarMensaje("No se han encontrado reservaciones con los filtros proporcionados", ETipoMensajeIU.INFORMACION);
                }

                this.vista.EstablecerResultado(lst);
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".ConsultarReservaciones: " + ex.Message);
            }
        }
        private string ConsultarDisponible()
        {
            ReservacionRDBOF bof = new ReservacionRDBOF();

            bof.Modelo          = new ModeloBO();
            bof.Unidad          = new Equipos.BO.UnidadBO();
            bof.FechaInicial    = new DateTime(this.vista.FechaReservacionInicial.Value.Year, this.vista.FechaReservacionInicial.Value.Month, this.vista.FechaReservacionInicial.Value.Day, this.vista.HoraReservacionInicial.Value.Hours, this.vista.HoraReservacionInicial.Value.Minutes, this.vista.HoraReservacionInicial.Value.Seconds);
            bof.FechaFinal      = new DateTime(this.vista.FechaReservacionFinal.Value.Year, this.vista.FechaReservacionFinal.Value.Month, this.vista.FechaReservacionFinal.Value.Day, this.vista.HoraReservacionFinal.Value.Hours, this.vista.HoraReservacionFinal.Value.Minutes, this.vista.HoraReservacionFinal.Value.Seconds);
            bof.Tipo            = (ETipoReservacion)Enum.Parse(typeof(ETipoReservacion), this.vista.TipoID.Value.ToString());
            bof.Modelo.Id       = vista.ModeloID;
            bof.Unidad.UnidadID = vista.UnidadID;
            bof.UnidadOperativa = new UnidadOperativaBO()
            {
                Id = this.vista.UnidadOperativaID
            };
            bof.Sucursal = new SucursalBO {
                Id = this.vista.SucursalID
            };                                                         //SC_0051

            List <ReservacionRDBOF> Resultado = controlador.ConsultarDisponibles(dctx, bof);

            if (Resultado.Count == 0 && !this.vista.ReservacionID.HasValue)
            {
                return("La unidad ya se encuentra reservada para ese período");
            }
            else if (this.vista.ReservacionID.HasValue)
            {
                var lstReservaciones = this.controlador.Consultar(this.dctx, new ReservacionRDBO {
                    ReservacionID = this.vista.ReservacionID
                });
                var reservacion = lstReservaciones.FirstOrDefault(x => x.ReservacionID == this.vista.ReservacionID);
                if (reservacion != null)
                {
                    if (reservacion.ReservacionID != this.vista.ReservacionID || reservacion.Unidad.UnidadID != this.vista.UnidadID ||
                        reservacion.FechaFinal.Value.Date != this.vista.FechaReservacionFinal.Value.Date ||
                        reservacion.FechaInicial.Value.Date != this.vista.FechaReservacionInicial.Value.Date ||
                        reservacion.FechaFinal.Value.TimeOfDay != this.vista.HoraReservacionFinal.Value ||
                        reservacion.FechaInicial.Value.TimeOfDay != this.vista.HoraReservacionInicial.Value)
                    {
                        if (reservacion.ReservacionID != this.vista.ReservacionID ||
                            reservacion.Unidad.UnidadID != this.vista.UnidadID ||
                            reservacion.FechaFinal.Value.Date <= this.vista.FechaReservacionFinal.Value.Date ||
                            reservacion.FechaInicial.Value.Date != this.vista.FechaReservacionInicial.Value.Date ||
                            reservacion.FechaFinal.Value.TimeOfDay <= this.vista.HoraReservacionFinal.Value ||
                            reservacion.FechaInicial.Value.TimeOfDay != this.vista.HoraReservacionInicial.Value)
                        {
                            reservacion = null;
                        }
                    }
                }

                if (reservacion == null && Resultado.Count == 0)
                {
                    return("La unidad ya se encuentra reservada para ese período");
                }
            }
            return(null);
        }
예제 #3
0
        private Object InterfazUsuarioADato()
        {
            ReservacionRDBOF bo = new ReservacionRDBOF();

            bo.Modelo          = new ModeloBO();
            bo.Unidad          = new Equipos.BO.UnidadBO();
            bo.UnidadOperativa = new UnidadOperativaBO();
            bo.UsuarioReservo  = new UsuarioBO();
            bo.Cliente         = new CuentaClienteIdealeaseBO();
            bo.Sucursal        = new SucursalBO();

            bo.Modelo.Id          = this.vista.ModeloID;
            bo.UnidadOperativa.Id = this.vista.UnidadOperativaID;
            bo.UsuarioReservo.Id  = this.vista.UsuarioReservoID;
            bo.Cliente.Id         = this.vista.CuentaClienteID;
            bo.Activo             = this.vista.Activo;

            if (!string.IsNullOrEmpty(this.vista.ModeloNombre) && !string.IsNullOrWhiteSpace(this.vista.ModeloNombre))
            {
                bo.Modelo.Nombre = this.vista.ModeloNombre;
            }
            if (!string.IsNullOrEmpty(this.vista.UsuarioReservoNombre) && !string.IsNullOrWhiteSpace(this.vista.UsuarioReservoNombre))
            {
                bo.UsuarioReservo.Nombre = this.vista.UsuarioReservoNombre;
            }
            if (!string.IsNullOrEmpty(this.vista.CuentaClienteNombre) && !string.IsNullOrWhiteSpace(this.vista.CuentaClienteNombre))
            {
                bo.Cliente.Nombre = this.vista.CuentaClienteNombre;
            }
            if (!string.IsNullOrEmpty(this.vista.NumeroEconomico) && !string.IsNullOrWhiteSpace(this.vista.NumeroEconomico))
            {
                bo.Unidad.NumeroEconomico = this.vista.NumeroEconomico;
            }
            if (!string.IsNullOrEmpty(this.vista.Numero) && !string.IsNullOrWhiteSpace(this.vista.Numero))
            {
                bo.Numero = this.vista.Numero;
            }

            bo.FechaInicial = this.CalcularFechaCompleta(this.vista.FechaReservacionInicial, this.vista.HoraReservacionInicial);
            bo.FechaFinal   = this.CalcularFechaCompleta(this.vista.FechaReservacionFinal, this.vista.HoraReservacionFinal);

            if (this.vista.SucursalID.HasValue)
            {
                bo.Sucursal.Id     = this.vista.SucursalID;
                bo.Sucursal.Nombre = this.vista.SucursalNombre;
            }
            else
            {
                bo.Sucursales = this.vista.SucursalesAutorizadas.ConvertAll(x => (SucursalBO)x);
            }

            return(bo);
        }
        public object PrepararBOBuscador(string catalogo)
        {
            object obj = null;

            switch (catalogo)
            {
            case "CuentaClienteIdealease":
                var cliente = new CuentaClienteIdealeaseBOF {
                    Cliente = new ClienteBO()
                };

                cliente.Nombre             = this.vista.CuentaClienteNombre;
                cliente.UnidadOperativa    = new UnidadOperativaBO();
                cliente.UnidadOperativa.Id = this.vista.UnidadOperativaID;

                obj = cliente;
                break;

            case "Modelo":
                ModeloBO modelo = new ModeloBO();
                modelo.Auditoria = new AuditoriaBO();
                modelo.Marca     = new MarcaBO();
                modelo.Nombre    = this.vista.ModeloNombre;
                modelo.Activo    = true;

                obj = modelo;
                break;

            case "UnidadDisponibleReservacion":
                ReservacionRDBOF reservacion = new ReservacionRDBOF();
                reservacion.Unidad          = new BPMO.SDNI.Equipos.BO.UnidadBO();
                reservacion.Unidad.Sucursal = new SucursalBO();

                reservacion.ConEquiposAliados  = false;
                reservacion.ConTramites        = false;
                reservacion.FechaInicial       = this.CalcularFechaCompleta(this.vista.FechaReservacionInicial, this.vista.HoraReservacionInicial);
                reservacion.FechaFinal         = this.CalcularFechaCompleta(this.vista.FechaReservacionFinal, this.vista.HoraReservacionFinal);
                reservacion.Modelo             = new ModeloBO();
                reservacion.Modelo.Id          = this.vista.ModeloID;
                reservacion.Modelo.Nombre      = this.vista.ModeloNombre;
                reservacion.UnidadOperativa    = new UnidadOperativaBO();
                reservacion.UnidadOperativa.Id = this.vista.UnidadOperativaID;

                if (this.vista.SucursalID.HasValue)
                {
                    reservacion.Unidad.Sucursal.Id = this.vista.SucursalID;
                }
                else if (this.vista.SucursalesSeguridad != null)
                {
                    reservacion.Sucursales = this.vista.SucursalesSeguridad.ConvertAll(p => new SucursalBO()
                    {
                        Id = p
                    });
                }

                obj = reservacion;
                break;

            case "Sucursal":
                SucursalBOF sucursal = new SucursalBOF();
                sucursal.UnidadOperativa = new UnidadOperativaBO {
                    Activo = true, Id = this.vista.UnidadOperativaID
                };
                sucursal.Nombre  = this.vista.SucursalNombre;
                sucursal.Usuario = new UsuarioBO {
                    Activo = true, Id = this.vista.UsuarioReservoID
                };                                                                                       //TODO:Revisar
                obj = sucursal;
                break;
            }

            return(obj);
        }
        public void SeleccionarUnidad(ReservacionRDBOF bof)
        {
            try
            {
                if (bof != null && bof.Unidad != null && bof.Unidad.UnidadID != null)
                {
                    bof.ConEquiposAliados = true;
                    bof.ConTramites       = true;

                    List <ReservacionRDBOF> lst = this.controlador.ConsultarDisponibles(this.dctx, bof);
                    if (lst.Count <= 0)
                    {
                        throw new Exception("No se encontró la unidad seleccionada.");
                    }

                    bof = lst[0];
                }

                if (bof == null)
                {
                    bof = new ReservacionRDBOF();
                }
                if (bof.Unidad == null)
                {
                    bof.Unidad = new Equipos.BO.UnidadBO();
                }
                if (bof.Unidad.CaracteristicasUnidad == null)
                {
                    bof.Unidad.CaracteristicasUnidad = new CaracteristicasUnidadBO();
                }
                if (bof.Unidad.Modelo == null)
                {
                    bof.Unidad.Modelo = new ModeloBO();
                }
                if (bof.Unidad.Modelo.Marca == null)
                {
                    bof.Unidad.Modelo.Marca = new MarcaBO();
                }

                this.vista.UnidadID                      = bof.Unidad.UnidadID;
                this.vista.UnidadAnio                    = bof.Unidad.Anio;
                this.vista.UnidadCapacidadCarga          = bof.Unidad.CaracteristicasUnidad.PBVMaximoRecomendado;
                this.vista.UnidadCapacidadTanque         = bof.Unidad.CaracteristicasUnidad.CapacidadTanque;
                this.vista.UnidadEquiposAliados          = bof.Unidad.EquiposAliados;
                this.vista.UnidadEstatusMantenimiento    = bof.EstatusMantenimiento;
                this.vista.UnidadEstatusOperacion        = bof.EstatusOperacion;
                this.vista.UnidadFechaPlaneadaLiberacion = bof.FechaPlaneadaLiberacion;
                this.vista.UnidadMarcaNombre             = bof.Unidad.Modelo.Marca.Nombre;
                this.vista.UnidadPlacaEstatal            = bof.ObtenerResultadoTramitePorTipo(ETipoTramite.PLACA_ESTATAL);
                this.vista.UnidadPlacaFederal            = bof.ObtenerResultadoTramitePorTipo(ETipoTramite.PLACA_FEDERAL);
                this.vista.UnidadRendimientoTanque       = bof.Unidad.CaracteristicasUnidad.RendimientoTanque;
                this.vista.UnidadSerie                   = bof.Unidad.NumeroSerie;
                this.vista.NumeroEconomico               = bof.Unidad.NumeroEconomico;

                this.vista.MostrarDetalleUnidad(bof.Unidad.UnidadID != null);
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".SeleccionarUnidad: " + ex.Message);
            }
        }