Ejemplo n.º 1
0
        /// <summary>
        /// 说明:<调用函数调用InsertMovieSchedules函数可以完成对电影时刻表增加多条记录的功能>
        /// </summary>
        /// <param name="<newMovieSchedules>"><接受调用函数传入的一个COLLECTION对象集合></param>
        /// <returns><操作成功返回True,否则返回False> </returns>
        ///<exception>数据库增加操作异常</exception>

        public bool InsertMovieSchedules(List <MOVIE_SCHEDULE> newMovieSchedules)
        {
            //创建数据库实体类对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            //添加新记录到内存
            foreach (MOVIE_SCHEDULE newMovieSchedule in newMovieSchedules)
            {
                _entity.AddToMOVIE_SCHEDULE(newMovieSchedule);
            }

            //保存修改到数据库
            try
            {
                int i = _entity.SaveChanges();
                isSucceed = true;
            }
            catch (Exception ex)
            {
                //异常处理?
                Console.WriteLine(ex);
                return(false);
            }

            //撤销entity对象
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 2
0
        public bool AddCinemaComment(string newCinemaName, int newCinemaId, CINAME_COMMENT newComment)
        {
            //添加用户对电影院的评论
            //修改 增加一个电影院的ID 唯一定位电影院
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from cinema in entity.CINEMA
                         where cinema.name == newCinemaName && cinema.id == newCinemaId
                         select cinema;//检索出对应的电影院

            if (result.Count() == 1)
            {
                entity.CINAME_COMMENT.AddObject(newComment);//向电影评论列表中添加一条新评论
                try
                {
                    int i = entity.SaveChanges();
                    entity.Dispose();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public List <MOVIE> SearchCollectedMovies(int newUserID)
        {
            //返回用户收藏列表
            WATCHMOVIEEntities w     = new WATCHMOVIEEntities();
            List <MOVIE>       movie = new List <MOVIE>();

            //sql语句
            //select *
            // from movie
            //where id in(select movie_id from Collection where user_id=newUserId)

            //方法一
            //var result = from m in w.MOVIE
            //             from c in w.COLLECTION
            //             where m.id == c.movie_id && c.user_id == newUserID
            //             select m;

            //方法二连接两张表
            var result = from m in w.MOVIE
                         join c in w.COLLECTION on m.id equals c.movie_id
                         where c.user_id == newUserID
                         select m;

            foreach (var r in result)
            {
                movie.Add(r);
            }

            return(movie);
        }
Ejemplo n.º 4
0
        public bool AddMovieComment(string newMovieName, MOVIE_COMMENT newComment)
        {
            //添加用户对电影的评论
            //??????????????????????????

            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from movie in entity.MOVIE
                         where movie.name == newMovieName
                         select movie;//定位到对应的电影

            if (result.Count() == 1)
            {
                entity.MOVIE_COMMENT.AddObject(newComment);
                try
                {
                    int i = entity.SaveChanges();
                    entity.Dispose();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool DeleteUser() //删除用户
        {
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from user in entity.RUSER
                         where user.id == _id
                         select user;

            if (result.Count() == 1)
            {
                entity.RUSER.DeleteObject(result.First());
                try
                {
                    int i = entity.SaveChanges();
                    entity.Dispose();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool UpdatePassword(string newEmail, string newPassword)
        {
            //更新密码
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from user in entity.RUSER
                         where user.email == newEmail
                         select user;

            if (result.Count() == 1)
            {
                //修改密码
                result.First().password = newPassword;
                try
                {
                    int i = entity.SaveChanges();//保存修改
                    entity.Dispose();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        public bool DeleteCinema(string name, string addr)
        {
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();

            //根据电影院名字遍历数据库表CINEMA
            var result = from cinema in entity.CINEMA
                         where cinema.name == name && cinema.address == addr
                         select cinema;

            //删除满足条件的电影院
            foreach (var deleteCinema in result)
            {
                entity.CINEMA.DeleteObject(deleteCinema);
            }
            try
            {
                int i = entity.SaveChanges();
            }
            catch (Exception exp)
            {
                // MessageBox.Show(exp.ToString());
                entity.Dispose();//销毁对象
                return(false);
            }
            entity.Dispose();//销毁对象
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 此函数用来增加一条电影院评论
        /// </summary>
        /// <param name="newComment"></param>
        /// <returns></returns>
        /// <exception>数据库插入异常</exception>
        public bool InsertCinemaComment(CINAME_COMMENT newComment)
        {
            //创建数据库实体类对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            //添加记录到内存
            _entity.AddToCINAME_COMMENT(newComment);

            //保存修改到数据库
            try
            {
                int i = _entity.SaveChanges();
                isSucceed = true;
            }
            catch (Exception ex)
            {
                //异常处理?
                Console.WriteLine(ex);
                return(false);
            }

            //撤销entity对象
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 说明:<调用函数调用InsertCollection函数可以完成对收藏夹增加一条记录的功能>
        /// </summary>
        /// <param name="<newCollection>"><接受调用函数传入的一个COLLECTION对象></param>
        /// <returns><操作成功返回True,否则返回False> </returns>
        ///<exception>数据库增加操作异常</exception>

        public bool InsertCollection(COLLECTION newCollection)
        {
            //创建数据库实体类对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            //添加记录到内存
            _entity.AddToCOLLECTION(newCollection);

            //保存修改到数据库
            try
            {
                int i = _entity.SaveChanges();
                isSucceed = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //异常处理?
                return(false);
            }

            //撤销entity对象
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 10
0
        public bool PreferenceSave(string newEmail, string newType)
        {
            //保存用户偏好
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from user in entity.RUSER
                         where user.email == newEmail
                         select user;//找到用户

            if (result.Count() == 1)
            {
                result.First().like_kind = newType;//保存用户偏好
                //result.First().address = newAddr;
                try
                {
                    int i = entity.SaveChanges();//同步到数据库
                    entity.Dispose();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 11
0
        /// 这个函数根据电影名,发表时间对电影院评论支持数增加1
        /// </summary>
        /// <param name="newMovieName"></param>
        /// <param name="newTime"></param>
        /// <returns></returns>
        //public bool IncreaseMovieCommentSupport(string newMovieName, DateTime newTime)
        //{
        //    bool isSucceed = false;
        //    _entity = new WATCHMOVIEEntities();
        //    int movieId = new Movie().GetMovieId(newMovieName);

        //    if (movieId != -1)//如果movie_id为-1则代表没有这个电影院,所以出错了
        //    {
        //        var result = from m in _entity.MOVIE_COMMENT
        //                     where m.movie_id == movieId && m.time.Equals(newTime)
        //                     select m;

        //        if (result.Count() == 1)
        //        {
        //            result.First().support += 1;
        //            try
        //            {
        //                int i = _entity.SaveChanges();
        //                isSucceed = true;
        //            }
        //            catch (Exception ex)
        //            {
        //                //异常处理
        //                Console.WriteLine(ex);
        //                return false;
        //            }
        //        }

        //        //撤销entity对象
        //        _entity.Dispose();
        //    }

        //    return isSucceed;
        //}


        // <summary>
        /// 这个函数根据电影名,发表时间对电影院评论支持数增加1
        /// </summary>
        /// <param name="newMovieName"></param>
        /// <param name="newTime"></param>
        /// <returns></returns>
        public bool IncreaseMovieCommentSupport(string newMovieName, DateTime newTime)
        {
            bool isSucceed = false;

            _entity = new WATCHMOVIEEntities();
            int movieId = new Movie().GetMovieId(newMovieName);

            if (movieId != -1)//如果movie_id为-1则代表没有这个电影院,所以出错了
            {
                var result = from m in _entity.MOVIE_COMMENT
                             where m.movie_id == movieId && m.time.Value.Equals(newTime)
                             select m;


                if (result.Count() == 1)
                {
                    result.First().support += 1;
                    try
                    {
                        int i = _entity.SaveChanges();
                        isSucceed = true;
                    }
                    catch (Exception ex)
                    {
                        //异常处理
                        Console.WriteLine(ex);
                        return(false);
                    }
                }
                //撤销entity对象
                _entity.Dispose();
            }

            return(isSucceed);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 这个函数根据电影院名,电影院地址,发表时间对电影院评论支持数增加1
        /// </summary>
        /// <param name="newCinemaName"></param>
        /// <param name="newCinemaAddr"></param>
        /// <param name="newTime"></param>
        /// <returns></returns>
        //public bool IncreaseCinemaCommentSupport(string newCinemaName, string newCinemaAddr, DateTime newTime)
        //{
        //    bool isSucceed = false;
        //    _entity = new WATCHMOVIEEntities();
        //    int cinemaId = new Cinema().GetCinemaId(newCinemaName, newCinemaAddr);

        //    if (cinemaId != -1)//如果cinema_id为-1则代表没有这个电影院,所以出错了
        //    {
        //        var result = from c in _entity.CINAME_COMMENT
        //                     where c.cinema_id == cinemaId && c.time.Equals(newTime)
        //                     select c;

        //        if (result.Count() == 1)
        //        {
        //            result.First().support += 1;
        //            try
        //            {
        //                int i = _entity.SaveChanges();
        //                isSucceed = true;
        //            }
        //            catch (Exception ex)
        //            {
        //                //异常处理
        //                Console.WriteLine(ex);
        //                return false;
        //            }
        //        }

        //        //撤销entity对象
        //        _entity.Dispose();
        //    }

        //    return isSucceed;
        //}

        /// <summary>
        /// 这个函数根据电影院名,电影院地址,发表时间对电影院评论支持数增加1
        /// </summary>
        /// <param name="newCinemaName"></param>
        /// <param name="newCinemaAddr"></param>
        /// <param name="newTime"></param>
        /// <returns></returns>
        //public bool IncreaseCinemaCommentSupport(string newCinemaName, string newCinemaAddr, DateTime newTime)
        //{
        //    bool isSucceed = false;
        //    _entity = new WATCHMOVIEEntities();
        //    int cinemaId = new Cinema().GetCinemaId(newCinemaName, newCinemaAddr);

        //    if (cinemaId != -1)//如果cinema_id为-1则代表没有这个电影院,所以出错了
        //    {
        //        var result = from c in _entity.CINAME_COMMENT
        //                     where c.cinema_id == cinemaId && c.time.Value.Equals(newTime)
        //                     select c;

        //        if (result.Count() == 1)
        //        {
        //            result.First().support += 1;
        //            try
        //            {
        //                int i = _entity.SaveChanges();
        //                isSucceed = true;
        //            }
        //            catch (Exception ex)
        //            {
        //                //异常处理
        //                Console.WriteLine(ex);
        //                return false;
        //            }
        //        }

        //        //撤销entity对象
        //        _entity.Dispose();
        //    }

        //    return isSucceed;
        //}
        public bool IncreaseCinemaCommentSupport(string newCinemaName, DateTime newTime)
        {
            bool isSucceed = false;

            _entity = new WATCHMOVIEEntities();
            int cinemaId = new Cinema().GetCinemaId(newCinemaName);

            if (cinemaId != -1)//如果cinema_id为-1则代表没有这个电影院,所以出错了
            {
                var result = from c in _entity.CINAME_COMMENT
                             where c.cinema_id == cinemaId && c.time.Value.Equals(newTime)
                             select c;

                if (result.Count() == 1)
                {
                    result.First().support += 1;
                    try
                    {
                        int i = _entity.SaveChanges();
                        isSucceed = true;
                    }
                    catch (Exception ex)
                    {
                        //异常处理
                        Console.WriteLine(ex);
                        return(false);
                    }
                }

                //撤销entity对象
                _entity.Dispose();
            }

            return(isSucceed);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 此函数用来根据id删除电影院评论
        /// </summary>
        /// <param name="<newId>"></param>
        /// <returns><操作成功返回True,否则返回False> </returns>
        ///<exception>数据库删除操作异常</exception>
        public bool DeleteCinemaCommentById(int newId)
        {
            //创建数据库实体对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            //查找到需要删除的数据——(根据收藏id查找 结果只可能是一个)
            var result = from c in _entity.CINAME_COMMENT
                         where c.id == newId
                         select c;

            //从数据库中删除查找到的记录 并保存
            if (result.Count() >= 1)
            {
                _entity.CINAME_COMMENT.DeleteObject(result.First());
                try
                {
                    int i = _entity.SaveChanges();
                    isSucceed = true;
                }
                catch (Exception ex)
                {
                    //异常处理
                    Console.WriteLine(ex);
                    return(false);
                }
            }

            //撤销entity对象
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 14
0
        public List <CINEMA> SearchAddrCinemas(string newAddr)
        {
            /*addr=null 时 返回所有的电影院列表
             * addr!=null 时 返回对应地区的电影院列表
             */
            WATCHMOVIEEntities w       = new WATCHMOVIEEntities();
            List <CINEMA>      cinemas = new List <CINEMA>();

            if (newAddr != null)
            {
                var result = from c in w.CINEMA
                             where c.address.Equals(newAddr)
                             select c;

                foreach (var r in result)
                {
                    cinemas.Add(r);
                }
            }
            else
            {
                var result = from c in w.CINEMA
                             select c;

                foreach (var r in result)
                {
                    cinemas.Add(r);
                }
            }
            return(cinemas);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 说明:<调用函数调用DeleteMovieScheduleById函数可以完成对电影时刻表删除一条记录的功能>
        /// </summary>
        /// <param name="<newId>"><接受调用函数传入的一个MOVIE_SCHEDULE对象的Id></param>
        /// <returns><操作成功返回True,否则返回False> </returns>
        ///<exception>数据库删除操作异常</exception>
        public bool DeleteMovieScheduleById(int newId)
        {
            //创建数据库实体对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            //查找到需要删除的数据——(根据电影时刻表id查找 结果只可能是一个)
            var result = from c in _entity.MOVIE_SCHEDULE
                         where c.id == newId
                         select c;

            //从数据库中删除查找到的记录 并保存
            if (result.Count() >= 1)
            {
                _entity.MOVIE_SCHEDULE.DeleteObject(result.First());

                try
                {
                    int i = _entity.SaveChanges();
                    isSucceed = true;
                }
                catch (Exception ex)
                {
                    //异常处理?
                    Console.WriteLine(ex);
                    return(false);
                }
            }

            //撤销entity对象
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 16
0
        public string SearchCinemaNameById(int newCinemaId)
        {
            //根据电影院id 得到电影院名
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from c in entity.CINEMA
                         where c.id == newCinemaId
                         select c;

            return(result.First().name);
        }
Ejemplo n.º 17
0
        public int GetGradeByName(string newMovieName)
        {
            //根据电影名字得到该电影的评分
            int grade = 0;
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();

            var result = from m in entity.MOVIE
                         where m.name.Equals(newMovieName)
                         select m;

            grade = (int)result.First().rank;

            return(grade);
        }
Ejemplo n.º 18
0
        public string GetKindByName(string newMovieName)
        {
            //根据电影名字得到电影种类
            string             kind   = null;
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();

            var result = from m in entity.MOVIE
                         where m.name.Equals(newMovieName)
                         select m;

            kind = result.First().kind;

            return(kind);
        }
Ejemplo n.º 19
0
        public CINEMA SearchCinema(int newCinemaId)
        {
            //根据电影院名 返回一个电影院对象
            WATCHMOVIEEntities w      = new WATCHMOVIEEntities();
            CINEMA             cinema = new CINEMA();

            var result = from c in w.CINEMA
                         where c.id == newCinemaId
                         select c;

            if (result.Count() > 0)
            {
                cinema = result.First();
            }
            return(cinema);
        }
Ejemplo n.º 20
0
        public CINEMA SearchCinema(string newCinemaName)
        {
            //根据电影院名 返回一个电影院对象
            WATCHMOVIEEntities w      = new WATCHMOVIEEntities();
            CINEMA             cinema = new CINEMA();

            var result = from c in w.CINEMA
                         where c.name.Equals(newCinemaName)
                         select c;

            if (result.Count() > 0)
            {
                cinema = result.First();
            }
            return(cinema);
        }
Ejemplo n.º 21
0
        public int GetUserId(string newEmail) //获取用户ID
        {
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from user in entity.RUSER
                         where user.email == newEmail
                         select user;

            if (result.Count() == 1)
            {
                return(result.First().id);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 22
0
        public int GetMovieId(string newMovieName)
        {
            //根据电影名字和位置得到电影的ID
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from movie in entity.MOVIE
                         where movie.name == newMovieName
                         select movie;

            if (result.Count() == 1)
            {
                return(result.First().id);
            }
            else
            {
                return(-1);//出错返回-1
            }
        }
Ejemplo n.º 23
0
        public List <MOVIE> SearchHotMovies()
        {
            //根据点击数排行显示电影,以列表形式返回
            WATCHMOVIEEntities w     = new WATCHMOVIEEntities();
            List <MOVIE>       movie = new List <MOVIE>();

            var result = from m in w.MOVIE
                         orderby m.click_number descending
                         select m;

            foreach (var r in result)
            {
                movie.Add(r);
            }

            return(movie);
        }
Ejemplo n.º 24
0
        public List <MOVIE> SearchRankMovies()
        {
            //根据评分排行检索电影 并且以列表的形式返回
            WATCHMOVIEEntities w     = new WATCHMOVIEEntities();
            List <MOVIE>       movie = new List <MOVIE>();

            var result = from m in w.MOVIE
                         orderby m.rank descending
                         select m;

            foreach (var r in result)
            {
                movie.Add(r);
            }

            return(movie);
        }
Ejemplo n.º 25
0
        public MOVIE SearchMovie(string newMovieName)
        {
            //根据电影名返回电影对象
            WATCHMOVIEEntities w = new WATCHMOVIEEntities();
            MOVIE movie          = new MOVIE();

            var result = from m in w.MOVIE
                         where m.name.Equals(newMovieName)
                         select m;

            if (result.Count() > 0)
            {
                movie = result.First();
            }

            return(movie);
        }
Ejemplo n.º 26
0
        public List <CINEMA> SearchAllCinemas()
        {
            //搜索得到所有的电影院信息
            WATCHMOVIEEntities entity  = new WATCHMOVIEEntities();
            List <CINEMA>      cinemas = new List <CINEMA>();

            var result = from c in entity.CINEMA
                         //where c.id > 0
                         select c;

            foreach (CINEMA ci in result)
            {
                cinemas.Add(ci);
            }

            return(cinemas);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 说明:<重载InsertCollection >
        /// </summary>
        /// <param name="<newUserId>" name="<newMovieId>">
        /// <接受调用函数传入COLLECTION的三个字段作为参数></param>
        /// <returns><操作成功返回True,否则返回False> </returns>
        ///<exception>数据库增加操作异常</exception>

        //public bool InsertCollection(int newUserId, int newMovieId)
        //{
        //    //创建数据库实体类对象
        //    _entity = new WATCHMOVIEEntities();

        //    bool isSucceed = false;

        //    //创建一个临时COLLECTION对象
        //    COLLECTION collection = new COLLECTION();


        //    //collection.id = newId;
        //    collection.user_id = newUserId;
        //    collection.movie_id = newMovieId;

        //    //添加记录到内存
        //    _entity.AddToCOLLECTION(collection);

        //    //保存修改到数据库
        //    try
        //    {
        //        int i = _entity.SaveChanges();
        //        isSucceed = true;
        //    }
        //    catch (Exception ex)
        //    {
        //        //异常处理?
        //        return false;
        //    }

        //    //撤销数据库实体
        //    _entity.Dispose();

        //    return isSucceed;
        //}
        public bool InsertCollection(int newUserId, int newMovieId)
        {
            //创建数据库实体类对象
            _entity = new WATCHMOVIEEntities();

            bool isSucceed = false;

            var result = from c in _entity.COLLECTION
                         where c.user_id == newUserId && c.movie_id == newMovieId
                         select c;

            if (result.Count() > 0)
            {
                return(isSucceed);
            }
            //创建一个临时COLLECTION对象
            COLLECTION collection = new COLLECTION();


            //collection.id = newId;
            collection.user_id  = newUserId;
            collection.movie_id = newMovieId;


            //添加记录到内存
            _entity.AddToCOLLECTION(collection);

            //保存修改到数据库
            try
            {
                int i = _entity.SaveChanges();
                isSucceed = true;
            }
            catch (Exception ex)
            {
                //异常处理?
                Console.WriteLine(ex);
                return(false);
            }

            //撤销数据库实体
            _entity.Dispose();

            return(isSucceed);
        }
Ejemplo n.º 28
0
        public List <MOVIE> GetMoviesByPlayType(string message)
        {
            DateTime dtNow = DateTime.Now;
            //bool is_on_show;


            //根据传经来的数据判断取出相应的类型的电影列表
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            List <MOVIE>       movies = new List <MOVIE>();

            if (message == "onshow")
            {
                var result = from m in entity.MOVIE
                             //where m.is_on_show == true
                             where m.first_showtime < dtNow
                             select m;
                foreach (var m in result)
                {
                    movies.Add(m);
                }
            }
            else if (message == "willshow")
            {
                var result = from m in entity.MOVIE
                             //where m.is_on_show == false
                             where m.first_showtime > dtNow
                             select m;
                foreach (var m in result)
                {
                    movies.Add(m);
                }
            }
            else
            {
                var result = from m in entity.MOVIE
                             //where m.is_on_show == false || m.is_on_show == true || m.is_on_show == null
                             where m.first_showtime > dtNow || m.first_showtime < dtNow || m.first_showtime == dtNow
                             select m;
                foreach (var m in result)
                {
                    movies.Add(m);
                }
            }
            return(movies);
        }
Ejemplo n.º 29
0
        //public int GetCinemaId(string newCinemaName, string newCinemaAdddr)
        //{
        //    //根据电影名字和位置得到电影的ID
        //    WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
        //    var result = from cinema in entity.CINEMA
        //                 where cinema.address == newCinemaAdddr && cinema.name == newCinemaName
        //                 select cinema;
        //    if (result.Count() == 1)
        //    {
        //        return result.First().id;
        //    }
        //    else
        //    {
        //        return -1;//出错返回-1
        //    }
        //}

        public int GetCinemaId(string newCinemaName)
        {
            //所有相关函数用到GetCinemaId都得修改,有点小麻烦
            //根据电影名字和位置得到电影的ID
            WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
            var result = from cinema in entity.CINEMA
                         where cinema.name.Equals(newCinemaName)
                         select cinema;

            if (result.Count() == 1)
            {
                return(result.First().id);
            }
            else
            {
                return(-1);//出错返回-1
            }
        }
Ejemplo n.º 30
0
        //重写此函数 cm_7.22

        /*public string SearchMoviePicture(string newMovieName)
         * {
         *  //根据电影名子搜索相关海报并且返回 海报所在位置
         *  //只返回了搜索到的对应电影的第一张图片
         *  string picturePath = string.Empty;
         *  WATCHMOVIEEntities w = new WATCHMOVIEEntities();
         *
         *  var result = from p in w.MOVIE_PICTURE
         *               where p.movie_id == (
         *                                                from m in w.MOVIE
         *                                                where m.name.Equals(newMovieName)
         *                                                select m
         *                                                ).FirstOrDefault().id
         *               select p;
         *  if (result.Count() > 0)
         *  {
         *      picturePath = result.First().path;
         *  }
         *  return picturePath;
         * }
         */

        public string SearchMoviePicture(string newMovieName)
        {
            //根据电影名子搜索相关海报并且返回 海报所在位置
            //只返回了搜索到的对应电影的第一张图片
            string             picturePath = string.Empty;
            WATCHMOVIEEntities entity      = new WATCHMOVIEEntities();

            var result = from p in entity.MOVIE
                         where p.name.Equals(newMovieName)
                         select p;

            if (result.Count() > 0)
            {
                picturePath = result.FirstOrDefault().path;
            }

            return(picturePath);
        }