Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Model = null;
        ckComplex.Attributes.Add("onclick", "javascript:ComplexClicked()");
        ckConstantProp.Attributes.Add("onclick", "javascript:ComplexElementClicked()");
        ckRetract.Attributes.Add("onclick", "javascript:ComplexElementClicked()");
        ckCowlFlaps.Attributes.Add("onclick", "javascript:ComplexElementClicked()");
        cmbCatClass.Attributes.Add("onchange", "javascript:ComplexElementClicked()");
        ckHighPerf.Attributes.Add("onchange", "javascript:HighPerfClicked()");
        ckLegacyHighPerf.Attributes.Add("onchange", "javascript:LegacyHighPerfClicked()");
        foreach (ListItem li in rblTurbineType.Items)
        {
            MakeModel.TurbineLevel tl = (MakeModel.TurbineLevel)Convert.ToInt32(li.Value, CultureInfo.InvariantCulture);
            li.Attributes.Add("onclick", tl.IsTurbine() ? "javascript:showSinglePilotCertification()" : "javascript:hideSinglePilotCertification()");
        }

        lblAddNewManufacturer.Attributes.Add("onclick", "fnSetFocus('" + txtManufacturer.ClientID + "');");
        btnManOK.OnClientClick           = String.Format(CultureInfo.InvariantCulture, "fnClickOK('{0}', '{1}')", btnManOK.UniqueID, "");
        pnlManufacturer.Style["display"] = "none";
        pnlDupesFound.Style["display"]   = "none";

        if (!IsPostBack)
        {
            cmbCatClass.DataSource = CategoryClass.CategoryClasses();
            cmbCatClass.DataBind();
            divIsSimOnly.Visible = ((MyFlightbook.Profile.GetUser(Page.User.Identity.Name)).CanManageData);
            InitFormForMake();
        }
    }
        // Save on some view state by loading this up on each page load.
        protected void Page_Init(object sender, EventArgs e)
        {
            cmbCatClasses.DataSource = CategoryClass.CategoryClasses();
            cmbCatClasses.DataBind();

            SetUpPermutations(pnlTimeRoot);
        }
