public void gvFlightLogs_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            int cCols = e.Row.Cells.Count;

            for (int i = cCols - 1; i >= 1; i--)
            {
                e.Row.Cells.RemoveAt(i);
            }
            e.Row.Cells[0].ColumnSpan = cCols;
        }
        else if (e.Row.RowType == DataControlRowType.Pager)
        {
            ((Label)e.Row.FindControl("lblNumFlights")).Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.NumberOfFlights, CachedData.Count());
        }
        else if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LogbookEntryDisplay le = (LogbookEntryDisplay)e.Row.DataItem;

            // Wire up the drop-menu.  We have to do this here because it is an iNamingContainer and can't access the gridviewrow
            Controls_popmenu popup = (Controls_popmenu)e.Row.FindControl("popmenu1");
            ((Controls_mfbMiniFacebook)popup.FindControl("mfbMiniFacebook")).FlightEntry = le;
            ((Controls_mfbTweetThis)popup.FindControl("mfbTweetThis")).FlightToTweet     = le;
            ((LinkButton)popup.FindControl("lnkReverse")).CommandArgument    = ((LinkButton)popup.FindControl("lnkClone")).CommandArgument = le.FlightID.ToString(CultureInfo.InvariantCulture);
            ((LinkButton)popup.FindControl("lnkSendFlight")).CommandArgument = le.FlightID.ToString(CultureInfo.InvariantCulture);
            ((HyperLink)popup.FindControl("lnkEditThisFlight")).NavigateUrl  = EditPath(le.FlightID);
            HyperLink h = (HyperLink)popup.FindControl("lnkRequestSignature");
            h.Visible     = le.CanRequestSig;
            h.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/RequestSigs.aspx?id={0}", le.FlightID);

            // fix the ID of the delete button to prevent replay attacks
            string     szDelID  = String.Format(CultureInfo.InvariantCulture, "lnkDel{0}", le.FlightID);
            LinkButton lbDelete = (LinkButton)e.Row.FindControl("lnkDelete");
            lbDelete.ID = szDelID;
            // If the host wants notifications of deletions, register full postback.
            if (ItemDeleted != null)
            {
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(lbDelete);
            }
            ((AjaxControlToolkit.ConfirmButtonExtender)e.Row.FindControl("ConfirmButtonExtender1")).TargetControlID = szDelID;

            // Bind to images.
            Controls_mfbImageList mfbIl = (Controls_mfbImageList)e.Row.FindControl("mfbilFlights");
            if (!SuppressImages)
            {
                // Flight images
                mfbIl.Key = le.FlightID.ToString(CultureInfo.InvariantCulture);
                mfbIl.Refresh();

                // wire up images
                if (mfbIl.Images.ImageArray.Count > 0 || le.Videos.Count > 0)
                {
                    e.Row.FindControl("pnlImagesHover").Visible = true;
                }
                else
                {
                    e.Row.FindControl("pnlFlightImages").Visible = false;
                }

                Aircraft ac = AircraftForUser.Find(a => a.AircraftID == le.AircraftID);
                string   szInstTypeDescription = ac == null ? string.Empty : AircraftInstance.ShortNameForInstanceType(ac.InstanceType);
                ((Label)e.Row.FindControl("lblInstanceTypeDesc")).Text = szInstTypeDescription;

                // And aircraft
                // for efficiency, see if we've already done this tail number; re-use if already done
                if (!m_dictAircraftHoverIDs.ContainsKey(le.AircraftID))
                {
                    if (ac != null)
                    {
                        mfbilAircraft.DefaultImage = ac.DefaultImage;
                    }

                    mfbilAircraft.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture);
                    mfbilAircraft.Refresh();

                    // cache the attributes string - there's a bit of computation involved in it.
                    string szAttributes = ((Label)e.Row.FindControl("lblModelAttributes")).Text.EscapeHTML();

                    // and the image table.
                    m_dictAircraftHoverIDs[le.AircraftID] = szInstTypeDescription + " " + szAttributes + mfbilAircraft.AsHTMLTable();
                }

                e.Row.FindControl("plcTail").Controls.Add(new LiteralControl(m_dictAircraftHoverIDs[le.AircraftID]));
            }

            // Set style for the row
            HtmlGenericControl divDate = (HtmlGenericControl)e.Row.FindControl("divDateAndRoute");
            switch (le.RowType)
            {
            case LogbookEntryDisplay.LogbookRowType.Flight:
                if (le.IsPageBreak)
                {
                    e.Row.CssClass = e.Row.CssClass + " pageBreakRow";
                }
                break;

            case LogbookEntryDisplay.LogbookRowType.RunningTotal:
                e.Row.CssClass  = "runningTotalRow";
                divDate.Visible = false;
                break;

            case LogbookEntryDisplay.LogbookRowType.Subtotal:
                e.Row.CssClass  = (le.IsPageBreak) ? "subtotalRowPageBreak" : "subtotalRow";
                divDate.Visible = false;
                break;
            }
        }
    }
Exemple #2
0
 /// <summary>
 /// The number of items currently in memory
 /// </summary>
 /// <returns></returns>
 public int TotalCachedItems()
 {
     return(CachedData.Count(cd => cd != default(S)));
 }
Exemple #3
0
 /// <summary>
 /// Publicly visible force-refresh method.  ALWAYS bypasses the cache and uses provided data or hits the database
 /// </summary>
 public void RefreshData()
 {
     FlushCache();
     BindData(Data);
     lblNumFlights.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.NumberOfFlights, CachedData.Count());
 }