private void ConsultarCompleto()
        {
            try
            {
                ReservacionRDBO bo = (ReservacionRDBO)this.InterfazUsuarioADato();

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

                if (lst.Count < 1)
                {
                    throw new Exception("No se encontró ningún registro que corresponda a la información proporcionada.");
                }
                if (lst.Count > 1)
                {
                    throw new Exception("La consulta devolvió más de un registro.");
                }

                this.DatoAInterfazUsuario(lst[0]);
                this.vista.UltimoObjeto = lst[0];

                //Se consulta y muestra la información de la unidad
                this.presentadorDetalle.SeleccionarUnidad(new ReservacionRDBOF()
                {
                    Unidad = lst[0].Unidad, ConEquiposAliados = true, ConTramites = true
                });
            }
            catch (Exception ex)
            {
                this.DatoAInterfazUsuario(new ReservacionRDBO());
                throw new Exception(this.nombreClase + ".ConsultarCompleto:" + ex.Message);
            }
        }
        public void Cancelar()
        {
            try
            {
                ReservacionRDBO bo     = (ReservacionRDBO)this.InterfazUsuarioADato();
                ReservacionRDBO ultimo = (ReservacionRDBO)this.InterfazUsuarioADato();

                bo.Activo = false;

                //Se crea el objeto de seguridad
                UsuarioBO usuario = new UsuarioBO()
                {
                    Id = this.vista.UsuarioID
                };
                AdscripcionBO adscripcion = new AdscripcionBO()
                {
                    UnidadOperativa = new UnidadOperativaBO()
                    {
                        Id = this.vista.UnidadOperativaID
                    }
                };
                SeguridadBO seguridadBO = new SeguridadBO(Guid.Empty, usuario, adscripcion);

                this.controlador.Actualizar(this.dctx, bo, ultimo, seguridadBO);

                this.Regresar();
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".Cancelar: " + ex.Message);
            }
        }
