public static List <BookTour> FillCollectionHotel(IDataReader _dr) { List <BookTour> _list = new List <BookTour>(); try { while (_dr.Read()) { BookTour bookTour = new BookTour(); bookTour.Id = ConvertHelper.ToGuid(_dr["Id"], Guid.Empty); bookTour.NguoiLon = ConvertHelper.ToInt32(_dr["NguoiLon"], 0); bookTour.TreEm = ConvertHelper.ToInt32(_dr["TreEm"], 0); bookTour.ThongDiep = ConvertHelper.ToString(_dr["ThongDiep"], string.Empty); bookTour.TenKhachHang = ConvertHelper.ToString(_dr["FullName"], string.Empty); bookTour.TenHotel = ConvertHelper.ToString(_dr["TenTour"], string.Empty); bookTour.TongTien = ConvertHelper.ToInt64(_dr["TongTien"], 0); if (_list.IndexOf(bookTour) < 0) { _list.Add(bookTour); } } } finally { _dr.Close(); } return(_list); }
public JsonResult Delete(int id) { var db = new MyDbDataContext(); BookTour del = db.BookTours.FirstOrDefault(a => a.ID == id); if (del == null) { return(Json(new { Result = "ERROR", Message = "does not exist" })); } db.BookTours.DeleteOnSubmit(del); db.SubmitChanges(); return(Json(new { Result = "OK", Message = "Successful" })); }
public static BookTour FillObject(IDataReader _dr) { List <BookTour> _list = new List <BookTour>(); try { while (_dr.Read()) { BookTour bookTour = new BookTour(); bookTour.Id = ConvertHelper.ToGuid(_dr["Id"], Guid.Empty); bookTour.KhachHangId = ConvertHelper.ToGuid(_dr["KhachHangId"], Guid.Empty); bookTour.TourDetailId = ConvertHelper.ToGuid(_dr["TourDetailId"], Guid.Empty); bookTour.NguoiLon = ConvertHelper.ToInt32(_dr["NguoiLon"], 0); bookTour.TreEm = ConvertHelper.ToInt32(_dr["TreEm"], 0); bookTour.ThongDiep = ConvertHelper.ToString(_dr["ThongDiep"], string.Empty); //bookTour.TenKhachHang = ConvertHelper.ToString(_dr["FullName"], string.Empty); //bookTour.TenTrip = ConvertHelper.ToString(_dr["Name"], string.Empty); //bookTour.TenHotel = ConvertHelper.ToString(_dr["TenTour"], string.Empty); bookTour.CreatedBy = ConvertHelper.ToString(_dr["CreatedBy"], string.Empty); bookTour.CreatedAt = ConvertHelper.ToDateTime(_dr["CreatedAt"], DateTime.Now); bookTour.UpdatedBy = ConvertHelper.ToString(_dr["UpdatedBy"], string.Empty); bookTour.UpdatedAt = ConvertHelper.ToDateTime(_dr["UpdatedAt"], DateTime.Now); bookTour.IsDeleted = ConvertHelper.ToInt32(_dr["IsDeleted"], 0); bookTour.TripId = ConvertHelper.ToGuid(_dr["TripId"], Guid.Empty); bookTour.TongTien = ConvertHelper.ToInt64(_dr["TongTien"], 0); if (_list.IndexOf(bookTour) < 0) { _list.Add(bookTour); } if (_list.Count > 0) { BookTour[] bookTours = _list.ToArray(); if (bookTours != null && bookTours.Length > 0) { return(bookTours[0]); } } } } finally { _dr.Close(); } return(null); }
public ActionResult Detail(int Id) { var db = new MyDbDataContext(); string cookieClient = Request.Cookies["name_client"].Value; string deCodecookieClient = CryptorEngine.Decrypt(cookieClient, true); string userName = deCodecookieClient.Substring(0, deCodecookieClient.IndexOf("||")); var user = db.Users.FirstOrDefault(a => a.UserName == userName); if (user.UserContent == true) { int cout = 0; HttpCookie langCookie = Request.Cookies["lang_client"]; while (langCookie != null) { langCookie.Expires = DateTime.Now.AddDays(-30); HttpContext.Response.Cookies.Add(langCookie); cout++; if (cout == 10) { break; } } cout = 0; HttpCookie nameCookie = Request.Cookies["name_client"]; while (nameCookie != null) { nameCookie.Expires = DateTime.Now.AddDays(-30); HttpContext.Response.Cookies.Add(nameCookie); cout++; if (cout == 10) { break; } } CurrentSession.ClearAll(); return(Redirect("http://swallowtravel.com/admin")); } BookTour detail = db.BookTours.FirstOrDefault(a => a.ID == Id); if (detail == null) { TempData["Messages"] = "does not exist"; return(RedirectToAction("Index")); } return(View("Detail", detail)); }
public ExcutionResult Insert(BookTour bookTour) { ExcutionResult rowaffected = new ExcutionResult(); try { Database db = this.GetDatabase(); string storeName = "BookTour_Insert"; using (DbCommand dbCommand = db.GetStoredProcCommand(storeName)) { bookTour.Id = Guid.NewGuid(); db.AddInParameter(dbCommand, "Id", DbType.Guid, bookTour.Id); db.AddInParameter(dbCommand, "KhachHangId", DbType.Guid, bookTour.KhachHangId); db.AddInParameter(dbCommand, "TourDetailId", DbType.Guid, bookTour.TourDetailId); db.AddInParameter(dbCommand, "NguoiLon", DbType.Int32, bookTour.NguoiLon); db.AddInParameter(dbCommand, "TreEm", DbType.Int32, bookTour.TreEm); db.AddInParameter(dbCommand, "ThongDiep", DbType.String, bookTour.ThongDiep); db.AddInParameter(dbCommand, "CreatedBy", DbType.String, bookTour.CreatedBy); db.AddInParameter(dbCommand, "CreatedAt", DbType.DateTime, bookTour.CreatedAt); db.AddInParameter(dbCommand, "UpdatedBy", DbType.String, bookTour.UpdatedBy); db.AddInParameter(dbCommand, "UpdatedAt", DbType.DateTime, bookTour.UpdatedAt); db.AddInParameter(dbCommand, "IsDeleted", DbType.Int16, bookTour.IsDeleted); db.AddInParameter(dbCommand, "TripId", DbType.Guid, bookTour.TripId); db.AddInParameter(dbCommand, "TongTien", DbType.Int64, bookTour.TongTien); db.AddOutParameter(dbCommand, "IsCheck", DbType.Int32, 0x20); db.ExecuteNonQuery(dbCommand); var isCheck = ConvertHelpers.ToInt32(db.GetParameterValue(dbCommand, "IsCheck"), 0); if (isCheck == 1) { rowaffected.ErrorCode = 2; rowaffected.Message = "Insert no success"; } } } catch (Exception e) { rowaffected.ErrorCode = 1; rowaffected.Message = e.Message; } return(rowaffected); }
public ExcutionResult Insert(BookTour bookTour) { ExcutionResult rowsAffected = new ExcutionResult(); try { var now = DateTime.Now; bookTour.CreatedAt = now; rowsAffected = BookTourManager.Insert(bookTour); if (rowsAffected.ErrorCode == 1 || rowsAffected.ErrorCode == 2) { rowsAffected.Message = "Insert failed"; } } catch (Exception e) { rowsAffected.ErrorCode = 1; rowsAffected.Message = e.Message; } return(rowsAffected); }
public static List <BookTour> FillCollectionTrip(IDataReader _dr) { List <BookTour> _list = new List <BookTour>(); try { while (_dr.Read()) { BookTour bookTour = new BookTour(); bookTour.Id = ConvertHelper.ToGuid(_dr["Id"], Guid.Empty); bookTour.KhachHangId = ConvertHelper.ToGuid(_dr["KhachHangId"], Guid.Empty); bookTour.TourDetailId = ConvertHelper.ToGuid(_dr["TourDetailId"], Guid.Empty); bookTour.NguoiLon = ConvertHelper.ToInt32(_dr["NguoiLon"], 0); bookTour.TreEm = ConvertHelper.ToInt32(_dr["TreEm"], 0); bookTour.ThongDiep = ConvertHelper.ToString(_dr["ThongDiep"], string.Empty); bookTour.TenKhachHang = ConvertHelper.ToString(_dr["FullName"], string.Empty); bookTour.TenTrip = ConvertHelper.ToString(_dr["Name"], string.Empty); bookTour.CreatedBy = ConvertHelper.ToString(_dr["CreatedBy"], string.Empty); bookTour.CreatedAt = ConvertHelper.ToDateTime(_dr["CreatedAt"], DateTime.Now); bookTour.UpdatedBy = ConvertHelper.ToString(_dr["UpdatedBy"], string.Empty); bookTour.UpdatedAt = ConvertHelper.ToDateTime(_dr["UpdatedAt"], DateTime.Now); bookTour.IsDeleted = ConvertHelper.ToInt32(_dr["IsDeleted"], 0); bookTour.TripId = ConvertHelper.ToGuid(_dr["TripId"], Guid.Empty); bookTour.TongTien = ConvertHelper.ToInt64(_dr["TongTien"], 0); if (_list.IndexOf(bookTour) < 0) { _list.Add(bookTour); } } } finally { _dr.Close(); } return(_list); }
public ExcutionResult Delete(BookTour employess) { throw new NotImplementedException(); }
public ExcutionResult Update(BookTour employees) { throw new NotImplementedException(); }
public static ExcutionResult Insert(BookTour bookTour) { ExcutionResult rowAffected = provider.Insert(bookTour); return(rowAffected); }
public ActionResult BookTour(int id) { using (var db = new MyDbDataContext()) { var bookTour = new BookTour(); Tour tour = db.Tours.FirstOrDefault(a => a.ID == id); if (tour == null) { var hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value); ViewBag.Messages = "Error! Can not find the selected tous. For more information, please contact us by email: <a href='mailto:" + hotel.Email + "'>" + hotel.Email + "</a> or phone number: < href='tel:" + hotel.Tel + "'>" + hotel.Tel + "</a>"; return(View("Messages")); } int caseOption = 0; string name = ""; decimal price = 0; List <TabTour> tabtours = new List <TabTour>(); if (tour.HotelService == true) { var option = Request.Params["option"]; int.TryParse(option, out caseOption); switch (caseOption) { case 1: name = "3-Star Hotels - " + tour.Title; price = (decimal)tour.ThreeStar; break; case 2: name = "4-Star Hotels - " + tour.Title; price = (decimal)tour.FourStar; break; case 3: name = "5-Star Hotels - " + tour.Title; price = (decimal)tour.FiveStar; break; default: var hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value); ViewBag.Messages = "Error! Can not find the selected tous. For more information, please contact us by email: <a href='mailto:" + hotel.Email + "'>" + hotel.Email + "</a> or phone number: < href='tel:" + hotel.Tel + "'>" + hotel.Tel + "</a>"; return(View("Messages")); } var tabtour = new TabTour { TourID = 0, TitleTab = name, Price = price }; tabtours.Add(tabtour); } else { var listTabtours = db.TabTours.Where(a => a.TourID == tour.ID && a.Price > 0).ToList(); if (listTabtours.Count > 0) { tabtours.AddRange(listTabtours); if (listTabtours.Count > 1) { price = 0; } else { price = (decimal)listTabtours[0].Price; } } else { var tabtour = new TabTour { TourID = 0, TitleTab = tour.Title, Price = tour.PriceSale }; tabtours.Add(tabtour); } } ViewBag.Tour = tour; ViewBag.title = tour.Title; ViewBag.tourID = tour.ID; ViewBag.name = name; ViewBag.price = price; ViewBag.Option = caseOption; bookTour.InfoBooking = tour.Title; bookTour.ID = tour.ID; ViewBag.TabTours = tabtours; return(View("BookTour", bookTour)); } }
public ActionResult SendBooking(MBookTour model) { string status = "success"; try { using (var db = new MyDbDataContext()) { Tour tour = db.Tours.FirstOrDefault(a => a.ID == model.TourId); Hotel hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value); SendEmail sendEmail = db.SendEmails.FirstOrDefault( a => a.Type == TypeSendEmail.BookTour); if (tour == null) { ViewBag.Messages = sendEmail.Error; return(View("Messages")); } //xác định xem tour có phải là option không string inforBooking = ""; decimal price = 0; if (tour.HotelService == true) { switch (model.Option) { case 1: inforBooking = "3-Star Hotels - " + tour.Title; price = (decimal)tour.ThreeStar; break; case 2: inforBooking = "4-Star Hotels - " + tour.Title; price = (decimal)tour.FourStar; break; case 3: inforBooking = "5-Star Hotels - " + tour.Title; price = (decimal)tour.FiveStar; break; default: ViewBag.Messages = sendEmail.Error; return(View("Messages")); } } else { #region ////xác định lịch trình var tabTour = db.TabTours.FirstOrDefault(a => a.TourID == model.TabTourID); if (tabTour == null) { inforBooking = tour.Title; price = (decimal)tour.PriceSale; } else { if (db.TabTours.Where(a => a.TourID == model.TourId).Count() > 0) { inforBooking = tour.Title + ", Itinerariy: " + tabTour.TitleTab; } else { inforBooking = tour.Title; } price = (decimal)tabTour.Price; } #endregion } //Check Promotion code double rate = 0; DateTime today = DateTime.Now; if (string.IsNullOrEmpty(model.PromotionCode) == false) { PromotionCode Pcode = db.PromotionCodes.FirstOrDefault(c => c.Code == model.PromotionCode && today <= c.EndDay && today >= c.StartDay && c.Status == true); if (Pcode != null) { /* * 1-het ma * 2-ok co ma va con luot dung * 3-loi ko co ma nao */ if (Pcode.Used >= Pcode.Total) { rate = 0; } else { rate = Pcode.Rate / 100; Pcode.Used = Pcode.Used + 1; db.SubmitChanges(); } } } //tính giá tour price = price * model.Adult - (price * model.Adult * (decimal)0.6); decimal deposit = 0; decimal Balance = 0; if (model.TypePayment == 1) { deposit = price * ((decimal)tour.Deposit / 100); } Balance = price - deposit; string codeBooking = hotel.CodeBooking + "1"; if (db.BookTours.Any()) { codeBooking = hotel.CodeBooking + db.BookTours.OrderByDescending(a => a.ID).FirstOrDefault().ID + 1; } BookTour bookTour = new BookTour(); bookTour.Departure = model.Departure; bookTour.Code = codeBooking; bookTour.CreateDate = DateTime.Now; bookTour.Gender = model.Gender; bookTour.FullName = model.FullName; //bookTour.SocialMedia = model.SocialMedia; bookTour.Tel = model.Tel; bookTour.RoomType = model.RoomType; bookTour.Country = model.Country; bookTour.Email = model.Email; bookTour.Request = model.Request; bookTour.Adult = model.Adult; bookTour.InfoBooking = inforBooking; bookTour.Total = (float)price; //bookTour.Deposit = (float)deposit; bookTour.Balance = (float)Balance; bookTour.TourId = model.TourId; db.BookTours.InsertOnSubmit(bookTour); db.SubmitChanges(); sendEmail.Title = sendEmail.Title.Replace("{HotelName}", hotel.Name); string content = sendEmail.Content; content = content.Replace("{HotelName}", hotel.Name); content = content.Replace("{Deposit}", deposit.ToString()); content = content.Replace("{Balance}", Balance.ToString()); content = content.Replace("{Code}", bookTour.Code); content = content.Replace("{Departure}", bookTour.Departure.ToString()); content = content.Replace("{InfoBooking}", bookTour.InfoBooking); content = content.Replace("{Adult}", bookTour.Adult.ToString()); content = content.Replace("{TitleTour}", tour.Title); content = content.Replace("{Price}", price.ToString()); content = content.Replace("{Gender}", model.Gender); content = content.Replace("{FullName}", model.FullName); content = content.Replace("{SocialMedia}", model.SocialMedia); content = content.Replace("{Tel}", model.Tel); content = content.Replace("{RoomType}", model.RoomType); content = content.Replace("{Country}", model.Country); content = content.Replace("{Email}", model.Email); content = content.Replace("{Request}", model.Request); if (rate != 0) { content = content.Replace("{Promotion}", model.PromotionCode + "/Rate: " + rate * 100 + " %"); } else { content = content.Replace("{Promotion}", "No"); } content = content.Replace("{Request}", model.Request); //infor Hotel content = content.Replace("{Add}", hotel.Address); content = content.Replace("{Hotline}", hotel.Hotline); content = content.Replace("{EmailHotel}", hotel.Email); content = content.Replace("{Website}", hotel.Website); MailHelper.SendMail(model.Email, sendEmail.Title, content); MailHelper.SendMail(hotel.Email, hotel.Name + " (" + bookTour.Code + ")- Booking tour of " + model.FullName, content); if (model.TypePayment == 1) { price = price * ((decimal)tour.Deposit / 100); return(RedirectToAction("SubmitInvoidOnePay", new { idOrder = bookTour.Code, deposit = (Math.Round(price * (decimal)CodeHelper.GetExrate(), 0)) * 100 })); } else { return(Redirect("/BookTour/Messages?status=" + status)); } } } catch (Exception ex) { status = "error"; } return(Redirect("/BookTour/Messages?status=" + status)); }
public IActionResult Insert(BookTour bookTour) { var rs = _bookTourService.Insert(bookTour); return(Ok(rs)); }