public ActionResult CreateUser(Merchant_info merchant_info) { merchant_info.status = true; using (db = new HotelDBContent()) { if (merchant_info.id > 0) { //if(merchant_info.password=="******") merchant_info.updateUser(merchant_info); } else { if (ModelState.IsValid) { merchant_info.password = new help.HotelInfoHelp().Md5(merchant_info.password); merchant_info.ctime = DateTime.Now; merchant_info.status = true; merchant_info.guid = Guid.NewGuid().ToString(); merchant_info.operator_id = new help.HotelInfoHelp().getUId(); merchant_info.status = true; //using (db=new HotelDBContent()) //{ db.Merchant_infos.Add(merchant_info); result = db.SaveChanges() > 0 ? 1 : 0; //} } } } return View("MyUser", getData()); }
//删除公寓 public int delApart(string hotelId) { try { int.TryParse(hotelId, out hotel_id); string u_id = new HotelInfoHelp().getUId(); using (db = new HotelDBContent()) { ((from h in db.hotel where h.hotel_id == hotel_id && h.source_id == 5 && h.u_id == u_id select h).SingleOrDefault()).h_state=false; result = db.SaveChanges() > 0 ? 1 : 0; } } catch (Exception) { result = 0; } return result; }
public ActionResult CreateHotel(hotel_info hotel_info) { try { //hotel_info.u_id = new HotelInfoHelp().getUId(); hotel_info.source_id = Convert.ToInt32(help.StringHelper.appSettings("source_id")); ; hotel_info.h_id = Guid.NewGuid().ToString(); hotel_info.h_state = true; hotel_info.h_utime = DateTime.Now; hotel_info.CheckState = 2; hotel_info.h_ctime = DateTime.Now; hotel_info.decorateTime = hotel_info.decorateTime == Convert.ToDateTime("0001/1/1 0:00:00") || hotel_info.decorateTime ==null? Convert.ToDateTime("1900-01") : hotel_info.decorateTime; hotel_info.h_opening_time = hotel_info.h_opening_time == Convert.ToDateTime("0001/1/1 0:00:00") ? Convert.ToDateTime("1900-01") : hotel_info.h_opening_time; //hotel_info.h_room_count = hotel_info.h_room_count == 0 ? 1 : hotel_info.h_room_count; hotel_info.u_id = hotel_info.h_mobile_phone; using(db=new HotelDBContent()) { if (hotel_info.hotel_id > 0) { db.Entry(hotel_info).State = EntityState.Modified; } else { var errors = ModelState.Values.SelectMany(v => v.Errors); //if (ModelState.IsValid) //{ db.hotel.Add(hotel_info); // result = db.SaveChanges() > 0 ? 1 : 0; var f = (from h in db.hotel where h.h_name_cn == hotel_info.h_name_cn && h.source_id == 4 select h).FirstOrDefault(); if (f != null) f.h_state = false; //把对应艺龙的酒店干掉 // return RedirectToAction("Room/Create/"+ddh.hotel_id); //} } result = db.SaveChanges() > 0 ? 1 : 0; if (result > 0) { var ddh = db.hotel.Select(h => new { h.hotel_id, h.h_id }).Single(h => h.h_id == hotel_info.h_id); return RedirectToAction("room", "AddHotel", new { hotelId = ddh.hotel_id }); } } } catch (Exception e) { throw e; help.DBhelp.log("新建公寓基本信息"+e.ToString()); } ViewBag.sign = result; getHelpData(); return View("Create", hotel_info); }
//删除担保 public ActionResult deleteG(string id) { int gId; int.TryParse(id, out gId); GuaranteeRule guran = null; using (db = new HotelDBContent()) { var gu = (from g in db.gu where g.id == gId select g).SingleOrDefault(); db.gu.Remove(gu); if (db.SaveChanges() > 0) ViewBag.sign = 1; else ViewBag.sign = 0; guran = gu; ViewBag.Id = gu.hotel_id; GetData(gu.hotel_id.ToString()); setName(); } guran.id = 0; return View("MyGuarantee", guran); }
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> /// 得到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; }
public void ProcessRequest(HttpContext context) { HotelDBContent db = new HotelDBContent(); string NewsFilePath = HttpContext.Current.Server.MapPath("\\") + "UploadFiles\\TitleImage\\"; string AdminFilePath = HttpContext.Current.Server.MapPath("\\") + "admin\\UploadFiles\\TitleImage\\"; context.Response.ContentType = "text/html"; HttpFileCollection files = context.Request.Files; // From中获取文件对象 string tag = Guid.NewGuid().ToString(); int roomId=Convert.ToInt32(context.Request.Form[0]); List<Image> list1 = new List<Image>(); string count=".."; if (files.Count > 0) { string path = ""; string fileD = "../"; if (!Directory.Exists(AdminFilePath)) Directory.CreateDirectory(AdminFilePath); if (!Directory.Exists(NewsFilePath)) Directory.CreateDirectory(NewsFilePath); //路径字符串 Random rnd = new Random(); for (int i = 0; i < files.Count; i++) { #region HttpPostedFile file = files[i]; //得到文件对象 if (file.ContentLength > 0) { int size = file.ContentLength; string fileName = file.FileName; Stream stream = file.InputStream; System.Drawing.Image image = System.Drawing.Image.FromStream(stream); int w = image.Width; int h = image.Height; string extension = Path.GetExtension(fileName); int num = rnd.Next(5000, 10000); //文件名称 //// path = ; ////保存文件。 string fileI = "UploadFiles\\TitleImage\\" + num.ToString() + extension; string thumbImgPath = context.Server.MapPath("/") + fileI; //string AdminthumbImgPath = context.Server.MapPath("/") + "admin/" + fileI; ////thumbImg.Save(); //file.SaveAs(thumbImgPath); //file.SaveAs(AdminthumbImgPath); //filePath = context.Server.MapPath(filePath + "/" + fileName); ////将上传来的 文件数据 保存在 对应的 物理路径上 //hpFile.SaveAs(filePath); string showImagePath = "..\\" + fileI; //string showImagePath = string.Empty; ; // && w > 500 && h > 300 string fileName1, message, oPath=string.Empty, tPath = string.Empty; string d = DateTime.Now.ToString("yyyy-MM"); if (!new help.ImgHelper().MoreImgUpload(file, out fileName1, out message, ThumbImages_SavePath, OriginalImages_SavePath, ThumbImages_Height, ThumbImages_Wight, Images_Height, Images_Wight, ThumbImages_Size, out oPath, out tPath)) { return; } string realOpath = ThumbImages_SavePath + d + "/" + "T_" + fileName1; string realTpath = ThumbImages_SavePath + d + "/" + "T_" + fileName1; if (size < maxSize && w >= 500 && h >= 300 ) { // string message= hotel_room_picture_info pic = new hotel_room_picture_info(); pic.h_r_p_pic_original_url = realOpath; pic.h_r_p_pic_thumb_url = realTpath; pic.souce_id = Convert.ToInt32(help.StringHelper.appSettings("source_id")); pic.State = false; pic.room_id = roomId; pic.h_r_p_tag = tag; pic.h_r_p_time = DateTime.Now; db.roomImages.Add(pic); db.SaveChanges(); } else { Image IM = new Image(); IM.oURL = count + realOpath; IM.tURL = count + realTpath; ; message = string.Empty; if (size > maxSize) message = "图片大小小于10M"; if (w < 500 ||h < 300) { if (message == string.Empty) message += "图片像素宽大于500px,高大于300px"; else message += ",图片像素宽大于500px,高大于300px"; } IM.Message = message; IM.PID = 0; list1.Add(IM); } } #endregion } // List<hotel_picture_info> list = (from p in db.room where p.h_p_tag ==tag select new { p.h_p_pic_original_url, p.h_p_id }).ToList(); var pics = from p in db.roomImages where p.h_r_p_tag == tag select new { p.h_r_p_id, p.h_r_p_pic_original_url, p.h_r_p_pic_thumb_url, p.h_r_p_title }; foreach (var item in pics) { Image pic = new Image(); pic.oURL = ".." + item.h_r_p_pic_original_url; pic.tURL = ".." + item.h_r_p_pic_thumb_url; pic.Message =""; pic.PID = item.h_r_p_id; list1.Add(pic); } string str = JsonConvert.SerializeObject(list1, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); context.Response.Write(str); //context.Response.Write(showImagePath + "$" + "1089023"); //返回文件存储后的路径,用于回显。 //context.Response.End(); } }