コード例 #1
0
        private double calculateCost()
        {
            int volume;

            try
            {
                volume = int.Parse(cargoVolume.GetValue());
            }
            catch (FormatException exception)
            {
                volume = 0;
            }
            int weight;

            try
            {
                weight = int.Parse(cargoWeight.GetValue());
            }
            catch (FormatException exception)
            {
                weight = 0;
            }
            string formOption = cargoFormOption.GetValue();
            int    kmLocal;

            try
            {
                kmLocal = int.Parse(this.kmLocal.GetValue());
            }
            catch (FormatException exception)
            {
                kmLocal = 0;
            }
            int kmAway;

            try
            {
                kmAway = int.Parse(this.kmAway.GetValue());
            }
            catch (FormatException exception)
            {
                kmAway = 0;
            }
            int value;

            try
            {
                value = int.Parse(cargoValue.GetValue());
            }
            catch (FormatException exception)
            {
                value = 0;
            }
            return(TransportCost.CalculateCost(volume, weight, formOption, kmLocal, kmAway, value));
        }
コード例 #2
0
 private void InitializeElements()
 {
     cargoVolume = new TextBoxWithLabelFormElement(this, cargoVolumeString);
     cargoVolume.SetTextBoxOfset(labelLength);
     cargoWeight = new TextBoxWithLabelFormElement(this, cargoWeightString);
     cargoWeight.SetTextBoxOfset(labelLength);
     cargoFormOption = new RadioButtonsFormElement(this, TransportCost.GetCargoFormOption());
     kmLocal         = new TextBoxWithLabelFormElement(this, kmLocalString);
     kmLocal.SetTextBoxOfset(labelLength);
     kmAway = new TextBoxWithLabelFormElement(this, kmAwayString);
     kmAway.SetTextBoxOfset(labelLength);
     cargoValue = new TextBoxWithLabelFormElement(this, cargoValueString);
     cargoValue.SetTextBoxOfset(labelLength);
     calculateCostButton        = new Button();
     calculateCostButton.Text   = calculateCostButtonString;
     calculateCostButton.Click += new EventHandler(CalculateCostButtonFunction);
     Controls.Add(calculateCostButton);
 }