示例#1
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);
            }
        }
示例#2
0
文件: Comment.cs 项目: zdhub/Movies
        /// <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);
        }
示例#3
0
文件: UsersBLL.cs 项目: zdhub/Movies
        public void MadeCommentOnCinema(string newCinemaName, int newId, CINAME_COMMENT newComment)
        {
            //添加对电影院的评论 传入一个电影院名字和一个评论对象
            int  id = newId;//获取登录ID
            User U  = new User(id);

            U.AddCinemaComment(newCinemaName, newId, newComment);
        }
示例#4
0
文件: Comment.cs 项目: zdhub/Movies
 public Comment(CINAME_COMMENT newComment)
 {
     //根据CINAME_COMMENT类型的newcomment生成Comment实例
     userName = new Search().SearchUserName((int)newComment.user_id);
     body     = newComment.body;
     time     = (DateTime)newComment.time;
     support  = (int)newComment.support;
     oppose   = (int)newComment.oppose;
 }
示例#5
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //获取电影d
            int cinemaId = new Cinema().GetCinemaId(cinemaName);

            if (cinemaId != -1)
            {
                string commentContext = CommentTextBox.Text.ToString();
                //获取评论内容
                DateTime commentTime = DateTime.Now.ToUniversalTime();
                //获取评论时间

                //生成评论对象
                CINAME_COMMENT cinemaComment = new CINAME_COMMENT();
                cinemaComment.body      = commentContext;
                cinemaComment.time      = commentTime;
                cinemaComment.user_id   = userID;
                cinemaComment.cinema_id = cinemaId;
                cinemaComment.support   = 0;
                cinemaComment.oppose    = 0;


                //添加评论
                if (!new Comment().InsertCinemaComment(cinemaComment))
                {
                    //Response.Write("评论失败,请重新评论");
                    //ClientScript.RegisterClientScriptBlock(GetType(), "", "<script Language=JavaScript>alert('抱歉,评论失败,请重新评论!')</script>");
                    Response.Write("<div class='msgboxbg'>" + "<div class='mainmsgbox'>" + "<br/><br/><br/><br/><div class='msgcon'>抱歉,评论失败,请重新评论!</div>" + " <a href='CinemaDetails.aspx'> <div class='tip'>返回</div></a>" + " </div></div></div>");
                }
                else
                {
                    //跳转到显示评论信息页面,显示最新评论
                    //Response.Write("<script Language=JavaScript>alert('评论成功!')</script>");
                    //Response.Redirect("~/CinemaDetails.aspx");
                    Response.Write("<div class='msgboxbg'>" + "<div class='mainmsgbox'>" + "<br/><br/><br/><br/><div class='msgcon'>评论成功!</div>" + " <a href='CinemaDetails.aspx'> <div class='tip'>返回</div></a>" + " </div></div></div>");
                }
            }
            else
            {
                //Response.Write("电影院不存在");
                //ClientScript.RegisterClientScriptBlock(GetType(), "", "<script Language=JavaScript>alert('抱歉,评论失败,请稍后再试!')</script>");
                Response.Write("<div class='msgboxbg'>" + "<div class='mainmsgbox'>" + "<br/><br/><br/><br/><div class='msgcon'>抱歉,评论失败,请重新评论!</div>" + " <a href='CinemaDetails.aspx'> <div class='tip'>返回</div></a>" + " </div></div></div>");
            }
        }