protected void rptPendings_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is Booking)
            {
                var booking = (Booking)e.Item.DataItem;
                var hplCode = e.Item.FindControl("hplCode") as HyperLink;
                if (hplCode != null)
                {
                    hplCode.Text        = string.Format(BookingFormat, booking.Id);
                    hplCode.NavigateUrl = string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}",
                                                        Node.Id, Section.Id, booking.Id);
                }

                var hplAgency = e.Item.FindControl("hplAgency") as HyperLink;
                if (hplAgency != null)
                {
                    hplAgency.Text        = booking.Agency.Name;
                    hplAgency.NavigateUrl = string.Format("AgencyEdit.aspx?NodeId={0}&SectionId={1}&AgencyId={2}",
                                                          Node.Id, Section.Id, booking.Agency.Id);
                }

                ValueBinder.BindLiteral(e.Item, "litRooms", booking.RoomName);
                ValueBinder.BindLiteral(e.Item, "litTrip", booking.Trip.Name);
                //ValueBinder.BindLiteral(e.Item, "litPartner", booking.Agency.Name);
                if (booking.Deadline.HasValue)
                {
                    ValueBinder.BindLiteral(e.Item, "litPending", booking.Deadline.Value.ToString("HH:mm dd/MM/yyyy"));
                }

                var lblCreatedBy = e.Item.FindControl("lblCreatedBy") as Label;
                if (lblCreatedBy != null)
                {
                    lblCreatedBy.Text = booking.CreatedBy.FullName;
                    ValueBinder.BindLiteral(e.Item, "litCreatedBy", booking.CreatedBy.FullName);
                    ValueBinder.BindLiteral(e.Item, "litCreatorPhone", booking.CreatedBy.Website);
                    ValueBinder.BindLiteral(e.Item, "litCreatorEmail", booking.CreatedBy.Email);
                }
                if (booking.Agency.Sale != null)
                {
                    ValueBinder.BindLabel(e.Item, "lblSaleInCharge", booking.Agency.Sale.FullName);
                    ValueBinder.BindLiteral(e.Item, "litSale", booking.Agency.Sale.FullName);
                    ValueBinder.BindLiteral(e.Item, "litSalePhone", booking.Agency.Sale.Website);
                    ValueBinder.BindLiteral(e.Item, "litSaleEmail", booking.Agency.Sale.Email);
                }
            }
        }
Exemplo n.º 2
0
        protected void rptRoomClass_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            {
                RoomClass roomClass = (RoomClass)e.Item.DataItem;

                #region -- Header --

                //// Đối với header, thêm danh sách roomType thông thường
                //using (Repeater rpt = e.Item.FindControl("rptRoomTypeHeader") as Repeater)
                //{
                //    if (rpt != null)
                //    {
                //        rpt.DataSource = Module.RoomTypexGetAll();
                //        rpt.DataBind();
                //    }
                //}

                #endregion

                #region -- Item --

                #region RoomClass Id

                using (Label labelRoomClassId = e.Item.FindControl("labelRoomClassId") as Label)
                {
                    if (labelRoomClassId != null)
                    {
                        labelRoomClassId.Text = roomClass.Id.ToString();
                    }
                }

                #endregion

                ValueBinder.BindLabel(e.Item, "lblTrip", Trip.TripCode);
                if (Trip.NumberOfOptions > 1)
                {
                    ValueBinder.BindLiteral(e.Item, "litOption", Option);
                }
                ValueBinder.BindLiteral(e.Item, "litName", roomClass.Name);

                //Đối với từng dòng
                using (Repeater rpt = e.Item.FindControl("rptRoomTypeCell") as Repeater)
                {
                    if (rpt != null)
                    {
                        // Gán sự kiện ItemDataBound (vì control trong Repeater không tự nhận hàm này)
                        rpt.ItemDataBound += RptRoomTypeItemDataBound;

                        IList roomTypeList = AllRoomTypes;

                        _hasRoom = false;

                        rpt.DataSource = roomTypeList;
                        rpt.DataBind();

                        e.Item.Visible = _hasRoom;
                    }
                }

                #endregion
            }
        }