Пример #3
0
        public void IrADetalle(int?reservacionID)
        {
            try
            {
                if (reservacionID == null)
                {
                    throw new Exception("No se encontró el registro seleccionado.");
                }

                ReservacionRDBO bo = new ReservacionRDBO {
                    ReservacionID = reservacionID
                };

                this.vista.LimpiarSesion();

                Dictionary <string, object> paquete = new Dictionary <string, object>();
                paquete.Add("ObjetoFiltro", this.InterfazUsuarioADato());
                paquete.Add("Bandera", true);

                this.vista.EstablecerPaqueteNavegacion("FiltrosReservacion", paquete);
                this.vista.EstablecerPaqueteNavegacion("ReservacionRDBO", bo);

                this.vista.RedirigirADetalle();
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".IrADetalle: " + ex.Message);
            }
        }
        private void DatoAInterfazUsuario(object obj)
        {
            ReservacionRDBO bo = (ReservacionRDBO)obj;

            this.vista.Numero        = bo.Numero;
            this.vista.ReservacionID = bo.ReservacionID;
        }
        public void Editar()
        {
            string s;

            if ((s = this.ValidarCampos()) != null)
            {
                this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null);
                return;
            }

            try
            {
                ReservacionRDBO bo = (ReservacionRDBO)this.InterfazUsuarioADato();

                //Se crea el objeto de seguridad
                UsuarioBO usuario = new UsuarioBO()
                {
                    Id = this.vista.UsuarioID
                };
                AdscripcionBO adscripcion = new AdscripcionBO()
                {
                    UnidadOperativa = new UnidadOperativaBO()
                    {
                        Id = this.vista.UnidadOperativaID
                    }
                };
                SeguridadBO seguridadBO = new SeguridadBO(Guid.Empty, usuario, adscripcion);

                this.controlador.Actualizar(this.dctx, bo, this.vista.UltimoObjeto as ReservacionRDBO, seguridadBO);

                this.vista.LimpiarSesion();
                this.vista.EstablecerPaqueteNavegacion("ReservacionRDBO", new ReservacionRDBO()
                {
                    ReservacionID = bo.ReservacionID
                });
                this.vista.RedirigirADetalle();
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".Editar: " + ex.Message);
            }
        }
        private object InterfazUsuarioADato()
        {
            ReservacionRDBO bo = new ReservacionRDBO();

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

            bo.Activo         = this.vista.Activo;
            bo.Auditoria.FC   = this.vista.FC;
            bo.Auditoria.FUA  = this.vista.FUA;
            bo.Auditoria.UC   = this.vista.UC;
            bo.Auditoria.UUA  = this.vista.UUA;
            bo.Cliente.Id     = this.vista.CuentaClienteID;
            bo.Cliente.Nombre = this.vista.CuentaClienteNombre;
            bo.FechaFinal     = this.vista.FechaReservacionFinal;
            bo.FechaInicial   = this.vista.FechaReservacionInicial;
            bo.Modelo.Id      = this.vista.ModeloID;
            bo.Modelo.Nombre  = this.vista.ModeloNombre;
            bo.Numero         = this.vista.Numero;
            bo.Observaciones  = this.vista.Observaciones;
            bo.ReservacionID  = this.vista.ReservacionID;
            if (this.vista.TipoID != null)
            {
                bo.Tipo = (ETipoReservacion)Enum.Parse(typeof(ETipoReservacion), this.vista.TipoID.Value.ToString());
            }
            bo.Unidad.UnidadID        = this.vista.UnidadID;
            bo.Unidad.NumeroEconomico = this.vista.NumeroEconomico;
            bo.UnidadOperativa.Id     = this.vista.UnidadOperativaID;
            bo.UsuarioReservo.Id      = this.vista.UsuarioReservoID;
            bo.UsuarioReservo.Nombre  = this.vista.UsuarioReservoNombre;
            bo.Sucursal.Id            = this.vista.SucursalID;     //SC_0051
            bo.Sucursal.Nombre        = this.vista.SucursalNombre; //SC_0051
            return(bo);
        }
        private void EstablecerDatosNavegacion(object paqueteNavegacion)
        {
            try
            {
                if (paqueteNavegacion == null)
                {
                    throw new Exception("Se esperaba un objeto en la navegación. No se puede identificar qué reservación se desea consultar.");
                }
                if (!(paqueteNavegacion is ReservacionRDBO))
                {
                    throw new Exception("Se esperaba una Reservación.");
                }

                ReservacionRDBO bo = (ReservacionRDBO)paqueteNavegacion;

                this.DatoAInterfazUsuario(bo);
            }
            catch (Exception ex)
            {
                this.DatoAInterfazUsuario(new ReservacionRDBO());
                throw new Exception(this.nombreClase + ".EstablecerDatosNavegacion: " + ex.Message);
            }
        }
        private void DatoAInterfazUsuario(object obj)
        {
            ReservacionRDBO bo = (ReservacionRDBO)obj;

            if (bo.Auditoria == null)
            {
                bo.Auditoria = new AuditoriaBO();
            }
            if (bo.Cliente == null)
            {
                bo.Cliente = new CuentaClienteIdealeaseBO();
            }
            if (bo.Modelo == null)
            {
                bo.Modelo = new ModeloBO();
            }
            if (bo.Unidad == null)
            {
                bo.Unidad = new Equipos.BO.UnidadBO();
            }
            if (bo.UnidadOperativa == null)
            {
                bo.UnidadOperativa = new UnidadOperativaBO();
            }
            if (bo.UsuarioReservo == null)
            {
                bo.UsuarioReservo = new UsuarioBO();
            }

            this.vista.Numero              = bo.Numero;
            this.vista.ReservacionID       = bo.ReservacionID;
            this.vista.Activo              = bo.Activo;
            this.vista.CuentaClienteID     = bo.Cliente.Id;
            this.vista.CuentaClienteNombre = bo.Cliente.Nombre;
            this.vista.FC = bo.Auditoria.FC;
            this.vista.FechaReservacionFinal   = bo.FechaFinal;
            this.vista.FechaReservacionInicial = bo.FechaInicial;
            this.vista.FUA             = bo.Auditoria.FUA;
            this.vista.ModeloID        = bo.Modelo.Id;
            this.vista.ModeloNombre    = bo.Modelo.Nombre;
            this.vista.NumeroEconomico = bo.Unidad.NumeroEconomico;
            this.vista.Observaciones   = bo.Observaciones;
            if (bo.Tipo != null)
            {
                this.vista.TipoID = (int)bo.Tipo;
            }
            else
            {
                this.vista.TipoID = null;
            }
            this.vista.UC                   = bo.Auditoria.UC;
            this.vista.UnidadID             = bo.Unidad.UnidadID;
            this.vista.UsuarioReservoID     = bo.UsuarioReservo.Id;
            this.vista.UsuarioReservoNombre = bo.UsuarioReservo.Nombre;
            this.vista.UUA                  = bo.Auditoria.UUA;

            if (bo.Sucursal == null)
            {
                bo.Sucursal = new SucursalBO();
            }

            this.vista.AnioUnidad     = bo.Unidad != null ? (bo.Unidad.Anio.HasValue ? bo.Unidad.Anio : null) : null; //SC_0051
            this.vista.SucursalID     = bo.Sucursal.Id;                                                               //SC_0051
            this.vista.SucursalNombre = bo.Sucursal.Nombre;                                                           //SC_0051
        }