Exemplo n.º 3
0
    private bool fHasBeenSetUp = false; // have we already been initialized for the user?

    protected void SetUpForUser()
    {
        if (fHasBeenSetUp)
        {
            return;
        }

        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        UserAircraft ua = new UserAircraft(Username);

        Aircraft[] rgac       = ua.GetAircraftForUser();
        Aircraft[] rgacActive = Array.FindAll(rgac, aircraft => !aircraft.HideFromSelection);

        // Hide inactive aircraft unless
        // (a) all aircraft are active, or
        // (b) the current query references inactive aircraft
        // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked)
        bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Length == rgac.Length || Array.Exists(Restriction.AircraftList, ac => ac.HideFromSelection);

        if (fShowAll)
        {
            pnlShowAllAircraft.Visible = false;
        }
        cklAircraft.DataSource = fShowAll ? rgac : rgacActive;
        cklAircraft.DataBind();

        cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac);
        cklMakes.DataBind();

        cklCatClass.DataSource = CategoryClass.CategoryClasses();
        cklCatClass.DataBind();

        CustomPropertyType[]      rgCpt = CustomPropertyType.GetCustomPropertyTypes(Username);
        List <CustomPropertyType> al    = new List <CustomPropertyType>();

        foreach (CustomPropertyType cpt in rgCpt)
        {
            if (cpt.IsFavorite)
            {
                al.Add(cpt);
            }
        }

        if (al.Count == 0)
        {
            pnlCustomProps.Visible = CustomPropsHeader.Visible = false;
        }
        else
        {
            cklCustomProps.DataSource = al;
            cklCustomProps.DataBind();
        }
        fHasBeenSetUp = true;
    }
    private void InitForm()
    {
        if (!m_fNeedsInit)
        {
            return;
        }

        m_fNeedsInit = false;

        foreach (CustomCurrencyTimespanType t in Enum.GetValues(typeof(CustomCurrencyTimespanType)))
        {
            cmbMonthsDays.Items.Add(new ListItem(t.DisplayString(), t.ToString()));
        }

        UserAircraft           ua    = new UserAircraft(Page.User.Identity.Name);
        IEnumerable <Aircraft> lstAc = ua.GetAircraftForUser();

        lstAircraft.DataSource = lstAc;
        lstAircraft.DataBind();

        List <ListItem> lstCurrencyEvents = new List <ListItem>();

        foreach (var value in Enum.GetValues(typeof(CustomCurrency.CustomCurrencyEventType)))
        {
            lstCurrencyEvents.Add(new ListItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CustomCurrency.EventTypeLabel(1, (CustomCurrency.CustomCurrencyEventType)value)), ((int)value).ToString(CultureInfo.CurrentCulture)));
        }

        lstCurrencyEvents.Sort(delegate(ListItem a, ListItem b) { return(a.Text.CompareCurrentCultureIgnoreCase(b.Text)); });
        foreach (ListItem li in lstCurrencyEvents)
        {
            cmbEventTypes.Items.Add(li);
        }

        lstModels.DataSource = MakeModel.ModelsForAircraft(lstAc);
        lstModels.DataBind();

        IEnumerable <CategoryClass> rgCatClass = CategoryClass.CategoryClasses();

        cmbCatClass.DataSource = rgCatClass;
        cmbCatClass.DataBind();

        // Get the categories (as opposed to catclass); this is something of a hack, but it avoids an extra DB call
        Dictionary <string, string> dictCategories = new Dictionary <string, string>();

        foreach (CategoryClass cc in rgCatClass)
        {
            dictCategories[cc.Category] = cc.Category;
        }
        List <string> lst = new List <string>(dictCategories.Keys);

        lst.Sort();
        foreach (string category in lst)
        {
            cmbCategory.Items.Add(new ListItem(category, category));
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// Updates the flight query with the category/class requested
 /// </summary>
 private void CatClassFromForm()
 {
     if (cklCatClass.SelectedIndex >= 0)
     {
         List <CategoryClass> rgcc = new List <CategoryClass>(CategoryClass.CategoryClasses());
         m_fq.CatClasses.Clear();
         foreach (ListItem li in cklCatClass.Items)
         {
             int idCc = Convert.ToInt32(li.Value, CultureInfo.InvariantCulture);
             if (li.Selected)
             {
                 m_fq.CatClasses.Add(rgcc.Find(cc => (int)cc.IdCatClass == idCc));
             }
         }
     }
 }
Exemplo n.º 6
0
        private void InitAircraftModelRestriction(string szReqTail, string szReqModel, string szReqICAO, string szcc)
        {
            if (!String.IsNullOrEmpty(szReqTail) || !String.IsNullOrEmpty(szReqModel) || !String.IsNullOrEmpty(szReqICAO))
            {
                UserAircraft          ua    = new UserAircraft(Restriction.UserName);
                Collection <Aircraft> lstac = new Collection <Aircraft>();
                HashSet <int>         lstmm = new HashSet <int>();

                foreach (Aircraft ac in ua.GetAircraftForUser())
                {
                    if (ac.DisplayTailnumber.CompareCurrentCultureIgnoreCase(szReqTail) == 0)
                    {
                        lstac.Add(ac);
                    }

                    MakeModel mm = MakeModel.GetModel(ac.ModelID);
                    if (!lstmm.Contains(mm.MakeModelID) &&
                        ((!String.IsNullOrEmpty(szReqModel) && mm.Model.CompareCurrentCultureIgnoreCase(szReqModel) == 0) ||
                         (!String.IsNullOrEmpty(szReqICAO) && mm.FamilyName.CompareCurrentCultureIgnoreCase(szReqICAO) == 0)))
                    {
                        lstmm.Add(mm.MakeModelID);
                    }
                }
                if (lstac.Count > 0)
                {
                    Restriction.AirportList.Clear();
                    Restriction.AddAircraft(lstac);
                }
                if (lstmm.Count > 0)
                {
                    Restriction.MakeList.Clear();
                    Restriction.AddModels(lstmm);
                }
            }
            if (!String.IsNullOrEmpty(szcc))
            {
                foreach (CategoryClass cc in CategoryClass.CategoryClasses())
                {
                    if (cc.CatClass.CompareCurrentCultureIgnoreCase(szcc) == 0)
                    {
                        Restriction.AddCatClass(cc);
                    }
                }
            }
        }
    protected void SetUpForUser()
    {
        if (fHasBeenSetUp)
        {
            return;
        }

        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        UserAircraft           ua         = new UserAircraft(Username);
        IEnumerable <Aircraft> rgac       = ua.GetAircraftForUser();
        IEnumerable <Aircraft> rgacActive = ua.FindMatching(aircraft => !aircraft.HideFromSelection);

        // Hide inactive aircraft unless
        // (a) all aircraft are active, or
        // (b) the current query references inactive aircraft
        // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked)
        bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Count() == rgac.Count() || Restriction.AircraftList.FirstOrDefault(ac => ac.HideFromSelection) != null;

        if (fShowAll)
        {
            pnlShowAllAircraft.Visible = false;
        }
        cklAircraft.DataSource = fShowAll ? rgac : rgacActive;
        cklAircraft.DataBind();
        ckAllAircraft.Visible = cklAircraft.Items.Count > 4;

        cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac);
        cklMakes.DataBind();
        ckAllMakes.Visible = cklMakes.Items.Count > 4;

        cklCatClass.DataSource = CategoryClass.CategoryClasses();
        cklCatClass.DataBind();

        SetUpPropertiesForUser(false);

        fHasBeenSetUp = true;
    }
 // Save on some view state by loading this up on each page load.
 protected void Page_Init(object sender, EventArgs e)
 {
     cmbCatClasses.DataSource = CategoryClass.CategoryClasses();
     cmbCatClasses.DataBind();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Inserts subtotals into an enumerable set of flights, returning an enumerable set of LogbookPrintedPages.
        /// </summary>
        /// <param name="lstIn">The input set of flights.  Should be ALL RowType=Flight and should have rowheight property set</param>
        /// <param name="pageSize">Max # of flights per table to subtotal; flights with rowheight > 1 will take up more rows</param>
        /// <param name="optionalColumns">Any optional columns to add</param>
        /// <param name="pullForwardTotals">Whether or not to pull forward totals from the previous page</param>
        /// <returns>A new enumerable with per-page subtotals and (optional) running totals</returns>
        public static IEnumerable <LogbookPrintedPage> Paginate(IEnumerable <LogbookEntryDisplay> lstIn, int pageSize, OptionalColumn[] optionalColumns, bool pullForwardTotals)
        {
            if (lstIn == null)
            {
                throw new ArgumentNullException("lstIn");
            }
            int cIn = lstIn.Count();

            if (cIn == 0)
            {
                return(new LogbookPrintedPage[0]);
            }

            // For speed, cache the names of each category/class
            Dictionary <int, string> dictCatClasses = new Dictionary <int, string>();

            foreach (CategoryClass cc in CategoryClass.CategoryClasses())
            {
                dictCatClasses.Add(cc.IDCatClassAsInt, cc.CatClass);
            }

            List <LogbookPrintedPage> lstOut = new List <LogbookPrintedPage>();

            Dictionary <string, LogbookEntryDisplay> dictPageTotals = null, dictPreviousTotals = new Dictionary <string, LogbookEntryDisplay>(), dictRunningTotals = new Dictionary <string, LogbookEntryDisplay>();
            List <LogbookEntryDisplay> lstFlightsThisPage = null;
            LogbookPrintedPage         currentPage = null;

            int flightIndexOnPage = 0;
            int index             = 0;
            int pageNum           = 0;

            foreach (LogbookEntryDisplay led in lstIn)
            {
                led.OptionalColumns = optionalColumns;
                if ((pageSize > 0 && flightIndexOnPage >= pageSize) || currentPage == null) // need to start a new page.
                {
                    flightIndexOnPage = 0;                                                  // reset
                    dictPageTotals    = new Dictionary <string, LogbookEntryDisplay>();
                    // COPY the running totals to the new previous totals, since AddFrom modifies the object,
                    dictPreviousTotals = new Dictionary <string, LogbookEntryDisplay>();
                    Dictionary <string, LogbookEntryDisplay> dictNewRunningTotals = new Dictionary <string, LogbookEntryDisplay>();
                    foreach (string szKeySrc in dictRunningTotals.Keys)
                    {
                        LogbookEntryDisplay ledRunningNew = JsonConvert.DeserializeObject <LogbookEntryDisplay>(JsonConvert.SerializeObject(dictRunningTotals[szKeySrc]));
                        ledRunningNew.RowType        = LogbookEntryDisplay.LogbookRowType.PreviousTotal;
                        dictPreviousTotals[szKeySrc] = ledRunningNew;
                        ledRunningNew                  = JsonConvert.DeserializeObject <LogbookEntryDisplay>(JsonConvert.SerializeObject(dictRunningTotals[szKeySrc]));
                        ledRunningNew.RowType          = LogbookEntryDisplay.LogbookRowType.RunningTotal;
                        dictNewRunningTotals[szKeySrc] = ledRunningNew;
                    }
                    dictRunningTotals  = dictNewRunningTotals; // set up for the new page to pick up where the last one left off...
                    lstFlightsThisPage = new List <LogbookEntryDisplay>();
                    currentPage        = new LogbookPrintedPage()
                    {
                        RunningTotals = dictRunningTotals, TotalsPreviousPages = dictPreviousTotals, TotalsThisPage = dictPageTotals, Flights = lstFlightsThisPage, PageNum = ++pageNum
                    };

                    lstOut.Add(currentPage);
                }

                flightIndexOnPage += led.RowHeight;

                string szCatClassKey = dictCatClasses[led.EffectiveCatClass];   // should never not be present!!

                led.Index = ++index;

                // Add the flight to the page
                lstFlightsThisPage.Add(led);

                // And add the flight to the page catclass totals and running catclass totals
                if (pageSize > 0)
                {
                    if (!dictPageTotals.ContainsKey(szCatClassKey))
                    {
                        dictPageTotals[szCatClassKey] = new LogbookEntryDisplay()
                        {
                            RowType = LogbookEntryDisplay.LogbookRowType.PageTotal, CatClassDisplay = szCatClassKey, OptionalColumns = optionalColumns
                        }
                    }
                    ;
                    dictPageTotals[szCatClassKey].AddFrom(led);
                }
                if (!dictRunningTotals.ContainsKey(szCatClassKey))
                {
                    dictRunningTotals[szCatClassKey] = new LogbookEntryDisplay()
                    {
                        RowType = LogbookEntryDisplay.LogbookRowType.RunningTotal, CatClassDisplay = szCatClassKey, OptionalColumns = optionalColumns
                    }
                }
                ;
                dictRunningTotals[szCatClassKey].AddFrom(led);
            }

            // Assign page number, and index totals
            foreach (LogbookPrintedPage lpp in lstOut)
            {
                // And add unstriped totals as needed
                ConsolidateTotals(lpp.TotalsThisPage, LogbookEntryDisplay.LogbookRowType.PageTotal, optionalColumns);
                ConsolidateTotals(lpp.TotalsPreviousPages, LogbookEntryDisplay.LogbookRowType.PreviousTotal, optionalColumns);
                ConsolidateTotals(lpp.RunningTotals, LogbookEntryDisplay.LogbookRowType.RunningTotal, optionalColumns);

                lpp.TotalPages = pageNum;
                int iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.TotalsThisPage.Values)
                {
                    lep.Index = iTotal++;
                }
                iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.TotalsPreviousPages.Values)
                {
                    lep.Index = iTotal++;
                }
                iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.RunningTotals.Values)
                {
                    lep.Index = iTotal++;
                }

                if (!pullForwardTotals)
                {
                    lpp.TotalsPreviousPages.Clear();
                }
            }

            return(lstOut);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Inserts subtotals into an enumerable set of flights, returning an enumerable set of LogbookPrintedPages.
        /// </summary>
        /// <param name="lstIn">The input set of flights.  Should be ALL RowType=Flight and should have rowheight property set</param>
        /// <param name="po">Options that guide pagination</param>
        /// <returns>A new enumerable with per-page subtotals and (optional) running totals</returns>
        public static IEnumerable <LogbookPrintedPage> Paginate(IEnumerable <LogbookEntryDisplay> lstIn, PrintingOptions po)
        {
            if (lstIn == null)
            {
                throw new ArgumentNullException(nameof(lstIn));
            }
            if (po == null)
            {
                throw new ArgumentNullException(nameof(po));
            }
            int cIn = lstIn.Count();

            if (cIn == 0)
            {
                return(Array.Empty <LogbookPrintedPage>());
            }

            // For speed, cache the names of each category/class
            Dictionary <int, string> dictCatClasses = new Dictionary <int, string>();

            foreach (CategoryClass cc in CategoryClass.CategoryClasses())
            {
                dictCatClasses.Add(cc.IDCatClassAsInt, cc.CatClass);
            }

            List <LogbookPrintedPage> lstOut = new List <LogbookPrintedPage>();

            Dictionary <string, LogbookEntryDisplay> dictPageTotals = null, dictPreviousTotals, dictRunningTotals = new Dictionary <string, LogbookEntryDisplay>();
            List <LogbookEntryDisplay> lstFlightsThisPage = null;
            LogbookPrintedPage         currentPage = null;

            int flightIndexOnPage = 0;
            int index             = 0;
            int pageNum           = 0;

            DateTime?dtLastEntry = null;

            foreach (LogbookEntryDisplay led in lstIn)
            {
                // force a page break if a new month is starting IF the option to do so has been set
                if (po.FlightsPerPage > 0 && po.BreakAtMonthBoundary && dtLastEntry != null && dtLastEntry.HasValue && (led.Date.Month != dtLastEntry.Value.Month || led.Date.Year != dtLastEntry.Value.Year))
                {
                    flightIndexOnPage = po.FlightsPerPage;
                }

                dtLastEntry = led.Date;
                led.SetOptionalColumns(po.OptionalColumns);
                if ((po.FlightsPerPage > 0 && flightIndexOnPage >= po.FlightsPerPage) || currentPage == null) // need to start a new page.
                {
                    flightIndexOnPage = 0;                                                                    // reset
                    dictPageTotals    = new Dictionary <string, LogbookEntryDisplay>();
                    // COPY the running totals to the new previous totals, since AddFrom modifies the object,
                    dictPreviousTotals = new Dictionary <string, LogbookEntryDisplay>();
                    Dictionary <string, LogbookEntryDisplay> dictNewRunningTotals = new Dictionary <string, LogbookEntryDisplay>();
                    foreach (string szKeySrc in dictRunningTotals.Keys)
                    {
                        LogbookEntryDisplay ledRunningNew = JsonConvert.DeserializeObject <LogbookEntryDisplay>(JsonConvert.SerializeObject(dictRunningTotals[szKeySrc]));
                        ledRunningNew.RowType        = LogbookEntryDisplay.LogbookRowType.PreviousTotal;
                        dictPreviousTotals[szKeySrc] = ledRunningNew;
                        ledRunningNew                  = JsonConvert.DeserializeObject <LogbookEntryDisplay>(JsonConvert.SerializeObject(dictRunningTotals[szKeySrc]));
                        ledRunningNew.RowType          = LogbookEntryDisplay.LogbookRowType.RunningTotal;
                        dictNewRunningTotals[szKeySrc] = ledRunningNew;
                    }
                    dictRunningTotals  = dictNewRunningTotals; // set up for the new page to pick up where the last one left off...
                    lstFlightsThisPage = new List <LogbookEntryDisplay>();
                    currentPage        = new LogbookPrintedPage()
                    {
                        RunningTotals = dictRunningTotals, TotalsPreviousPages = dictPreviousTotals, TotalsThisPage = dictPageTotals, Flights = lstFlightsThisPage, PageNum = ++pageNum
                    };

                    lstOut.Add(currentPage);
                }

                flightIndexOnPage += led.RowHeight;

                string szCatClassKey = dictCatClasses[led.EffectiveCatClass];   // should never not be present!!

                led.Index = ++index;

                // Add the flight to the page
                lstFlightsThisPage.Add(led);

                // And add the flight to the page catclass totals and running catclass totals
                if (po.FlightsPerPage > 0)
                {
                    if (!dictPageTotals.ContainsKey(szCatClassKey))
                    {
                        dictPageTotals[szCatClassKey] = new LogbookEntryDisplay(po.OptionalColumns)
                        {
                            RowType = LogbookEntryDisplay.LogbookRowType.PageTotal, CatClassDisplay = szCatClassKey
                        }
                    }
                    ;
                    dictPageTotals[szCatClassKey].AddFrom(led);
                }
                if (!dictRunningTotals.ContainsKey(szCatClassKey))
                {
                    dictRunningTotals[szCatClassKey] = new LogbookEntryDisplay(po.OptionalColumns)
                    {
                        RowType = LogbookEntryDisplay.LogbookRowType.RunningTotal, CatClassDisplay = szCatClassKey
                    }
                }
                ;
                dictRunningTotals[szCatClassKey].AddFrom(led);
            }

            // Assign page number, and index totals
            foreach (LogbookPrintedPage lpp in lstOut)
            {
                // And add unstriped totals as needed
                ConsolidateTotals(lpp.TotalsThisPage, LogbookEntryDisplay.LogbookRowType.PageTotal, po.OptionalColumns);
                ConsolidateTotals(lpp.TotalsPreviousPages, LogbookEntryDisplay.LogbookRowType.PreviousTotal, po.OptionalColumns);
                ConsolidateTotals(lpp.RunningTotals, LogbookEntryDisplay.LogbookRowType.RunningTotal, po.OptionalColumns);

                lpp.TotalPages = pageNum;
                int iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.TotalsThisPage.Values)
                {
                    lep.Index = iTotal++;
                }
                iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.TotalsPreviousPages.Values)
                {
                    lep.Index = iTotal++;
                }
                iTotal = 0;
                foreach (LogbookEntryDisplay lep in lpp.RunningTotals.Values)
                {
                    lep.Index = iTotal++;
                }

                if (!po.StripeSubtotalsByCategoryClass)
                {
                    RemoveStripedSubtotals(lpp.TotalsThisPage);
                    RemoveStripedSubtotals(lpp.TotalsPreviousPages);
                    RemoveStripedSubtotals(lpp.RunningTotals);
                }

                if (!po.IncludePullForwardTotals)
                {
                    lpp.TotalsPreviousPages.Clear();
                }
            }

            return(lstOut);
        }
