Beispiel #1
0
        public void GetData(string hotelId)
        {

            int hotel_id;
            int.TryParse(hotelId, out hotel_id);
            string u_id = "test1";
           // GetData();
            //所有酒店列表
            ViewData["rooms"] = new hotel_room_info().getRoomsByHoltelId(hotel_id);
            //所有酒店对应的房型列表
            
            // ViewData["drrModes"] = help.HotelInfoHelp.getDrrModeList(u_id);
            ViewData["drrs"] = new DrrRules().getDrrsByHoltelId(hotel_id);
            ViewBag.Id = hotel_id;

        }
Beispiel #2
0
        public ActionResult Create(DrrRules drrrule)
        {
            SetName();
            drrrule.DayNum = drrrule.CheckInNum == null ?0 : drrrule.DayNum;
            drrrule.CheckInNum = drrrule.DayNum == null ?0 :drrrule.CheckInNum;

            if (drrrule.TypeCode == "DRRBookAhead")
            {
                string last = string.Format("提前{0}天预订,每间晚优惠{1}%", drrrule.DayNum, drrrule.DeductNum * 10);
                drrrule.Description = string.Format("促销规则:入住日期在{0}-{1},{2}", drrrule.StartDate.Value.ToShortDateString(), drrrule.EndDate.Value.ToShortDateString(), last);
            }
            if (drrrule.TypeCode == "DRRStayPerRoomPerNight")
            {
                string last = string.Format("连住{2}天,每间晚优惠{3}%", drrrule.StartDate, drrrule.EndDate, drrrule.CheckInNum, drrrule.DeductNum * 10);
                drrrule.Description = string.Format("促销规则:入住日期在{0}-{1},{2}", drrrule.StartDate.Value.ToShortDateString(), drrrule.EndDate.Value.ToShortDateString(), last);

            }
            if (drrrule.id > 0)
            {
                if (ModelState.IsValid)
                {
                    db.Entry(drrrule).State = EntityState.Modified;
                    db.SaveChanges();
                   
                }
            }
            else
            {
                #region
                string guid = Guid.NewGuid().ToString();

                Hotel_room_RP_info rp = new Hotel_room_RP_info();

                rp.RatePlanId = guid;
                rp.hotel_id = drrrule.hotel_id;
                rp.h_room_rp_is_to_store_pay = true;
                rp.h_room_rp_check_in = "00:00:00";
                rp.h_room_rp_check_out = "23:59:00";
                rp.h_room_rp_least_day = 1;
                rp.h_room_rp_longest_day = 365;
                rp.h_room_rp_ctime = DateTime.Now;
                rp.h_room_rp_name_cn = "";
              
                rp.h_room_rp_name_cn = string.Format("促销({0})", drrrule.DrrName);

                var tempRp = (from r in db.rps where r.h_room_rp_name_cn == rp.h_room_rp_name_cn && r.hotel_id == drrrule.hotel_id select r).SingleOrDefault();
                if (tempRp != null)
                {
                    drrrule.h_room_rp_id = tempRp.h_room_rp_id; ;
                }
                else
                {
                    db.rps.Add(rp);
                    db.SaveChanges();
                    //取rpId
                    var f = (from r in db.rps where r.RatePlanId == guid select r.h_room_rp_id).SingleOrDefault();
                    drrrule.h_room_rp_id = f; ;
                }
                // drrrule.StartDate.Value.tos;
                //drrrule.StartDate=drrrule.EndDate.Value.ToShortDateString();
                //插入RP

                //要操作的酒店

             

             //   if (ModelState.IsValid)
               // {
                    db.drrs.Add(drrrule);
                    db.SaveChanges();
                

             //   }
                #endregion
            }
            GetData();
            GetData(drrrule.hotel_id.ToString());
            return View("MyDrr", new DrrRules());
          
        }