public void GetCustomer(Customer customer, SailsModule module) { if (customer.Nationality != null) { ddlNationalities.SelectedValue = customer.Nationality.Id.ToString(); } txtName.Text = customer.Fullname; if (customer.IsMale.HasValue) { if (customer.IsMale.Value) { ddlGender.SelectedIndex = 1; } else { ddlGender.SelectedIndex = 2; } } else { ddlGender.SelectedIndex = 0; } txtPassport.Text = customer.Passport; txtVisaNo.Text = customer.VisaNo; if (customer.Birthday.HasValue) { txtBirthDay.Text = customer.Birthday.Value.ToString("dd/MM/yyyy"); } else { txtBirthDay.Text = DateTime.Now.ToString("dd/MM/yyyy"); } if (customer.VisaExpired.HasValue) { txtVisaExpired.Text = customer.VisaExpired.Value.ToString("dd/MM/yyyy"); } chkVietKieu.Checked = customer.IsVietKieu; txtCode.Text = customer.Code; txtTotal.Text = customer.Total.ToString(); if (!String.IsNullOrEmpty(customer.NguyenQuan)) { txtNguyenQuan.Text = customer.NguyenQuan; } if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE))) { txtTotal.Visible = true; } else { txtTotal.Visible = false; } hiddenId.Value = customer.Id.ToString(); }
/// <summary> /// Dùng cho sự kiện data bound của một danh sách booking room /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="module"></param> /// <param name="customPrice"></param> /// <param name="policies"></param> /// <param name="page"></param> /// <param name="roomTypes"></param> public static void rptRoomList_itemDataBound(object sender, RepeaterItemEventArgs e, SailsModule module, bool customPrice, IList policies, SailsAdminBasePage page, ListItemCollection roomTypes) { if (e.Item.ItemType != ListItemType.Header) { BookingRoom item = e.Item.DataItem as BookingRoom; if (item != null) { #region -- Thông tin thường -- Label lblRoomName = (Label)e.Item.FindControl("lblRoomName"); if (item.Room != null) { Label label_RoomId = (Label)e.Item.FindControl("label_RoomId"); label_RoomId.Text = item.Room.Id.ToString(); if (item.Room != null) { lblRoomName.Text = string.Format("{2}: {0} {1}", item.RoomClass.Name, item.RoomType.Name, item.Room.Name); } else { lblRoomName.Text = string.Format("{0} {1}", item.RoomClass.Name, item.RoomType.Name); } } else { lblRoomName.Text = string.Format("Room {2}: {0} {1}", item.RoomClass.Name, item.RoomType.Name, e.Item.ItemIndex + 1); } HiddenField hiddenRoomClassId = (HiddenField)e.Item.FindControl("hiddenRoomClassId"); HiddenField hiddenRoomTypeId = (HiddenField)e.Item.FindControl("hiddenRoomTypeId"); hiddenRoomClassId.Value = item.RoomClass.Id.ToString(); hiddenRoomTypeId.Value = item.RoomType.Id.ToString(); if (item.Booked == 1 && item.RoomType.Id == SailsModule.TWIN) { e.Item.FindControl("trCustomer2").Visible = false; e.Item.FindControl("trExtra").Visible = false; } CheckBox checkBoxAddChild = (CheckBox)e.Item.FindControl("checkBoxAddChild"); HtmlControl trChild = (HtmlControl)e.Item.FindControl("trChild"); HtmlControl trChildServices = (HtmlControl)e.Item.FindControl("trChildServices"); string scriptChild = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');", trChild.ClientID, trChildServices.ClientID); checkBoxAddChild.Attributes.Add("onclick", scriptChild); CheckBox checkBoxAddBaby = (CheckBox)e.Item.FindControl("checkBoxAddBaby"); HtmlControl trBaby = (HtmlControl)e.Item.FindControl("trBaby"); HtmlControl trBabyServices = (HtmlControl)e.Item.FindControl("trBabyServices"); string scriptBaby = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');", trBaby.ClientID, trBabyServices.ClientID); checkBoxAddBaby.Attributes.Add("onclick", scriptBaby); CheckBox checkBoxSingle = (CheckBox)e.Item.FindControl("checkBoxSingle"); HtmlControl trCustomer2 = (HtmlControl)e.Item.FindControl("trCustomer2"); HtmlControl trCustomer2Services = (HtmlControl)e.Item.FindControl("trCustomer2Services"); string scriptCustomer = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');", trCustomer2.ClientID, trCustomer2Services.ClientID); checkBoxSingle.Attributes.Add("onclick", scriptCustomer); #endregion #region -- (back-end) -- bool isSecond = false; // Load customer info đã có #region -- customer info -- foreach (Customer customer in item.Customers) { if (customer.Type == CustomerType.Adult) { if (!isSecond) { CustomerInfoInput customer1 = e.Item.FindControl("customer1") as CustomerInfoInput; Repeater rptService1 = e.Item.FindControl("rptServices1") as Repeater; if (customer1 != null && rptService1 != null) { customer1.GetCustomer(customer, module); if (page.DetailService) { CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(customer, module); rptService1.DataSource = module.CustomerServices; rptService1.ItemDataBound += handler.ItemDataBound; rptService1.DataBind(); } else { rptService1.Visible = false; } isSecond = true; } } else { CustomerInfoInput customer2 = e.Item.FindControl("customer2") as CustomerInfoInput; Repeater rptService2 = e.Item.FindControl("rptServices2") as Repeater; if (customer2 != null && rptService2 != null) { customer2.GetCustomer(customer, module); if (page.DetailService) { CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(customer, module); rptService2.DataSource = module.CustomerServices; rptService2.ItemDataBound += handler.ItemDataBound; rptService2.DataBind(); } else { rptService2.Visible = false; } } } } if (customer.Type == CustomerType.Children) { CustomerInfoInput customerChild = e.Item.FindControl("customerChild") as CustomerInfoInput; Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater; if (customerChild != null && rptServicesChild != null) { customerChild.GetCustomer(customer, module); if (page.DetailService) { CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler( customer, module); rptServicesChild.DataSource = module.CustomerServices; rptServicesChild.ItemDataBound += handler.ItemDataBound; rptServicesChild.DataBind(); } else { rptServicesChild.Visible = false; } } } if (customer.Type == CustomerType.Baby) { CustomerInfoInput customerBaby = e.Item.FindControl("customerBaby") as CustomerInfoInput; Repeater rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater; if (customerBaby != null && rptServicesBaby != null) { customerBaby.GetCustomer(customer, module); if (page.DetailService) { CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler( customer, module); rptServicesBaby.DataSource = module.CustomerServices; rptServicesBaby.ItemDataBound += handler.ItemDataBound; rptServicesBaby.DataBind(); } else { rptServicesBaby.Visible = false; } } } } #endregion #region -- Check box và visible -- if (item.VirtualAdult == 1) { e.Item.FindControl("trCustomer2").Visible = false; e.Item.FindControl("rptServices2").Visible = false; } if (item.HasChild) { trChild.Attributes.CssStyle["display"] = ""; trChildServices.Attributes.CssStyle["display"] = ""; checkBoxAddChild.Checked = true; } else { Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater; if (rptServicesChild != null) { rptServicesChild.DataSource = module.CustomerServices; rptServicesChild.DataBind(); } } if (item.HasBaby) { trBaby.Attributes.CssStyle["display"] = ""; trBabyServices.Attributes.CssStyle["display"] = ""; checkBoxAddBaby.Checked = true; } else { Repeater rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater; if (rptServicesBaby != null) { rptServicesBaby.DataSource = module.CustomerServices; rptServicesBaby.DataBind(); } } if (item.IsSingle) { trCustomer2.Attributes.CssStyle["display"] = "none"; trCustomer2Services.Attributes.CssStyle["display"] = "none"; checkBoxSingle.Checked = true; } #endregion // Load room available #region -- available -- DropDownList ddlRooms = e.Item.FindControl("ddlRooms") as DropDownList; if (ddlRooms != null) { // Danh sách phòng được chọn bao gồm: toàn bộ các phòng chưa được chọn và phòng trong book hiện tại IList datasouce = module.RoomGetAvailable(item.Book.Cruise, item, (item.Book.EndDate - item.Book.StartDate).Days, item.Book); Room room = new Room("", false, null, null); datasouce.Insert(0, room); ddlRooms.DataSource = datasouce; ddlRooms.DataTextField = Room.NAME; ddlRooms.DataValueField = "Id"; ddlRooms.DataBind(); if (item.Room != null) { ListItem listItem = ddlRooms.Items.FindByValue(item.Room.Id.ToString()); if (listItem != null) { listItem.Selected = true; } } } #endregion #region -- room price -- if (customPrice) { TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox; if (txtPrice != null) { if (item.Total <= 0) { if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE))) { txtPrice.Visible = false; } else { txtPrice.Visible = true; } item.Total = item.Calculate(module, policies, page.ChildPrice, page.AgencySupplement, null); } txtPrice.Text = item.Total.ToString("0.#"); } } else { PlaceHolder plhRoomPrice = e.Item.FindControl("plhRoomPrice") as PlaceHolder; if (plhRoomPrice != null) { plhRoomPrice.Visible = false; } } #endregion DropDownList ddlRoomTypes = e.Item.FindControl("ddlRoomTypes") as DropDownList; if (ddlRoomTypes != null) { if (item.VirtualAdult == 2) { ddlRoomTypes.DataSource = roomTypes; //module.RoomTypexGetAll(); ddlRoomTypes.DataValueField = "Value"; ddlRoomTypes.DataTextField = "Text"; ddlRoomTypes.DataBind(); ListItem listitem = ddlRoomTypes.Items.FindByValue(string.Format("{0}|{1}", item.RoomClass.Id, item.RoomType.Id)); if (listitem != null) { listitem.Selected = true; } else { ddlRoomTypes.Items.Add(new ListItem(item.RoomClass.Name + " " + item.RoomType.Name, string.Format("{0}|{1}", item.RoomClass.Id, item.RoomType.Id))); ddlRoomTypes.SelectedValue = string.Format("{0}|{1}", item.RoomClass.Id, item.RoomType.Id); } } else { ddlRoomTypes.Visible = false; e.Item.FindControl("labelRoomTypes").Visible = false; } } #endregion } } }
public void GetCustomer(Customer customer, SailsModule module) { ddlNationalities.DataSource = module.NationalityGetAll(); ddlNationalities.DataTextField = "Name"; ddlNationalities.DataValueField = "Id"; ddlNationalities.DataBind(); ddlNationalities.Items.Insert(0, "-- Nationality --"); if (customer.Nationality != null) { ddlNationalities.SelectedValue = customer.Nationality.Id.ToString(); } txtName.Text = customer.Fullname; txtNationality.Text = customer.Country; if (customer.IsMale.HasValue) { if (customer.IsMale.Value) { ddlGender.SelectedIndex = 1; } else { ddlGender.SelectedIndex = 2; } } else { ddlGender.SelectedIndex = 0; } txtPassport.Text = customer.Passport; txtVisaNo.Text = customer.VisaNo; if (customer.Birthday.HasValue) { txtBirthDay.Text = customer.Birthday.Value.ToString("dd/MM/yyyy"); } if (customer.VisaExpired.HasValue) { txtVisaExpired.Text = customer.VisaExpired.Value.ToString("dd/MM/yyyy"); } chkChild.Checked = customer.IsChild; chkVietKieu.Checked = customer.IsVietKieu; txtCode.Text = customer.Code; txtTotal.Text = customer.Total.ToString(); if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE))) { txtTotal.Visible = true; } else { txtTotal.Visible = false; } hiddenId.Value = customer.Id.ToString(); switch (customer.Type) { case CustomerType.Adult: ddlCustomerType.SelectedIndex = 0; break; case CustomerType.Children: ddlCustomerType.SelectedIndex = 1; break; case CustomerType.Baby: ddlCustomerType.SelectedIndex = 2; break; } }