Пример #9
0
        private void DatoAInterfazUsuario(Object obj)
        {
            ReservacionRDBO bo = (ReservacionRDBO)obj;

            if (!String.IsNullOrEmpty(bo.Numero) && !String.IsNullOrWhiteSpace(bo.Numero))
            {
                this.vista.Numero = bo.Numero;
            }
            else
            {
                this.vista.Numero = null;
            }

            if (bo.Cliente != null && !String.IsNullOrEmpty(bo.Cliente.Nombre) && !String.IsNullOrWhiteSpace(bo.Cliente.Nombre))
            {
                this.vista.CuentaClienteNombre = bo.Cliente.Nombre;
            }
            else
            {
                this.vista.CuentaClienteNombre = null;
            }

            if (bo.Cliente != null && bo.Cliente.Id != null)
            {
                this.vista.CuentaClienteID = bo.Cliente.Id;
            }
            else
            {
                this.vista.CuentaClienteID = null;
            }

            if (bo.Modelo != null && !String.IsNullOrEmpty(bo.Modelo.Nombre) && !String.IsNullOrWhiteSpace(bo.Modelo.Nombre))
            {
                this.vista.ModeloNombre = bo.Modelo.Nombre;
            }
            else
            {
                this.vista.ModeloNombre = null;
            }

            if (bo.Modelo != null && bo.Modelo.Id != null)
            {
                this.vista.ModeloID = bo.Modelo.Id;
            }
            else
            {
                this.vista.ModeloID = null;
            }

            if (bo.Unidad != null && !String.IsNullOrEmpty(bo.Unidad.NumeroEconomico) && !String.IsNullOrWhiteSpace(bo.Unidad.NumeroEconomico))
            {
                this.vista.NumeroEconomico = bo.Unidad.NumeroEconomico;
            }
            else
            {
                this.vista.NumeroEconomico = null;
            }

            if (bo.UsuarioReservo != null && bo.UsuarioReservo.Id != null)
            {
                this.vista.UsuarioReservoID = bo.UsuarioReservo.Id;
            }
            else
            {
                this.vista.UsuarioReservoID = null;
            }

            if (bo.UsuarioReservo != null && !String.IsNullOrEmpty(bo.UsuarioReservo.Nombre) && !String.IsNullOrWhiteSpace(bo.UsuarioReservo.Nombre))
            {
                this.vista.UsuarioReservoNombre = bo.UsuarioReservo.Nombre;
            }
            else
            {
                this.vista.UsuarioReservoNombre = null;
            }

            if (bo.FechaInicial != null)
            {
                this.vista.FechaReservacionInicial = bo.FechaInicial.Value.Date;
                this.vista.HoraReservacionInicial  = bo.FechaInicial.Value.TimeOfDay;
            }
            else
            {
                this.vista.FechaReservacionInicial = null;
                this.vista.HoraReservacionInicial  = null;
            }

            if (bo.FechaFinal != null)
            {
                this.vista.FechaReservacionFinal = bo.FechaFinal.Value.Date;
                this.vista.HoraReservacionFinal  = bo.FechaFinal.Value.TimeOfDay;
            }
            else
            {
                this.vista.FechaReservacionFinal = null;
                this.vista.HoraReservacionFinal  = null;
            }

            if (bo.Activo != null)
            {
                this.vista.Activo = bo.Activo;
            }
            else
            {
                this.vista.Activo = null;
            }

            this.vista.SucursalID     = bo.Sucursal != null ? (bo.Sucursal.Id.HasValue ? bo.Sucursal.Id : null) : null;                                       //SC051
            this.vista.SucursalNombre = bo.Sucursal != null ? (!string.IsNullOrEmpty(bo.Sucursal.Nombre) ? bo.Sucursal.Nombre : string.Empty) : string.Empty; //SC051
        }
        public void Registrar()
        {
            string s;

            if ((s = this.ValidarCampos()) != null)
            {
                this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null);
                return;
            }

            try
            {
                ReservacionRDBO bo = (ReservacionRDBO)this.InterfazUsuarioADato();

                //Se crea el objeto de seguridad
                UsuarioBO usuario = new UsuarioBO()
                {
                    Id = this.vista.UsuarioID
                };
                AdscripcionBO adscripcion = new AdscripcionBO()
                {
                    UnidadOperativa = new UnidadOperativaBO()
                    {
                        Id = this.vista.UnidadOperativaID
                    }
                };
                SeguridadBO seguridadBO = new SeguridadBO(Guid.Empty, usuario, adscripcion);

                this.controlador.InsertarCompleto(this.dctx, bo, seguridadBO);

                //Se consulta lo insertado para recuperar los ID
                DataSet ds = this.controlador.ConsultarSet(this.dctx, bo);
                if (ds.Tables[0].Rows.Count <= 0)
                {
                    throw new Exception("Al consultar lo insertado no se encontraron coincidencias.");
                }
                if (ds.Tables[0].Rows.Count > 1)
                {
                    throw new Exception("Al consultar lo insertado se encontró más de una coincidencia.");
                }

                bo.ReservacionID = this.controlador.DataRowToReservacionRDBO(ds.Tables[0].Rows[0]).ReservacionID;
                bo.Numero        = this.controlador.DataRowToReservacionRDBO(ds.Tables[0].Rows[0]).Numero;

                //Se obtiene el nombre del usuario que reservó
                if (bo.UsuarioReservo != null && bo.UsuarioReservo.Id != null)
                {
                    List <UsuarioBO> lst = FacadeBR.ConsultarUsuario(this.dctx, bo.UsuarioReservo);
                    if (lst.Count > 0)
                    {
                        bo.UsuarioReservo = lst[0];
                    }
                }

                //Se agrega a la lista de registradas
                List <ReservacionRDBO> lstReservacionesRealizadas = new List <ReservacionRDBO>();
                if (this.vista.ReservacionesRealizadas != null)
                {
                    lstReservacionesRealizadas = (List <ReservacionRDBO>) this.vista.ReservacionesRealizadas;
                }
                lstReservacionesRealizadas.Add(bo);
                this.vista.ReservacionesRealizadas = lstReservacionesRealizadas;

                //Se reinicia el formulario
                this.presentadorDetalle.PrepararNuevo();
                this.EstablecerConfiguracionInicial();
            }
            catch (Exception ex)
            {
                throw new Exception(this.nombreClase + ".Registrar: " + ex.Message);
            }
        }