Exemple #1
0
 public ActionResult Edit(Hotel_comment_info hotel_comment_info)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel_comment_info).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(hotel_comment_info);
 }
Exemple #2
0
        public ActionResult Create(Hotel_comment_info hotel_comment_info)
        {
            if (ModelState.IsValid)
            {
                db.coments.Add(hotel_comment_info);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(hotel_comment_info);
        }
        public Hotel_comment_info getdata(string hotelId, string IsReply, string page, string startTime, string endTime)
        {
            int currentPage = 1; int.TryParse(page, out currentPage);

            //List<hotel_info> list = new HotelInfoHelp().getHotlList("");

            //string hotelIds = string.Empty;
            //if (string.IsNullOrEmpty(hotelId))
            //{
            //    foreach (var item in list)
            //    {
            //        if (string.IsNullOrEmpty(hotelId))
            //            hotelId += item.hotel_id;
            //        else
            //            hotelId += "," + item.hotel_id;
            //    }

            //}
            //MobileContractClient client = new MobileContractClient();
            //client.ClientCredentials.UserName.UserName = help.StringHelper.appSettings("WCFUserName");
            //client.ClientCredentials.UserName.Password = help.StringHelper.appSettings("WCFPassWord");
            DateTime s = new HotelInfoHelp().getStartDate(startTime); DateTime e = new HotelInfoHelp().getEndDate(endTime);
            //var coments = client.GetHotelCommentList(new CommentHParamsDTO() { Hotel_id = hotelId, IsReply = false, currentPage = currentPage, pageSize = HotelInfoHelp.pageSize, StartTime = s, EndTime = e });
            List<hotel_info> list; object allpage;
            Hotel_comment_info ment = new Hotel_comment_info();
            ment.CommnetList = ment.getComments(hotelId, IsReply, s, e, currentPage, out allpage, out list);
            ViewData["hotels"] = list;
            ViewBag.startTime = s.ToString("yyyy-MM-dd");
            ViewBag.endTime = e.ToString("yyyy-MM-dd");
            int t = string.IsNullOrEmpty(hotelId) ? 0 : Convert.ToInt32(hotelId);
            ViewBag.currentHotelId = string.IsNullOrEmpty(hotelId) ?0: Convert.ToInt32(hotelId);
            ViewBag.allPage = allpage;
            ViewBag.IsReply = IsReply;
            ViewBag.curentPage = currentPage == 0 ? currentPage + 1 : currentPage;
           
            
            return ment;
        }
        /// <summary>
        /// 账单查询(out decimal totalPrice,out decimal totalGureetePrice,out totalOtherPrice,out int totalPage)
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public List<Hotel_comment_info> getComments(string hotelId,string isreply,DateTime start,DateTime end, int page, out object totalPage, out List<hotel_info> ListHotels)
        {
            string tableName="hotel_comment_info";
            int pageSize = 30, allCount = 0, count = 0; decimal FreePercent = 0;
            object ototalPrice = 0, ototalGureetePrice = 0, ototalOtherPrice = 0, ototalPage;
            List<hotel_info> ListHotelsTemp = new List<hotel_info>();
            string sqlGetAllHotel = string.Format("select hotel_id,h_name_cn from {0}  where u_id='{1}'", "hotel_info", new HotelInfoHelp().getUId());
           // string hho = comment.createTime.ToString();
            string condition = string.Empty;
            List<Hotel_comment_info> list = new List<Hotel_comment_info>();
            ////酒店ID
            if (!string.IsNullOrEmpty(hotelId))
            {
                if (condition == string.Empty)
                    condition = string.Format("hotel_id={0}", hotelId);
                else
                    condition += string.Format("and hotel_id={0}", hotelId);

            }
            if (!string.IsNullOrEmpty(isreply))
            {
                if (isreply == "1")
                    condition = string.Format("IsReply={0}", isreply);
                else
                    condition += string.Format("and IsReply={0}", isreply);
            }
            //入住日期
            if (start != null && start.ToString() != "0001/1/1 0:00:00")
            {
                if (condition == string.Empty)
                    condition = string.Format("createTime>='{0}'", start);
                else
                    condition += string.Format(" and createTime>='{0}'", start);
            }
            //入住日期
            if (end != null && end.ToString() != "0001/1/1 0:00:00")
            {
                if (condition == string.Empty)
                    condition = string.Format("createTime<='{0}'", end);
                else
                    condition += string.Format(" and createTime<='{0}'", end);
            }
          
            if (string.IsNullOrEmpty(condition))
                condition += string.Format("hotel_id in(select hotel_id from hotel_info where u_id='{0}') ", new HotelInfoHelp().getUId());
            else
                condition += string.Format("and hotel_id in(select hotel_id from hotel_info where u_id='{0}') ", new HotelInfoHelp().getUId());
            if (condition != string.Empty)
            {

                string needFild = "orderID,content,userName,room_name,IsReply,commentid,createTime,hotel_Id,answer";
                string sql = page == 0 || page == 1 ? string.Format("select top {0} {2} from {3} where {1} ", pageSize, condition, needFild, tableName) : string.Format("select top {0} {3} from {4} where commentid>(select max(commentid) from (select top {1} commentid from {4} where {2} order by commentid) as a) and {2} order by commentid", pageSize, pageSize * (page - 1), condition, needFild, tableName);
                string sqlSum = string.Format("select count(*) from {2} where {0}", condition, new HotelInfoHelp().getUId(),tableName);
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmdSum = new SqlCommand(sqlSum, conn))
                    {
                        using (SqlDataReader drSum = cmdSum.ExecuteReader())
                        {
                            while (drSum.Read())
                            {
                                allCount = Convert.ToInt32(drSum[0]);
                            }
                        }
                    }

                    using (SqlCommand cmd = new SqlCommand(sql + ";" + sqlGetAllHotel, conn))
                    {
                        using (SqlDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                              //  decimal price = Convert.ToDecimal(dr[6]);
                                Hotel_comment_info o = new Hotel_comment_info() { orderID = dr[0].ToString(), content = dr[1].ToString(), userName = dr[2].ToString(), room_name = dr[3].ToString(), IsReply = Convert.ToBoolean(dr[4]),commentId=Convert.ToInt32(dr[5]),createTime=Convert.ToDateTime(dr[6]) ,hotel_id=dr[7].ToString(),answer=dr[8].ToString()};
                                list.Add(o);
                            }
                            //读取所有酒店信息
                            dr.NextResult();
                            while (dr.Read())
                            {
                                ListHotelsTemp.Add(new hotel_info() { hotel_id = Convert.ToInt32(dr[0]), h_name_cn = dr[1].ToString() });
                            }
                        }
                    }
                }
            }
            // allCount = 60;
            //totalPrice = Convert.ToDecimal(ototalPrice) - Convert.ToDecimal(ototalGureetePrice) + Convert.ToDecimal(ototalGureetePrice); totalGureetePrice = ototalGureetePrice; totalOtherPrice = ototalOtherPrice;
            totalPage = Convert.ToDecimal(allCount) / pageSize > Convert.ToInt32(allCount / pageSize) ? Convert.ToInt32(allCount / pageSize) + 1 : Convert.ToInt32(allCount / pageSize);
            ListHotels = ListHotelsTemp;
            return list;
        }
        public ActionResult CommentSubmit(Hotel_comment_info comment,string page)
        {
          //  var  result= new help.RefrenceHelp().GetMobileContractClientTest().ReplyReview(new ReplyReviewRequest(){commentId=comment.commentId,answer=comment.content});
            ViewBag.sign = help.DBhelp.ExcuteTableBySQL(string.Format("update Hotel_comment_info set answer='{0}',isreply=1 where commentid in({1})", comment.content, comment.commentId)) > 0 ? 1 : 0;

            return View("MyComment", getdata(comment.hotel_id.ToString(), "", page, null, null));
        }