protected void buttonSubmit_Click(object sender, EventArgs e) { try { if (listSelectedRooms.Items.Count > 0) { int i = 1; // Save thông tin các phòng đã chọn vào trong session foreach (ListItem item in listSelectedRooms.Items) { Session.Add("Room" + i, item.Value.Split(',')[2]); i++; } Session.Add("SelectedRoom", i - 1); // Đối với từng phòng đã chọn tìm match tương ứng trong Booking //Session.Add("Finish",true); PageEngine.PageRedirect(string.Format("{0}/{1}{2}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_CUSTOMER_INFO_PARAM, UrlHelper.EXTENSION)); } } catch (Exception ex) { _logger.Error("Error when buttonSubmit_Click in PreferedRooms", ex); throw; } }
protected void rptTripList_ItemCommand(object source, RepeaterCommandEventArgs e) { try { SailsTrip item = Module.TripGetById(Convert.ToInt32(e.CommandArgument)); DropDownList ddlOption = (DropDownList)e.Item.FindControl("ddlOption"); TextBox textBoxStartDate = (TextBox)e.Item.FindControl("textBoxStartDate"); CultureInfo cultureInfo = new CultureInfo("vi-VN"); switch (e.CommandName) { case "Book": DateTime startDate; try { startDate = DateTime.ParseExact(textBoxStartDate.Text, "dd/MM/yyyy", cultureInfo.DateTimeFormat); } catch (Exception) { startDate = DateTime.Today.AddDays(1); } if (startDate < DateTime.Today.AddDays(1)) { Label labelError = e.Item.FindControl("labelError") as Label; if (labelError != null) { labelError.Text = "You can not book in the past!"; return; } } Session.Add("StartDate", startDate.ToString("dd/MM/yyyy")); Session.Add("TripId", item.Id); Session.Add("TripOption", ddlOption.SelectedValue); if (item.NumberOfOptions > 1) { PageEngine.PageRedirect(string.Format("{0}/{1}/{2}/{3}/{4}{5}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_ORDER_PARAM, item.Id, ddlOption.SelectedValue, item.Name, UrlHelper.EXTENSION)); } else { PageEngine.PageRedirect(string.Format("{0}/{1}/{2}/{3}/{4}{5}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_ORDER_PARAM, item.Id, 0, item.Name, UrlHelper.EXTENSION)); } break; default: break; } } catch (Exception ex) { _logger.Error("Error when rptTripList_ItemCommand in TripList control", ex); throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["Finish"] == null) { PageEngine.PageRedirect(UrlHelper.GetUrlFromSection(Module.Section)); return; } Role role; if (PageEngine.CuyahogaUser != null) { role = PageEngine.CuyahogaUser.Roles[0] as Role; } else { role = Module.RoleGetById(4); } _booking = Module.BookingGetById(Convert.ToInt32(Session["Finish"])); rptRooms.DataSource = Module.BookingRoomGetByBooking(_booking); _total = _booking.Calculate(Module, _booking.Agency, Convert.ToDouble(Module.ModuleSettings("CHILD_PRICE")), Convert.ToDouble(Module.ModuleSettings("AgencySupplement")), false, false); rptRooms.DataBind(); labelTotal.Text = string.Format("{0:#,0.#}", _total); } }
protected void buttonSelectRoom_Click(object sender, EventArgs e) { if (PageEngine.IsValid) { if (!SaveData()) { return; } // Chuyển sang trang nhập thông tin khách hàng PageEngine.PageRedirect(string.Format("{0}/{1}{2}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_PREFERED_ROOM_PARAM, UrlHelper.EXTENSION)); } }
protected void imageButtonBook_Click(object sender, ImageClickEventArgs e) { if (PageEngine.IsValid) { DateTime startDate; try { startDate = DateTime.ParseExact(textBoxStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { startDate = DateTime.Now.AddDays(1); } if (startDate < DateTime.Today.AddDays(1)) { labelError.Text = "You can not book in the past!"; return; } _trip = Module.TripGetById(Module.TripId); Session.Add("StartDate", textBoxStartDate.Text); Session.Add("TripId", _trip.Id); if (_trip.NumberOfOptions > 1) { Session.Add("TripOption", ddlOption.SelectedValue); PageEngine.PageRedirect(string.Format("{0}/{1}/{2}/{3}/{4}{5}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_ORDER_PARAM, _trip.Id, ddlOption.SelectedValue, _trip.Name, UrlHelper.EXTENSION)); } else { Session.Add("TripOption", Enum.GetName(typeof(TripOption), TripOption.Option1)); PageEngine.PageRedirect(string.Format("{0}/{1}/{2}/{3}/{4}{5}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_ORDER_PARAM, _trip.Id, 0, _trip.Name, UrlHelper.EXTENSION)); } } }
protected void btnConfirm_Click(object sender, EventArgs e) { _booking = Module.BookingGetById(Convert.ToInt32(Session["Finish"])); _booking.Status = StatusType.Pending; Role role; if (PageEngine.CuyahogaUser != null) { _booking.IsApproved = true; role = PageEngine.CuyahogaUser.Roles[0] as Role; } else { _booking.IsApproved = false; role = Module.RoleGetById(4); } _booking.Total = _booking.Calculate(Module, _booking.Agency, Convert.ToDouble(Module.ModuleSettings("CHILD_PRICE")), Convert.ToDouble(Module.ModuleSettings("AgencySupplement")), false, false); Module.Update(_booking, null); PageEngine.PageRedirect(UrlHelper.GetUrlFromSection(Module.Section)); }
protected void btnSearch_Click(object sender, EventArgs e) { string query = string.Empty; if (ddlTourTypes.SelectedIndex > 0) { query += "&Type=" + ddlTourTypes.SelectedValue; } if (ddlTourRegions.SelectedIndex > 0) { query += "&Region=" + ddlTourRegions.SelectedValue; } if (!string.IsNullOrEmpty(textBoxName.Text)) { query += "&Name=" + textBoxName.Text; } if (!string.IsNullOrEmpty(textBoxNumberOfDays.Text)) { int numberOfDays; if (Int32.TryParse(textBoxNumberOfDays.Text, out numberOfDays)) { query += string.Format("&TimeLt={0}&TimeGt={1}", numberOfDays + 1, numberOfDays - 1); } } if (string.IsNullOrEmpty(query)) { PageEngine.PageRedirect(UrlHelper.GetUrlFromSection(_module.Section)); return; } query = query.Substring(1); query = "?" + query; PageEngine.PageRedirect(UrlHelper.GetUrlFromSection(_module.Section) + query); }
protected void buttonSubmit_Click(object sender, EventArgs e) { try { if (PageEngine.IsValid) { if (!SaveData()) { return; } // Chuyển sang trang nhập thông tin khách hàng PageEngine.PageRedirect(string.Format("{0}/{1}{2}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_CUSTOMER_INFO_PARAM, UrlHelper.EXTENSION)); } } catch (Exception ex) { _logger.Error("Error when buttonSubmit_Click in SelectRoom", ex); throw; } }
protected void buttonSubmit_Click(object sender, EventArgs e) { try { //Biến để đếm tổng số customer // Tạo đối tượng booking mới Booking booking = new Booking(); CultureInfo cultureInfo = new CultureInfo("vi-VN"); #region -- Các thông tin cơ bản -- if (PageEngine.User.Identity is User) { booking.CreatedBy = (User)Page.User.Identity; booking.ModifiedBy = (User)Page.User.Identity; booking.Partner = (User)Page.User.Identity; //booking.Sale = (User)Page.User.Identity; } booking.CreatedDate = DateTime.Now; booking.ModifiedDate = DateTime.Now; DateTime startDate = DateTime.ParseExact(Session["StartDate"].ToString(), "dd/MM/yyyy", cultureInfo.DateTimeFormat); booking.StartDate = startDate; booking.Status = StatusType.Cancelled; #endregion #region - Lấy trip và trip option đã book từ biến session - SailsTrip trip = Module.TripGetById(Convert.ToInt32(Session["TripId"])); booking.Trip = trip; TripOption tripOption = TripOption.Option1; if (!string.IsNullOrEmpty(Session["TripOption"].ToString())) { tripOption = (TripOption)Convert.ToInt32(Session["TripOption"]); } booking.TripOption = tripOption; #endregion // Save booking lại if (panelCustomer.Visible) { booking.Note = fckCustomers.Value; } if (liAnonymous.Visible) { booking.Name = txtYourName.Text; booking.Email = txtEmail.Text; } booking.PickupAddress = txtPickupAddress.Text; booking.SpecialRequest = txtSpecialRequest.Text; Module.Save(booking, null); #region -- Lấy thông tin về extra services từ session -- // Mặc dù extra service đã được chọn từ form trước, tuy nhiên tại form này mới lưu lại thông tin booking // Do đó đến form này mới lấy lại thông tin extra service if (Session["ExtraService"] != null) { string[] services = Session["ExtraService"].ToString().Split(','); foreach (string serviceId in services) { ExtraOption service = Module.ExtraOptionGetById(Convert.ToInt32(serviceId)); BookingExtra bookingService = new BookingExtra(); bookingService.Booking = booking; bookingService.ExtraOption = service; Module.Save(bookingService); } } #endregion #region -- Lưu thông tin khách hàng -- foreach (RepeaterItem item in rptRoomList.Items) { // Đối với mỗi đối tượng trong room list Label label_RoomId = (Label)item.FindControl("label_RoomId"); #region -- Thông tin về phòng -- HiddenField hiddenRoomClassId = (HiddenField)item.FindControl("hiddenRoomClassId"); HiddenField hiddenRoomTypeId = (HiddenField)item.FindControl("hiddenRoomTypeId"); // Lấy về room id theo label Room id đã bound trước đó int roomId = 0; // Lấy ID của phòng nếu đã có phòng chọn (prefer room) if (!string.IsNullOrEmpty(label_RoomId.Text)) { roomId = Convert.ToInt32(label_RoomId.Text); } Room room = null; if (roomId > 0) { room = Module.RoomGetById(roomId); } #endregion #region -- Lấy thông tin khách hàng -- CheckBox checkBoxAddChild = (CheckBox)item.FindControl("checkBoxAddChild"); CheckBox checkBoxAddBaby = (CheckBox)item.FindControl("checkBoxAddBaby"); CheckBox checkBoxSingle = (CheckBox)item.FindControl("checkBoxSingle"); //TODO: CHECK THIS //BookingType bookingType = (BookingType) Enum.Parse(typeof(BookingType),ddlRoomType.SelectedValue); const BookingType bookingType = BookingType.Double; CustomerInfoInput customerInfo1 = (CustomerInfoInput)item.FindControl("customer1"); CustomerInfoInput customerInfo2 = (CustomerInfoInput)item.FindControl("customer2"); BookingRoom bookingRoom; if (room != null) { bookingRoom = new BookingRoom(booking, room, room.RoomClass, room.RoomType); } else { RoomClass roomClass = Module.RoomClassGetById(Convert.ToInt32(hiddenRoomClassId.Value)); RoomTypex roomType = Module.RoomTypexGetById(Convert.ToInt32(hiddenRoomTypeId.Value)); bookingRoom = new BookingRoom(booking, null, roomClass, roomType); } bookingRoom.BookingType = bookingType; bookingRoom.HasBaby = checkBoxAddBaby.Checked; bookingRoom.HasChild = checkBoxAddChild.Checked; bookingRoom.IsSingle = checkBoxSingle.Checked; Module.Save(bookingRoom); #endregion #region -- Khách hàng -- Customer customer1; Customer customer2; Control trCustomer2 = item.FindControl("trCustomer2"); customer1 = customerInfo1.NewCustomer(Module); customer1.BookingRoom = bookingRoom; customer1.Booking = booking; customer1.Type = CustomerType.Adult; Module.Save(customer1); if (bookingRoom.RoomType.Id != SailsModule.TWIN || trCustomer2.Visible) { customer2 = customerInfo2.NewCustomer(Module); customer2.BookingRoom = bookingRoom; customer2.Booking = booking; customer2.Type = CustomerType.Adult; Module.Save(customer2); } if (checkBoxAddChild.Checked) { CustomerInfoInput customerChild = (CustomerInfoInput)item.FindControl("customerChild"); Customer child = customerChild.NewCustomer(Module); child.BookingRoom = bookingRoom; child.Booking = booking; child.Type = CustomerType.Children; Module.Save(child); } if (checkBoxAddBaby.Checked) { CustomerInfoInput customerBaby = (CustomerInfoInput)item.FindControl("customerBaby"); Customer baby = customerBaby.NewCustomer(Module); baby.BookingRoom = bookingRoom; baby.Booking = booking; baby.Type = CustomerType.Baby; Module.Save(baby); } #endregion } #endregion Session.Add("Finish", booking.Id); // Chuyển sang trang kết thúc (trang confirm lại lần cuối booking) PageEngine.PageRedirect(string.Format("{0}/{1}{2}", UrlHelper.GetUrlFromSection(Module.Section), SailsModule.ACTION_BOOKING_FINISH_PARAM, UrlHelper.EXTENSION)); } catch (Exception ex) { _logger.Error("Error when buttonSubmit_Click inCustomersInfo control", ex); throw; } }
protected void buttonSubmit_Click(object sender, EventArgs e) { PageEngine.PageRedirect(Request.RawUrl.Replace("order", "tour")); }