Exemplo n.º 11
0
    private void InitForm()
    {
        if (!m_fNeedsInit)
        {
            return;
        }

        m_fNeedsInit = false;

        List <TimespanType> lstTst = new List <TimespanType>();

        foreach (TimespanType t in Enum.GetValues(typeof(TimespanType)))
        {
            lstTst.Add(t);
        }
        // Move sliding months up - we don't want an alphabetical sort.  Want days/calendar months/sliding months, then everything else.
        lstTst.RemoveAll(tst => tst == TimespanType.Days || tst == TimespanType.CalendarMonths || tst == TimespanType.SlidingMonths);
        lstTst.InsertRange(0, new TimespanType[] { TimespanType.Days, TimespanType.CalendarMonths, TimespanType.SlidingMonths });
        foreach (TimespanType t in lstTst)
        {
            cmbMonthsDays.Items.Add(new ListItem(t.DisplayString().Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + t.DisplayString().Substring(1), t.ToString()));
        }

        UserAircraft           ua    = new UserAircraft(Page.User.Identity.Name);
        IEnumerable <Aircraft> lstAc = ua.GetAircraftForUser();

        lstAircraft.DataSource = lstAc;
        lstAircraft.DataBind();

        List <ListItem> lstCurrencyEvents = new List <ListItem>();

        foreach (var value in Enum.GetValues(typeof(CustomCurrency.CustomCurrencyEventType)))
        {
            lstCurrencyEvents.Add(new ListItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CustomCurrency.EventTypeLabel(1, (CustomCurrency.CustomCurrencyEventType)value)), ((int)value).ToString(CultureInfo.CurrentCulture)));
        }

        lstCurrencyEvents.Sort(delegate(ListItem a, ListItem b) { return(a.Text.CompareCurrentCultureIgnoreCase(b.Text)); });
        foreach (ListItem li in lstCurrencyEvents)
        {
            cmbEventTypes.Items.Add(li);
        }

        lstModels.DataSource = MakeModel.ModelsForAircraft(lstAc);
        lstModels.DataBind();

        IEnumerable <CategoryClass> rgCatClass = CategoryClass.CategoryClasses();

        cmbCatClass.DataSource = rgCatClass;
        cmbCatClass.DataBind();

        List <CustomPropertyType> lstCpt = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name));

        lstCpt.RemoveAll(cpt => !cpt.IsFavorite);
        lstProps.DataSource = lstCpt;
        lstProps.DataBind();

        // Get the categories (as opposed to catclass); this is something of a hack, but it avoids an extra DB call
        Dictionary <string, string> dictCategories = new Dictionary <string, string>();

        foreach (CategoryClass cc in rgCatClass)
        {
            dictCategories[cc.Category] = cc.Category;
        }
        List <string> lst = new List <string>(dictCategories.Keys);

        lst.Sort();
        foreach (string category in lst)
        {
            cmbCategory.Items.Add(new ListItem(category, category));
        }
    }