public bool DiaYHoraDisponible(Lugar pLugar, DateTime pFecha, int pDuracion, TimeSpan pHora)
        {
            bool resultado = true;

            //Verifico si para ese dia existe algun espectaculo en ese lugar
            foreach (Espectaculo e in espectaculos)
            {
                if (e != null)
                {
                    //Si en el mismo lugar existe un espectaculo ese mismo dia
                    if (e.Lugar.Equals(pLugar))
                    {
                        if (DateTime.Compare(e.Fecha, pFecha) == 0)
                        {
                            //Hora final del espectaculo existente
                            TimeSpan horaFinalizacion = e.Hora.Add(TimeSpan.FromMinutes(pDuracion));
                            //Si el espectaculo a insertar empieza antes de que finalice el espectaculo que ya existe, el lugar no se encuentra disponible
                            if (pHora < horaFinalizacion)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            return(resultado);
        }
        public Lugar BuscarLugar(string pNombre)
        {
            Lugar lugarAux = new Lugar();

            foreach (Lugar l in lugares)
            {
                if (l.Nombre.Equals(pNombre))
                {
                    lugarAux = l;
                }
            }
            return(lugarAux);
        }
        public bool AltaLugar(string pNombre, string pDir, int pTel, int pCapMax)
        {
            bool retorno = false;

            //Verifico que sean valores validos
            if (!string.IsNullOrEmpty(pNombre) && !string.IsNullOrEmpty(pDir) && Herramientas.ochoCaracteres(pTel.ToString()) && pCapMax > 0)
            {
                //Verifico que no exista otro lugar con el mismo nombre y direccion
                if (!ExisteLugar(pNombre, pDir))
                {
                    Lugar lugarAux = new Lugar(pNombre, pDir, pTel, pCapMax);
                    lugares.Add(lugarAux);
                }
            }
            return(retorno);
        }
Exemple #4
0
        public VIP(string pNombre, string pTipo, DateTime pFecha, int pDuracion,
                   TimeSpan pHora, Lugar pLugar, decimal pPrecio, string pCategoria, string pDescripcion, decimal pRecargo)
            : base(pNombre, pTipo, pFecha, pDuracion, pHora, pLugar, pPrecio, pCategoria, pDescripcion)
        {
            this.Nombre      = pNombre;
            this.Tipo        = pTipo;
            this.Fecha       = pFecha;
            this.Duracion    = pDuracion;
            this.Hora        = pHora;
            this.Lugar       = pLugar;
            this.Precio      = pPrecio;
            this.Categoria   = pCategoria;
            this.Descripcion = pDescripcion;

            this.recargo = pRecargo;
        }
        //LO LLAMA EL SERIALIZADOR AL DESERIALIZAR EL OBJETO
        public Espectaculo(SerializationInfo info, StreamingContext context)
        {
            this.idEspec      = (int)info.GetValue("id", typeof(int));
            Espectaculo.ultId = (int)info.GetValue("ultId", typeof(int));

            this.nombre           = (string)info.GetValue("nombre", typeof(string));
            this.tipo             = (string)info.GetValue("tipo", typeof(string));
            this.fecha            = (DateTime)info.GetValue("fecha", typeof(DateTime));
            this.duracion         = (int)info.GetValue("duracion", typeof(int));
            this.hora             = (TimeSpan)info.GetValue("hora", typeof(TimeSpan));
            this.lugar            = (Lugar)info.GetValue("lugar", typeof(Lugar));
            this.precio           = (decimal)info.GetValue("precio", typeof(decimal));
            this.categoria        = (string)info.GetValue("categoria", typeof(string));
            this.descripcion      = (string)info.GetValue("descripcion", typeof(string));
            this.entradasVendidas = (int)info.GetValue("entradasVendidas", typeof(int));
            this.lleno            = (bool)info.GetValue("lleno", typeof(bool));
        }
        public Estandar(string pNombre, string pTipo, DateTime pFecha, int pDuracion,
                        TimeSpan pHora, Lugar pLugar, decimal pPrecio, string pCategoria, string pDescripcion, bool pImpreso)
            : base(pNombre, pTipo, pFecha, pDuracion, pHora, pLugar, pPrecio, pCategoria, pDescripcion)
        {
            this.Nombre      = pNombre;
            this.Tipo        = pTipo;
            this.Fecha       = pFecha;
            this.Duracion    = pDuracion;
            this.Hora        = pHora;
            this.Lugar       = pLugar;
            this.Precio      = pPrecio;
            this.Categoria   = pCategoria;
            this.Descripcion = pDescripcion;

            this.impreso       = pImpreso;
            Estandar.costoFijo = 50;
        }
        public Espectaculo(string pNombre, string pTipo, DateTime pFecha, int pDuracion,
                           TimeSpan pHora, Lugar pLugar, decimal pPrecio, string pCategoria, string pDescripcion)
        {
            this.nombre           = pNombre;
            this.tipo             = pTipo;
            this.fecha            = pFecha;
            this.duracion         = pDuracion;
            this.hora             = pHora;
            this.lugar            = pLugar;
            this.precio           = pPrecio;
            this.categoria        = pCategoria;
            this.descripcion      = pDescripcion;
            this.entradasVendidas = 0;
            this.lleno            = false;

            this.idEspec = ultId + 1;
            ultId        = this.idEspec;
        }
        public string AltaVip(string pNombre, string pTipo, DateTime pFecha, int pDuracion, TimeSpan pHora, Lugar pLugar, decimal pPrecio,
                              string pCategoria, string pDescripcion, decimal pRecargo)
        {
            string mensaje = "";

            //Valido todos los campos
            if (!string.IsNullOrEmpty(pNombre) && !string.IsNullOrEmpty(pTipo) && pFecha != null && pDuracion > 5 && pHora != null && pLugar != null &&
                pPrecio >= 0 && !string.IsNullOrEmpty(pCategoria) && !string.IsNullOrEmpty(pDescripcion) && pRecargo >= 0)
            {
                //Valido que el tipo de espectaculo sea valido
                if (instanciaEspectaculo.TipoEspectaculoValido(pTipo))
                {
                    //Si no existe otro Espectaculo con el mismo nombre
                    if (!instanciaEspectaculo.ExisteEspectaculo(pNombre))
                    {
                        //Validar que no haya otro espectaculo en ese horario
                        if (instanciaEspectaculo.DiaYHoraDisponible(pLugar, pFecha, pDuracion, pHora))
                        {
                            VIP vip = new VIP(pNombre, pTipo, pFecha, pDuracion, pHora, pLugar, pPrecio, pCategoria, pDescripcion, pRecargo);
                            instanciaEspectaculo.espectaculos.Add(vip);
                            mensaje = "Alta exitosa!";
                        }
                        else
                        {
                            mensaje = "El lugar no se encuentra disponible a ese dia y hora";
                        }
                    }
                    else
                    {
                        mensaje = "Ya existe otro espectaculo con ese nombre";
                    }
                }
                else
                {
                    mensaje = "Tipo de espectaculo invalido";
                }
            }
            else
            {
                mensaje = "Datos invalidos";
            }
            return(mensaje);
        }