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; } }
private void Page_Load(object sender, EventArgs e) { try { if (this.Page is PageEngine) { this._page = (PageEngine)this.Page; // Bind home hyperlink if (this._page.RootNode.ShowInNavigation && this._page.RootNode.ViewAllowed(this._page.CuyahogaUser)) { this.hplHome.NavigateUrl = UrlHelper.GetUrlFromNode(this._page.RootNode); this.hplHome.Text = this._page.RootNode.Title; } else { this.hplHome.Visible = false; } // Bind level 1 nodes this.rptNav1.ItemDataBound += new RepeaterItemEventHandler(rptNav1_ItemDataBound); this.rptNav1.DataSource = this._page.RootNode.ChildNodes; this.rptNav1.DataBind(); } } catch (InvalidCastException ex) { throw new Exception("This control requires a Page of the type Cuyahoga.Web.UI.Page.", ex); } }
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); } }
public override IEnumerable <Rule> GetRules(int pageID) { PageData page = PageEngine.GetPage(pageID); if (page != null) { string pageTypeName = HttpUtility.UrlEncode(page.PageTypeName); var pageTypeQuery = (from rules in RuleDataStore.Items <Rule>() where rules.PageTypeLeft.ToLower().Contains(pageTypeName.ToLower()) || rules.PageTypeRight.ToLower().Contains(pageTypeName.ToLower()) select rules); List <Rule> allRules = pageTypeQuery.ToList(); List <Rule> relevantRules = new List <Rule>(); foreach (Rule rule in allRules) { int startPage = (RuleEngine.Instance.IsLeftRule(pageID, rule) ? rule.RelationHierarchyStartLeft : rule.RelationHierarchyStartRight); if (startPage < 1 || IsDescendent(pageID, startPage)) { relevantRules.Add(rule); } } return(relevantRules); } return(new List <Rule>()); }
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; } }
private void Page_Load(object sender, EventArgs e) { if (Page is PageEngine) { _page = (PageEngine)Page; BuildNavigationTree(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page is PageEngine) { _page = (PageEngine)Page; BuildNavigationTree(); } }
protected override void Render(HtmlTextWriter writer) { if (!(Page is PageEngine)) { return; } _page = (PageEngine)Page; BuildNavigationTree(); base.Render(writer); }
protected void Page_Load(object sender, EventArgs e) { if (!(this.Page is PageEngine)) { throw new Exception("The Manager toolbar control needs to be on a Page of type PageEngine to work properly."); } this._pageEngine = (PageEngine)this.Page; this._pageEngine.RegisterStylesheet("managertoolbar", UrlUtil.GetApplicationPath() + "Manager/Content/Css/ManagerToolbar.css"); if (!IsPostBack) { EnableLinks(); } }
protected override void OnPreRender(EventArgs e) { if (PageEngine == null) { return; } if (Module.Section.Node.Id == PageEngine.ActiveNode.Id) { PageEngine.RegisterNavigationPath(Album.Title, Request.RawUrl); } base.OnPreRender(e); }
/* * public static PageDataCollection GetRelatedPagesRoundTripHierarchy(Rule rule, Relation relation, int pageID) * { * PageReference pr = new PageReference(pageID); * PageData origPage = DataFactory.Instance.GetPage(pr); * List<int> relationPages = RelationEngine.GetRelationsForPageRoundTripHierarchy(pageID, rule, relation); * return PageIDListToPages(relationPages); * }*/ /// <summary> /// Helper method for page relation getters to convert relations to pages. /// </summary> /// <param name="pageIDList">Collection of page IDs</param> /// <returns>Collection of pages</returns> public static PageDataCollection PageIDListToPages(List <int> pageIDList) { PageDataCollection pages = new PageDataCollection(); foreach (int pgid in pageIDList) { PageData pd = PageEngine.GetPage(pgid); if (pd != null && !pages.Contains(pd)) { pages.Add(pd); } } return(pages); }
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; } }
private void Page_Load(object sender, EventArgs e) { try { if (this.Page is PageEngine) { this._page = (PageEngine)this.Page; // Bind home hyperlink if (this._page.RootNode.ShowInNavigation && this._page.RootNode.ViewAllowed(this._page.CuyahogaUser)) { this.hplHome.NavigateUrl = UrlHelper.GetUrlFromNode(this._page.RootNode); this.hplHome.Text = this._page.RootNode.Title; } else { this.hplHome.Visible = false; } // Bind level 1 nodes this.rptNav1.ItemDataBound += new RepeaterItemEventHandler(rptNav1_ItemDataBound); this.rptNav1.DataSource = this._page.RootNode.ChildNodes; this.rptNav1.DataBind(); if (this._page.CuyahogaUser != null) { // show <li> tag for Admin link this.liAdmin.Visible = this._page.CuyahogaUser.HasPermission(AccessLevel.Administrator); this.hplAdmin.NavigateUrl = this._page.ResolveUrl("~/Admin"); this.hplAdmin.Visible = this._page.CuyahogaUser.HasPermission(AccessLevel.Administrator); } } } catch (InvalidCastException ex) { throw new Exception("This control requires a Page of the type CMS.Web.UI.Page.", ex); } }
protected override IEnumerable <IContent> GetContent(ContentQueryParameters parameters) { if (HttpContext.Current.Session != null) { HttpContext.Current.Session["ValidationResult"] = ""; } bool isLeftRule = (HttpUtility.HtmlDecode(parameters.AllParameters["direction"]) == "left"); var queryText = HttpUtility.HtmlDecode(parameters.AllParameters["queryText"]); var relationPageLeft = HttpUtility.HtmlDecode(parameters.AllParameters["relationPageLeft"]); string relationPageRightUrl = HttpUtility.HtmlDecode(parameters.AllParameters["relationPageRight"]); //string relationPageRight = ""; /* * if (!string.IsNullOrEmpty(relationPageRightUrl)) { * * Match match = regex.Match(HttpUtility.HtmlDecode(parameters.AllParameters["relationPageRight"])); * if (match.Success) * { * relationPageRight = (match.Groups[1].Value); * } * }*/ var relationRule = HttpUtility.HtmlDecode(parameters.AllParameters["relationRule"]); var action = HttpUtility.HtmlDecode(parameters.AllParameters["action"]); PageReference contextPage = (relationPageLeft != null) ? new PageReference(relationPageLeft) : null; PageDataCollection result = new PageDataCollection(); if (contextPage != null && relationPageLeft != null) { try { List <int> relations = new List <int>(); if (RuleEngine.Instance.GetRule(relationRule).RuleTextLeft == RuleEngine.Instance.GetRule(relationRule).RuleTextRight) { relations = RelationEngine.Instance.GetRelationPagesForPage(contextPage.ID, RuleEngine.Instance.GetRule(relationRule)); } else { relations = isLeftRule ? RelationEngine.Instance.GetRelationPagesForPage(contextPage.ID, RuleEngine.Instance.GetRule(relationRule), Rule.Direction.Left).Distinct <int>().ToList <int>() : RelationEngine.Instance.GetRelationPagesForPage(contextPage.ID, RuleEngine.Instance.GetRule(relationRule), Rule.Direction.Right).Distinct <int>().ToList <int>(); } foreach (int pageid in relations) { try { result.Add(PageEngine.GetPage(pageid)); } catch { Logging.Warning(string.Format("Error fetching page {0} related to {1}", pageid, contextPage.ID)); } } } catch { Logging.Warning(string.Format("Error fetching relations from page {0}", contextPage.ID)); } } return(result); }
protected void buttonSubmit_Click(object sender, EventArgs e) { PageEngine.PageRedirect(Request.RawUrl.Replace("order", "tour")); }
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; } }