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()); }
public ActionResult Create(GuaranteeRule guaranteerule) { setName(); using (db = new HotelDBContent()) { if (guaranteerule.id > 0) { db.Entry(guaranteerule).State = EntityState.Modified; } else { Hotel_room_RP_info ratePlan = new Hotel_room_RP_info(); ratePlan.hotel_id = guaranteerule.hotel_id; ratePlan.h_room_rp_name_cn = "标准价"; int ratePlanId = help.HotelInfoHelp.getRatePlanId(ratePlan); // var rp=(from r in db.rps where r.hotel_id==guaranteerule.hotel_id && r.h_room_rp_state==true && r.h_room_rp_name_cn=="标准价"select r.h_room_rp_id).SingleOrDefault(); guaranteerule.h_room_rp_id = ratePlanId; if (ModelState.IsValid) { db.gu.Add(guaranteerule); } db.SaveChanges(); } } GetData(guaranteerule.hotel_id.ToString()); return View("MyGuarantee", new GuaranteeRule() { GuaranteeType = "FirstNightCost",ChangeRule=1 }); }
/// <summary> /// 插入价格 /// </summary> /// <param name="p"></param> /// <returns></returns> public bool InsertPriceBatch(hotel_room_RP_price_info p) { bool result = false; try { using (DBC.HotelDBContent db = new DBC.HotelDBContent()) { Hotel_room_RP_info rp = new Hotel_room_RP_info(); rp.h_room_rp_name_cn = "标准价"; rp.hotel_id = p.hotel_id; Hotel_room_RP_price_batch pBacth = new Hotel_room_RP_price_batch(); pBacth.Addbed = -1; pBacth.HpStatus = 0; pBacth.Room_rp_id = help.HotelInfoHelp.getRatePlanId(rp); DateTime start = p.room_rp_start_time; DateTime end = p.room_rp_end_time; pBacth.Room_rp_start_time = start; pBacth.Room_rp_end_time = end; pBacth.Room_id = p.room_id; pBacth.Hotel_id = p.hotel_id; pBacth.Price = p.room_rp_price; pBacth.Idate = DateTime.Now; pBacth.Hpdate = DateTime.Now; pBacth.AuditDate = DateTime.Now; db.publicPrices.Add(pBacth); result=db.SaveChanges()>0?true:false; //DBhelp.CallProc(p.room_id, "proc_hotel_room_RP_price_batch_roomid"); } } catch (Exception e) { result = false; } return result; }
/// <summary> /// 得到RatePlanId /// </summary> /// <param name="rp"></param> /// <returns></returns> public static int getRatePlanId(Hotel_room_RP_info rp) { int ratePlanId = 0; rp.RatePlanId = Guid.NewGuid().ToString(); 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 = ""; using (HotelDBContent db = new HotelDBContent()) { var tempRp = (from r in db.rps where r.h_room_rp_name_cn == rp.h_room_rp_name_cn && r.hotel_id == rp.hotel_id select r).SingleOrDefault(); if (tempRp != null) { ratePlanId = tempRp.h_room_rp_id; ; } else { db.rps.Add(rp); db.SaveChanges(); //取rpId ratePlanId = (from r in db.rps where r.RatePlanId == rp.RatePlanId select r.h_room_rp_id).SingleOrDefault(); } } return ratePlanId; }