예제 #1
0
        public void fillDropDowns()
        {
            int             i            = 0;
            List <currency> currencyList = KP.getCurrencyList();
            currency        C            = null;
            String          option       = "";

            //no currencies - quit early
            if (currencyList.Count == 0)
            {
                return;
            }

            for (i = 0; i < currencyList.Count; i++)
            {
                C      = currencyList[i];
                option = C.getISO() + " - " + C.getName();

                LeftDropdown.Items.Add(option);
                RightDropdown.Items.Add(option);
            }

            //attempt to set default to USD - United States Dollar
            try
            {
                LeftDropdown.SelectedIndex  = 17;
                RightDropdown.SelectedIndex = 17;
            }
            catch (Exception E) { }

            return;
        }
예제 #2
0
        public void insertAlphabetical(currency C)
        {
            int    i           = 0;
            int    j           = 0;
            int    length      = currencyList.Count;
            String insertName  = C.getISO().ToUpper();
            String compareName = "";

            //empty list, insert at front
            if (length == 0)
            {
                currencyList.Add(C);
                return;
            }

            //iterate through every element of our list
            for (i = 0; i < length; i++)
            {
                compareName = currencyList[i].getISO().ToUpper();

                //ignore duplicates
                if (insertName.Equals(compareName))
                {
                    return;
                }

                //insert comes before compare alphabetically, insert here
                if (insertName[0] < compareName[0])
                {
                    currencyList.Insert(i, C);
                    return;
                }
                //each one begins with the same letter
                else if (insertName[0] == compareName[0])
                {
                    //compare each character in Insertname and Comparename until we find a mismatching character
                    for (j = 0; j < insertName.Length && j < compareName.Length; j++)
                    {
                        //insertName comes before compareName alphabetically at index j
                        if (insertName[j] < compareName[j])
                        {
                            currencyList.Insert(i, C);
                            return;
                        }
                    }
                }
            }

            //exhausted list, insert at end
            currencyList.Insert(i, C);
            return;
        }