Esempio n. 1
0
        }//end ValidateValues

        //--------------------------------------------------------------
        // Calls the Currency_Exchange class to convert the value
        // according to the currency provided
        //
        // Precondition: inputValue - double retrieved from the amount
        // entered by the user
        //
        // Postcondition: returns a double from the final conversion
        // to the output currency using the Currency_Exchange class
        //--------------------------------------------------------------
        public double Convert(double inputValue)
        {
            int inputCurrency, outputCurrency;

            //get inputed currencies
            inputCurrency  = cboCurrency1.SelectedIndex;
            outputCurrency = cboCurrency2.SelectedIndex;
            //If the first currency is AUD, proceed to final conversion
            if (cboCurrency1.SelectedItem.ToString() != "Australia (AUD)")
            {
                //Convert inputValue from value in input currency to value in AUD currency
                double tempValue = Currency_Exchange.ToAUD(inputCurrency, inputValue);
                //If the final currency is to be AUD, return the tempValue
                if (cboCurrency2.SelectedItem.ToString() != "Australia (AUD)")
                {
                    //Convert tempValue from value in AUD currency to value in output currency
                    return(Currency_Exchange.FromAUD(outputCurrency, tempValue));
                }
                else
                {
                    //return AUD value
                    return(tempValue);
                }
            }
            else
            {
                //Convert inputValue from value in AUD to value in output currency
                return(Currency_Exchange.FromAUD(outputCurrency, inputValue));
            }
        }//end Convert
Esempio n. 2
0
        }//end OutputConversion

        //--------------------------------------------------------------
        // Changes the form elements according to the given stage of the
        // user input
        //
        // Precondition: stage - integer identifiying the particular
        // stage of the input
        //
        // Postcondition: n/a
        //--------------------------------------------------------------
        public void InputStates(int stage)
        {
            switch (stage)
            {
            //Following cboCurrency1 select
            case 1:
                cboCurrency1.Enabled = false;
                cboCurrency2.Enabled = true;
                break;

            //Following cboCurrency2 select
            case 2:
                //disable current input
                cboCurrency2.Enabled = false;
                //get currency code based on first selection and output to label
                lblCurrencyCode1.Text    = Currency_Exchange.GetCurrencyCode(cboCurrency1.SelectedIndex);
                lblCurrencyCode1.Visible = true;
                //enable next input
                txtInput.Enabled = true;
                //disabled convert button (if enabled)
                btnConvert.Enabled = false;
                break;

            //Following txtInput edit (with value entered)
            case 3:
                //enable convert button
                btnConvert.Enabled = true;
                break;

            //Final Form State (following conversion)
            case 4:
                //get currency code based on second selection and output to label
                lblCurrencyCode2.Text    = Currency_Exchange.GetCurrencyCode(cboCurrency2.SelectedIndex);
                lblCurrencyCode2.Visible = true;
                //disable current inputs
                txtInput.Enabled   = false;
                btnConvert.Enabled = false;
                //enable next input
                grpPromptRepeat.Visible = true;
                break;

            //Reset/Default Form State
            default:
                //enable first input
                cboCurrency1.Enabled = true;
                //clear textboxes
                txtInput.Clear();
                txtOutput.Clear();
                //disable other inputs
                btnConvert.Enabled   = false;
                cboCurrency2.Enabled = false;
                txtInput.Enabled     = false;
                txtOutput.Enabled    = false;
                //hide currency codes
                lblCurrencyCode1.Visible = false;
                lblCurrencyCode2.Visible = false;
                //hide final prompt
                grpPromptRepeat.Visible = false;
                break;
            } //end switch
        }     //end InputStates